orquestra-mcp 1.76.0 → 1.77.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/package.json +1 -1
- package/src/designApps.mjs +30 -0
- package/src/designFlow.mjs +40 -17
- package/src/server.mjs +155 -80
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orquestra-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.77.0",
|
|
4
4
|
"description": "Servidor MCP de Orquestra -- 161 tools para leer y escribir tareas, ideas, changelog, infraestructura, contenido, QA y más desde un agente de IA",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// ORQ-577: apps de Diseño / UI. El `app` viaja SIEMPRE en el query de la API (también en
|
|
2
|
+
// POST/PATCH/DELETE/bulk). Helpers puros, sin red.
|
|
3
|
+
import { DESIGN_PLATFORMS } from './designFlow.mjs'
|
|
4
|
+
|
|
5
|
+
export const APP_SLUG_RE = /^[a-z0-9][a-z0-9_-]*$/
|
|
6
|
+
export const APP_DESC = 'Key de la app (list_design_apps); obligatoria con varias apps'
|
|
7
|
+
export const APP_TOKEN_DESC = 'Key de la app (list_design_apps); omitido = token del proyecto, compartido'
|
|
8
|
+
|
|
9
|
+
// Saca de `body` (mutándolo) las claves que van al query y devuelve { clave: valor } con las definidas.
|
|
10
|
+
export function takeQuery(body, keys = []) {
|
|
11
|
+
const query = {}
|
|
12
|
+
for (const k of keys) {
|
|
13
|
+
if (k in body) {
|
|
14
|
+
if (body[k] !== undefined) query[k] = body[k]
|
|
15
|
+
delete body[k]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return query
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const arrayOf = r => (Array.isArray(r) ? r : Array.isArray(r?.items) ? r.items : [])
|
|
22
|
+
|
|
23
|
+
// Resumen compacto de una app: sus plataformas con los mismos conteos y su `next`.
|
|
24
|
+
export function summarizeAppStatus(app, status) {
|
|
25
|
+
const wanted = Array.isArray(app?.platforms) && app.platforms.length ? app.platforms : DESIGN_PLATFORMS
|
|
26
|
+
const platforms = Object.fromEntries(Object.entries(status.platforms).filter(([pl]) => wanted.includes(pl)))
|
|
27
|
+
const out = { key: app.key, name: app.name, platforms }
|
|
28
|
+
if (status.errors) out.errors = status.errors
|
|
29
|
+
return out
|
|
30
|
+
}
|
package/src/designFlow.mjs
CHANGED
|
@@ -15,6 +15,9 @@ const PRINCIPLES = [
|
|
|
15
15
|
'No crees tareas (create_parity_tasks, create_task) sin confirmar antes con el usuario.',
|
|
16
16
|
'Cada paso termina cuando get_design_status lo confirma (el campo `next` avanza), no cuando tú lo sientes terminado.',
|
|
17
17
|
'Antes de crear cualquier cosa llama a list_* para no duplicar.',
|
|
18
|
+
'Una app a la vez: con varias apps (list_design_apps) pasa app=<key> en cada llamada y no mezcles apps en una misma pasada.',
|
|
19
|
+
'Dentro de una app usa los mismos nombres de key en todas sus plataformas; la misma pantalla en OTRA app NO comparte key obligatoriamente.',
|
|
20
|
+
'Tokens: sin app = token del proyecto (compartido por todas las apps); con app = token de esa app.',
|
|
18
21
|
]
|
|
19
22
|
|
|
20
23
|
const GLOSSARY = {
|
|
@@ -41,7 +44,20 @@ const GLOSSARY = {
|
|
|
41
44
|
|
|
42
45
|
const STEPS = [
|
|
43
46
|
{
|
|
44
|
-
|
|
47
|
+
id: 'apps', title: 'Apps del proyecto',
|
|
48
|
+
goal: 'Saber si el proyecto tiene varias apps de Diseño y trabajar una a la vez.',
|
|
49
|
+
tools: ['list_design_apps', 'migrate_design_apps', 'upsert_design_tokens'],
|
|
50
|
+
how: [
|
|
51
|
+
'Llama list_design_apps. Con UNA app el parámetro `app` es opcional y todo funciona como siempre; con VARIAS es obligatorio en nav, componentes, paridad, deriva, sync y capturas (la API responde 400 con la lista si falta).',
|
|
52
|
+
'Con varias apps, cárgalas una por una: cada app con sus plataformas (platforms de list_design_apps) y pasando app=<key> en cada llamada.',
|
|
53
|
+
'Los tokens compartidos de marca van SIN app (valen para todas); los propios de una app van con app=<key> y pueden sobreescribir uno del proyecto.',
|
|
54
|
+
'Si ya había datos de antes de tener apps, asígnalos con migrate_design_apps (dryRun:true informa; dryRun:false aplica) SOLO con confirmación del usuario.',
|
|
55
|
+
],
|
|
56
|
+
doneWhen: 'Sabes qué app(s) existen y con cuál trabajas en esta pasada.',
|
|
57
|
+
pitfalls: ['Omitir `app` con varias apps (400).', 'Cargar tokens de marca con app (dejan de ser compartidos).', 'Correr migrate_design_apps con dryRun:false sin confirmar.'],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: 'check', title: 'Revisar qué ya existe',
|
|
45
61
|
goal: 'Saber qué hay cargado en Diseño / UI para no duplicar ni pisar nada.',
|
|
46
62
|
tools: ['get_design_status', 'list_design_tokens', 'list_design_nav', 'list_design_components'],
|
|
47
63
|
how: [
|
|
@@ -53,7 +69,7 @@ const STEPS = [
|
|
|
53
69
|
pitfalls: ['Crear sin listar primero genera duplicados.', 'Empezar por iOS/Android sin que la web tenga navegación cargada.'],
|
|
54
70
|
},
|
|
55
71
|
{
|
|
56
|
-
|
|
72
|
+
id: 'identity', title: 'Identidad: design tokens',
|
|
57
73
|
goal: 'Registrar colores, tipografía, radios, sombras, espaciado, iconos y logo de la plataforma.',
|
|
58
74
|
tools: ['list_design_tokens', 'upsert_design_tokens', 'create_design_token', 'update_design_token'],
|
|
59
75
|
how: [
|
|
@@ -67,7 +83,7 @@ const STEPS = [
|
|
|
67
83
|
pitfalls: ['Registrar valores hex que no están en el archivo del tema.', 'Nombres distintos por plataforma para lo mismo (impide comparar paridad).', 'Olvidar valueDark cuando el tema tiene modo oscuro.'],
|
|
68
84
|
},
|
|
69
85
|
{
|
|
70
|
-
|
|
86
|
+
id: 'navigation', title: 'Navegación: árbol de pantallas',
|
|
71
87
|
goal: 'Registrar el árbol de menús, secciones, pantallas, pestañas, acciones y overlays con keys estables entre plataformas.',
|
|
72
88
|
tools: ['list_design_nav', 'upsert_design_nav', 'update_design_nav_node', 'reorder_design_nav'],
|
|
73
89
|
how: [
|
|
@@ -81,7 +97,7 @@ const STEPS = [
|
|
|
81
97
|
pitfalls: ['Keys nuevas en iOS/Android para pantallas que ya existen en web.', 'Pantallas sin parentKey (quedan en la raíz).', 'Lotes de más de 40 nodos.'],
|
|
82
98
|
},
|
|
83
99
|
{
|
|
84
|
-
|
|
100
|
+
id: 'blocks', title: 'Bloques de cada pantalla',
|
|
85
101
|
goal: 'Describir cada pantalla (kind screen/tab) como bloques de arriba a abajo.',
|
|
86
102
|
tools: ['upsert_design_nav', 'update_design_nav_node'],
|
|
87
103
|
how: [
|
|
@@ -94,7 +110,7 @@ const STEPS = [
|
|
|
94
110
|
pitfalls: ['Describir el diseño ideal en vez del código real.', 'Nombres de bloque distintos para lo mismo entre plataformas.'],
|
|
95
111
|
},
|
|
96
112
|
{
|
|
97
|
-
|
|
113
|
+
id: 'actions-states', title: 'Acciones y estados por pantalla',
|
|
98
114
|
goal: 'Registrar qué puede hacer el usuario en cada pantalla y qué estados maneja; es lo que compara la paridad.',
|
|
99
115
|
tools: ['upsert_design_nav', 'update_design_nav_node'],
|
|
100
116
|
how: [
|
|
@@ -107,7 +123,7 @@ const STEPS = [
|
|
|
107
123
|
pitfalls: ['Registrar estados que la pantalla no maneja.', 'Verbos distintos para la misma operación (delete vs remove).', 'Usar update_design_nav_node y reemplazar sin querer el array completo.'],
|
|
108
124
|
},
|
|
109
125
|
{
|
|
110
|
-
|
|
126
|
+
id: 'components', title: 'Catálogo de componentes',
|
|
111
127
|
goal: 'Catalogar los componentes de UI reales con su referencia en código por plataforma.',
|
|
112
128
|
tools: ['list_design_components', 'upsert_design_components', 'update_design_component'],
|
|
113
129
|
how: [
|
|
@@ -121,7 +137,7 @@ const STEPS = [
|
|
|
121
137
|
pitfalls: ['Inventar tokens o usedIn que no existen.', 'Dos agentes cargando componentes al mismo tiempo.', 'Nombres distintos al canónico para el mismo componente.'],
|
|
122
138
|
},
|
|
123
139
|
{
|
|
124
|
-
|
|
140
|
+
id: 'parity', title: 'Paridad entre plataformas',
|
|
125
141
|
goal: 'Revisar huecos entre web, iOS y Android y fijar los que no aplican.',
|
|
126
142
|
tools: ['get_design_parity', 'set_design_parity_cell', 'create_parity_tasks'],
|
|
127
143
|
how: [
|
|
@@ -133,7 +149,7 @@ const STEPS = [
|
|
|
133
149
|
pitfalls: ['Crear tareas sin confirmar.', 'Marcar not_applicable sin motivo (la API lo rechaza).', 'Marcar not_applicable un hueco real para que "salga verde".'],
|
|
134
150
|
},
|
|
135
151
|
{
|
|
136
|
-
|
|
152
|
+
id: 'drift', title: 'Deriva de tokens',
|
|
137
153
|
goal: 'Detectar valores de diseño escritos a mano fuera de los tokens.',
|
|
138
154
|
tools: ['report_design_drift', 'list_design_drift', 'update_design_drift', 'resolve_missing_design_drift'],
|
|
139
155
|
how: [
|
|
@@ -147,7 +163,7 @@ const STEPS = [
|
|
|
147
163
|
pitfalls: ['Resolver sin haber terminado la pasada completa.', 'Reportar el archivo del tema como deriva.', 'Mezclar plataformas en una misma pasada.'],
|
|
148
164
|
},
|
|
149
165
|
{
|
|
150
|
-
|
|
166
|
+
id: 'sync', title: 'Sincronía con el código (mantenimiento)',
|
|
151
167
|
goal: 'Detectar qué cambió en el código desde la última carga de Diseño / UI y mantener el catálogo al día.',
|
|
152
168
|
tools: ['check_design_sync', 'mark_design_synced', 'upsert_design_nav', 'upsert_design_components'],
|
|
153
169
|
how: [
|
|
@@ -161,7 +177,7 @@ const STEPS = [
|
|
|
161
177
|
pitfalls: ['Usar mark_design_synced sin haber revisado lo que cambió (oculta el cambio).', 'Pasar el repoPath de otra plataforma.', 'Borrar nodos porque su archivo no existe sin confirmar con el usuario.'],
|
|
162
178
|
},
|
|
163
179
|
{
|
|
164
|
-
|
|
180
|
+
id: 'screenshots', title: 'Capturas (opcional)',
|
|
165
181
|
goal: 'Adjuntar capturas a las pantallas clave.',
|
|
166
182
|
tools: ['add_design_screenshot', 'remove_design_screenshot'],
|
|
167
183
|
how: [
|
|
@@ -173,9 +189,12 @@ const STEPS = [
|
|
|
173
189
|
},
|
|
174
190
|
]
|
|
175
191
|
|
|
192
|
+
// order derivado de la posición: insertar un paso no obliga a renumerar a mano.
|
|
193
|
+
STEPS.forEach((st, i) => { st.order = i + 1 })
|
|
194
|
+
|
|
176
195
|
const PLATFORM_LABEL = { web: 'web (React)', ios: 'iOS (Swift)', android: 'Android (Kotlin)' }
|
|
177
196
|
|
|
178
|
-
function adjustStep(step, platform) {
|
|
197
|
+
function adjustStep(step, platform, app) {
|
|
179
198
|
const s = { ...step, how: [...step.how], pitfalls: [...step.pitfalls], tools: [...step.tools] }
|
|
180
199
|
if (step.id === 'navigation' && platform !== 'web') {
|
|
181
200
|
s.how.unshift('PRIMERO lee list_design_nav platform=web (tree o plano) y reutiliza sus keys para las mismas pantallas.')
|
|
@@ -186,16 +205,20 @@ function adjustStep(step, platform) {
|
|
|
186
205
|
if (step.id === 'drift' || step.id === 'identity' || step.id === 'components') {
|
|
187
206
|
s.how.push(`Trabaja SOLO platform=${platform} en esta pasada.`)
|
|
188
207
|
}
|
|
208
|
+
if (app) s.how.push(`Trabaja SOLO app=${app}: pásala en cada llamada de este paso.`)
|
|
189
209
|
return s
|
|
190
210
|
}
|
|
191
211
|
|
|
192
|
-
function buildAgentPrompt(platform, steps) {
|
|
212
|
+
function buildAgentPrompt(platform, steps, app) {
|
|
193
213
|
const ids = steps.map(s => `${s.order}. ${s.id}`).join('; ')
|
|
194
214
|
const webNote = platform === 'web'
|
|
195
215
|
? 'La web es la referencia: define keys y nombres estables, porque iOS y Android los reutilizarán.'
|
|
196
216
|
: 'Antes de crear nodos lee list_design_nav platform=web y reutiliza sus keys; la web es la referencia.'
|
|
197
217
|
return [
|
|
198
|
-
`Vas a llenar el módulo Diseño / UI de Orquestra para la plataforma ${PLATFORM_LABEL[platform]}, leyendo su código real. Trabaja SOLO esta plataforma y no inventes nada que no esté en el código.`,
|
|
218
|
+
`Vas a llenar el módulo Diseño / UI de Orquestra para la plataforma ${PLATFORM_LABEL[platform]}${app ? ` de la app "${app}"` : ''}, leyendo su código real. Trabaja SOLO esta plataforma${app ? ' y esta app' : ''} y no inventes nada que no esté en el código.`,
|
|
219
|
+
app
|
|
220
|
+
? `Pasa app="${app}" en TODAS las llamadas de Diseño (tokens propios de la app con app; los de marca compartidos van sin app). Las keys son las de esta app: la misma pantalla en otra app no comparte key obligatoriamente.`
|
|
221
|
+
: 'Si list_design_apps devuelve varias apps, pide cuál trabajar y pasa app=<key> en todas las llamadas; con una sola app no hace falta.',
|
|
199
222
|
webNote,
|
|
200
223
|
`Pasos en orden (ids de get_design_flow): ${ids}.`,
|
|
201
224
|
'Empieza llamando get_design_status: su campo `next` te dice el primer paso pendiente de tu plataforma. Para cada paso llama get_design_flow con step=<id> y sigue sus `how`, usando los `tools` indicados.',
|
|
@@ -208,9 +231,9 @@ export const DESIGN_PLATFORM_ARGS = ['web', 'ios', 'android', 'all']
|
|
|
208
231
|
export const STEP_IDS = STEPS.map(s => s.id)
|
|
209
232
|
|
|
210
233
|
// Devuelve { error } si el step no existe (la tool lo convierte en un 404 amable).
|
|
211
|
-
export function getDesignFlow({ platform = 'all', step } = {}) {
|
|
212
|
-
const adjust = platform === 'all' ? s => s : s => adjustStep(s, platform)
|
|
213
|
-
const base = { version: 1, platform, principles: PRINCIPLES, glossary: GLOSSARY }
|
|
234
|
+
export function getDesignFlow({ platform = 'all', step, app } = {}) {
|
|
235
|
+
const adjust = platform === 'all' ? s => s : s => adjustStep(s, platform, app)
|
|
236
|
+
const base = { version: 1, platform, ...(app ? { app } : {}), principles: PRINCIPLES, glossary: GLOSSARY }
|
|
214
237
|
if (step) {
|
|
215
238
|
const found = STEPS.find(s => s.id === step)
|
|
216
239
|
if (!found) return { error: `Error (404): no existe el paso "${step}". Pasos disponibles: ${STEP_IDS.join(', ')}.` }
|
|
@@ -218,7 +241,7 @@ export function getDesignFlow({ platform = 'all', step } = {}) {
|
|
|
218
241
|
}
|
|
219
242
|
const steps = STEPS.map(adjust)
|
|
220
243
|
const out = { ...base, steps }
|
|
221
|
-
if (platform !== 'all') out.agentPrompt = buildAgentPrompt(platform, steps)
|
|
244
|
+
if (platform !== 'all') out.agentPrompt = buildAgentPrompt(platform, steps, app)
|
|
222
245
|
return out
|
|
223
246
|
}
|
|
224
247
|
|
package/src/server.mjs
CHANGED
|
@@ -14,6 +14,7 @@ import { parseSource, previewSkill, installSkill } from './skillInstall.mjs'
|
|
|
14
14
|
import { normalizeStatuses, findClosePath } from './closePath.mjs'
|
|
15
15
|
import { TOOL_GUIDES, GUIDE_TOPICS } from './toolGuides.mjs'
|
|
16
16
|
import { runCheck, runMark } from './designSync.mjs'
|
|
17
|
+
import { APP_SLUG_RE, APP_DESC, APP_TOKEN_DESC, takeQuery, arrayOf, summarizeAppStatus } from './designApps.mjs'
|
|
17
18
|
import { getDesignFlow, computeDesignStatus, DESIGN_PLATFORM_ARGS, DESIGN_PLATFORMS } from './designFlow.mjs'
|
|
18
19
|
|
|
19
20
|
// Versión leída de package.json (3 sep 2026) -- antes estaba hardcodeada
|
|
@@ -325,15 +326,16 @@ export function createServer() {
|
|
|
325
326
|
|
|
326
327
|
// `post(data, body, pid)` (opcional) decora la respuesta tras crear y puede quitar campos del body antes del POST
|
|
327
328
|
// con `pre(body)`; create_task lo usa para el checklist (ORQ-535).
|
|
328
|
-
function registerCreate(name, path, description, extraSchema, { pre, post } = {}) {
|
|
329
|
+
function registerCreate(name, path, description, extraSchema, { pre, post, query: queryKeys = [] } = {}) {
|
|
329
330
|
server.registerTool(
|
|
330
331
|
name,
|
|
331
332
|
{ description, inputSchema: { projectId: z.string().optional().describe(PROJECT_ID_DESC), ...extraSchema } },
|
|
332
333
|
async ({ projectId, ...body }) => {
|
|
333
334
|
try {
|
|
334
335
|
const pid = resolveProjectId(projectId)
|
|
336
|
+
const query = takeQuery(body, queryKeys)
|
|
335
337
|
const extra = pre ? pre(body) : undefined
|
|
336
|
-
const data = await apiPost(config, path, { projectId: pid, ...body })
|
|
338
|
+
const data = await apiPost(config, path, { projectId: pid, ...body }, query)
|
|
337
339
|
return textResult(post ? await post(data, extra, pid) : data)
|
|
338
340
|
} catch (err) {
|
|
339
341
|
return errorResult(err)
|
|
@@ -342,7 +344,7 @@ export function createServer() {
|
|
|
342
344
|
)
|
|
343
345
|
}
|
|
344
346
|
|
|
345
|
-
function registerUpdate(name, path, description, extraSchema, { idAlias, compact } = {}) {
|
|
347
|
+
function registerUpdate(name, path, description, extraSchema, { idAlias, compact, query: queryKeys = [] } = {}) {
|
|
346
348
|
server.registerTool(
|
|
347
349
|
name,
|
|
348
350
|
{
|
|
@@ -361,8 +363,9 @@ export function createServer() {
|
|
|
361
363
|
try {
|
|
362
364
|
const { projectId, id: idArg, compact: wantsCompact, ...rest } = args
|
|
363
365
|
if (idAlias) delete rest[idAlias]
|
|
366
|
+
const query = takeQuery(rest, queryKeys)
|
|
364
367
|
const id = idAlias ? resolveAlias({ id: idArg, [idAlias]: args[idAlias] }, 'id', idAlias) : idArg
|
|
365
|
-
const data = await apiPatch(config, path, { projectId: resolveProjectId(projectId), id, ...rest })
|
|
368
|
+
const data = await apiPatch(config, path, { projectId: resolveProjectId(projectId), id, ...rest }, query)
|
|
366
369
|
return textResult(compact && wantsCompact ? compactTaskResult(data, Object.keys(rest).filter(k => k !== 'opId' && k !== 'comment')) : data)
|
|
367
370
|
} catch (err) {
|
|
368
371
|
return errorResult(err)
|
|
@@ -2903,6 +2906,8 @@ export function createServer() {
|
|
|
2903
2906
|
)
|
|
2904
2907
|
|
|
2905
2908
|
// ═══ IDENTIDAD DE DISEÑO (ORQ-560) ═════════════════════════════════════════
|
|
2909
|
+
const APP_STR = z.string().max(40).regex(APP_SLUG_RE, 'slug: minúsculas, números, - o _')
|
|
2910
|
+
const appArg = desc => APP_STR.optional().describe(desc || APP_DESC)
|
|
2906
2911
|
const DESIGN_TOKEN_KINDS = ['color', 'typography', 'radius', 'shadow', 'spacing', 'logo', 'icon-set']
|
|
2907
2912
|
const DESIGN_TOKEN_PLATFORMS = ['all', 'web', 'ios', 'android']
|
|
2908
2913
|
const DESIGN_TOKEN_VARIANTS = ['light', 'dark', 'icon']
|
|
@@ -2932,15 +2937,17 @@ export function createServer() {
|
|
|
2932
2937
|
{
|
|
2933
2938
|
kind: z.enum(DESIGN_TOKEN_KINDS).optional().describe('Filtra por tipo'),
|
|
2934
2939
|
platform: z.enum(DESIGN_TOKEN_PLATFORMS).optional().describe('Filtra por plataforma (los "all" cuentan como all)'),
|
|
2940
|
+
app: appArg(APP_TOKEN_DESC),
|
|
2941
|
+
scope: z.enum(['own']).optional().describe('own = solo los propios de la app (requiere app); omitido = efectivos (proyecto + app)'),
|
|
2935
2942
|
},
|
|
2936
|
-
(args, projectId) => ({ projectId, kind: args.kind, platform: args.platform })
|
|
2943
|
+
(args, projectId) => ({ projectId, kind: args.kind, platform: args.platform, app: args.app, scope: args.scope })
|
|
2937
2944
|
)
|
|
2938
2945
|
registerCreate('create_design_token', '/v1/design-tokens',
|
|
2939
2946
|
`Crea un token de identidad de diseño. ${DESIGN_TOKEN_PURPOSE} Para cargar muchos de una vez usa upsert_design_tokens, no esta tool en bucle.`,
|
|
2940
|
-
designTokenFields(false))
|
|
2947
|
+
{ ...designTokenFields(false), app: appArg(APP_TOKEN_DESC) }, { query: ['app'] })
|
|
2941
2948
|
registerUpdate('update_design_token', '/v1/design-tokens',
|
|
2942
2949
|
`Edita un token de identidad de diseño existente (parche parcial: manda solo lo que cambia). ${DESIGN_TOKEN_PURPOSE}`,
|
|
2943
|
-
designTokenFields(true))
|
|
2950
|
+
{ ...designTokenFields(true), app: appArg(APP_TOKEN_DESC) }, { query: ['app'] })
|
|
2944
2951
|
|
|
2945
2952
|
server.registerTool(
|
|
2946
2953
|
'delete_design_token',
|
|
@@ -2949,11 +2956,12 @@ export function createServer() {
|
|
|
2949
2956
|
inputSchema: {
|
|
2950
2957
|
projectId: z.string().optional().describe(PROJECT_ID_DESC),
|
|
2951
2958
|
tokenId: z.string().describe('ID del token a borrar (ver list_design_tokens)'),
|
|
2959
|
+
app: appArg(APP_TOKEN_DESC),
|
|
2952
2960
|
},
|
|
2953
2961
|
},
|
|
2954
|
-
async ({ projectId, tokenId }) => {
|
|
2962
|
+
async ({ projectId, tokenId, app }) => {
|
|
2955
2963
|
try {
|
|
2956
|
-
return textResult(await apiDelete(config, '/v1/design-tokens', { projectId: resolveProjectId(projectId), id: tokenId }))
|
|
2964
|
+
return textResult(await apiDelete(config, '/v1/design-tokens', { projectId: resolveProjectId(projectId), id: tokenId }, { app }))
|
|
2957
2965
|
} catch (err) {
|
|
2958
2966
|
return errorResult(err)
|
|
2959
2967
|
}
|
|
@@ -2968,11 +2976,12 @@ export function createServer() {
|
|
|
2968
2976
|
projectId: z.string().optional().describe(PROJECT_ID_DESC),
|
|
2969
2977
|
compact: z.boolean().optional().describe('true (default) = el lote devuelve items resumidos {id,name,key?,platform?,action}; false = filas completas'),
|
|
2970
2978
|
tokens: z.array(z.object(designTokenFields(false))).min(1).max(100).describe('Tokens a crear/actualizar (1-100)'),
|
|
2979
|
+
app: appArg(APP_TOKEN_DESC),
|
|
2971
2980
|
},
|
|
2972
2981
|
},
|
|
2973
|
-
async ({ projectId, tokens, compact }) => {
|
|
2982
|
+
async ({ projectId, tokens, compact, app }) => {
|
|
2974
2983
|
try {
|
|
2975
|
-
return textResult(await apiPost(config, '/v1/design-tokens/bulk', { projectId: resolveProjectId(projectId), tokens, compact: compact ?? true }))
|
|
2984
|
+
return textResult(await apiPost(config, '/v1/design-tokens/bulk', { projectId: resolveProjectId(projectId), tokens, compact: compact ?? true }, { app }))
|
|
2976
2985
|
} catch (err) {
|
|
2977
2986
|
return errorResult(err)
|
|
2978
2987
|
}
|
|
@@ -3044,14 +3053,15 @@ export function createServer() {
|
|
|
3044
3053
|
platform: z.enum(NAV_PLATFORMS).describe('Plataforma: web | ios | android'),
|
|
3045
3054
|
tree: z.boolean().optional().describe('true = árbol anidado ({ items } con children); default lista plana'),
|
|
3046
3055
|
parentId: z.string().optional().describe('Solo lista plana: hijos directos de este nodo'),
|
|
3056
|
+
app: appArg(),
|
|
3047
3057
|
},
|
|
3048
3058
|
},
|
|
3049
|
-
async ({ projectId, platform, tree, parentId }) => {
|
|
3059
|
+
async ({ projectId, platform, tree, parentId, app }) => {
|
|
3050
3060
|
try {
|
|
3051
3061
|
const pid = resolveProjectId(projectId)
|
|
3052
3062
|
return textResult(tree
|
|
3053
|
-
? await apiGet(config, '/v1/design-nav/tree', { projectId: pid, platform })
|
|
3054
|
-
: await apiGet(config, '/v1/design-nav', { projectId: pid, platform, parentId }))
|
|
3063
|
+
? await apiGet(config, '/v1/design-nav/tree', { projectId: pid, platform, app })
|
|
3064
|
+
: await apiGet(config, '/v1/design-nav', { projectId: pid, platform, parentId, app }))
|
|
3055
3065
|
} catch (err) {
|
|
3056
3066
|
return errorResult(err)
|
|
3057
3067
|
}
|
|
@@ -3059,10 +3069,10 @@ export function createServer() {
|
|
|
3059
3069
|
)
|
|
3060
3070
|
registerCreate('create_design_nav_node', '/v1/design-nav',
|
|
3061
3071
|
`Crea un nodo de navegación de diseño. ${NAV_PURPOSE} Para cargar muchos de una vez usa upsert_design_nav, no esta tool en bucle. Cada nodo acepta "actions" (convención entidad.verbo, ej. task.create; la misma acción lleva la MISMA key en web, iOS y Android) y "states" (recomendados: loading, empty, error, readonly, no-access, offline, refreshing, search-empty). La matriz de paridad compara primero por capacidades (acciones y estados) y cae a bloques si la referencia no las define.`,
|
|
3062
|
-
navNodeFields(false))
|
|
3072
|
+
{ ...navNodeFields(false), app: appArg() }, { query: ['app'] })
|
|
3063
3073
|
registerUpdate('update_design_nav_node', '/v1/design-nav',
|
|
3064
3074
|
`Edita un nodo de navegación de diseño existente (parche parcial: manda solo lo que cambia; parentId puede mover el nodo o ponerlo en null para dejarlo en la raíz). Ojo: "actions" y "states" REEMPLAZAN el array completo del nodo (manda la lista final; para mezclar por key usa upsert_design_nav). Convención de actions: entidad.verbo (task.create), misma key en web, iOS y Android; states recomendados: loading, empty, error, readonly, no-access, offline, refreshing, search-empty. La matriz de paridad compara primero por capacidades (acciones y estados) y cae a bloques si la referencia no las define. ${NAV_PURPOSE}`,
|
|
3065
|
-
navNodeFields(true))
|
|
3075
|
+
{ ...navNodeFields(true), app: appArg() }, { query: ['app'] })
|
|
3066
3076
|
|
|
3067
3077
|
server.registerTool(
|
|
3068
3078
|
'delete_design_nav_node',
|
|
@@ -3071,11 +3081,12 @@ export function createServer() {
|
|
|
3071
3081
|
inputSchema: {
|
|
3072
3082
|
projectId: z.string().optional().describe(PROJECT_ID_DESC),
|
|
3073
3083
|
nodeId: z.string().describe('ID del nodo a borrar (ver list_design_nav)'),
|
|
3084
|
+
app: appArg(),
|
|
3074
3085
|
},
|
|
3075
3086
|
},
|
|
3076
|
-
async ({ projectId, nodeId }) => {
|
|
3087
|
+
async ({ projectId, nodeId, app }) => {
|
|
3077
3088
|
try {
|
|
3078
|
-
return textResult(await apiDelete(config, '/v1/design-nav', { projectId: resolveProjectId(projectId), id: nodeId }))
|
|
3089
|
+
return textResult(await apiDelete(config, '/v1/design-nav', { projectId: resolveProjectId(projectId), id: nodeId }, { app }))
|
|
3079
3090
|
} catch (err) {
|
|
3080
3091
|
return errorResult(err)
|
|
3081
3092
|
}
|
|
@@ -3091,11 +3102,12 @@ export function createServer() {
|
|
|
3091
3102
|
platform: z.enum(NAV_PLATFORMS).describe('Plataforma: web | ios | android'),
|
|
3092
3103
|
parentId: z.string().nullable().describe('ID del padre cuyos hijos se reordenan; null = raíz'),
|
|
3093
3104
|
ids: z.array(z.string()).min(1).describe('IDs de los hermanos en el orden final'),
|
|
3105
|
+
app: appArg(),
|
|
3094
3106
|
},
|
|
3095
3107
|
},
|
|
3096
|
-
async ({ projectId, platform, parentId, ids }) => {
|
|
3108
|
+
async ({ projectId, platform, parentId, ids, app }) => {
|
|
3097
3109
|
try {
|
|
3098
|
-
return textResult(await apiPost(config, '/v1/design-nav/reorder', { projectId: resolveProjectId(projectId), platform, parentId, ids }))
|
|
3110
|
+
return textResult(await apiPost(config, '/v1/design-nav/reorder', { projectId: resolveProjectId(projectId), platform, parentId, ids }, { app }))
|
|
3099
3111
|
} catch (err) {
|
|
3100
3112
|
return errorResult(err)
|
|
3101
3113
|
}
|
|
@@ -3106,7 +3118,7 @@ export function createServer() {
|
|
|
3106
3118
|
server.registerTool(
|
|
3107
3119
|
'upsert_design_nav',
|
|
3108
3120
|
{
|
|
3109
|
-
description: `Carga en lote (hasta 300 nodos) la navegación de diseño: es el camino para cargar el árbol completo de una plataforma leyendo su código (rutas del router, tab bar, sidebar, pantallas y sus bloques). ${NAV_PURPOSE} En vez de parentId cada nodo lleva parentKey (la key del padre, que puede venir en el mismo lote; sin parentKey = raíz). Un nodo existente se identifica por (platform, key) o, si no hay key, por (platform, parentId, name): se actualiza, si no se crea; nada se borra. "actions" (convención entidad.verbo, ej. task.create; la misma acción = la MISMA key en web, iOS y Android, es lo que permite compararlas) y "states" (recomendados: loading, empty, error, readonly, no-access, offline, refreshing, search-empty) se MEZCLAN por key al actualizar un nodo existente (update_design_nav_node reemplaza el array completo). La paridad compara por capacidades y cae a bloques si la referencia no las define. Ejemplo: [{"platform":"web","kind":"section","name":"Ajustes","key":"settings","route":"/settings"},{"platform":"web","kind":"screen","name":"General","key":"settings.general","parentKey":"settings","route":"/settings/general","blocks":[{"name":"Datos del workspace","description":"Nombre y logo"},{"name":"Zona de peligro"}],"actions":[{"key":"workspace.rename","name":"Renombrar workspace","roles":["owner"]}],"states":[{"key":"loading"},{"key":"readonly"}]}]. Usa la misma key para la misma pantalla en web, iOS y Android. Devuelve { created, updated, items };
|
|
3121
|
+
description: `Carga en lote (hasta 300 nodos) la navegación de diseño: es el camino para cargar el árbol completo de una plataforma leyendo su código (rutas del router, tab bar, sidebar, pantallas y sus bloques). ${NAV_PURPOSE} En vez de parentId cada nodo lleva parentKey (la key del padre, que puede venir en el mismo lote; sin parentKey = raíz). Un nodo existente se identifica por (platform, key) o, si no hay key, por (platform, parentId, name): se actualiza, si no se crea; nada se borra. "actions" (convención entidad.verbo, ej. task.create; la misma acción = la MISMA key en web, iOS y Android, es lo que permite compararlas) y "states" (recomendados: loading, empty, error, readonly, no-access, offline, refreshing, search-empty) se MEZCLAN por key al actualizar un nodo existente (update_design_nav_node reemplaza el array completo). La paridad compara por capacidades y cae a bloques si la referencia no las define. Ejemplo: [{"platform":"web","kind":"section","name":"Ajustes","key":"settings","route":"/settings"},{"platform":"web","kind":"screen","name":"General","key":"settings.general","parentKey":"settings","route":"/settings/general","blocks":[{"name":"Datos del workspace","description":"Nombre y logo"},{"name":"Zona de peligro"}],"actions":[{"key":"workspace.rename","name":"Renombrar workspace","roles":["owner"]}],"states":[{"key":"loading"},{"key":"readonly"}]}]. Usa la misma key para la misma pantalla en web, iOS y Android. Devuelve { created, updated, items }; compact=true (default) resume items, false trae filas completas.`,
|
|
3110
3122
|
inputSchema: {
|
|
3111
3123
|
projectId: z.string().optional().describe(PROJECT_ID_DESC),
|
|
3112
3124
|
compact: z.boolean().optional().describe('true (default) = el lote devuelve items resumidos {id,name,key?,platform?,action}; false = filas completas'),
|
|
@@ -3114,11 +3126,12 @@ export function createServer() {
|
|
|
3114
3126
|
...navBulkBase,
|
|
3115
3127
|
parentKey: z.string().optional().describe('Key del nodo padre (en este lote o ya existente); ausente = raíz'),
|
|
3116
3128
|
})).min(1).max(300).describe('Nodos a crear/actualizar (1-300)'),
|
|
3129
|
+
app: appArg(),
|
|
3117
3130
|
},
|
|
3118
3131
|
},
|
|
3119
|
-
async ({ projectId, nodes, compact }) => {
|
|
3132
|
+
async ({ projectId, nodes, compact, app }) => {
|
|
3120
3133
|
try {
|
|
3121
|
-
return textResult(await apiPost(config, '/v1/design-nav/bulk', { projectId: resolveProjectId(projectId), nodes, compact: compact ?? true }))
|
|
3134
|
+
return textResult(await apiPost(config, '/v1/design-nav/bulk', { projectId: resolveProjectId(projectId), nodes, compact: compact ?? true }, { app }))
|
|
3122
3135
|
} catch (err) {
|
|
3123
3136
|
return errorResult(err)
|
|
3124
3137
|
}
|
|
@@ -3129,8 +3142,8 @@ export function createServer() {
|
|
|
3129
3142
|
const SHOT_MIME_BY_EXT = { png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg', webp: 'image/webp' }
|
|
3130
3143
|
const SHOT_MAX_BYTES = 5 * 1024 * 1024
|
|
3131
3144
|
const SHOT_NOTE = 'Las capturas son INTERNAS del equipo (se guardan en un bucket privado y se ven con URL firmada de 1 h). No uses capturas del workspace real si van a usarse en marketing o videos: arma un usuario demo.'
|
|
3132
|
-
const findNavNode = async (pid, platform, key) => {
|
|
3133
|
-
const list = await apiGet(config, '/v1/design-nav', { projectId: pid, platform })
|
|
3145
|
+
const findNavNode = async (pid, platform, key, app) => {
|
|
3146
|
+
const list = await apiGet(config, '/v1/design-nav', { projectId: pid, platform, app })
|
|
3134
3147
|
const node = (list.items || []).find(n => n.key === key)
|
|
3135
3148
|
if (!node) throw new Error(`No hay un nodo con key "${key}" en ${platform}; revisa list_design_nav o créalo con upsert_design_nav`)
|
|
3136
3149
|
return node
|
|
@@ -3146,9 +3159,10 @@ export function createServer() {
|
|
|
3146
3159
|
filePath: z.string().describe('Ruta local a la imagen (png/jpg/jpeg/webp, máx. 5 MB)'),
|
|
3147
3160
|
caption: z.string().max(200).optional().describe('Pie de la captura (máx. 200)'),
|
|
3148
3161
|
state: z.string().optional().describe('Estado que muestra, ej: empty, loading, error'),
|
|
3162
|
+
app: appArg(),
|
|
3149
3163
|
},
|
|
3150
3164
|
},
|
|
3151
|
-
async ({ projectId, platform, key, filePath, caption, state }) => {
|
|
3165
|
+
async ({ projectId, platform, key, filePath, caption, state, app }) => {
|
|
3152
3166
|
try {
|
|
3153
3167
|
const pid = resolveProjectId(projectId)
|
|
3154
3168
|
const ext = path.extname(filePath).slice(1).toLowerCase()
|
|
@@ -3157,12 +3171,12 @@ export function createServer() {
|
|
|
3157
3171
|
const stat = statSync(filePath)
|
|
3158
3172
|
if (!stat.isFile()) throw new Error('filePath no es un archivo')
|
|
3159
3173
|
if (stat.size > SHOT_MAX_BYTES) throw new Error(`La imagen pesa ${(stat.size / 1048576).toFixed(1)} MB; el máximo es 5 MB`)
|
|
3160
|
-
const node = await findNavNode(pid, platform, key)
|
|
3174
|
+
const node = await findNavNode(pid, platform, key, app)
|
|
3161
3175
|
const name = path.basename(filePath)
|
|
3162
|
-
const { uploadUrl, key: shotKey, headers } = await apiPost(config, '/v1/design-assets/presign', { projectId: pid, nodeId: node.id, filename: name, contentType: mime, size: stat.size })
|
|
3176
|
+
const { uploadUrl, key: shotKey, headers } = await apiPost(config, '/v1/design-assets/presign', { projectId: pid, nodeId: node.id, filename: name, contentType: mime, size: stat.size }, { app })
|
|
3163
3177
|
await putToPresignedUrl(uploadUrl, readFileSync(filePath), mime, headers)
|
|
3164
3178
|
const shot = { key: shotKey, takenAt: Date.now(), ...(caption ? { caption } : {}), ...(state ? { state } : {}) }
|
|
3165
|
-
const res = await apiPost(config, '/v1/design-nav/bulk', { projectId: pid, compact: false, nodes: [{ platform, kind: node.kind, name: node.name, key, screenshots: [shot] }] })
|
|
3179
|
+
const res = await apiPost(config, '/v1/design-nav/bulk', { projectId: pid, compact: false, nodes: [{ platform, kind: node.kind, name: node.name, key, screenshots: [shot] }] }, { app })
|
|
3166
3180
|
const updated = res.items?.[0]
|
|
3167
3181
|
return textResult({ key: shotKey, name, nodeId: node.id, screenshots: updated?.screenshots ?? [shot] })
|
|
3168
3182
|
} catch (err) {
|
|
@@ -3179,15 +3193,16 @@ export function createServer() {
|
|
|
3179
3193
|
platform: z.enum(NAV_PLATFORMS).describe('Plataforma del nodo: web | ios | android'),
|
|
3180
3194
|
key: z.string().describe('Key del nodo de navegación'),
|
|
3181
3195
|
screenshotKey: z.string().describe('Key de S3 de la captura a quitar'),
|
|
3196
|
+
app: appArg(),
|
|
3182
3197
|
},
|
|
3183
3198
|
},
|
|
3184
|
-
async ({ projectId, platform, key, screenshotKey }) => {
|
|
3199
|
+
async ({ projectId, platform, key, screenshotKey, app }) => {
|
|
3185
3200
|
try {
|
|
3186
3201
|
const pid = resolveProjectId(projectId)
|
|
3187
|
-
const node = await findNavNode(pid, platform, key)
|
|
3202
|
+
const node = await findNavNode(pid, platform, key, app)
|
|
3188
3203
|
const current = node.screenshots || []
|
|
3189
3204
|
if (!current.some(s => s.key === screenshotKey)) throw new Error(`El nodo "${key}" no tiene una captura con key "${screenshotKey}"`)
|
|
3190
|
-
const data = await apiPatch(config, '/v1/design-nav', { projectId: pid, id: node.id, screenshots: current.filter(s => s.key !== screenshotKey) })
|
|
3205
|
+
const data = await apiPatch(config, '/v1/design-nav', { projectId: pid, id: node.id, screenshots: current.filter(s => s.key !== screenshotKey) }, { app })
|
|
3191
3206
|
return textResult({ removed: screenshotKey, nodeId: node.id, screenshots: data.screenshots ?? [] })
|
|
3192
3207
|
} catch (err) {
|
|
3193
3208
|
return errorResult(err)
|
|
@@ -3229,15 +3244,16 @@ export function createServer() {
|
|
|
3229
3244
|
{
|
|
3230
3245
|
platform: z.enum(COMP_PLATFORMS).optional().describe('Filtra por plataforma: web | ios | android'),
|
|
3231
3246
|
category: z.string().optional().describe('Filtra por categoría'),
|
|
3247
|
+
app: appArg(),
|
|
3232
3248
|
},
|
|
3233
|
-
(args, projectId) => ({ projectId, platform: args.platform, category: args.category })
|
|
3249
|
+
(args, projectId) => ({ projectId, platform: args.platform, category: args.category, app: args.app })
|
|
3234
3250
|
)
|
|
3235
3251
|
registerCreate('create_design_component', '/v1/design-components',
|
|
3236
3252
|
`Crea un componente de diseño. ${COMP_PURPOSE} Para cargar muchos de una vez usa upsert_design_components, no esta tool en bucle.`,
|
|
3237
|
-
designComponentFields(false))
|
|
3253
|
+
{ ...designComponentFields(false), app: appArg() }, { query: ['app'] })
|
|
3238
3254
|
registerUpdate('update_design_component', '/v1/design-components',
|
|
3239
3255
|
`Edita un componente de diseño existente (parche parcial: manda solo lo que cambia). ${COMP_PURPOSE}`,
|
|
3240
|
-
designComponentFields(true))
|
|
3256
|
+
{ ...designComponentFields(true), app: appArg() }, { query: ['app'] })
|
|
3241
3257
|
|
|
3242
3258
|
server.registerTool(
|
|
3243
3259
|
'delete_design_component',
|
|
@@ -3246,11 +3262,12 @@ export function createServer() {
|
|
|
3246
3262
|
inputSchema: {
|
|
3247
3263
|
projectId: z.string().optional().describe(PROJECT_ID_DESC),
|
|
3248
3264
|
componentId: z.string().describe('ID del componente a borrar (ver list_design_components)'),
|
|
3265
|
+
app: appArg(),
|
|
3249
3266
|
},
|
|
3250
3267
|
},
|
|
3251
|
-
async ({ projectId, componentId }) => {
|
|
3268
|
+
async ({ projectId, componentId, app }) => {
|
|
3252
3269
|
try {
|
|
3253
|
-
return textResult(await apiDelete(config, '/v1/design-components', { projectId: resolveProjectId(projectId), id: componentId }))
|
|
3270
|
+
return textResult(await apiDelete(config, '/v1/design-components', { projectId: resolveProjectId(projectId), id: componentId }, { app }))
|
|
3254
3271
|
} catch (err) {
|
|
3255
3272
|
return errorResult(err)
|
|
3256
3273
|
}
|
|
@@ -3265,11 +3282,12 @@ export function createServer() {
|
|
|
3265
3282
|
projectId: z.string().optional().describe(PROJECT_ID_DESC),
|
|
3266
3283
|
compact: z.boolean().optional().describe('true (default) = el lote devuelve items resumidos {id,name,key?,platform?,action}; false = filas completas'),
|
|
3267
3284
|
components: z.array(z.object(designComponentFields(false))).min(1).max(200).describe('Componentes a crear/actualizar (1-200)'),
|
|
3285
|
+
app: appArg(),
|
|
3268
3286
|
},
|
|
3269
3287
|
},
|
|
3270
|
-
async ({ projectId, components, compact }) => {
|
|
3288
|
+
async ({ projectId, components, compact, app }) => {
|
|
3271
3289
|
try {
|
|
3272
|
-
return textResult(await apiPost(config, '/v1/design-components/bulk', { projectId: resolveProjectId(projectId), components, compact: compact ?? true }))
|
|
3290
|
+
return textResult(await apiPost(config, '/v1/design-components/bulk', { projectId: resolveProjectId(projectId), components, compact: compact ?? true }, { app }))
|
|
3273
3291
|
} catch (err) {
|
|
3274
3292
|
return errorResult(err)
|
|
3275
3293
|
}
|
|
@@ -3285,38 +3303,86 @@ export function createServer() {
|
|
|
3285
3303
|
description: 'Guía paso a paso para llenar Diseño / UI (tokens, navegación, bloques, acciones, componentes, paridad, deriva). Datos estáticos, sin red. Con platform devuelve además un agentPrompt listo para pegar; con step, solo ese paso. Empieza por get_design_status.',
|
|
3286
3304
|
inputSchema: {
|
|
3287
3305
|
platform: z.enum(DESIGN_PLATFORM_ARGS).optional().describe('web | ios | android | all (default all)'),
|
|
3288
|
-
|
|
3306
|
+
app: appArg('Key de la app (list_design_apps); con platform, el agentPrompt la incluye'),
|
|
3307
|
+
step: z.string().optional().describe('Id de un paso (apps, check, identity, navigation, blocks, actions-states, components, parity, drift, sync, screenshots)'),
|
|
3289
3308
|
},
|
|
3290
3309
|
},
|
|
3291
|
-
async ({ platform, step }) => {
|
|
3292
|
-
const data = getDesignFlow({ platform, step })
|
|
3310
|
+
async ({ platform, step, app }) => {
|
|
3311
|
+
const data = getDesignFlow({ platform, step, app })
|
|
3293
3312
|
if (data.error) return { content: [{ type: 'text', text: data.error }], isError: true }
|
|
3294
3313
|
return textResult(data)
|
|
3295
3314
|
}
|
|
3296
3315
|
)
|
|
3297
3316
|
|
|
3317
|
+
const safeDesign = p => p.catch(e => ({ __error: e instanceof ApiError ? `HTTP ${e.status}: ${e.message}` : e.message }))
|
|
3318
|
+
// Estado de una app (o del proyecto sin app): las 4 lecturas globales + nav y sync por plataforma.
|
|
3319
|
+
async function fetchDesignStatus(pid, app) {
|
|
3320
|
+
const [tokens, components, drift, parity, ...rest] = await Promise.all([
|
|
3321
|
+
safeDesign(apiGet(config, '/v1/design-tokens', { projectId: pid, app })),
|
|
3322
|
+
safeDesign(apiGet(config, '/v1/design-components', { projectId: pid, app })),
|
|
3323
|
+
safeDesign(apiGet(config, '/v1/design-drift', { projectId: pid, app })),
|
|
3324
|
+
safeDesign(apiGet(config, '/v1/design-parity', { projectId: pid, app })),
|
|
3325
|
+
...DESIGN_PLATFORMS.map(platform => safeDesign(apiGet(config, '/v1/design-nav', { projectId: pid, platform, app }))),
|
|
3326
|
+
...DESIGN_PLATFORMS.map(platform => safeDesign(apiGet(config, '/v1/design-sync', { projectId: pid, platform, app }))),
|
|
3327
|
+
])
|
|
3328
|
+
const n = DESIGN_PLATFORMS.length
|
|
3329
|
+
const nav = Object.fromEntries(DESIGN_PLATFORMS.map((pl, i) => [pl, rest[i]]))
|
|
3330
|
+
const sync = Object.fromEntries(DESIGN_PLATFORMS.map((pl, i) => [pl, rest[n + i]]))
|
|
3331
|
+
return computeDesignStatus({ tokens, components, drift, parity, nav, sync })
|
|
3332
|
+
}
|
|
3333
|
+
|
|
3298
3334
|
server.registerTool(
|
|
3299
3335
|
'get_design_status',
|
|
3300
3336
|
{
|
|
3301
|
-
description: 'Estado de Diseño / UI por plataforma (web, ios, android): tokens, nodos
|
|
3337
|
+
description: 'Estado de Diseño / UI por plataforma (web, ios, android): tokens, nodos, pantallas con bloques/acciones/estados, componentes, deriva, sync y paridad, más `next`: el primer paso de get_design_flow pendiente. Solo números. Con varias apps y sin app devuelve un resumen por app.',
|
|
3338
|
+
inputSchema: {
|
|
3339
|
+
projectId: z.string().optional().describe(PROJECT_ID_DESC),
|
|
3340
|
+
app: appArg('Key de la app (list_design_apps). Con varias apps y sin app: resumen compacto por app'),
|
|
3341
|
+
},
|
|
3342
|
+
},
|
|
3343
|
+
async ({ projectId, app }) => {
|
|
3344
|
+
try {
|
|
3345
|
+
const pid = resolveProjectId(projectId)
|
|
3346
|
+
if (app) return textResult(await fetchDesignStatus(pid, app))
|
|
3347
|
+
const apps = await safeDesign(apiGet(config, '/v1/design-apps', { projectId: pid }))
|
|
3348
|
+
if (apps.__error || !apps.multiple || !arrayOf(apps).length) return textResult(await fetchDesignStatus(pid))
|
|
3349
|
+
const perApp = await Promise.all(arrayOf(apps).map(a =>
|
|
3350
|
+
fetchDesignStatus(pid, a.key).then(st => summarizeAppStatus(a, st), e => ({ key: a.key, name: a.name, error: e instanceof ApiError ? `HTTP ${e.status}: ${e.message}` : e.message }))))
|
|
3351
|
+
return textResult({ multiple: true, apps: perApp })
|
|
3352
|
+
} catch (err) {
|
|
3353
|
+
return errorResult(err)
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
3356
|
+
)
|
|
3357
|
+
|
|
3358
|
+
server.registerTool(
|
|
3359
|
+
'list_design_apps',
|
|
3360
|
+
{
|
|
3361
|
+
description: 'Lista las apps de Diseño / UI del proyecto ({key,name,platforms,distributionIds,productKey}) y `multiple`. Con varias apps, casi todas las tools de Diseño exigen `app`.',
|
|
3302
3362
|
inputSchema: { projectId: z.string().optional().describe(PROJECT_ID_DESC) },
|
|
3303
3363
|
},
|
|
3304
3364
|
async ({ projectId }) => {
|
|
3305
3365
|
try {
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3366
|
+
return textResult(await apiGet(config, '/v1/design-apps', { projectId: resolveProjectId(projectId) }))
|
|
3367
|
+
} catch (err) {
|
|
3368
|
+
return errorResult(err)
|
|
3369
|
+
}
|
|
3370
|
+
}
|
|
3371
|
+
)
|
|
3372
|
+
|
|
3373
|
+
server.registerTool(
|
|
3374
|
+
'migrate_design_apps',
|
|
3375
|
+
{
|
|
3376
|
+
description: 'Asigna a UNA app todo lo de Diseño que aún no tiene app (nav, componentes, deriva, paridad). Cambia datos existentes: con dryRun:true (default) solo informa qué movería.',
|
|
3377
|
+
inputSchema: {
|
|
3378
|
+
projectId: z.string().optional().describe(PROJECT_ID_DESC),
|
|
3379
|
+
appKey: APP_STR.describe('Key de la app destino (list_design_apps)'),
|
|
3380
|
+
dryRun: z.boolean().optional().describe('true (default) = solo informa; false = aplica la asignación'),
|
|
3381
|
+
},
|
|
3382
|
+
},
|
|
3383
|
+
async ({ projectId, appKey, dryRun }) => {
|
|
3384
|
+
try {
|
|
3385
|
+
return textResult(await apiPost(config, '/v1/design-apps/migrate', { projectId: resolveProjectId(projectId), appKey, dryRun: dryRun ?? true }))
|
|
3320
3386
|
} catch (err) {
|
|
3321
3387
|
return errorResult(err)
|
|
3322
3388
|
}
|
|
@@ -3324,15 +3390,15 @@ export function createServer() {
|
|
|
3324
3390
|
)
|
|
3325
3391
|
|
|
3326
3392
|
// ═══ SINCRONÍA CON EL CÓDIGO (ORQ-575) ═════════════════════════════════════
|
|
3327
|
-
const designSyncIo = (pid, platform, staleDays) => ({
|
|
3328
|
-
fetchSync: () => apiGet(config, '/v1/design-sync', { projectId: pid, platform, staleDays }),
|
|
3393
|
+
const designSyncIo = (pid, platform, staleDays, app) => ({
|
|
3394
|
+
fetchSync: () => apiGet(config, '/v1/design-sync', { projectId: pid, platform, staleDays, app }),
|
|
3329
3395
|
fetchCategories: async () => {
|
|
3330
|
-
const r = await apiGet(config, '/v1/design-components', { projectId: pid })
|
|
3396
|
+
const r = await apiGet(config, '/v1/design-components', { projectId: pid, app })
|
|
3331
3397
|
const list = Array.isArray(r) ? r : Array.isArray(r?.items) ? r.items : []
|
|
3332
3398
|
return new Map(list.filter(c => c?.name && c.category).map(c => [c.name, c.category]))
|
|
3333
3399
|
},
|
|
3334
|
-
writeNav: nodes => apiPost(config, '/v1/design-nav/bulk', { projectId: pid, nodes, compact: true }),
|
|
3335
|
-
writeComponents: components => apiPost(config, '/v1/design-components/bulk', { projectId: pid, components, compact: true }),
|
|
3400
|
+
writeNav: nodes => apiPost(config, '/v1/design-nav/bulk', { projectId: pid, nodes, compact: true }, { app }),
|
|
3401
|
+
writeComponents: components => apiPost(config, '/v1/design-components/bulk', { projectId: pid, components, compact: true }, { app }),
|
|
3336
3402
|
})
|
|
3337
3403
|
const SYNC_PLATFORM = z.enum(['web', 'ios', 'android']).describe('web | ios | android')
|
|
3338
3404
|
const SYNC_REPO = z.string().min(1).describe('Ruta absoluta del repo de esa plataforma en esta máquina')
|
|
@@ -3347,12 +3413,13 @@ export function createServer() {
|
|
|
3347
3413
|
repoPath: SYNC_REPO,
|
|
3348
3414
|
staleDays: z.number().int().min(1).max(365).optional().describe('Días sin sincronizar para considerar stale (1-365)'),
|
|
3349
3415
|
record: z.boolean().optional().describe('false = solo reporta, no marca outdated (default true)'),
|
|
3416
|
+
app: appArg(),
|
|
3350
3417
|
},
|
|
3351
3418
|
},
|
|
3352
|
-
async ({ projectId, platform, repoPath, staleDays, record }) => {
|
|
3419
|
+
async ({ projectId, platform, repoPath, staleDays, record, app }) => {
|
|
3353
3420
|
try {
|
|
3354
3421
|
if (!path.isAbsolute(repoPath)) throw new Error('repoPath debe ser una ruta absoluta')
|
|
3355
|
-
return textResult(await runCheck({ platform, repoPath, record }, designSyncIo(resolveProjectId(projectId), platform, staleDays)))
|
|
3422
|
+
return textResult(await runCheck({ platform, repoPath, record }, designSyncIo(resolveProjectId(projectId), platform, staleDays, app)))
|
|
3356
3423
|
} catch (err) {
|
|
3357
3424
|
return errorResult(err)
|
|
3358
3425
|
}
|
|
@@ -3370,12 +3437,13 @@ export function createServer() {
|
|
|
3370
3437
|
nav: z.array(z.string()).optional().describe('Keys de nodos de navegación a marcar'),
|
|
3371
3438
|
components: z.array(z.string()).optional().describe('Nombres de componentes a marcar'),
|
|
3372
3439
|
all: z.boolean().optional().describe('true = línea base de todo lo que tenga sourceRef en la plataforma'),
|
|
3440
|
+
app: appArg(),
|
|
3373
3441
|
},
|
|
3374
3442
|
},
|
|
3375
|
-
async ({ projectId, platform, repoPath, nav, components, all }) => {
|
|
3443
|
+
async ({ projectId, platform, repoPath, nav, components, all, app }) => {
|
|
3376
3444
|
try {
|
|
3377
3445
|
if (!path.isAbsolute(repoPath)) throw new Error('repoPath debe ser una ruta absoluta')
|
|
3378
|
-
return textResult(await runMark({ platform, repoPath, nav, components, all }, designSyncIo(resolveProjectId(projectId), platform)))
|
|
3446
|
+
return textResult(await runMark({ platform, repoPath, nav, components, all }, designSyncIo(resolveProjectId(projectId), platform, undefined, app)))
|
|
3379
3447
|
} catch (err) {
|
|
3380
3448
|
return errorResult(err)
|
|
3381
3449
|
}
|
|
@@ -3392,11 +3460,12 @@ export function createServer() {
|
|
|
3392
3460
|
ref: z.enum(PARITY_PLATFORMS).optional().describe('Plataforma de referencia: web | ios | android (default web)'),
|
|
3393
3461
|
soloHuecos: z.boolean().optional().describe('true = devuelve solo summary, gaps y threshold (sin las filas), para ahorrar tokens'),
|
|
3394
3462
|
threshold: z.number().min(0).max(1).optional().describe('Umbral de similitud de bloques (0..1, default 0.6) para considerar "same"'),
|
|
3463
|
+
app: appArg(),
|
|
3395
3464
|
},
|
|
3396
3465
|
},
|
|
3397
|
-
async ({ projectId, ref, soloHuecos, threshold }) => {
|
|
3466
|
+
async ({ projectId, ref, soloHuecos, threshold, app }) => {
|
|
3398
3467
|
try {
|
|
3399
|
-
const data = await apiGet(config, '/v1/design-parity', { projectId: resolveProjectId(projectId), ref, threshold })
|
|
3468
|
+
const data = await apiGet(config, '/v1/design-parity', { projectId: resolveProjectId(projectId), ref, threshold, app })
|
|
3400
3469
|
if (soloHuecos && data && typeof data === 'object') return textResult({ summary: data.summary, gaps: data.gaps, threshold: data.threshold })
|
|
3401
3470
|
return textResult(data)
|
|
3402
3471
|
} catch (err) {
|
|
@@ -3418,14 +3487,15 @@ export function createServer() {
|
|
|
3418
3487
|
taskId: z.string().optional().describe('Folio de la tarea que cierra el hueco, ej: ORQ-123'),
|
|
3419
3488
|
reason: z.string().max(500).optional().describe('Motivo de la decisión (máx. 500). Obligatorio al fijar status not_applicable'),
|
|
3420
3489
|
adr: z.string().max(60).optional().describe('Id del doc (ADR) que documenta la decisión; se envía como docId. "" lo quita'),
|
|
3490
|
+
app: appArg(),
|
|
3421
3491
|
},
|
|
3422
3492
|
},
|
|
3423
|
-
async ({ projectId, key, platform, status, note, taskId, reason, adr }) => {
|
|
3493
|
+
async ({ projectId, key, platform, status, note, taskId, reason, adr, app }) => {
|
|
3424
3494
|
try {
|
|
3425
3495
|
if (status === 'not_applicable' && !(reason && reason.trim())) {
|
|
3426
3496
|
return errorResult(new Error('motivo obligatorio al fijar No aplica: pasa reason con el porqué (y opcionalmente adr con el id del doc)'))
|
|
3427
3497
|
}
|
|
3428
|
-
return textResult(await apiPut(config, '/v1/design-parity/cell', { projectId: resolveProjectId(projectId), key, platform, status, note, taskId, reason, docId: adr }))
|
|
3498
|
+
return textResult(await apiPut(config, '/v1/design-parity/cell', { projectId: resolveProjectId(projectId), key, platform, status, note, taskId, reason, docId: adr }, { app }))
|
|
3429
3499
|
} catch (err) {
|
|
3430
3500
|
return errorResult(err)
|
|
3431
3501
|
}
|
|
@@ -3448,11 +3518,12 @@ export function createServer() {
|
|
|
3448
3518
|
dueDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, 'Formato YYYY-MM-DD').optional().describe('Fecha límite YYYY-MM-DD; si falta, hoy + 14 días'),
|
|
3449
3519
|
priority: z.enum(['high', 'medium', 'low']).optional().describe('Prioridad de las tareas'),
|
|
3450
3520
|
force: z.boolean().optional().describe('true = crea la tarea aunque la celda ya tenga folio'),
|
|
3521
|
+
app: appArg(),
|
|
3451
3522
|
},
|
|
3452
3523
|
},
|
|
3453
|
-
async ({ projectId, cells, ref, threshold, moduleId, dueDate, priority, force }) => {
|
|
3524
|
+
async ({ projectId, cells, ref, threshold, moduleId, dueDate, priority, force, app }) => {
|
|
3454
3525
|
try {
|
|
3455
|
-
return textResult(await apiPost(config, '/v1/design-parity/tasks', { projectId: resolveProjectId(projectId), cells, ref, threshold, moduleId, dueDate, priority, force }))
|
|
3526
|
+
return textResult(await apiPost(config, '/v1/design-parity/tasks', { projectId: resolveProjectId(projectId), cells, ref, threshold, moduleId, dueDate, priority, force }, { app }))
|
|
3456
3527
|
} catch (err) {
|
|
3457
3528
|
return errorResult(err)
|
|
3458
3529
|
}
|
|
@@ -3483,11 +3554,12 @@ export function createServer() {
|
|
|
3483
3554
|
projectId: z.string().optional().describe(PROJECT_ID_DESC),
|
|
3484
3555
|
compact: z.boolean().optional().describe('true (default) = items resumidos {id,platform,file,line?,value,status,action}; false = filas completas'),
|
|
3485
3556
|
items: z.array(driftItemSchema).min(1).max(200).describe('Hallazgos a reportar (1-200)'),
|
|
3557
|
+
app: appArg(),
|
|
3486
3558
|
},
|
|
3487
3559
|
},
|
|
3488
|
-
async ({ projectId, items, compact }) => {
|
|
3560
|
+
async ({ projectId, items, compact, app }) => {
|
|
3489
3561
|
try {
|
|
3490
|
-
return textResult(await apiPost(config, '/v1/design-drift/bulk', { projectId: resolveProjectId(projectId), items, compact: compact ?? true }))
|
|
3562
|
+
return textResult(await apiPost(config, '/v1/design-drift/bulk', { projectId: resolveProjectId(projectId), items, compact: compact ?? true }, { app }))
|
|
3491
3563
|
} catch (err) {
|
|
3492
3564
|
return errorResult(err)
|
|
3493
3565
|
}
|
|
@@ -3503,11 +3575,12 @@ export function createServer() {
|
|
|
3503
3575
|
platform: z.enum(PARITY_PLATFORMS).optional().describe('Filtra por plataforma'),
|
|
3504
3576
|
kind: z.enum(DRIFT_KINDS).optional().describe('Filtra por tipo'),
|
|
3505
3577
|
status: z.enum(DRIFT_STATUSES).optional().describe('Filtra por estado: open | ignored | fixed'),
|
|
3578
|
+
app: appArg(),
|
|
3506
3579
|
},
|
|
3507
3580
|
},
|
|
3508
|
-
async ({ projectId, platform, kind, status }) => {
|
|
3581
|
+
async ({ projectId, platform, kind, status, app }) => {
|
|
3509
3582
|
try {
|
|
3510
|
-
return textResult(await apiGet(config, '/v1/design-drift', { projectId: resolveProjectId(projectId), platform, kind, status }))
|
|
3583
|
+
return textResult(await apiGet(config, '/v1/design-drift', { projectId: resolveProjectId(projectId), platform, kind, status, app }))
|
|
3511
3584
|
} catch (err) {
|
|
3512
3585
|
return errorResult(err)
|
|
3513
3586
|
}
|
|
@@ -3524,14 +3597,15 @@ export function createServer() {
|
|
|
3524
3597
|
status: z.enum(DRIFT_STATUSES).optional().describe('open | ignored | fixed'),
|
|
3525
3598
|
note: z.string().max(300).optional().describe('Nota (≤300), ej. el motivo de ignorarlo'),
|
|
3526
3599
|
suggestedToken: z.string().max(80).optional().describe('name del token que lo reemplazaría (≤80)'),
|
|
3600
|
+
app: appArg(),
|
|
3527
3601
|
},
|
|
3528
3602
|
},
|
|
3529
|
-
async ({ projectId, driftId, status, note, suggestedToken }) => {
|
|
3603
|
+
async ({ projectId, driftId, status, note, suggestedToken, app }) => {
|
|
3530
3604
|
if (status === undefined && note === undefined && suggestedToken === undefined) {
|
|
3531
3605
|
return errorResult(new Error('Nada que actualizar: manda status, note o suggestedToken'))
|
|
3532
3606
|
}
|
|
3533
3607
|
try {
|
|
3534
|
-
return textResult(await apiPatch(config, '/v1/design-drift', { projectId: resolveProjectId(projectId), id: driftId, status, note, suggestedToken }))
|
|
3608
|
+
return textResult(await apiPatch(config, '/v1/design-drift', { projectId: resolveProjectId(projectId), id: driftId, status, note, suggestedToken }, { app }))
|
|
3535
3609
|
} catch (err) {
|
|
3536
3610
|
return errorResult(err)
|
|
3537
3611
|
}
|
|
@@ -3547,11 +3621,12 @@ export function createServer() {
|
|
|
3547
3621
|
platform: z.enum(PARITY_PLATFORMS).describe('Plataforma de la pasada: web | ios | android'),
|
|
3548
3622
|
reportedBefore: z.number().int().positive().describe('ms epoch: se marcan los open con seenAt anterior a este valor'),
|
|
3549
3623
|
dryRun: z.boolean().optional().describe('true (default) = solo informa; false = marca fixed'),
|
|
3624
|
+
app: appArg(),
|
|
3550
3625
|
},
|
|
3551
3626
|
},
|
|
3552
|
-
async ({ projectId, platform, reportedBefore, dryRun }) => {
|
|
3627
|
+
async ({ projectId, platform, reportedBefore, dryRun, app }) => {
|
|
3553
3628
|
try {
|
|
3554
|
-
return textResult(await apiPost(config, '/v1/design-drift/resolve-missing', { projectId: resolveProjectId(projectId), platform, reportedBefore, dryRun: dryRun ?? true }))
|
|
3629
|
+
return textResult(await apiPost(config, '/v1/design-drift/resolve-missing', { projectId: resolveProjectId(projectId), platform, reportedBefore, dryRun: dryRun ?? true }, { app }))
|
|
3555
3630
|
} catch (err) {
|
|
3556
3631
|
return errorResult(err)
|
|
3557
3632
|
}
|