orquestra-mcp 1.86.0 → 1.88.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/api.mjs +3 -2
- package/src/codingContext.mjs +92 -0
- package/src/server.mjs +57 -7
- package/src/toolGuides.mjs +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orquestra-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.88.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": {
|
package/src/api.mjs
CHANGED
|
@@ -75,8 +75,9 @@ function buildUrl(config, path, params) {
|
|
|
75
75
|
const auth = config => ({ Authorization: `Bearer ${config.apiToken}`, 'x-orquestra-client': 'mcp' })
|
|
76
76
|
const jsonHeaders = config => ({ ...auth(config), 'Content-Type': 'application/json' })
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
// `opts` (ORQ-661) pasa plazo/reintentos propios a request(), p. ej. para una lectura best-effort con plazo corto.
|
|
79
|
+
export async function apiGet(config, path, params = {}, opts = {}) {
|
|
80
|
+
return request(buildUrl(config, path, params), { headers: auth(config) }, opts)
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
export async function apiPost(config, path, { projectId, ...body }, query = {}) {
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// ORQ-661: contexto de código del proyecto (GET /v1/coding-context, infra ORQ-660) dentro de las tools.
|
|
2
|
+
// `get_coding_context` lo expone completo; `get_task` agrega solo un índice corto y `create_task_branch` el
|
|
3
|
+
// contexto completo. Las dos inyecciones son best-effort: con un plazo corto y sin reintentos, y si fallan la
|
|
4
|
+
// tool responde igual sin el campo (mismo criterio que withRecommendedSkills).
|
|
5
|
+
|
|
6
|
+
export const CONTEXT_TIMEOUT_MS = 1500
|
|
7
|
+
const MAX_TITLES = 8
|
|
8
|
+
const TITLE_MAX = 50 // 8 títulos + hint caben en < 600 caracteres (criterio 8 de la spec)
|
|
9
|
+
export const CODING_CONTEXT_HINT = 'Léelas con get_coding_context antes de codificar.'
|
|
10
|
+
|
|
11
|
+
const shortTitle = t => {
|
|
12
|
+
const s = String(t || '').trim()
|
|
13
|
+
return s.length > TITLE_MAX ? `${s.slice(0, TITLE_MAX - 1)}…` : s
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Convenciones (incluido el conocimiento con tag convencion) que aplican, contando también las que no
|
|
17
|
+
* cupieron en el presupuesto (vienen en `truncated`). */
|
|
18
|
+
function conventionEntries(ctx) {
|
|
19
|
+
const included = [...(ctx?.conventions || []), ...(ctx?.knowledge || [])]
|
|
20
|
+
const cut = (ctx?.truncated || []).filter(t => t.block === 'conventions' || t.block === 'knowledge')
|
|
21
|
+
return [...included, ...cut]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Índice corto para get_task: `{ count, titles (máx 8 de 50 caracteres), hint }`, o null si no hay convenciones. */
|
|
25
|
+
export function summarizeCodingContext(ctx) {
|
|
26
|
+
const entries = conventionEntries(ctx)
|
|
27
|
+
if (!entries.length) return null
|
|
28
|
+
return { count: entries.length, titles: entries.slice(0, MAX_TITLES).map(e => shortTitle(e.title)), hint: CODING_CONTEXT_HINT }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function taskOf(data) {
|
|
32
|
+
return data && typeof data === 'object' && data.task && typeof data.task === 'object' ? data.task : null
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* get_task: agrega `task.codingContext` (índice) si la tarea tiene convenciones que aplican.
|
|
37
|
+
* `load(taskId)` trae la respuesta de /v1/coding-context; cualquier error o plazo vencido deja `data` tal cual.
|
|
38
|
+
*/
|
|
39
|
+
export async function withCodingContextIndex(data, load) {
|
|
40
|
+
try {
|
|
41
|
+
const task = taskOf(data)
|
|
42
|
+
if (!task?.id) return data
|
|
43
|
+
const summary = summarizeCodingContext(await load(task.id))
|
|
44
|
+
if (!summary) return data
|
|
45
|
+
return { ...data, task: { ...task, codingContext: summary } }
|
|
46
|
+
} catch (err) {
|
|
47
|
+
console.error('codingContext omitido:', err?.message || err)
|
|
48
|
+
return data
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** create_task_branch: agrega `codingContext` con la respuesta completa. Nunca bloquea la rama ya creada. */
|
|
53
|
+
export async function withCodingContext(data, taskId, load) {
|
|
54
|
+
try {
|
|
55
|
+
if (!taskId || !data || typeof data !== 'object') return data
|
|
56
|
+
return { ...data, codingContext: await load(taskId) }
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.error('codingContext omitido:', err?.message || err)
|
|
59
|
+
return data
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Query de GET /v1/coding-context a partir de los parámetros de la tool (listas como texto separado por comas). */
|
|
64
|
+
export function codingContextQuery({ taskId, distributionIds, stack, q, budget } = {}) {
|
|
65
|
+
const list = v => (Array.isArray(v) && v.length ? v.join(',') : undefined)
|
|
66
|
+
return { taskId, distributionIds: list(distributionIds), stack: list(stack), q, budget }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ── Al pasar a "En progreso" (después de ORQ-661) ─────────────────────────────
|
|
70
|
+
// Mover una tarea a un estatus de trabajo es el inicio real del código (más común que create_task_branch, que exige la
|
|
71
|
+
// integración de GitHub). Misma clasificación que `classifyStatus` de orquestra-infra (lib/presence.mjs), que la API usa
|
|
72
|
+
// para marcar la presencia del agente: cambiar las dos juntas.
|
|
73
|
+
const foldName = s => String(s || '').normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLowerCase()
|
|
74
|
+
export function isWorkStatus(status) {
|
|
75
|
+
if (!status || status.isFinal || status.isCancel || status.isArchive || status.isInitial) return false
|
|
76
|
+
const n = foldName(status.name)
|
|
77
|
+
if (/revis|review/.test(n)) return false
|
|
78
|
+
return /progres|progress|curso|doing|desarroll|trabaj/.test(n)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Contexto completo si `statusId` es de trabajo; null si no aplica o si algo falla (nunca rompe update_task). */
|
|
82
|
+
export async function codingContextOnWorkStart(statusId, loadStatuses, loadContext) {
|
|
83
|
+
try {
|
|
84
|
+
if (!statusId) return null
|
|
85
|
+
const statuses = await loadStatuses()
|
|
86
|
+
if (!isWorkStatus((statuses || []).find(s => s.id === statusId))) return null
|
|
87
|
+
return await loadContext()
|
|
88
|
+
} catch (err) {
|
|
89
|
+
console.error('codingContext omitido:', err?.message || err)
|
|
90
|
+
return null
|
|
91
|
+
}
|
|
92
|
+
}
|
package/src/server.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import { FOUNDATIONS } from './foundations.mjs'
|
|
|
12
12
|
import { PLATFORM_PLAYBOOKS, TRACKING_TOOLS } from './platformPlaybooks.mjs'
|
|
13
13
|
import { SKILLS_CATALOG } from './skillsCatalog.mjs'
|
|
14
14
|
import { withRecommendedSkills } from './skillRecommend.mjs'
|
|
15
|
+
import { withCodingContextIndex, withCodingContext, codingContextQuery, codingContextOnWorkStart, CONTEXT_TIMEOUT_MS } from './codingContext.mjs'
|
|
15
16
|
import { parseSource, previewSkill, installSkill } from './skillInstall.mjs'
|
|
16
17
|
import { normalizeStatuses, findClosePath } from './closePath.mjs'
|
|
17
18
|
import { TOOL_GUIDES, GUIDE_TOPICS } from './toolGuides.mjs'
|
|
@@ -81,7 +82,7 @@ const CHANGELOG_SECTIONS = ['Added', 'Changed', 'Deprecated', 'Removed', 'Fixed'
|
|
|
81
82
|
// 'postmortem' faltaba aquí (gap preexistente, encontrado 12 ago 2026) --
|
|
82
83
|
// mismo fix del lado de write.mjs en orquestra-infra.
|
|
83
84
|
// 'spec'/'specs' (ORQ-643): specs del flujo /orquestra-spec en su propio tipo y carpeta.
|
|
84
|
-
const DOC_TYPES = ['readme', 'usecase', 'diagram', 'env', 'adr', 'runbook', 'postmortem', 'api', 'spec']
|
|
85
|
+
const DOC_TYPES = ['readme', 'usecase', 'diagram', 'env', 'adr', 'runbook', 'postmortem', 'api', 'spec', 'convention']
|
|
85
86
|
const ADR_STATUSES = ['propuesto', 'aceptado', 'deprecado', 'rechazado']
|
|
86
87
|
const SPEC_STATUSES = ['borrador', 'en_revision', 'aprobada'] // ORQ-637
|
|
87
88
|
const IDEA_ASSESSMENTS = ['go', 'needs-clarification', 'kill'] // ORQ-637
|
|
@@ -394,7 +395,17 @@ export function createServer() {
|
|
|
394
395
|
} else {
|
|
395
396
|
data = await apiPatch(config, path, { projectId: pid, id, ...rest }, query)
|
|
396
397
|
}
|
|
397
|
-
|
|
398
|
+
const out = compact && wantsCompact ? compactTaskResult(data, sent) : data
|
|
399
|
+
// Al pasar una tarea a un estatus de trabajo ("En progreso"), las convenciones del proyecto llegan solas:
|
|
400
|
+
// es el inicio real del código. Best-effort con plazo corto; nunca rompe la respuesta.
|
|
401
|
+
if (transition && rest.statusId !== undefined) {
|
|
402
|
+
const ctxOpts = { timeoutMs: CONTEXT_TIMEOUT_MS, retries: 0 }
|
|
403
|
+
const ctx = await codingContextOnWorkStart(rest.statusId,
|
|
404
|
+
async () => normalizeStatuses(await apiGet(config, '/v1/statuses', { projectId: pid }, ctxOpts)),
|
|
405
|
+
() => apiGet(config, '/v1/coding-context', { projectId: pid, taskId: id }, ctxOpts))
|
|
406
|
+
if (ctx) return textResult({ ...out, codingContext: ctx })
|
|
407
|
+
}
|
|
408
|
+
return textResult(out)
|
|
398
409
|
} catch (err) {
|
|
399
410
|
return errorResult(err)
|
|
400
411
|
}
|
|
@@ -1485,7 +1496,7 @@ export function createServer() {
|
|
|
1485
1496
|
server.registerTool(
|
|
1486
1497
|
'create_task_branch',
|
|
1487
1498
|
{
|
|
1488
|
-
description: 'Crea una rama en GitHub para esta tarea (ej. "ORQ-123-arregla-el-login") desde la rama base de la integración, y la guarda en task.branch. Idempotente: si la rama ya existe, no falla. Si el proyecto tiene varios repos conectados, pasa integrationId (list_github_integrations).',
|
|
1499
|
+
description: 'Crea una rama en GitHub para esta tarea (ej. "ORQ-123-arregla-el-login") desde la rama base de la integración, y la guarda en task.branch. Idempotente: si la rama ya existe, no falla. Si el proyecto tiene varios repos conectados, pasa integrationId (list_github_integrations). La respuesta trae `codingContext` con las convenciones que aplican a la tarea (si se pudieron leer): respétalas al escribir el código.',
|
|
1489
1500
|
inputSchema: {
|
|
1490
1501
|
projectId: z.string().optional().describe(PROJECT_ID_DESC),
|
|
1491
1502
|
taskId: z.string().describe('ID de la tarea'),
|
|
@@ -1495,7 +1506,11 @@ export function createServer() {
|
|
|
1495
1506
|
},
|
|
1496
1507
|
async ({ projectId, taskId, integrationId, branchName }) => {
|
|
1497
1508
|
try {
|
|
1498
|
-
|
|
1509
|
+
const pid = resolveProjectId(projectId)
|
|
1510
|
+
const data = await apiPost(config, `/v1/tasks/${taskId}/github-branch`, { projectId: pid, ...(integrationId ? { integrationId } : {}), ...(branchName ? { branchName } : {}) })
|
|
1511
|
+
// ORQ-661: el inicio del código trae las convenciones completas (best-effort, nunca bloquea la rama).
|
|
1512
|
+
return textResult(await withCodingContext(data, taskId, id =>
|
|
1513
|
+
apiGet(config, '/v1/coding-context', { projectId: pid, taskId: id }, { timeoutMs: CONTEXT_TIMEOUT_MS, retries: 0 })))
|
|
1499
1514
|
} catch (err) {
|
|
1500
1515
|
return errorResult(err)
|
|
1501
1516
|
}
|
|
@@ -2011,7 +2026,7 @@ export function createServer() {
|
|
|
2011
2026
|
server.registerTool(
|
|
2012
2027
|
'get_task',
|
|
2013
2028
|
{
|
|
2014
|
-
description: 'Trae UNA tarea completa (con checklist y verificaciones) por `code` (folio ORQ-N, o el código de módulo/grupo como AUTH-3 / V2-3) o por `id`. Úsala en vez de list_tasks cuando ya sabes cuál tarea quieres: es mucho más barata en contexto. Respuesta: { task }; si trae `activeAgents` ([{ label, branch?, since, lastSeenAt }]) hay agentes trabajando esa tarea ahora (caduca a los 15 min): antes de empezar, si hay otro, avisa al usuario. Da 404 si no existe y 409 si el código es ambiguo (usa entonces el id, de list_tasks).',
|
|
2029
|
+
description: 'Trae UNA tarea completa (con checklist y verificaciones) por `code` (folio ORQ-N, o el código de módulo/grupo como AUTH-3 / V2-3) o por `id`. Úsala en vez de list_tasks cuando ya sabes cuál tarea quieres: es mucho más barata en contexto. Respuesta: { task }; si trae `activeAgents` ([{ label, branch?, since, lastSeenAt }]) hay agentes trabajando esa tarea ahora (caduca a los 15 min): antes de empezar, si hay otro, avisa al usuario. Da 404 si no existe y 409 si el código es ambiguo (usa entonces el id, de list_tasks). Si trae `task.codingContext` ({ count, titles, hint }), el proyecto tiene convenciones para esta tarea: léelas con get_coding_context antes de escribir código.',
|
|
2015
2030
|
inputSchema: {
|
|
2016
2031
|
projectId: z.string().optional().describe(PROJECT_ID_DESC),
|
|
2017
2032
|
code: z.string().min(1).optional().describe('Folio o código de la tarea (ej. "ORQ-123", "AUTH-3")'),
|
|
@@ -2026,8 +2041,11 @@ export function createServer() {
|
|
|
2026
2041
|
? await apiGet(config, `/v1/tasks/${encodeURIComponent(id)}`, { projectId: pid })
|
|
2027
2042
|
: await apiGet(config, '/v1/tasks', { projectId: pid, code })
|
|
2028
2043
|
// ORQ-634: sugerencia de orquestra-spec en tareas grandes sin spec (nunca rompe la respuesta)
|
|
2029
|
-
|
|
2030
|
-
normalizeStatuses(await apiGet(config, '/v1/statuses', { projectId: pid })).filter(s => s.isFinal || s.isCancel || s.isArchive).map(s => s.id)))
|
|
2044
|
+
const withSkills = await withRecommendedSkills(data, async () => new Set(
|
|
2045
|
+
normalizeStatuses(await apiGet(config, '/v1/statuses', { projectId: pid })).filter(s => s.isFinal || s.isCancel || s.isArchive).map(s => s.id)))
|
|
2046
|
+
// ORQ-661: índice de convenciones que aplican (solo títulos; nunca rompe la respuesta).
|
|
2047
|
+
return textResult(await withCodingContextIndex(withSkills, id =>
|
|
2048
|
+
apiGet(config, '/v1/coding-context', { projectId: pid, taskId: id }, { timeoutMs: CONTEXT_TIMEOUT_MS, retries: 0 })))
|
|
2031
2049
|
} catch (err) {
|
|
2032
2050
|
return errorResult(err)
|
|
2033
2051
|
}
|
|
@@ -2765,6 +2783,13 @@ export function createServer() {
|
|
|
2765
2783
|
}
|
|
2766
2784
|
)
|
|
2767
2785
|
|
|
2786
|
+
// ORQ-661: alcance de una convención (solo type='convention'); vacío = todo el proyecto.
|
|
2787
|
+
const APPLIES_TO = z.object({
|
|
2788
|
+
distributionIds: z.array(z.string()).optional().describe('Distribuciones a las que aplica (list_distributions)'),
|
|
2789
|
+
stack: z.array(z.string()).optional().describe('Tecnologías a las que aplica (ej. "react", "swift"; deben estar en el catálogo)'),
|
|
2790
|
+
})
|
|
2791
|
+
const APPLIES_TO_DESC = 'Solo para type=\'convention\': a qué distribuciones o stack aplica (una regla aplica si comparte al menos una). Sin esto = todo el proyecto.'
|
|
2792
|
+
|
|
2768
2793
|
registerCreate(
|
|
2769
2794
|
'create_doc',
|
|
2770
2795
|
'/v1/docs',
|
|
@@ -2786,6 +2811,7 @@ export function createServer() {
|
|
|
2786
2811
|
visibility: z.enum(DOC_VISIBILITY).optional().describe('"team" (default) | "workspace" | "public". "public" expone el doc sin sesión en una URL propia.'),
|
|
2787
2812
|
reviewOwnerUid: z.string().optional().describe('uid de quién recibe el aviso cuando el doc queda desactualizado.'),
|
|
2788
2813
|
reviewIntervalDays: z.number().optional().describe('Cada cuántos días revisar por calendario (30/90/180) -- sin esto, solo se detecta vencimiento por actividad del módulo vinculado, nunca por fecha.'),
|
|
2814
|
+
appliesTo: APPLIES_TO.optional().describe(APPLIES_TO_DESC),
|
|
2789
2815
|
}
|
|
2790
2816
|
)
|
|
2791
2817
|
|
|
@@ -2818,6 +2844,30 @@ export function createServer() {
|
|
|
2818
2844
|
reviewOwnerUid: z.string().optional(),
|
|
2819
2845
|
reviewIntervalDays: z.number().optional(),
|
|
2820
2846
|
archived: z.boolean().optional().describe('true archiva (sale de la lista de Docs, sigue en búsqueda y wikilinks, se puede editar); false lo regresa. Idempotente; solo con este campo no crea versión ni cuenta como edición.'),
|
|
2847
|
+
appliesTo: APPLIES_TO.nullable().optional().describe(APPLIES_TO_DESC + ' null lo quita; reemplaza el alcance completo.'),
|
|
2848
|
+
}
|
|
2849
|
+
)
|
|
2850
|
+
|
|
2851
|
+
// ORQ-661: lo que un agente debe saber del proyecto antes de escribir código (GET /v1/coding-context, infra ORQ-660).
|
|
2852
|
+
server.registerTool(
|
|
2853
|
+
'get_coding_context',
|
|
2854
|
+
{
|
|
2855
|
+
description: 'Convenciones del proyecto que aplican a una tarea (o a unas distribuciones/stack), más el conocimiento del workspace con tag "convencion", los ADR aceptados y un índice de docs de API. Llámala ANTES de escribir código en una tarea y respeta lo que diga: son reglas del equipo. Con taskId usa el alcance y el stack de la tarea. Respuesta: { conventions, knowledge, adrs, apiDocs, truncated, orphans, budget, used }; lo que no cupo en el presupuesto sale en truncated (léelo con get_doc o get_knowledge si hace falta).',
|
|
2856
|
+
inputSchema: {
|
|
2857
|
+
projectId: z.string().optional().describe(PROJECT_ID_DESC),
|
|
2858
|
+
taskId: z.string().optional().describe('Tarea: toma su alcance (scope) y su stack'),
|
|
2859
|
+
distributionIds: z.array(z.string()).optional().describe('Distribuciones extra (se suman a las de la tarea)'),
|
|
2860
|
+
stack: z.array(z.string()).optional().describe('Tecnologías extra (se suman a las de la tarea)'),
|
|
2861
|
+
q: z.string().optional().describe('Filtra por texto en título y contenido'),
|
|
2862
|
+
budget: z.number().int().optional().describe('Tope en caracteres (default 6000, 500-20000)'),
|
|
2863
|
+
},
|
|
2864
|
+
},
|
|
2865
|
+
async ({ projectId, ...params }) => {
|
|
2866
|
+
try {
|
|
2867
|
+
return textResult(await apiGet(config, '/v1/coding-context', { projectId: resolveProjectId(projectId), ...codingContextQuery(params) }))
|
|
2868
|
+
} catch (err) {
|
|
2869
|
+
return errorResult(err)
|
|
2870
|
+
}
|
|
2821
2871
|
}
|
|
2822
2872
|
)
|
|
2823
2873
|
|
package/src/toolGuides.mjs
CHANGED
|
@@ -9,6 +9,7 @@ export const TOOL_GUIDES = {
|
|
|
9
9
|
- Checklist: no deja pasar a un estatus final (isFinal) con ítems sin terminar (400 "Quedan X de Y..."). Marca primero los que de verdad hiciste con update_checklist_item y descarta los que ya no aplican con skipped:true + skipReason (no bloquean). completeChecklist:true (solo junto con un statusId final) marca como hechos los pendientes y cierra, y solo si el usuario confirma que lo pendiente ya está hecho.
|
|
10
10
|
- Verificaciones: no deja cerrar con verificaciones por plataforma abiertas (pending/failed, ver list_verifications): no cierres a mano; deja la tarea en "En revisión" y se cierra sola cuando todas quedan aprobadas. waiveVerifications:true (solo con statusId final) las marca "waived" y cierra: SOLO con confirmación explícita del usuario de que ya no aplican.
|
|
11
11
|
- taskId es alias de id. compact:true responde solo { id, shortCode, statusId, updatedAt } y los campos que modificaste.
|
|
12
|
+
- Convenciones (ORQ-669): al pasar a un estatus de trabajo ("En progreso") la respuesta trae codingContext con las convenciones del proyecto que aplican a la tarea (mismo formato que get_coding_context). Léelas y respétalas antes de escribir código. Si no viene, no hay convenciones o no se pudieron leer a tiempo: puedes pedirlas con get_coding_context({taskId}).
|
|
12
13
|
- Presencia (ORQ-513): al pasar a "En progreso" el server te marca como agente activo (activeAgents, caduca a los 15 min sin actividad; tocar el checklist o llamar update_task la renueva; pasar a "En revisión" o cerrar te quita). Si la respuesta trae presenceConflict ({ others: [labels] }), otro agente ya trabaja la tarea: avisa al usuario con los nombres y NO sigas editando en paralelo sin su confirmación.
|
|
13
14
|
- relatedImpact: ver el tema related_impact.
|
|
14
15
|
- unresolvedLinks: si la respuesta trae unresolvedLinks ([{ text, suggestions }]), algún [[enlace]] del texto no se resolvió; corrige el texto con la forma exacta de las suggestions y avisa al usuario cuáles quedaron sin resolver; no ignores el campo.
|