orca-multiagent-kit 1.6.0 → 1.7.1
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/AI_INSTALL.md +4 -3
- package/CHANGELOG.md +47 -1
- package/GUIA.html +11 -9
- package/README.md +22 -23
- package/VERSION +1 -1
- package/bin/backup.js +44 -0
- package/bin/fetch.js +243 -0
- package/bin/hooks.js +187 -0
- package/bin/omk.js +147 -51
- package/bin/run/cleanup.js +402 -0
- package/bin/run/git.js +641 -0
- package/bin/run/glob.js +193 -0
- package/bin/run/ledger.js +243 -0
- package/bin/run/plan.js +328 -0
- package/bin/run/units.js +101 -0
- package/bin/run/util.js +116 -0
- package/bin/run.js +224 -0
- package/bin/setup.js +81 -8
- package/bin/sync.js +222 -0
- package/bin/ui.js +8 -4
- package/bin/update.js +169 -0
- package/core/AGENTS.md +7 -7
- package/docs/EJECUTABLE.md +5 -4
- package/docs/MANUAL.md +16 -3
- package/docs/ORQUESTADOR.md +59 -1
- package/docs/PLUGIN-ORCA.md +34 -16
- package/hooks/orca-gate.cjs +402 -0
- package/install.sh +26 -13
- package/orca-plugin/README.md +3 -1
- package/orca-plugin/orca-plugin.json +2 -2
- package/orca-plugin/src/kit.test.ts +35 -13
- package/orca-plugin/src/kit.ts +64 -19
- package/orca-plugin/src/panel-state.ts +11 -3
- package/orca-plugin/src/panel.check.ts +71 -0
- package/orca-plugin/src/panel.test.tsx +69 -4
- package/orca-plugin/src/panel.tsx +32 -16
- package/orca-plugin/src/protocol.ts +39 -0
- package/orca-plugin/src/tabs/autonomy.tsx +3 -1
- package/orca-plugin/src/tabs/history.test.tsx +1 -0
- package/orca-plugin/src/tabs/history.tsx +1 -0
- package/orca-plugin/src/tabs/notices.test.tsx +1 -0
- package/orca-plugin/src/tabs/worktrees.test.tsx +1 -0
- package/orca-plugin/src/ui/action-card.tsx +112 -0
- package/orca-plugin/src/worker/actions.test.ts +288 -0
- package/orca-plugin/src/worker/actions.ts +292 -0
- package/orca-plugin/src/worker/context.ts +4 -1
- package/orca-plugin/src/worker/history.ts +3 -3
- package/orca-plugin/src/worker/notices.ts +1 -4
- package/orca-plugin/src/worker.test.ts +24 -6
- package/orca-plugin/src/worker.ts +79 -83
- package/output-styles/csr-minimal.md +1 -0
- package/package.json +3 -3
- package/rules/50-done-gate.md +1 -1
- package/rules/95-multi-agent.md +13 -3
- package/skills/kit-init/SKILL.md +16 -4
- package/skills/orca/SKILL.md +27 -5
- package/skills/orca/references/adapters/artifact.md +2 -0
- package/skills/orca/references/adapters/chat.md +2 -0
- package/skills/orca/references/adapters/native-plan.md +6 -0
- package/skills/orca/references/adapters/plan-file.md +2 -0
- package/skills/orca/references/engine-manual.md +7 -5
- package/skills/orca/references/engine-subagents.md +4 -4
- package/skills/orca/references/integrate.md +14 -2
- package/skills/orca/references/ledger.md +1 -1
- package/skills/orca/references/olimpo.md +1 -1
- package/skills/orca/references/plan.md +2 -1
- package/skills/orca/references/units.md +1 -1
- package/skills/orca/references/worker-contract.md +2 -2
- package/templates/AGENTS.md +2 -2
- package/templates/CLAUDE.md +1 -1
- package/templates/claude-settings.json +25 -0
package/orca-plugin/src/kit.ts
CHANGED
|
@@ -40,9 +40,10 @@ export function withContractHint(
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export const ORCHESTRATE_HINT =
|
|
43
|
-
'[Orca Multiagent Kit] Antes de empezar,
|
|
44
|
-
'
|
|
45
|
-
'
|
|
43
|
+
'[Orca Multiagent Kit] Antes de empezar, y antes de la primera edición, carga la skill orca ' +
|
|
44
|
+
'(~/.agents/skills/orca/SKILL.md) y escribe en el chat su veredicto en una línea `ORCA: …`: si la tarea tiene ' +
|
|
45
|
+
'2 o más entregables separables, repártela entre agentes. La entrada es este prompt (adaptador de chat): ' +
|
|
46
|
+
'no hace falta spec-kit. Si es un solo entregable, hazla tú directamente.'
|
|
46
47
|
|
|
47
48
|
// Prompts que ya pasan por la skill orca (Repartir del panel, un despacho, el propio aviso) o que
|
|
48
49
|
// son de kit-init: no se les añade nada. «orca-cli» u «orchestration» no cuentan como la skill orca.
|
|
@@ -69,28 +70,72 @@ export function isMissingCommand(lines: readonly string[], command = 'omk'): boo
|
|
|
69
70
|
return lines.some((line) => name.test(line) && MISSING_COMMAND.test(line))
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
export
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
export const INSTALL_HINT =
|
|
74
|
+
'Instálalo con `npm install -g orca-multiagent-kit` o con el ejecutable de la última release (lo deja en el PATH), ' +
|
|
75
|
+
'reinicia Orca y vuelve a lanzar el comando.'
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Opción con la que `omk` escribe al salir una línea `[omk:fin] <comando> salida=<código>`
|
|
79
|
+
* (bin/omk.js): es como el plugin sabe que el comando de un terminal ha terminado y cómo.
|
|
80
|
+
*/
|
|
81
|
+
export const EXIT_MARKER_FLAG = '--exit-marker'
|
|
82
|
+
|
|
83
|
+
const EXIT_MARKER = /\[omk:fin\] \S+ salida=(\d{1,3})(?!\d)/
|
|
84
|
+
// Un omk anterior a la opción la rechaza: «Opcion desconocida: --exit-marker».
|
|
85
|
+
const UNKNOWN_EXIT_MARKER = /desconocid[ao][^\n]*--exit-marker/i
|
|
86
|
+
// La pregunta de aprobación de `omk` (bin/setup.js): «¿Apruebas este acceso? [s/N]».
|
|
87
|
+
const YES_NO_PROMPT = /\[s\/N\]\s*$/
|
|
88
|
+
|
|
89
|
+
export const OLD_OMK_HINT =
|
|
90
|
+
'El omk instalado es anterior a este plugin y no avisa cuando termina. Actualízalo en un terminal con ' +
|
|
91
|
+
'`npm install -g orca-multiagent-kit@latest` (o con el ejecutable de la última release) y repite.'
|
|
92
|
+
|
|
93
|
+
/** El código con el que terminó `omk`, si su línea de cierre ya está en la salida; si no, `null`. */
|
|
94
|
+
export function exitCodeOf(lines: readonly string[]): number | null {
|
|
95
|
+
for (let i = lines.length - 1; i >= 0; i -= 1) {
|
|
96
|
+
const code = EXIT_MARKER.exec(lines[i] ?? '')?.[1]
|
|
97
|
+
if (code !== undefined) return Number(code)
|
|
98
|
+
}
|
|
99
|
+
return null
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Si la salida dice que este `omk` no conoce la opción de la línea de cierre. */
|
|
103
|
+
export function lacksExitMarker(lines: readonly string[]): boolean {
|
|
104
|
+
return lines.some((line) => UNKNOWN_EXIT_MARKER.test(line))
|
|
76
105
|
}
|
|
77
106
|
|
|
78
|
-
/**
|
|
79
|
-
export
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
): Promise<boolean> {
|
|
84
|
-
for (let attempt = 0; attempt < options.attempts; attempt += 1) {
|
|
85
|
-
await options.sleep(options.delayMs)
|
|
86
|
-
if (matches(await read())) return true
|
|
107
|
+
/** Si lo último que hay en la salida es una pregunta de sí o no de `omk`. */
|
|
108
|
+
export function isYesNoPrompt(lines: readonly string[]): boolean {
|
|
109
|
+
for (let i = lines.length - 1; i >= 0; i -= 1) {
|
|
110
|
+
const line = lines[i] ?? ''
|
|
111
|
+
if (line.trim() !== '') return YES_NO_PROMPT.test(line)
|
|
87
112
|
}
|
|
88
113
|
return false
|
|
89
114
|
}
|
|
90
115
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
116
|
+
// Códigos de escape de terminal (CSI y OSC); se quitan antes que los demás caracteres de control.
|
|
117
|
+
export const ANSI = /\u001b\[[0-?]*[ -/]*[@-~]|\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)/g
|
|
118
|
+
|
|
119
|
+
export const OUTPUT_LINES = 80
|
|
120
|
+
export const OUTPUT_LINE_MAX = 240
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* La salida de un terminal lista para enseñarla: sin códigos de escape, caracteres de control ni
|
|
124
|
+
* de formato, sin la línea de cierre de `omk` ni huecos al final, con su sangría, y acotada a las
|
|
125
|
+
* últimas `max` líneas de hasta `OUTPUT_LINE_MAX` caracteres. De una línea repintada con retornos
|
|
126
|
+
* de carro (un spinner, si Orca da la salida acumulada y no la pantalla) queda lo último pintado.
|
|
127
|
+
*/
|
|
128
|
+
export function outputLines(lines: readonly string[], max = OUTPUT_LINES): string[] {
|
|
129
|
+
const clean: string[] = []
|
|
130
|
+
for (const line of lines) {
|
|
131
|
+
const painted = line.replace(ANSI, '').split('\r').filter((part) => part.trim() !== '')
|
|
132
|
+
const text = (painted[painted.length - 1] ?? '').replace(/[\p{Cc}\p{Cf}]/gu, ' ').trimEnd()
|
|
133
|
+
if (EXIT_MARKER.test(text)) continue
|
|
134
|
+
clean.push(text.length > OUTPUT_LINE_MAX ? `${text.slice(0, OUTPUT_LINE_MAX - 1)}…` : text)
|
|
135
|
+
}
|
|
136
|
+
while (clean.length > 0 && clean[clean.length - 1] === '') clean.pop()
|
|
137
|
+
return clean.slice(-max)
|
|
138
|
+
}
|
|
94
139
|
|
|
95
140
|
export type FocusedWorkspace = { branch: string; displayName: string }
|
|
96
141
|
export type WorkspaceEntry = { id: string; name: string; branch: string | null }
|
|
@@ -12,12 +12,20 @@ export const outcome = atom<Outcome | null>(null)
|
|
|
12
12
|
export const describeError = (error: unknown) =>
|
|
13
13
|
error instanceof Error ? `${(error as { code?: string }).code ?? 'error'}: ${error.message}` : String(error)
|
|
14
14
|
|
|
15
|
-
/**
|
|
16
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Una petición al worker cada vez; su respuesta o su error quedan en el aviso de arriba. Con
|
|
17
|
+
* `tracked`, la petición lanza algo que el panel sigue en su tarjeta (src/ui/action-card.tsx): su
|
|
18
|
+
* respuesta no se enseña, porque «hecho» sería mentira mientras sigue en curso; un error, sí.
|
|
19
|
+
*/
|
|
20
|
+
export async function ask(
|
|
21
|
+
label: string,
|
|
22
|
+
request: () => Promise<{ message: string }>,
|
|
23
|
+
options: { tracked?: boolean } = {}
|
|
24
|
+
): Promise<boolean> {
|
|
17
25
|
set(busy, label)
|
|
18
26
|
try {
|
|
19
27
|
const { message } = await request()
|
|
20
|
-
set(outcome, { tone: 'success', text: message })
|
|
28
|
+
set(outcome, options.tracked ? null : { tone: 'success', text: message })
|
|
21
29
|
return true
|
|
22
30
|
} catch (error) {
|
|
23
31
|
set(outcome, { tone: 'danger', text: describeError(error) })
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Escenarios de `orca plugin check` y de `orca plugin shot . --scenario <nombre>`: el panel con una
|
|
2
|
+
// acción en curso, una que pregunta y una que falló, sin lanzar nada de verdad.
|
|
3
|
+
import { defineCheck } from 'orca/testing'
|
|
4
|
+
import type { ActionView } from './protocol.ts'
|
|
5
|
+
|
|
6
|
+
const action = (patch: Partial<ActionView>): { action: ActionView } => ({
|
|
7
|
+
action: {
|
|
8
|
+
id: 'a1',
|
|
9
|
+
kind: 'omk',
|
|
10
|
+
title: 'omk update',
|
|
11
|
+
state: 'running',
|
|
12
|
+
detail: null,
|
|
13
|
+
startedAt: Date.now() - 40_000,
|
|
14
|
+
endedAt: null,
|
|
15
|
+
lines: [
|
|
16
|
+
' ◆ ORCA MULTIAGENT KIT v1.7.0',
|
|
17
|
+
' Claude Code · Codex',
|
|
18
|
+
'',
|
|
19
|
+
' ✓ Fuente única en ~/.agents núcleo · 31 reglas · 6 skills · extensión de spec-kit',
|
|
20
|
+
' + actualizada de v1.6.0 a v1.7.0',
|
|
21
|
+
' ✓ Claude Code',
|
|
22
|
+
' ✓ Proyecto app',
|
|
23
|
+
' + AGENTS.md actualizado (tu contenido se conserva)',
|
|
24
|
+
' = ORCHESTRATION.md ya existía: se conserva'
|
|
25
|
+
],
|
|
26
|
+
canAnswer: false,
|
|
27
|
+
...patch
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
export default defineCheck({
|
|
32
|
+
'sin-accion': {},
|
|
33
|
+
'accion-en-curso': { requests: { 'kit.action': action({}) } },
|
|
34
|
+
'accion-pregunta': {
|
|
35
|
+
requests: {
|
|
36
|
+
'kit.action': action({
|
|
37
|
+
state: 'asking',
|
|
38
|
+
detail: 'omk pregunta antes de seguir: lee en la salida lo que pide y contesta aquí o en su terminal.',
|
|
39
|
+
canAnswer: true,
|
|
40
|
+
lines: [
|
|
41
|
+
' ◆ Plugin de Orca',
|
|
42
|
+
'',
|
|
43
|
+
' Orca pide tu aprobación para Orca Multiagent Kit 0.7.0',
|
|
44
|
+
' · Runs its own code in a separate Node.js process.',
|
|
45
|
+
' · terminal:send: Type and run commands in your terminals, local and SSH',
|
|
46
|
+
' · terminal:read: Read the output of your terminals',
|
|
47
|
+
' › ¿Apruebas este acceso? [s/N]'
|
|
48
|
+
]
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
'accion-fallo': {
|
|
53
|
+
requests: {
|
|
54
|
+
'kit.action': action({
|
|
55
|
+
title: 'omk verify',
|
|
56
|
+
state: 'failed',
|
|
57
|
+
detail: 'Terminó con errores (código 1): míralos en la salida.',
|
|
58
|
+
endedAt: Date.now() - 5000,
|
|
59
|
+
lines: [
|
|
60
|
+
' ◆ VERIFICACIÓN',
|
|
61
|
+
' Claude Code',
|
|
62
|
+
'',
|
|
63
|
+
' ✓ núcleo en ~/.agents/AGENTS.md (v1.7.0)',
|
|
64
|
+
' ✗ Claude Code: skills copiadas en vez de enlazadas (acabarán divergiendo; ejecuta omk install): orca',
|
|
65
|
+
'',
|
|
66
|
+
' ✗ 1 fallo repáralos con omk install'
|
|
67
|
+
]
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// El panel tal como lo dibuja Orca, con el worker sustituido por respuestas fijas.
|
|
2
2
|
import { afterEach, assert, hostError, mockHost, mount, test, type TestPanel } from 'orca/testing'
|
|
3
3
|
import type { Team } from './kit.ts'
|
|
4
|
-
import type { AgentsView } from './protocol.ts'
|
|
4
|
+
import type { ActionView, AgentsView } from './protocol.ts'
|
|
5
5
|
import * as panel from './panel.tsx'
|
|
6
6
|
|
|
7
7
|
const NO_AGENTS: AgentsView = { text: 'MAW', tone: 'neutral', tooltip: 'ninguno', groups: [] }
|
|
@@ -58,6 +58,9 @@ const open = async (options: { settings?: Record<string, string | boolean>; requ
|
|
|
58
58
|
'notices.list': () => ({ items: [] }),
|
|
59
59
|
'worktrees.list': () => ({ groups: [] }),
|
|
60
60
|
'history.list': () => ({ items: [] }),
|
|
61
|
+
'kit.action': () => ({ action: null }),
|
|
62
|
+
'kit.answer': answer('kit.answer'),
|
|
63
|
+
'kit.dismiss': answer('kit.dismiss'),
|
|
61
64
|
'kit.run': (input: { action: string }) => {
|
|
62
65
|
calls.push({ name: 'kit.run', input })
|
|
63
66
|
return { message: `hecho: ${input.action}` }
|
|
@@ -218,14 +221,76 @@ test('muestra los ajustes guardados', async () => {
|
|
|
218
221
|
assert.deepEqual(view.errors, [])
|
|
219
222
|
})
|
|
220
223
|
|
|
221
|
-
test('cada botón pide su acción al worker
|
|
224
|
+
test('cada botón pide su acción al worker; lo lanzado no se da por hecho', async () => {
|
|
222
225
|
const { view, calls } = await open()
|
|
223
226
|
await tab(view, 'kit')
|
|
224
227
|
await view.press({ text: 'Verificar instalación' })
|
|
225
228
|
await view.press({ text: 'Inicializar proyecto' })
|
|
226
229
|
await view.press({ text: 'Actualizar kit' })
|
|
227
230
|
assert.deepEqual(calls.map((c) => c.input), [{ action: 'verify' }, { action: 'init' }, { action: 'update' }])
|
|
228
|
-
|
|
231
|
+
// Su estado lo cuenta la tarjeta de la acción en curso: un «Hecho» aquí sería mentira.
|
|
232
|
+
assert.equal(/Callout/.test(view.summary().join(' ')), false)
|
|
233
|
+
assert.deepEqual(view.warnings, [])
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
const ACTION: ActionView = {
|
|
237
|
+
id: 'a1',
|
|
238
|
+
kind: 'omk',
|
|
239
|
+
title: 'omk update',
|
|
240
|
+
state: 'running',
|
|
241
|
+
detail: null,
|
|
242
|
+
startedAt: 1,
|
|
243
|
+
endedAt: null,
|
|
244
|
+
lines: [' ✓ Fuente única en ~/.agents', ' ⠋ Claude Code…'],
|
|
245
|
+
canAnswer: false
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
test('la acción en curso sale encima de las pestañas con su estado y su salida', async () => {
|
|
249
|
+
const { view } = await open({ requests: { 'kit.action': () => ({ action: ACTION }) } })
|
|
250
|
+
// Se ve desde cualquier pestaña, sin ir a Kit.
|
|
251
|
+
assert.ok(view.find({ type: 'Card', label: 'omk update' }))
|
|
252
|
+
assert.match(text(view), /en curso/)
|
|
253
|
+
assert.match(text(view), /Fuente única en ~\/\.agents/)
|
|
254
|
+
assert.ok(view.find({ text: 'Dejar de seguir' }))
|
|
255
|
+
assert.equal(view.find({ text: 'Aprobar' }), null)
|
|
256
|
+
|
|
257
|
+
await view.post('action.changed', {
|
|
258
|
+
action: { ...ACTION, state: 'failed', detail: 'Terminó con errores (código 1): míralos en la salida.', endedAt: 2 }
|
|
259
|
+
})
|
|
260
|
+
assert.match(text(view), /falló/)
|
|
261
|
+
assert.match(text(view), /código 1/)
|
|
262
|
+
assert.ok(view.find({ text: 'Quitar' }))
|
|
263
|
+
|
|
264
|
+
await view.post('action.changed', { action: null })
|
|
265
|
+
assert.equal(view.find({ type: 'Card', label: 'omk update' }), null)
|
|
266
|
+
assert.deepEqual(view.errors, [])
|
|
267
|
+
assert.deepEqual(view.warnings, [])
|
|
268
|
+
})
|
|
269
|
+
|
|
270
|
+
test('si omk pregunta, se le contesta desde la tarjeta; quitarla la deja de seguir', async () => {
|
|
271
|
+
const asking: ActionView = { ...ACTION, state: 'asking', detail: 'omk pregunta antes de seguir.', canAnswer: true }
|
|
272
|
+
const { view, calls } = await open({ requests: { 'kit.action': () => ({ action: asking }) } })
|
|
273
|
+
await view.press({ text: 'Aprobar' })
|
|
274
|
+
await view.press({ text: 'Rechazar' })
|
|
275
|
+
await view.press({ text: 'Dejar de seguir' })
|
|
276
|
+
assert.deepEqual(calls, [
|
|
277
|
+
{ name: 'kit.answer', input: { id: 'a1', approve: true } },
|
|
278
|
+
{ name: 'kit.answer', input: { id: 'a1', approve: false } },
|
|
279
|
+
{ name: 'kit.dismiss', input: { id: 'a1' } }
|
|
280
|
+
])
|
|
281
|
+
assert.deepEqual(view.refusals, [])
|
|
282
|
+
})
|
|
283
|
+
|
|
284
|
+
test('una salida larga enseña el final y deja el resto plegado', async () => {
|
|
285
|
+
const lines = Array.from({ length: 40 }, (_, i) => `línea ${i + 1}`)
|
|
286
|
+
const { view } = await open({ requests: { 'kit.action': () => ({ action: { ...ACTION, lines } }) } })
|
|
287
|
+
const shown = () => view.findAll({ type: 'CodeView' }).map(({ props }) => String(props.code).split('\n').length)
|
|
288
|
+
assert.match(String(view.find({ type: 'CodeView' })?.props.code), /línea 40$/)
|
|
289
|
+
// Solo el final, que es donde está el resultado; el resto, al desplegar.
|
|
290
|
+
assert.deepEqual(shown(), [14])
|
|
291
|
+
await view.toggle({ label: 'Salida completa' })
|
|
292
|
+
assert.deepEqual(shown(), [14, 40])
|
|
293
|
+
assert.deepEqual(view.warnings, [])
|
|
229
294
|
})
|
|
230
295
|
|
|
231
296
|
test('un fallo del worker se enseña, no se calla', async () => {
|
|
@@ -245,7 +310,7 @@ test('un fallo del worker se enseña, no se calla', async () => {
|
|
|
245
310
|
test('el resultado de una acción tiene título propio y se cierra', async () => {
|
|
246
311
|
const { view } = await open()
|
|
247
312
|
await tab(view, 'kit')
|
|
248
|
-
await view.
|
|
313
|
+
await view.toggle({ label: 'Avisos de agentes' })
|
|
249
314
|
// Sin título, Orca pinta un Callout como un «Consejo» de Markdown.
|
|
250
315
|
assert.match(view.summary().join(' '), /Callout success "Hecho"/)
|
|
251
316
|
await view.press({ text: 'Cerrar' })
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Panel lateral del kit en pestañas: lo que espera tu respuesta (Avisos), los agentes activos con
|
|
2
2
|
// su ficha, los worktrees de la orquestación, repartir una tarea entre agentes, el historial, el
|
|
3
3
|
// equipo de roles del proyecto y el kit (acciones y ajustes del plugin). Avisos, Worktrees e
|
|
4
|
-
// Historial viven en src/tabs/; el estado que comparten todas, en src/panel-state.ts.
|
|
4
|
+
// Historial viven en src/tabs/; el estado que comparten todas, en src/panel-state.ts. Encima de
|
|
5
|
+
// las pestañas va la acción en curso (src/ui/action-card.tsx): lo que se lanza desde aquí se ve aquí.
|
|
5
6
|
// Los ajustes son los mismos de Settings → Plugins → Orca Multiagent Kit: cambiarlos aquí o allí
|
|
6
7
|
// es lo mismo, y el worker se entera por `settings.onDidChange`.
|
|
7
8
|
// Orca transpila este fichero al cargarlo: no hay paso de build.
|
|
@@ -70,6 +71,7 @@ import { AutonomyCard, AutonomyOverride, runAutonomy } from './tabs/autonomy.tsx
|
|
|
70
71
|
import { History, setupHistory } from './tabs/history.tsx'
|
|
71
72
|
import { Notices, noticesLabel, setupNotices } from './tabs/notices.tsx'
|
|
72
73
|
import { Worktrees, setupWorktrees } from './tabs/worktrees.tsx'
|
|
74
|
+
import { ActionCard, setupAction } from './ui/action-card.tsx'
|
|
73
75
|
import { AgentIcon } from './ui/agent-icon.tsx'
|
|
74
76
|
|
|
75
77
|
type Preferences = {
|
|
@@ -95,9 +97,13 @@ const CONTRACT_OPTIONS: readonly { value: ContractHintMode; label: string }[] =
|
|
|
95
97
|
]
|
|
96
98
|
|
|
97
99
|
const ACTIONS: readonly { action: KitAction; label: string; hint: string }[] = [
|
|
98
|
-
{ action: 'verify', label: 'Verificar instalación', hint: 'omk verify
|
|
100
|
+
{ action: 'verify', label: 'Verificar instalación', hint: 'omk verify: comprueba enlaces, imports y copias divergentes' },
|
|
99
101
|
{ action: 'init', label: 'Inicializar proyecto', hint: 'el agente de inicializar con «inicializa el proyecto»' },
|
|
100
|
-
{
|
|
102
|
+
{
|
|
103
|
+
action: 'update',
|
|
104
|
+
label: 'Actualizar kit',
|
|
105
|
+
hint: 'omk update: el paquete, ~/.agents, este proyecto (con los apartados nuevos de ORCHESTRATION.md) y este plugin'
|
|
106
|
+
}
|
|
101
107
|
]
|
|
102
108
|
|
|
103
109
|
const PRESET_OPTIONS: readonly { value: TeamPreset | 'custom'; label: string }[] = [
|
|
@@ -161,19 +167,25 @@ async function save(key: keyof Preferences, value: string | boolean): Promise<vo
|
|
|
161
167
|
}
|
|
162
168
|
}
|
|
163
169
|
|
|
164
|
-
|
|
170
|
+
// Lo que lanzan estas peticiones se sigue en la tarjeta de la acción en curso, no en el aviso.
|
|
171
|
+
const TRACKED = { tracked: true }
|
|
172
|
+
|
|
173
|
+
const run = (action: KitAction) => ask(action, () => plugin.request('kit.run', { action }), TRACKED)
|
|
165
174
|
|
|
166
175
|
const openAgent = (id: string) => ask('open', () => plugin.request('agents.open', { id }))
|
|
167
176
|
|
|
168
177
|
async function orchestrate(): Promise<void> {
|
|
169
178
|
const autonomy = read(runAutonomy)
|
|
170
|
-
const sent = await ask(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
179
|
+
const sent = await ask(
|
|
180
|
+
'orchestrate',
|
|
181
|
+
() =>
|
|
182
|
+
plugin.request('team.orchestrate', {
|
|
183
|
+
agent: read(team).coordinator,
|
|
184
|
+
task: read(task),
|
|
185
|
+
source: read(source),
|
|
186
|
+
...(autonomy ? { autonomy } : {})
|
|
187
|
+
}),
|
|
188
|
+
TRACKED
|
|
177
189
|
)
|
|
178
190
|
if (sent) set(task, '')
|
|
179
191
|
}
|
|
@@ -184,10 +196,10 @@ async function applyTeam(): Promise<void> {
|
|
|
184
196
|
set(outcome, { tone: 'danger', text: 'El equipo no es válido: revisa los proveedores y los roles propios.' })
|
|
185
197
|
return
|
|
186
198
|
}
|
|
187
|
-
await ask('team', () => plugin.request('team.apply', { team: ready }))
|
|
199
|
+
await ask('team', () => plugin.request('team.apply', { team: ready }), TRACKED)
|
|
188
200
|
}
|
|
189
201
|
|
|
190
|
-
const showTeam = () => ask('team', () => plugin.request('team.show'))
|
|
202
|
+
const showTeam = () => ask('team', () => plugin.request('team.show'), TRACKED)
|
|
191
203
|
|
|
192
204
|
// Cualquier cambio a mano convierte el equipo en personalizado; el coordinador no cuenta.
|
|
193
205
|
const editTeam = (patch: Partial<TeamDraft>) => set(team, { ...read(team), ...patch, preset: 'custom' })
|
|
@@ -227,6 +239,7 @@ export function setup(ctx: PanelContext): void {
|
|
|
227
239
|
setupNotices(ctx)
|
|
228
240
|
setupWorktrees(ctx)
|
|
229
241
|
setupHistory(ctx)
|
|
242
|
+
setupAction(ctx)
|
|
230
243
|
void plugin
|
|
231
244
|
.request('agents.summary')
|
|
232
245
|
.then((view) => set(agents, view))
|
|
@@ -507,7 +520,7 @@ function Team() {
|
|
|
507
520
|
function Actions() {
|
|
508
521
|
const current = read(busy)
|
|
509
522
|
return (
|
|
510
|
-
<Card title="Acciones" description="Se ejecutan en el workspace activo.">
|
|
523
|
+
<Card title="Acciones" description="Se ejecutan en el workspace activo. Su estado y su salida salen arriba, sobre las pestañas.">
|
|
511
524
|
<Stack gap="sm">
|
|
512
525
|
{ACTIONS.map(({ action, label, hint }) => (
|
|
513
526
|
<Button
|
|
@@ -574,6 +587,7 @@ export default function Panel() {
|
|
|
574
587
|
</Stack>
|
|
575
588
|
</Callout>
|
|
576
589
|
) : null}
|
|
590
|
+
<ActionCard />
|
|
577
591
|
<Tabs label="Secciones" defaultValue="notices">
|
|
578
592
|
<Tab value="notices" label={noticesLabel()} icon="bell">
|
|
579
593
|
<Notices />
|
|
@@ -598,8 +612,10 @@ export default function Panel() {
|
|
|
598
612
|
<Actions />
|
|
599
613
|
<Settings />
|
|
600
614
|
<Text muted size="xs">
|
|
601
|
-
|
|
602
|
-
|
|
615
|
+
«Actualizar kit» pone al día el paquete, <Code>~/.agents</Code>, el proyecto activo y este plugin; si
|
|
616
|
+
el plugin nuevo pide más acceso, te lo pregunta arriba. Desde un terminal: <Code>omk setup</Code>{' '}
|
|
617
|
+
prepara el entorno la primera vez, <Code>omk team</Code> enseña el equipo del proyecto y{' '}
|
|
618
|
+
<Code>omk plugin status</Code> muestra el plugin.
|
|
603
619
|
</Text>
|
|
604
620
|
</Stack>
|
|
605
621
|
</Tab>
|
|
@@ -101,7 +101,35 @@ export type WorktreeItem = {
|
|
|
101
101
|
/** Los worktrees de un mismo run del kit o, sin run, los demás que ha creado la orquestación. */
|
|
102
102
|
export type WorktreeGroup = { run: string | null; title: string; worktrees: WorktreeItem[] }
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Cómo va la acción que el panel sigue: en curso, esperando a la persona, terminada bien,
|
|
106
|
+
* terminada con fallo, o sin seguimiento (su terminal se cerró o tardó demasiado).
|
|
107
|
+
*/
|
|
108
|
+
export type ActionState = 'running' | 'asking' | 'done' | 'failed' | 'lost'
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* La última acción lanzada desde el panel o la paleta, seguida en su terminal: un comando `omk`
|
|
112
|
+
* (verificar, actualizar, equipo) o un agente (inicializar, repartir).
|
|
113
|
+
*/
|
|
114
|
+
export type ActionView = {
|
|
115
|
+
/** Cambia con cada acción: el panel lo devuelve para responder o dejar de seguirla. */
|
|
116
|
+
id: string
|
|
117
|
+
kind: 'omk' | 'agent'
|
|
118
|
+
/** «omk update», «Inicializar proyecto · claude». */
|
|
119
|
+
title: string
|
|
120
|
+
state: ActionState
|
|
121
|
+
/** Una línea que explica el estado: el código de salida, qué falta o dónde seguir. */
|
|
122
|
+
detail: string | null
|
|
123
|
+
startedAt: number
|
|
124
|
+
endedAt: number | null
|
|
125
|
+
/** Las últimas líneas de su terminal, limpias y acotadas. */
|
|
126
|
+
lines: string[]
|
|
127
|
+
/** Si espera un sí o un no que el panel puede escribir en su terminal. */
|
|
128
|
+
canAnswer: boolean
|
|
129
|
+
}
|
|
130
|
+
|
|
104
131
|
export type HistoryKind =
|
|
132
|
+
| 'kit'
|
|
105
133
|
| 'dispatch'
|
|
106
134
|
| 'state'
|
|
107
135
|
| 'outcome'
|
|
@@ -131,6 +159,15 @@ declare module 'orca' {
|
|
|
131
159
|
interface PluginRequests {
|
|
132
160
|
/** Ejecuta una acción del kit en el workspace activo y responde qué ha hecho. */
|
|
133
161
|
'kit.run': { input: { action: KitAction }; output: Message }
|
|
162
|
+
/** La acción que se está siguiendo o la última que terminó; `null` si no hay ninguna. */
|
|
163
|
+
'kit.action': { output: { action: ActionView | null } }
|
|
164
|
+
/**
|
|
165
|
+
* Contesta la pregunta de sí o no de la acción `id` escribiendo `s` o `n` e Intro en su
|
|
166
|
+
* terminal. Solo vale mientras `canAnswer`.
|
|
167
|
+
*/
|
|
168
|
+
'kit.answer': { input: { id: string; approve: boolean }; output: Message }
|
|
169
|
+
/** Deja de seguir la acción `id` y la quita del panel; su terminal sigue como esté. */
|
|
170
|
+
'kit.dismiss': { input: { id: string }; output: Message }
|
|
134
171
|
/** Los agentes activos, como los cuenta la barra de estado. */
|
|
135
172
|
'agents.summary': { output: AgentsView }
|
|
136
173
|
/** Muestra el workspace de un agente (`id` de una `AgentLine`). */
|
|
@@ -172,6 +209,8 @@ declare module 'orca' {
|
|
|
172
209
|
interface PluginPanelEvents {
|
|
173
210
|
/** Se envía a los paneles abiertos cuando cambia lo que cuentan los agentes. */
|
|
174
211
|
'agents.changed': AgentsView
|
|
212
|
+
/** La acción seguida cambió de estado o de salida, o se dejó de seguir (`null`). */
|
|
213
|
+
'action.changed': { action: ActionView | null }
|
|
175
214
|
'notices.changed': { items: NoticeItem[] }
|
|
176
215
|
'worktrees.changed': { groups: WorktreeGroup[] }
|
|
177
216
|
'history.changed': { items: HistoryEntry[] }
|
|
@@ -20,7 +20,9 @@ export const runAutonomy = atom<Autonomy | null>(null)
|
|
|
20
20
|
|
|
21
21
|
const hint = (level: Autonomy) => AUTONOMY_LEVELS.find(({ id }) => id === level)?.hint ?? ''
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
// `omk team set --autonomy` se sigue en la tarjeta de la acción en curso.
|
|
24
|
+
const saveAutonomy = () =>
|
|
25
|
+
ask('autonomy', () => plugin.request('team.autonomy', { autonomy: read(projectAutonomy) }), { tracked: true })
|
|
24
26
|
|
|
25
27
|
export function AutonomyCard() {
|
|
26
28
|
const level = read(projectAutonomy)
|
|
@@ -29,6 +29,7 @@ const open = async (items: HistoryEntry[]) => {
|
|
|
29
29
|
const host = mockHost({
|
|
30
30
|
requests: {
|
|
31
31
|
'agents.summary': () => NO_AGENTS,
|
|
32
|
+
'kit.action': () => ({ action: null }),
|
|
32
33
|
// Las demás pestañas también piden su lista al montar el panel.
|
|
33
34
|
'notices.list': () => ({ items: [] }),
|
|
34
35
|
'worktrees.list': () => ({ groups: [] }),
|
|
@@ -62,6 +62,7 @@ const open = async (items: NoticeItem[], requests: Requests = {}) => {
|
|
|
62
62
|
requests: {
|
|
63
63
|
'agents.summary': { text: 'MAW', tone: 'neutral', tooltip: 'ninguno', groups: [] },
|
|
64
64
|
'notices.list': { items },
|
|
65
|
+
'kit.action': { action: null },
|
|
65
66
|
// Las demás pestañas también piden su lista al montar el panel.
|
|
66
67
|
'worktrees.list': { groups: [] },
|
|
67
68
|
'history.list': { items: [] },
|
|
@@ -50,6 +50,7 @@ const open = async (groups: WorktreeGroup[] = GROUPS) => {
|
|
|
50
50
|
settings: {},
|
|
51
51
|
requests: {
|
|
52
52
|
'agents.summary': () => NO_AGENTS,
|
|
53
|
+
'kit.action': () => ({ action: null }),
|
|
53
54
|
// Las demás pestañas también piden su lista al montar el panel.
|
|
54
55
|
'notices.list': () => ({ items: [] }),
|
|
55
56
|
'history.list': () => ({ items: [] }),
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// La acción en curso, encima de las pestañas: el comando `omk` o el agente que se acaba de lanzar
|
|
2
|
+
// desde el panel o la paleta, con su estado, lo último de su terminal y, si `omk` pregunta antes
|
|
3
|
+
// de seguir, los botones para contestarle (`kit.action`, `kit.answer` y `kit.dismiss` en
|
|
4
|
+
// src/protocol.ts; el worker lo sigue en src/worker/actions.ts).
|
|
5
|
+
import {
|
|
6
|
+
atom,
|
|
7
|
+
Badge,
|
|
8
|
+
Button,
|
|
9
|
+
Card,
|
|
10
|
+
CodeView,
|
|
11
|
+
Collapsible,
|
|
12
|
+
plugin,
|
|
13
|
+
read,
|
|
14
|
+
RelativeTime,
|
|
15
|
+
Row,
|
|
16
|
+
set,
|
|
17
|
+
Spinner,
|
|
18
|
+
Stack,
|
|
19
|
+
Text,
|
|
20
|
+
type PanelContext
|
|
21
|
+
} from 'orca'
|
|
22
|
+
import { ask, busy, describeError, outcome } from '../panel-state.ts'
|
|
23
|
+
import type { ActionState, ActionView, Tone } from '../protocol.ts'
|
|
24
|
+
|
|
25
|
+
// Las líneas que se ven sin desplegar nada: el final de la salida, que es donde está el resultado.
|
|
26
|
+
const TAIL_LINES = 14
|
|
27
|
+
// Cuando `omk` pregunta, más: lo que pide aprobar (el acceso del plugin) va justo antes de la pregunta.
|
|
28
|
+
const ASKING_LINES = 30
|
|
29
|
+
|
|
30
|
+
const STATE: Record<ActionState, { tone: Tone; text: string }> = {
|
|
31
|
+
running: { tone: 'accent', text: 'en curso' },
|
|
32
|
+
asking: { tone: 'warning', text: 'espera tu respuesta' },
|
|
33
|
+
done: { tone: 'success', text: 'terminado' },
|
|
34
|
+
failed: { tone: 'danger', text: 'falló' },
|
|
35
|
+
lost: { tone: 'neutral', text: 'sin seguimiento' }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const WHERE: Record<ActionView['kind'], string> = {
|
|
39
|
+
omk: 'Se ejecuta en un terminal del workspace activo; aquí va su salida.',
|
|
40
|
+
agent: 'El agente trabaja en su terminal del workspace activo; aquí va lo último que pinta.'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const action = atom<ActionView | null>(null)
|
|
44
|
+
|
|
45
|
+
export function setupAction(ctx: PanelContext): void {
|
|
46
|
+
set(action, null)
|
|
47
|
+
ctx.subscriptions.push(plugin.on('action.changed', ({ action: next }) => set(action, next)))
|
|
48
|
+
void plugin
|
|
49
|
+
.request('kit.action')
|
|
50
|
+
.then(({ action: current }) => set(action, current))
|
|
51
|
+
.catch((error: unknown) => set(outcome, { tone: 'danger', text: `Acción en curso no leída: ${describeError(error)}` }))
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const answer = (id: string, approve: boolean) =>
|
|
55
|
+
ask('answer', () => plugin.request('kit.answer', { id, approve }), { tracked: true })
|
|
56
|
+
|
|
57
|
+
const dismiss = (id: string) => ask('dismiss', () => plugin.request('kit.dismiss', { id }), { tracked: true })
|
|
58
|
+
|
|
59
|
+
export function ActionCard() {
|
|
60
|
+
const view = read(action)
|
|
61
|
+
if (view === null) return null
|
|
62
|
+
const working = read(busy) !== null
|
|
63
|
+
const badge = STATE[view.state]
|
|
64
|
+
const ended = view.endedAt !== null
|
|
65
|
+
const tail = view.lines.slice(view.canAnswer ? -ASKING_LINES : -TAIL_LINES)
|
|
66
|
+
return (
|
|
67
|
+
<Card title={view.title} description={WHERE[view.kind]}>
|
|
68
|
+
<Stack gap="sm">
|
|
69
|
+
<Row gap="xs" align="center" wrap>
|
|
70
|
+
{view.state === 'running' ? <Spinner label="En curso" labelHidden /> : null}
|
|
71
|
+
<Badge tone={badge.tone}>{badge.text}</Badge>
|
|
72
|
+
<Text muted size="xs">
|
|
73
|
+
{ended ? 'acabó ' : 'empezó '}
|
|
74
|
+
<RelativeTime at={view.endedAt ?? view.startedAt} />
|
|
75
|
+
</Text>
|
|
76
|
+
</Row>
|
|
77
|
+
{view.detail === null ? null : (
|
|
78
|
+
<Text size="sm" tone={view.state === 'failed' ? 'danger' : undefined}>
|
|
79
|
+
{view.detail}
|
|
80
|
+
</Text>
|
|
81
|
+
)}
|
|
82
|
+
{tail.length === 0 ? (
|
|
83
|
+
<Text muted size="sm">
|
|
84
|
+
Sin salida todavía.
|
|
85
|
+
</Text>
|
|
86
|
+
) : (
|
|
87
|
+
<CodeView label={`Salida de ${view.title}`} code={tail.join('\n')} wrap maxHeight="none" />
|
|
88
|
+
)}
|
|
89
|
+
{view.lines.length > tail.length ? (
|
|
90
|
+
<Collapsible title="Salida completa" description={`${view.lines.length} líneas`}>
|
|
91
|
+
<CodeView label={`Salida completa de ${view.title}`} code={view.lines.join('\n')} wrap maxHeight="lg" />
|
|
92
|
+
</Collapsible>
|
|
93
|
+
) : null}
|
|
94
|
+
<Row gap="xs" wrap>
|
|
95
|
+
{view.canAnswer ? (
|
|
96
|
+
<Button icon="check" disabled={working} onPress={() => answer(view.id, true)}>
|
|
97
|
+
Aprobar
|
|
98
|
+
</Button>
|
|
99
|
+
) : null}
|
|
100
|
+
{view.canAnswer ? (
|
|
101
|
+
<Button variant="outline" tone="danger" icon="close" disabled={working} onPress={() => answer(view.id, false)}>
|
|
102
|
+
Rechazar
|
|
103
|
+
</Button>
|
|
104
|
+
) : null}
|
|
105
|
+
<Button variant="ghost" size="sm" icon="close" disabled={working} onPress={() => dismiss(view.id)}>
|
|
106
|
+
{ended ? 'Quitar' : 'Dejar de seguir'}
|
|
107
|
+
</Button>
|
|
108
|
+
</Row>
|
|
109
|
+
</Stack>
|
|
110
|
+
</Card>
|
|
111
|
+
)
|
|
112
|
+
}
|