@roilab/crm-cli 0.16.0 → 0.17.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/CHANGELOG.md +63 -0
- package/SKILL.md +20 -5
- package/SURFACE.txt +74 -13
- package/dist/src/auth/credentials.js +83 -15
- package/dist/src/auth/credentials.js.map +1 -1
- package/dist/src/commands/auth.js +43 -5
- package/dist/src/commands/auth.js.map +1 -1
- package/dist/src/commands/board.js +22 -2
- package/dist/src/commands/board.js.map +1 -1
- package/dist/src/commands/doctor.js +6 -2
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/src/commands/generic.js +33 -0
- package/dist/src/commands/generic.js.map +1 -1
- package/dist/src/commands/mention.js +2 -2
- package/dist/src/commands/mention.js.map +1 -1
- package/dist/src/commands/meta.js +2 -2
- package/dist/src/commands/meta.js.map +1 -1
- package/dist/src/commands/rank.js +26 -0
- package/dist/src/commands/rank.js.map +1 -1
- package/dist/src/commands/skill.js +45 -14
- package/dist/src/commands/skill.js.map +1 -1
- package/dist/src/commands/task.js +8 -8
- package/dist/src/commands/task.js.map +1 -1
- package/dist/src/lib/skillManifest.js +17 -0
- package/dist/src/lib/skillManifest.js.map +1 -1
- package/dist/src/lib/skillSidecar.js +2 -1
- package/dist/src/lib/skillSidecar.js.map +1 -1
- package/dist/src/transport/envelope.js +13 -1
- package/dist/src/transport/envelope.js.map +1 -1
- package/dist/src/transport/http.js +10 -0
- package/dist/src/transport/http.js.map +1 -1
- package/dist/src/transport/run.js +31 -2
- package/dist/src/transport/run.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,69 @@ Todos los cambios notables se documentan aquí. El formato sigue
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.17.0] — 2026-07-14
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- **La URL base por defecto es ahora `https://crm.roilab.es`** (antes
|
|
14
|
+
`http://localhost:3000`). El CLI publicado habla con producción sin
|
|
15
|
+
configurar nada. Para otro deployment o desarrollo local: `--api-url` o la
|
|
16
|
+
variable `CRM_API_URL` (p. ej. `http://localhost:3000`).
|
|
17
|
+
|
|
18
|
+
### Security
|
|
19
|
+
|
|
20
|
+
- **Path traversal (alta):** `crm skill pull --all` / `update` construían
|
|
21
|
+
`.claude/skills/<slug>` con slugs venidos del servidor sin validar. Nuevo
|
|
22
|
+
`assertSafeSlug()` rechaza `/`, `\`, `..` y punto inicial antes de tocar el
|
|
23
|
+
disco.
|
|
24
|
+
- **Exfiltración del token (alta):** la paginación seguía cabeceras
|
|
25
|
+
`Link: rel="next"` absolutas re-adjuntando el `Authorization`. Ahora se
|
|
26
|
+
exige mismo origen; un enlace a otro host aborta con error de red.
|
|
27
|
+
- **Inyección ANSI (media):** los títulos/summaries del servidor se imprimían
|
|
28
|
+
crudos en `--markdown` / `--ids-only` / `--jq`. Se stripean secuencias de
|
|
29
|
+
control C0/C1 en toda la salida (se conservan `\n`/`\t`).
|
|
30
|
+
- **Fichero de credenciales atómico + 0600 (media):** escritura con
|
|
31
|
+
`tmp+rename` y modo 0600 desde el primer byte; sin ventana world-readable ni
|
|
32
|
+
corrupción por refresh concurrente.
|
|
33
|
+
- **Aviso http no cifrado (media):** stderr avisa si la URL base es `http:` en
|
|
34
|
+
un host no local (el token viajaría en claro).
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
|
|
38
|
+
- `crm auth logout` **revoca la sesión en el servidor** (nueva ruta
|
|
39
|
+
`/api/v1/cli/token/revoke`) además de borrar el perfil local — antes el
|
|
40
|
+
refresh token vivía hasta caducar (30 d). Best-effort si no hay red.
|
|
41
|
+
- **Refresh multi-proceso:** ventana de gracia de 2 min para el token recién
|
|
42
|
+
rotado, así dos invocaciones simultáneas del CLI no se expulsan.
|
|
43
|
+
- **Reintento tras 401:** ante un token rechazado dentro de su ventana
|
|
44
|
+
(desfase de reloj / revocación temprana) el CLI fuerza un refresh y
|
|
45
|
+
reintenta una vez. Solo sesiones.
|
|
46
|
+
- Refresh de sesión cubierto también en `doctor`, `meta`, `mention` y `skill`
|
|
47
|
+
(antes solo `run` y las subidas de archivo refrescaban).
|
|
48
|
+
|
|
49
|
+
### Performance
|
|
50
|
+
|
|
51
|
+
- `crm skill pull --all` descarga en paralelo con concurrencia acotada (6); las
|
|
52
|
+
escrituras a disco siguen en serie para no competir por el manifest.
|
|
53
|
+
|
|
54
|
+
## [0.16.1] — 2026-06-29
|
|
55
|
+
|
|
56
|
+
### Docs
|
|
57
|
+
|
|
58
|
+
- `SURFACE.txt` puesto al día con la superficie real: añadidos `marketplace`
|
|
59
|
+
(compare/domain/providers/import/scrape), `task delete`, `task awaiting-reply`,
|
|
60
|
+
`task board {list,add,remove}`, `comment update`, `skill {init,push,remove,
|
|
61
|
+
review {list,approve,reject}}`, `rank {inspect,reconcile}`, y flags que
|
|
62
|
+
faltaban (`--description-file`, `--body-file`, `ga4 --dimensions/--metrics`,
|
|
63
|
+
`task list --review-pending/--review-acked`, global `--as-agent`/`--styled`).
|
|
64
|
+
|
|
65
|
+
### Internal
|
|
66
|
+
|
|
67
|
+
- Nuevo guardrail `__tests__/surface-parity.test.mjs`: deriva el árbol real de
|
|
68
|
+
`crm commands` y falla si SURFACE.txt omite un comando/flag o documenta uno
|
|
69
|
+
inexistente — impide que la doc vuelva a derivar. `smoke.test.mjs` ahora
|
|
70
|
+
también deriva su lista del catálogo en vez de un array a mano.
|
|
71
|
+
|
|
9
72
|
## [0.16.0] — 2026-06-20
|
|
10
73
|
|
|
11
74
|
### Added
|
package/SKILL.md
CHANGED
|
@@ -160,6 +160,21 @@ Errors **always** appear on stderr with full envelope, bypassing `--jq`. Exit co
|
|
|
160
160
|
|
|
161
161
|
**Do NOT confuse this with `[[feedback_task_refs_use_chip_syntax]]`**: inside task descriptions, comments, and chat bodies you still use `#[Title](taskId)` chips, never raw dashboard URLs. The dashboard URL goes only in your chat reply to the human reviewing your work — that is where they need a one-click destination.
|
|
162
162
|
|
|
163
|
+
## Descubrir tableros (antes de colocar o mover tareas)
|
|
164
|
+
|
|
165
|
+
`crm board list` enumera los tableros del workspace (`_id`, `name`, `clientId`,
|
|
166
|
+
`order`, `isDefault`). Es el **descubrimiento**: sin él solo puedes conocer un
|
|
167
|
+
board por una tarea que ya viva en él, así que un tablero vacío (p. ej. un "Web"
|
|
168
|
+
recién creado) es invisible. Fíltralo con `--client <id>` para ver solo los de un
|
|
169
|
+
cliente. Staff-only. Úsalo antes de `crm task update <id> --board <boardId>` o de
|
|
170
|
+
`crm board columns <boardId>` cuando no tengas el id a mano — no adivines el id ni
|
|
171
|
+
pidas la URL del CRM.
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
crm board list --client cli_xyz --jq '.data[].name' # nombres
|
|
175
|
+
crm board list --client cli_xyz --ids-only # ids para pipe
|
|
176
|
+
```
|
|
177
|
+
|
|
163
178
|
## Colocar tareas en columnas kanban (swimlanes por persona)
|
|
164
179
|
|
|
165
180
|
Algunos tableros usan **columnas personalizadas** — una por redactor/persona —
|
|
@@ -403,11 +418,11 @@ crm task create \
|
|
|
403
418
|
--description "Current H1 buries the value prop; replace with 'Plans that scale with you'." \
|
|
404
419
|
--idempotency-key 01HY8X...
|
|
405
420
|
|
|
406
|
-
#
|
|
407
|
-
#
|
|
408
|
-
#
|
|
409
|
-
#
|
|
410
|
-
#
|
|
421
|
+
# Change events (log de cambios on-page): disponibles en cualquier tarea
|
|
422
|
+
# anclada a un dominio (task.domainId) — el backend rechaza tareas sin
|
|
423
|
+
# dominio. Lectura via GET /api/v1/domains/<domainId>/changes o
|
|
424
|
+
# `crm change list`. No hay verbo de escritura todavía (ni CLI ni REST);
|
|
425
|
+
# los registros se crean desde la UI web de la tarea.
|
|
411
426
|
|
|
412
427
|
# Search across everything
|
|
413
428
|
crm search "meta title" --kind change --domain dom_xyz --limit 5
|
package/SURFACE.txt
CHANGED
|
@@ -19,8 +19,11 @@ CMD crm auth list
|
|
|
19
19
|
CMD crm auth switch <name>
|
|
20
20
|
CMD crm auth logout [name]
|
|
21
21
|
|
|
22
|
-
CMD crm task list --status <status> --domain <id> --board <id> --column <id> --assignee <id> --tag <id> --limit <n>
|
|
23
|
-
# --
|
|
22
|
+
CMD crm task list --status <status> --domain <id> --board <id> --column <id> --assignee <id> --tag <id> --review-pending --review-acked --limit <n>
|
|
23
|
+
# --review-pending / --review-acked filtran la cola de revisión (agente pendiente
|
|
24
|
+
# de aceptar vs ya aceptada por staff).
|
|
25
|
+
# --board filtra al tablero de anclaje de la tarea (no incluye multi-home);
|
|
26
|
+
# --column a una columna kanban. Combínalos
|
|
24
27
|
# para leer una sola swimlane (p. ej. el backlog "To Do" de un board de redactores).
|
|
25
28
|
CMD crm task get <id>
|
|
26
29
|
# task get returns `participants[]` with name, role, expertise, and
|
|
@@ -29,6 +32,9 @@ CMD crm task get <id>
|
|
|
29
32
|
CMD crm task related <id>
|
|
30
33
|
# task related groups: referenced (already linked via #), sameDomain, sharedTags.
|
|
31
34
|
CMD crm task search <query> --limit <n>
|
|
35
|
+
# task awaiting-reply — cola de tareas con un comentario de cliente aún sin
|
|
36
|
+
# respuesta del equipo (--client la acota a un cliente).
|
|
37
|
+
CMD crm task awaiting-reply --client <id>
|
|
32
38
|
# task preflight — OBLIGATORIO antes de `task create`. Bundle de 1 round-trip:
|
|
33
39
|
# similarTasks (FTS + Jaccard) · recall si --url · recentChanges en el dominio
|
|
34
40
|
# · urlScopedTasks · recentBacklinks · openTaskCounts del dominio · hints[].
|
|
@@ -45,12 +51,20 @@ CMD crm task preflight --title <title> --url <url> --domain <id> --limit <n> --s
|
|
|
45
51
|
# el CLI avisa en stderr a partir de 2 MB y rechaza localmente >10 MB antes de
|
|
46
52
|
# tocar la red. En `task update` la lista es REEMPLAZO (los adjuntos antiguos
|
|
47
53
|
# se borran salvo que también los pases); usa `--clear-files` para vaciar.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
# `--description-file <path>` lee el cuerpo de un fichero (markdown / code fences
|
|
55
|
+
# seguros, evita la substitución de shell con backticks). Gana a `--description`.
|
|
56
|
+
CMD crm task create --title <title> --description <text> --description-file <path> --domain <id> --board <id> --status <status> --assignee <id...> --collaborator <id...> --tag <id...> --start <date> --due <date> --completion-strategy <all|any|manual> --client-visible --no-review --file <path...>
|
|
57
|
+
CMD crm task update <id> --title <title> --description <text> --description-file <path> --status <status> --domain <id> --board <id> --column <id> --assignee <id...> --collaborator <id...> --tag <id...> --start <date> --due <date> --completion-strategy <all|any|manual> --client-visible --no-client-visible --file <path...> --clear-files
|
|
58
|
+
# task delete — destructivo, owner/admin. Borra la tarea (desadjunta timeEntries).
|
|
59
|
+
CMD crm task delete <id>
|
|
60
|
+
# Tableros kanban — `board list` descubre los tableros del workspace (id, nombre,
|
|
61
|
+
# cliente, orden, isDefault); imprescindible para tableros vacíos, que de otro
|
|
62
|
+
# modo solo se conocen por una tarea que ya viva en ellos. Filtra con --client.
|
|
63
|
+
# Staff-only. `board columns <boardId>` lista las columnas (ordenadas) con su
|
|
64
|
+
# autoAssignUserId / autoMoveOnAssign. Flujo redactores: `board columns` para
|
|
52
65
|
# resolver la columna de cada redactor → `task update <id> --column <colId>`
|
|
53
66
|
# (la auto-asignación coloca al redactor y la tarjeta cae en su columna).
|
|
67
|
+
CMD crm board list --client <id> --archived
|
|
54
68
|
CMD crm board columns <boardId>
|
|
55
69
|
# Phase 41 — task ↔ backlink linking. `assets` returns the primary FK +
|
|
56
70
|
# outgoing mentions in one payload; `link-backlink` / `link-offer` set the
|
|
@@ -66,11 +80,21 @@ CMD crm task complete-with-evidence <task-id> --asset <kind:id> --comment <id>
|
|
|
66
80
|
CMD crm task attach list <taskId>
|
|
67
81
|
CMD crm task attach add <taskId> --file <path...>
|
|
68
82
|
CMD crm task attach remove <taskId> <attachmentId>
|
|
83
|
+
# task board — multi-home (Asana-style). Una tarea vive en N boards del mismo
|
|
84
|
+
# cliente, todos iguales (no hay board "principal"). `list` muestra los boards;
|
|
85
|
+
# `add`/`remove` gestionan la pertenencia. Se puede quitar cualquiera; lo único
|
|
86
|
+
# vetado es dejar la tarea sin ningún board.
|
|
87
|
+
CMD crm task board list <taskId>
|
|
88
|
+
CMD crm task board add <taskId> <boardId>
|
|
89
|
+
CMD crm task board remove <taskId> <boardId>
|
|
69
90
|
|
|
70
91
|
CMD crm comment list <taskId>
|
|
71
|
-
# `--body` opcional si pasas `--file`. `--file <path>`
|
|
92
|
+
# `--body` opcional si pasas `--file`. `--body-file <path>` lee el cuerpo de un
|
|
93
|
+
# fichero (markdown / code fences seguros). `--file <path>` repetible para varios
|
|
72
94
|
# adjuntos (máx 10 MB cada uno; aviso a partir de 2 MB).
|
|
73
|
-
CMD crm comment create --task <id> --body <text> --kind <note|agent_log|decision> --file <path...>
|
|
95
|
+
CMD crm comment create --task <id> --body <text> --body-file <path> --kind <note|agent_log|decision> --file <path...>
|
|
96
|
+
# comment update — edita el cuerpo de un comentario propio (--id obligatorio).
|
|
97
|
+
CMD crm comment update --id <commentId> --body <text> --body-file <path>
|
|
74
98
|
|
|
75
99
|
# Chat — conversaciones ancladas a workspace/cliente/dominio + DMs y grupos.
|
|
76
100
|
# Per-cliente las salas Interna y Compartida se auto-crean. Para chats libres
|
|
@@ -87,11 +111,15 @@ CMD crm chat thread --workspace --client <id> --shared
|
|
|
87
111
|
CMD crm chat send <threadId> --body <text> --file <path...> --kind <message|agent_log> --parent <messageId>
|
|
88
112
|
CMD crm chat reply <messageId> --thread <id> --body <text> --file <path...> --kind <message|agent_log>
|
|
89
113
|
CMD crm chat react <messageId> --emoji <👍|✅|👀|🙏|❤️|❓|🔥|🚀>
|
|
90
|
-
CMD crm chat dm --member <id
|
|
114
|
+
CMD crm chat dm --member <id...> --title <name> --client <id>
|
|
91
115
|
CMD crm chat mark-read <threadId> --message <id>
|
|
92
116
|
|
|
93
117
|
CMD crm client list
|
|
94
118
|
CMD crm client get <id>
|
|
119
|
+
# create provisiona presupuesto + tablero por defecto; delete es cascade
|
|
120
|
+
# (budgets + columnas + refs). Ambos solo owner/admin.
|
|
121
|
+
CMD crm client create --name <name>
|
|
122
|
+
CMD crm client delete <id>
|
|
95
123
|
# Profile responses carry `internalNotes` (markdown, staff-only) — handling
|
|
96
124
|
# rules like "never mention X to this CEO" / "always cc Eric as follower".
|
|
97
125
|
# Read these before drafting any comment/mention. Never echo into client-
|
|
@@ -211,7 +239,7 @@ CMD crm integration sync --property <id>
|
|
|
211
239
|
# Operators (GA4 adds): batch (inListFilter; value is newline-separated)
|
|
212
240
|
# ads query is read-only GAQL; cost is returned in micros (÷1e6 for currency).
|
|
213
241
|
CMD crm gsc query --property <id> --account <id> --site-url <url> --start <date> --end <date> --dimension <date|page|query|country|device> --filters <expr> --cursor <n>
|
|
214
|
-
CMD crm ga4 query --property <id> --account <id> --ga4-property <num> --start <date> --end <date> --filters <expr>
|
|
242
|
+
CMD crm ga4 query --property <id> --account <id> --ga4-property <num> --start <date> --end <date> --filters <expr> --dimensions <list> --metrics <list>
|
|
215
243
|
CMD crm bing query --property <id> --account <id> --site-url <url> --start <date> --end <date>
|
|
216
244
|
CMD crm ads query --property <id> --account <id> --customer-id <id> --start <date> --end <date>
|
|
217
245
|
CMD crm ads whoami --account <id> # diagnóstico OAuth: scopes concedidos + ¿'adwords'? + MCC/dev-token
|
|
@@ -225,6 +253,8 @@ CMD crm ads import # dispara ingesta fresca de Google Ads (diaria + campañas)
|
|
|
225
253
|
# Agency skills — librería de playbooks para Claude Code. `pull` escribe en
|
|
226
254
|
# `.claude/skills/<slug>/SKILL.md` + recursos; el manifest se guarda en
|
|
227
255
|
# `.claude/skills/.crm-manifest.json` para que `update` detecte desactualizados.
|
|
256
|
+
# `init` copia los tool-skills que vienen en el bundle del CLI (sin login).
|
|
257
|
+
CMD crm skill init --dry-run --force --preserve
|
|
228
258
|
CMD crm skill list --category <name> --status <draft|published|archived> --tag <id> --q <text>
|
|
229
259
|
CMD crm skill show <slug> --revision <id>
|
|
230
260
|
CMD crm skill revisions <slug>
|
|
@@ -233,12 +263,23 @@ CMD crm skill revision <id>
|
|
|
233
263
|
CMD crm skill create --slug <slug> --name <name> --description <text> --category <local-seo|google-ads|technical-seo|content|link-building|crm-ops|workflow|general> --kind <playbook|workflow|tool|reference> --tag <id...> --visibility <workspace|staff_only> --body <md> --frontmatter <yaml>
|
|
234
264
|
# skill set patches metadata only; body edits go through `crm skill push`.
|
|
235
265
|
CMD crm skill set <slug> --name <name> --description <text> --category <name> --kind <kind> --tag <id...> --visibility <workspace|staff_only>
|
|
266
|
+
# skill push — sube el cuerpo editado a Convex (draft). `--submit` lo manda al
|
|
267
|
+
# inbox de revisión (member/agent); `--publish` publica directo (owner/admin);
|
|
268
|
+
# `--force` ignora drift; `--force-overwrite-draft` pisa un draft pendiente ajeno.
|
|
269
|
+
CMD crm skill push <slug> --note <text> --publish --submit --force --force-overwrite-draft --dry-run
|
|
236
270
|
CMD crm skill archive <slug>
|
|
237
271
|
CMD crm skill restore <slug>
|
|
238
|
-
|
|
272
|
+
# skill remove — borra el mirror local (`--purge` también quita la entrada del manifest).
|
|
273
|
+
CMD crm skill remove <slug> --purge
|
|
274
|
+
CMD crm skill pull <slug> --revision <id> --dry-run --preserve --force
|
|
239
275
|
CMD crm skill pull --all --category <name> --tag <id>
|
|
240
|
-
CMD crm skill update --dry-run
|
|
276
|
+
CMD crm skill update --dry-run --preserve --prune-archived
|
|
241
277
|
CMD crm skill diff <slug>
|
|
278
|
+
# skill review — inbox de aprobación (owner/admin). `list` muestra revisiones
|
|
279
|
+
# sugeridas pendientes; `approve`/`reject` resuelven una por id.
|
|
280
|
+
CMD crm skill review list
|
|
281
|
+
CMD crm skill review approve <id>
|
|
282
|
+
CMD crm skill review reject <id> --reason <text>
|
|
242
283
|
|
|
243
284
|
# Documentos de trabajo de cliente — procesos en markdown editables por IA.
|
|
244
285
|
# Anclados a un cliente; internos por defecto, opt-in a cliente con `share`.
|
|
@@ -274,10 +315,18 @@ CMD crm time usage <id>
|
|
|
274
315
|
# positionally, via --stdin (newline/space/comma) or --ids-from-file.
|
|
275
316
|
# `delete` refuses the whole batch when any keyword still has an active
|
|
276
317
|
# rank goal — unlink the task first.
|
|
277
|
-
CMD crm rank list --domain <id> --country <iso2> --device <mobile|desktop> --state <pending_sync|active|orphan|archived> --unranked --canibalised --search <text> --limit <n>
|
|
318
|
+
CMD crm rank list --domain <id> --country <iso2> --device <mobile|desktop> --state <pending_sync|active|orphan|archived> --unranked --canibalised --favorites --search <text> --limit <n>
|
|
278
319
|
CMD crm rank get <id>
|
|
320
|
+
# rank inspect — diagnóstico GRATIS de una keyword (0 unidades Ahrefs): por qué no
|
|
321
|
+
# tiene snapshot / posición. rank reconcile — chequeo de drift gratis que marca
|
|
322
|
+
# keywords huérfanas (dry-run por defecto).
|
|
323
|
+
CMD crm rank inspect <id>
|
|
324
|
+
CMD crm rank reconcile --domain <id> --dry-run
|
|
279
325
|
CMD crm rank add --domain <id> --country <iso2> --device <mobile|desktop> --tag <name...> --text <raw>|--file <path>|--stdin
|
|
280
326
|
CMD crm rank tag [ids...] --add <tag...> --remove <tag...> --replace <tag...> --stdin --ids-from-file <path>
|
|
327
|
+
# rank favorite — marca (o --off desmarca) el set top-N que alimenta la posición
|
|
328
|
+
# media del proyecto (la vista que ve el cliente en el portal). Máx 500 por lote.
|
|
329
|
+
CMD crm rank favorite [ids...] --off --stdin --ids-from-file <path>
|
|
281
330
|
CMD crm rank archive [ids...] --stdin --ids-from-file <path>
|
|
282
331
|
CMD crm rank restore [ids...] --stdin --ids-from-file <path>
|
|
283
332
|
CMD crm rank delete [ids...] --stdin --ids-from-file <path>
|
|
@@ -308,6 +357,16 @@ CMD crm report snapshot <id>
|
|
|
308
357
|
CMD crm report approve <id> --note <text>
|
|
309
358
|
CMD crm report reject <id> --reason <text>
|
|
310
359
|
|
|
360
|
+
# Marketplace — comparador cross-provider de precios de backlinks (Phase 35).
|
|
361
|
+
# `compare` consulta el catálogo global con filtros; `domain <domain>` agrupa
|
|
362
|
+
# las ofertas de un dominio; `providers` lista los proveedores; `import` carga
|
|
363
|
+
# ofertas manualmente (--file/--stdin); `scrape` dispara el worker hosted.
|
|
364
|
+
CMD crm marketplace compare --search <text> --provider <id> --country <iso2> --min-dr <n> --max-price <eur> --in-stock
|
|
365
|
+
CMD crm marketplace domain <domain>
|
|
366
|
+
CMD crm marketplace providers
|
|
367
|
+
CMD crm marketplace import --provider <id> --file <path> --stdin
|
|
368
|
+
CMD crm marketplace scrape --provider <id>
|
|
369
|
+
|
|
311
370
|
# Dump the full CLI surface as JSON so agents can introspect without help-text
|
|
312
371
|
# parsing. `{ data: { tree, flat } }` — `flat` is the linear command list.
|
|
313
372
|
CMD crm commands
|
|
@@ -320,6 +379,7 @@ FLAG --quiet only `data`, no envelope
|
|
|
320
379
|
FLAG --ids-only one id per line
|
|
321
380
|
FLAG --count single integer
|
|
322
381
|
FLAG --markdown human-readable preview
|
|
382
|
+
FLAG --styled alias of --markdown (reserved for colored output)
|
|
323
383
|
FLAG --jq <expr> tiny jq (.a, .a.b, .a[], .a[].b)
|
|
324
384
|
FLAG --profile <name> named credentials profile
|
|
325
385
|
FLAG --workspace <id> workspace override
|
|
@@ -330,3 +390,4 @@ FLAG --idempotency-key stable retry key (autogenerated on writes if omitted)
|
|
|
330
390
|
FLAG --wait-for-approval block until a human decides (shadow-mode writes only)
|
|
331
391
|
FLAG --timeout <dur> timeout for --wait-for-approval, e.g. 30s, 5m, 2h (default 30m)
|
|
332
392
|
FLAG --shadow force this write to land as a pending proposal for human review (one-way: agents cannot downgrade to autonomous)
|
|
393
|
+
FLAG --as-agent stamp this invocation as an AI agent (actorType:agent, AGENT badge). Auto-detected under Claude Code / Codex.
|
|
@@ -19,10 +19,12 @@
|
|
|
19
19
|
* Both use the same ResolvedCredentials shape downstream — the transport
|
|
20
20
|
* layer doesn't care which token it's carrying, just that it's live.
|
|
21
21
|
*/
|
|
22
|
-
import { readFileSync, writeFileSync, existsSync, mkdirSync, chmodSync } from "node:fs";
|
|
22
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync, chmodSync, renameSync } from "node:fs";
|
|
23
23
|
import { homedir } from "node:os";
|
|
24
24
|
import { join } from "node:path";
|
|
25
|
-
|
|
25
|
+
/** Producción por defecto — el CLI publicado en npm habla con la app real.
|
|
26
|
+
* Desarrollo local: `CRM_API_URL=http://localhost:3000` o `--api-url`. */
|
|
27
|
+
const DEFAULT_API_BASE_URL = "https://crm.roilab.es";
|
|
26
28
|
function credentialsDir() {
|
|
27
29
|
return join(homedir(), ".config", "crm");
|
|
28
30
|
}
|
|
@@ -58,9 +60,15 @@ function load() {
|
|
|
58
60
|
function save(file) {
|
|
59
61
|
const dir = credentialsDir();
|
|
60
62
|
if (!existsSync(dir))
|
|
61
|
-
mkdirSync(dir, { recursive: true });
|
|
63
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
62
64
|
const path = credentialsPath();
|
|
63
|
-
|
|
65
|
+
// Atomic write: tmp sibling + rename, so a crash mid-write (or two CLI
|
|
66
|
+
// invocations refreshing tokens at once) never leaves a truncated/corrupt
|
|
67
|
+
// credentials file. `mode` on the tmp file means the secret is 0600 from
|
|
68
|
+
// the very first byte — no window where the file exists world-readable.
|
|
69
|
+
const tmp = `${path}.tmp.${process.pid}.${Date.now()}`;
|
|
70
|
+
writeFileSync(tmp, JSON.stringify(file, null, 2), { encoding: "utf8", mode: 0o600 });
|
|
71
|
+
renameSync(tmp, path);
|
|
64
72
|
try {
|
|
65
73
|
chmodSync(path, 0o600);
|
|
66
74
|
}
|
|
@@ -68,11 +76,33 @@ function save(file) {
|
|
|
68
76
|
// Windows, etc. — no-op
|
|
69
77
|
}
|
|
70
78
|
}
|
|
79
|
+
/** Warn (once per process) when the base URL is plaintext http on a non-local
|
|
80
|
+
* host — the bearer token would travel unencrypted. */
|
|
81
|
+
let warnedInsecureBaseUrl = false;
|
|
82
|
+
function warnIfInsecureBaseUrl(baseUrl) {
|
|
83
|
+
if (warnedInsecureBaseUrl)
|
|
84
|
+
return;
|
|
85
|
+
try {
|
|
86
|
+
const u = new URL(baseUrl);
|
|
87
|
+
if (u.protocol !== "http:")
|
|
88
|
+
return;
|
|
89
|
+
const host = u.hostname;
|
|
90
|
+
if (host === "localhost" || host === "127.0.0.1" || host === "[::1]" || host === "::1") {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
warnedInsecureBaseUrl = true;
|
|
94
|
+
process.stderr.write(`[crm] AVISO: la URL base ${baseUrl} usa http sin cifrar — el token de autenticación viaja en claro. Usa https salvo en desarrollo local.\n`);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
// URL inválida — el transporte fallará con su propio error más claro.
|
|
98
|
+
}
|
|
99
|
+
}
|
|
71
100
|
/** Resolve credentials from env or the configured profile. Throws if missing. */
|
|
72
101
|
export function resolveCredentials(explicitProfile) {
|
|
73
102
|
const envBaseUrl = process.env.CRM_API_URL ?? DEFAULT_API_BASE_URL;
|
|
74
103
|
const envKey = process.env.CRM_API_KEY ?? process.env.CRM_TOKEN;
|
|
75
104
|
if (envKey) {
|
|
105
|
+
warnIfInsecureBaseUrl(envBaseUrl);
|
|
76
106
|
return {
|
|
77
107
|
apiKey: envKey,
|
|
78
108
|
apiBaseUrl: envBaseUrl,
|
|
@@ -87,16 +117,20 @@ export function resolveCredentials(explicitProfile) {
|
|
|
87
117
|
throw new Error(`No credentials for profile "${profileName}". Run \`crm auth login\` to add one, or set CRM_API_KEY / CRM_TOKEN.`);
|
|
88
118
|
}
|
|
89
119
|
if (profile.kind === "apiKey") {
|
|
120
|
+
const apiBaseUrl = profile.apiBaseUrl ?? DEFAULT_API_BASE_URL;
|
|
121
|
+
warnIfInsecureBaseUrl(apiBaseUrl);
|
|
90
122
|
return {
|
|
91
123
|
apiKey: profile.apiKey,
|
|
92
|
-
apiBaseUrl
|
|
124
|
+
apiBaseUrl,
|
|
93
125
|
profileName,
|
|
94
126
|
source: "profile",
|
|
95
127
|
};
|
|
96
128
|
}
|
|
129
|
+
const apiBaseUrl = profile.apiBaseUrl ?? DEFAULT_API_BASE_URL;
|
|
130
|
+
warnIfInsecureBaseUrl(apiBaseUrl);
|
|
97
131
|
return {
|
|
98
132
|
apiKey: profile.accessToken,
|
|
99
|
-
apiBaseUrl
|
|
133
|
+
apiBaseUrl,
|
|
100
134
|
profileName,
|
|
101
135
|
source: "profile",
|
|
102
136
|
session: {
|
|
@@ -163,20 +197,41 @@ export function updateSessionTokens(profileName, tokens) {
|
|
|
163
197
|
* would have refreshed in time. Bug surfaced on `crm task update --file`
|
|
164
198
|
* (0.8.0 / 0.8.1).
|
|
165
199
|
*/
|
|
166
|
-
export async function refreshIfNeeded(creds
|
|
200
|
+
export async function refreshIfNeeded(creds,
|
|
201
|
+
/** Force a refresh even outside the 5-min window — used by the transport's
|
|
202
|
+
* retry-after-401 path when the server rejected an access token we thought
|
|
203
|
+
* was still live (clock skew / early server-side revoke). */
|
|
204
|
+
force = false) {
|
|
167
205
|
if (!creds.session || creds.source === "env")
|
|
168
206
|
return creds;
|
|
169
207
|
const REFRESH_WINDOW_MS = 5 * 60 * 1000;
|
|
170
|
-
if (creds.session.accessExpiresAt - Date.now() > REFRESH_WINDOW_MS)
|
|
208
|
+
if (!force && creds.session.accessExpiresAt - Date.now() > REFRESH_WINDOW_MS)
|
|
171
209
|
return creds;
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
210
|
+
// Best-effort: a network failure here must not kill the command — the
|
|
211
|
+
// request itself will surface a proper 401 if the token really expired.
|
|
212
|
+
let payload;
|
|
213
|
+
try {
|
|
214
|
+
const ac = new AbortController();
|
|
215
|
+
const timer = setTimeout(() => ac.abort(), 10_000);
|
|
216
|
+
let res;
|
|
217
|
+
try {
|
|
218
|
+
res = await fetch(`${creds.apiBaseUrl}/api/v1/cli/token/refresh`, {
|
|
219
|
+
method: "POST",
|
|
220
|
+
headers: { "content-type": "application/json" },
|
|
221
|
+
body: JSON.stringify({ refreshToken: creds.session.refreshToken }),
|
|
222
|
+
signal: ac.signal,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
finally {
|
|
226
|
+
clearTimeout(timer);
|
|
227
|
+
}
|
|
228
|
+
if (!res.ok)
|
|
229
|
+
return creds;
|
|
230
|
+
payload = (await res.json());
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
178
233
|
return creds;
|
|
179
|
-
|
|
234
|
+
}
|
|
180
235
|
if (payload.status !== "ok" || !payload.accessToken || !payload.refreshToken) {
|
|
181
236
|
return creds;
|
|
182
237
|
}
|
|
@@ -218,6 +273,19 @@ export function listProfiles() {
|
|
|
218
273
|
accessExpiresAt: p.kind === "session" ? p.accessExpiresAt : undefined,
|
|
219
274
|
}));
|
|
220
275
|
}
|
|
276
|
+
/** Read the refresh token + base URL of a session profile, for server-side
|
|
277
|
+
* revoke on logout. Returns null for API-key profiles or unknown names —
|
|
278
|
+
* those have no server session to kill. */
|
|
279
|
+
export function peekSessionForRevoke(profileName) {
|
|
280
|
+
const file = load();
|
|
281
|
+
const profile = file.profiles[profileName];
|
|
282
|
+
if (!profile || profile.kind !== "session")
|
|
283
|
+
return null;
|
|
284
|
+
return {
|
|
285
|
+
refreshToken: profile.refreshToken,
|
|
286
|
+
apiBaseUrl: profile.apiBaseUrl ?? DEFAULT_API_BASE_URL,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
221
289
|
/** Remove a profile. If it was active, falls back to the first remaining one. */
|
|
222
290
|
export function removeProfile(profileName) {
|
|
223
291
|
const file = load();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../../src/auth/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAA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
|
3
|
-
import { saveProfile, saveSession, listProfiles, removeProfile, switchProfile, resolveCredentials, } from "../auth/credentials.js";
|
|
3
|
+
import { saveProfile, saveSession, listProfiles, removeProfile, switchProfile, resolveCredentials, peekSessionForRevoke, } from "../auth/credentials.js";
|
|
4
4
|
import { run } from "../transport/run.js";
|
|
5
5
|
import { outputFromFlags, readFlags } from "./options.js";
|
|
6
|
-
|
|
6
|
+
// Producción por defecto (espejo de credentials.ts::DEFAULT_API_BASE_URL);
|
|
7
|
+
// desarrollo local via --api-url o CRM_API_URL.
|
|
8
|
+
const DEFAULT_API_URL = process.env.CRM_API_URL ?? "https://crm.roilab.es";
|
|
7
9
|
/**
|
|
8
10
|
* Poll the device-flow exchange endpoint until the user approves, denies,
|
|
9
11
|
* or the code expires. Recommended `interval` comes from the start payload.
|
|
@@ -187,12 +189,48 @@ export function registerAuth(program) {
|
|
|
187
189
|
});
|
|
188
190
|
auth
|
|
189
191
|
.command("logout")
|
|
190
|
-
.description("Elimina un perfil")
|
|
192
|
+
.description("Elimina un perfil y revoca su sesión en el servidor")
|
|
191
193
|
.argument("[name]", "perfil a eliminar (por defecto: el activo)")
|
|
192
|
-
.action((name) => {
|
|
194
|
+
.action(async (name) => {
|
|
193
195
|
const target = name ?? resolveCredentials().profileName;
|
|
196
|
+
// Revoca la sesión en el servidor ANTES de borrar el perfil local — si
|
|
197
|
+
// no, el refresh token seguiría vivo hasta caducar (30 d). Best-effort:
|
|
198
|
+
// sin red o siendo una key de API (sin sesión), seguimos y borramos el
|
|
199
|
+
// perfil igualmente.
|
|
200
|
+
let serverRevoked = false;
|
|
201
|
+
const session = peekSessionForRevoke(target);
|
|
202
|
+
if (session) {
|
|
203
|
+
try {
|
|
204
|
+
const ac = new AbortController();
|
|
205
|
+
const timer = setTimeout(() => ac.abort(), 10_000);
|
|
206
|
+
try {
|
|
207
|
+
const res = await fetch(`${session.apiBaseUrl}/api/v1/cli/token/revoke`, {
|
|
208
|
+
method: "POST",
|
|
209
|
+
headers: { "content-type": "application/json" },
|
|
210
|
+
body: JSON.stringify({ refreshToken: session.refreshToken }),
|
|
211
|
+
signal: ac.signal,
|
|
212
|
+
});
|
|
213
|
+
if (res.ok) {
|
|
214
|
+
const payload = (await res.json());
|
|
215
|
+
serverRevoked = payload.revoked === true;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
finally {
|
|
219
|
+
clearTimeout(timer);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
// Red caída — el perfil local se borra igual; la sesión caducará sola.
|
|
224
|
+
}
|
|
225
|
+
}
|
|
194
226
|
removeProfile(target);
|
|
195
|
-
process.stdout.write(JSON.stringify({
|
|
227
|
+
process.stdout.write(JSON.stringify({
|
|
228
|
+
ok: true,
|
|
229
|
+
summary: serverRevoked
|
|
230
|
+
? `Perfil "${target}" eliminado y sesión revocada en el servidor.`
|
|
231
|
+
: `Perfil "${target}" eliminado.`,
|
|
232
|
+
data: { serverRevoked },
|
|
233
|
+
}) + "\n");
|
|
196
234
|
});
|
|
197
235
|
}
|
|
198
236
|
//# sourceMappingURL=auth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAG5D,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EACL,WAAW,EACX,WAAW,EACX,YAAY,EACZ,aAAa,EACb,aAAa,EACb,kBAAkB,
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAG5D,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EACL,WAAW,EACX,WAAW,EACX,YAAY,EACZ,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,GAAG,E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Y,EAAE,CAAC;wBAC5D,MAAM,EAAE,EAAE,CAAC,MAAM;qBAClB,CACF,CAAC;oBACF,IAAI,GAAG,CAAC,EAAE,EAAE,CAAC;wBACX,MAAM,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAA0B,CAAC;wBAC5D,aAAa,GAAG,OAAO,CAAC,OAAO,KAAK,IAAI,CAAC;oBAC3C,CAAC;gBACH,CAAC;wBAAS,CAAC;oBACT,YAAY,CAAC,KAAK,CAAC,CAAC;gBACtB,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,uEAAuE;YACzE,CAAC;QACH,CAAC;QACD,aAAa,CAAC,MAAM,CAAC,CAAC;QACtB,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,IAAI,CAAC,SAAS,CAAC;YACb,EAAE,EAAE,IAAI;YACR,OAAO,EAAE,aAAa;gBACpB,CAAC,CAAC,WAAW,MAAM,+CAA+C;gBAClE,CAAC,CAAC,WAAW,MAAM,cAAc;YACnC,IAAI,EAAE,EAAE,aAAa,EAAE;SACxB,CAAC,GAAG,IAAI,CACV,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,10 +1,30 @@
|
|
|
1
|
-
/** `crm board` — introspección de tableros kanban (columnas + auto-asignación). */
|
|
1
|
+
/** `crm board` — introspección de tableros kanban (descubrimiento + columnas + auto-asignación). */
|
|
2
2
|
import { run } from "../transport/run.js";
|
|
3
3
|
import { outputFromFlags, readFlags } from "./options.js";
|
|
4
4
|
export function registerBoard(program) {
|
|
5
5
|
const board = program
|
|
6
6
|
.command("board")
|
|
7
|
-
.description("Tableros kanban — columnas y
|
|
7
|
+
.description("Tableros kanban — descubrimiento, columnas y auto-asignación");
|
|
8
|
+
board
|
|
9
|
+
.command("list")
|
|
10
|
+
.description("Lista los tableros del workspace (id, nombre, cliente, orden, isDefault). Es el descubrimiento de tableros: sin él solo conoces un board por una tarea que ya viva en él, así que los tableros vacíos son invisibles. Filtra con --client. Staff-only.")
|
|
11
|
+
.option("--client <id>", "filtra por id de cliente")
|
|
12
|
+
.option("--archived", "incluye los tableros archivados")
|
|
13
|
+
.action(async (opts, cmd) => {
|
|
14
|
+
const flags = readFlags(cmd);
|
|
15
|
+
await run({
|
|
16
|
+
method: "GET",
|
|
17
|
+
path: "/boards",
|
|
18
|
+
request: {
|
|
19
|
+
query: {
|
|
20
|
+
clientId: opts.client,
|
|
21
|
+
includeArchived: opts.archived ? true : undefined,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
output: outputFromFlags(flags),
|
|
25
|
+
profile: flags.profile,
|
|
26
|
+
});
|
|
27
|
+
});
|
|
8
28
|
board
|
|
9
29
|
.command("columns")
|
|
10
30
|
.description("Lista las columnas de un tablero (ordenadas) con su autoAssignUserId / autoMoveOnAssign. Úsalo para resolver qué columna auto-asigna a qué redactor antes de colocar tareas con `crm task update <id> --column <colId>`.")
|