orca-multiagent-kit 1.5.0 → 1.6.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.
Files changed (66) hide show
  1. package/CHANGELOG.md +30 -1
  2. package/README.md +2 -1
  3. package/VERSION +1 -1
  4. package/bin/omk.js +7 -0
  5. package/bin/team.js +353 -0
  6. package/core/AGENTS.md +1 -1
  7. package/docs/PLUGIN-ORCA.md +107 -18
  8. package/orca-plugin/README.md +5 -1
  9. package/orca-plugin/assets/logos/README.md +10 -0
  10. package/orca-plugin/assets/logos/agent.png +0 -0
  11. package/orca-plugin/assets/logos/aider.png +0 -0
  12. package/orca-plugin/assets/logos/amp.png +0 -0
  13. package/orca-plugin/assets/logos/antigravity.png +0 -0
  14. package/orca-plugin/assets/logos/claude.png +0 -0
  15. package/orca-plugin/assets/logos/cline.png +0 -0
  16. package/orca-plugin/assets/logos/codex.png +0 -0
  17. package/orca-plugin/assets/logos/copilot.png +0 -0
  18. package/orca-plugin/assets/logos/cursor.png +0 -0
  19. package/orca-plugin/assets/logos/devin.png +0 -0
  20. package/orca-plugin/assets/logos/droid.png +0 -0
  21. package/orca-plugin/assets/logos/gemini.png +0 -0
  22. package/orca-plugin/assets/logos/goose.png +0 -0
  23. package/orca-plugin/assets/logos/grok.png +0 -0
  24. package/orca-plugin/assets/logos/kimi.png +0 -0
  25. package/orca-plugin/assets/logos/kiro.png +0 -0
  26. package/orca-plugin/assets/logos/opencode.png +0 -0
  27. package/orca-plugin/assets/logos/qwen-code.png +0 -0
  28. package/orca-plugin/orca-plugin.json +25 -7
  29. package/orca-plugin/src/icons.test.ts +14 -0
  30. package/orca-plugin/src/icons.ts +30 -0
  31. package/orca-plugin/src/kit.test.ts +456 -9
  32. package/orca-plugin/src/kit.ts +626 -21
  33. package/orca-plugin/src/models.test.ts +28 -0
  34. package/orca-plugin/src/models.ts +29 -0
  35. package/orca-plugin/src/node.d.ts +40 -0
  36. package/orca-plugin/src/panel-state.ts +28 -0
  37. package/orca-plugin/src/panel.test.tsx +228 -30
  38. package/orca-plugin/src/panel.tsx +482 -78
  39. package/orca-plugin/src/plan-card.test.ts +99 -0
  40. package/orca-plugin/src/plan-card.ts +107 -0
  41. package/orca-plugin/src/protocol.ts +166 -5
  42. package/orca-plugin/src/tabs/autonomy.tsx +70 -0
  43. package/orca-plugin/src/tabs/history.test.tsx +78 -0
  44. package/orca-plugin/src/tabs/history.tsx +118 -0
  45. package/orca-plugin/src/tabs/notices.test.tsx +183 -0
  46. package/orca-plugin/src/tabs/notices.tsx +274 -0
  47. package/orca-plugin/src/tabs/worktrees.test.tsx +130 -0
  48. package/orca-plugin/src/tabs/worktrees.tsx +138 -0
  49. package/orca-plugin/src/ui/agent-icon.tsx +13 -0
  50. package/orca-plugin/src/worker/context.test.ts +32 -0
  51. package/orca-plugin/src/worker/context.ts +92 -0
  52. package/orca-plugin/src/worker/history.test.ts +149 -0
  53. package/orca-plugin/src/worker/history.ts +181 -0
  54. package/orca-plugin/src/worker/notices.test.ts +356 -0
  55. package/orca-plugin/src/worker/notices.ts +291 -0
  56. package/orca-plugin/src/worker/system.test.ts +58 -0
  57. package/orca-plugin/src/worker/system.ts +122 -0
  58. package/orca-plugin/src/worker/worktrees.test.ts +177 -0
  59. package/orca-plugin/src/worker/worktrees.ts +188 -0
  60. package/orca-plugin/src/worker.test.ts +265 -22
  61. package/orca-plugin/src/worker.ts +318 -34
  62. package/package.json +2 -2
  63. package/skills/orca/SKILL.md +1 -0
  64. package/skills/orca/references/engine-orca.md +1 -0
  65. package/skills/orca/references/olimpo.md +1 -0
  66. package/skills/orca/references/plan-card.md +45 -0
@@ -0,0 +1,183 @@
1
+ // La pestaña Avisos tal como la dibuja Orca, con el worker sustituido por respuestas fijas.
2
+ import { afterEach, assert, hostError, mockHost, mount, test, type TestPanel } from 'orca/testing'
3
+ import type { NoticeItem } from '../protocol.ts'
4
+ import * as panel from '../panel.tsx'
5
+
6
+ const PLAN: NoticeItem = {
7
+ id: 'plan:r1',
8
+ kind: 'plan',
9
+ title: 'Plan de rondas · r1',
10
+ agent: 'claude',
11
+ workspace: 'app',
12
+ unit: null,
13
+ since: 1000,
14
+ context: [],
15
+ canReply: true,
16
+ via: 'terminal',
17
+ plan: {
18
+ run: 'r1',
19
+ source: 'spec-kit 003-recargas',
20
+ autonomy: 'semi',
21
+ base: 'origin/main @ 1a2b3c4',
22
+ integration: 'feat/003-recargas',
23
+ merge: 'feat/003-recargas → main',
24
+ units: [
25
+ { round: 0, id: 'U0', title: 'setup', role: 'Hefesto', level: 'alto', agent: 'coordinador', model: null, resource: 'inline', files: '7', depends: null },
26
+ { round: 1, id: 'U2', title: 'recarga con tarjeta', role: 'Ariadna', level: 'medio', agent: 'claude', model: 'opus', resource: 'worker', files: '11', depends: 'U0' },
27
+ { round: 1, id: 'U3', title: 'revisión', role: null, level: null, agent: 'codex', model: null, resource: 'manual', files: null, depends: null }
28
+ ],
29
+ notes: ['modelos: nuevo en antigravity'],
30
+ orcaRun: null
31
+ }
32
+ }
33
+ const BLOCKED: NoticeItem = {
34
+ id: 't:2',
35
+ kind: 'blocked',
36
+ title: 'U2 · Ariadna — Pagos',
37
+ agent: 'codex',
38
+ workspace: 'app',
39
+ unit: 'U2 · Ariadna — Pagos',
40
+ since: 2000,
41
+ context: ['Allow edit to src/pay.ts? (y/n)', '> '],
42
+ canReply: true,
43
+ via: 'terminal',
44
+ plan: null
45
+ }
46
+ const CHAT: NoticeItem = { ...BLOCKED, id: 'p:structured-agent-session-claude_a:1', kind: 'waiting', title: 'chat', context: [], canReply: false, via: null }
47
+
48
+ type Requests = Record<string, (input: never) => unknown>
49
+ let view: TestPanel | undefined
50
+ afterEach(async () => {
51
+ await view?.unmount()
52
+ view = undefined
53
+ })
54
+
55
+ const open = async (items: NoticeItem[], requests: Requests = {}) => {
56
+ const calls: { name: string; input: unknown }[] = []
57
+ const answer = (name: string) => (input: unknown) => {
58
+ calls.push({ name, input })
59
+ return { message: `hecho: ${name}` }
60
+ }
61
+ const host = mockHost({
62
+ requests: {
63
+ 'agents.summary': { text: 'MAW', tone: 'neutral', tooltip: 'ninguno', groups: [] },
64
+ 'notices.list': { items },
65
+ // Las demás pestañas también piden su lista al montar el panel.
66
+ 'worktrees.list': { groups: [] },
67
+ 'history.list': { items: [] },
68
+ 'notices.reply': answer('notices.reply'),
69
+ 'notices.dismiss': answer('notices.dismiss'),
70
+ 'agents.open': answer('agents.open'),
71
+ ...requests
72
+ }
73
+ })
74
+ view = await mount(panel, { host })
75
+ await view.select({ label: 'Secciones' }, 'notices')
76
+ return { view, calls }
77
+ }
78
+ const text = (v: TestPanel) => JSON.stringify(v.tree())
79
+ const clean = (v: TestPanel) => {
80
+ assert.deepEqual(v.errors, [])
81
+ assert.deepEqual(v.warnings, [])
82
+ assert.deepEqual(v.refusals, [])
83
+ }
84
+
85
+ test('sin avisos sale el estado vacío', async () => {
86
+ const { view } = await open([])
87
+ assert.match(view.summary().join(' '), /Nada pendiente/)
88
+ clean(view)
89
+ })
90
+
91
+ test('la tarjeta del plan enseña cabecera, rondas, unidades y notas', async () => {
92
+ const { view } = await open([PLAN])
93
+ const all = text(view)
94
+ for (const expected of [/Plan de rondas · r1/, /spec-kit 003-recargas/, /Ronda 0/, /Ronda 1/, /recarga con tarjeta/, /Ariadna · medio/, /opus/, /depende de: U0/, /Notas/, /modelos: nuevo/, /Merge final/]) {
95
+ assert.match(all, expected)
96
+ }
97
+ assert.equal(view.find({ text: 'Pedir cambio' })?.disabled, true)
98
+ clean(view)
99
+ })
100
+
101
+ test('«Sí, lánzalo» responde sí y «Pedir cambio» responde cambia: …', async () => {
102
+ const { view, calls } = await open([PLAN])
103
+ await view.press({ text: 'Sí, lánzalo' })
104
+ await view.type({ label: '¿Qué cambio?' }, ' sin la ronda 2 ')
105
+ await view.press({ text: 'Pedir cambio' })
106
+ assert.deepEqual(calls, [
107
+ { name: 'notices.reply', input: { id: 'plan:r1', text: 'sí' } },
108
+ { name: 'notices.reply', input: { id: 'plan:r1', text: 'cambia: sin la ronda 2' } }
109
+ ])
110
+ assert.equal(view.valueOf({ label: '¿Qué cambio?' }), '')
111
+ clean(view)
112
+ })
113
+
114
+ test('el aviso desaparece cuando el worker lo quita', async () => {
115
+ const { view } = await open([PLAN])
116
+ await view.post('notices.changed', { items: [] })
117
+ assert.match(view.summary().join(' '), /Nada pendiente/)
118
+ clean(view)
119
+ })
120
+
121
+ test('sin canReply los controles salen deshabilitados y lo explica', async () => {
122
+ const { view } = await open([{ ...PLAN, canReply: false }, CHAT])
123
+ assert.equal(view.find({ text: 'Sí, lánzalo' })?.disabled, true)
124
+ assert.equal(view.findAll({ text: 'Responde en el chat del agente.' }).length > 0, true)
125
+ assert.equal(view.find({ text: 'Enviar' })?.disabled, true)
126
+ assert.equal(view.find({ text: 'Ir a su workspace' })?.disabled, false)
127
+ clean(view)
128
+ })
129
+
130
+ test('un agente bloqueado enseña su contexto y se le responde', async () => {
131
+ const { view, calls } = await open([BLOCKED])
132
+ const all = text(view)
133
+ assert.match(all, /necesita tu permiso/)
134
+ assert.match(all, /app/)
135
+ await view.toggle({ text: /Lo último del terminal/ })
136
+ assert.match(text(view), /Allow edit to src\/pay\.ts/)
137
+ assert.equal(view.find({ text: 'Enviar' })?.disabled, true)
138
+ await view.type({ label: 'Respuesta para U2 · Ariadna — Pagos' }, 'y')
139
+ await view.press({ text: 'Enviar' })
140
+ assert.deepEqual(calls, [{ name: 'notices.reply', input: { id: 't:2', text: 'y' } }])
141
+ assert.equal(view.valueOf({ label: 'Respuesta para U2 · Ariadna — Pagos' }), '')
142
+ clean(view)
143
+ })
144
+
145
+ test('ir a su workspace y descartar usan el id del aviso', async () => {
146
+ const { view, calls } = await open([BLOCKED])
147
+ await view.press({ text: 'Ir a su workspace' })
148
+ await view.press({ text: 'Descartar' })
149
+ assert.deepEqual(calls, [
150
+ { name: 'agents.open', input: { id: 't:2' } },
151
+ { name: 'notices.dismiss', input: { id: 't:2' } }
152
+ ])
153
+ clean(view)
154
+ })
155
+
156
+ test('un error de la respuesta sale arriba y la caja conserva el texto', async () => {
157
+ const { view } = await open([BLOCKED], {
158
+ 'notices.reply': () => {
159
+ throw hostError('unavailable', 'el terminal no aceptó el texto')
160
+ }
161
+ })
162
+ await view.type({ label: 'Respuesta para U2 · Ariadna — Pagos' }, 'y')
163
+ await view.press({ text: 'Enviar' })
164
+ assert.match(text(view), /no aceptó el texto/)
165
+ assert.equal(view.valueOf({ label: 'Respuesta para U2 · Ariadna — Pagos' }), 'y')
166
+ assert.deepEqual(view.errors, [])
167
+ })
168
+
169
+ test('si la lista no se puede leer sale el error', async () => {
170
+ const { view } = await open([], {
171
+ 'notices.list': () => {
172
+ throw hostError('unavailable', 'sin worker')
173
+ }
174
+ })
175
+ assert.match(text(view), /Avisos no leídos/)
176
+ assert.deepEqual(view.errors, [])
177
+ })
178
+
179
+ test('la pestaña dice cuántos avisos esperan', async () => {
180
+ const { view } = await open([PLAN])
181
+ assert.ok(text(view).includes('"label":"Avisos (1)"'))
182
+ clean(view)
183
+ })
@@ -0,0 +1,274 @@
1
+ // Pestaña Avisos: planes de rondas por confirmar y agentes que esperan a la persona, con la
2
+ // respuesta que se les escribe en su terminal (`notices.*` en src/protocol.ts).
3
+ import {
4
+ atom,
5
+ Badge,
6
+ Box,
7
+ Button,
8
+ Callout,
9
+ Card,
10
+ Code,
11
+ Collapsible,
12
+ EmptyState,
13
+ KeyValue,
14
+ plugin,
15
+ read,
16
+ RelativeTime,
17
+ Row,
18
+ set,
19
+ Stack,
20
+ Text,
21
+ Textarea,
22
+ type PanelContext
23
+ } from 'orca'
24
+ import { ask, busy, describeError, outcome } from '../panel-state.ts'
25
+ import type { NoticeItem, PlanCard, PlanUnit, Tone } from '../protocol.ts'
26
+ import { AgentIcon } from '../ui/agent-icon.tsx'
27
+ import { agentLabel } from '../kit.ts'
28
+
29
+ // «sí» + `cambia: ` caben en las 2000 letras que admite el worker.
30
+ const CHANGE_MAX = 1900
31
+ const NO_REPLY = 'Responde en el chat del agente.'
32
+ const VIA_RUN = 'Le llega al coordinador en su chat, por el buzón de su run de Orca.'
33
+
34
+ const notices = atom<NoticeItem[] | null>(null)
35
+ // Lo que se está escribiendo en la caja de cada aviso, por id; se vacía al enviar con éxito.
36
+ const drafts = atom<Record<string, string>>({})
37
+
38
+ const LEVEL_TONE: Record<string, Tone> = { alto: 'warning', medio: 'accent', bajo: 'neutral' }
39
+ const RESOURCE_TONE: Record<string, Tone> = { inline: 'neutral', worker: 'success', subagente: 'accent', manual: 'warning' }
40
+
41
+ const BLOCKED_BADGE: Record<NoticeItem['kind'], { tone: Tone; text: string }> = {
42
+ plan: { tone: 'accent', text: 'plan por confirmar' },
43
+ blocked: { tone: 'warning', text: 'necesita tu permiso' },
44
+ waiting: { tone: 'accent', text: 'espera instrucciones' }
45
+ }
46
+
47
+ /** «Avisos» con cuántos esperan, para la etiqueta de su pestaña. */
48
+ export function noticesLabel(): string {
49
+ const count = read(notices)?.length ?? 0
50
+ return count > 0 ? `Avisos (${count})` : 'Avisos'
51
+ }
52
+
53
+ export function setupNotices(ctx: PanelContext): void {
54
+ ctx.subscriptions.push(
55
+ plugin.on('notices.changed', ({ items }) => {
56
+ set(notices, items)
57
+ const ids = new Set(items.map(({ id }) => id))
58
+ const current = read(drafts)
59
+ if (Object.keys(current).some((id) => !ids.has(id))) {
60
+ set(drafts, Object.fromEntries(Object.entries(current).filter(([id]) => ids.has(id))))
61
+ }
62
+ })
63
+ )
64
+ void plugin
65
+ .request('notices.list')
66
+ .then(({ items }) => set(notices, items))
67
+ .catch((error: unknown) => set(outcome, { tone: 'danger', text: `Avisos no leídos: ${describeError(error)}` }))
68
+ }
69
+
70
+ const draftOf = (id: string) => read(drafts)[id] ?? ''
71
+ const setDraft = (id: string, text: string) => set(drafts, { ...read(drafts), [id]: text })
72
+
73
+ async function reply(id: string, text: string): Promise<void> {
74
+ const sent = await ask(`notice:${id}`, () => plugin.request('notices.reply', { id, text }))
75
+ if (sent) setDraft(id, '')
76
+ }
77
+
78
+ const dismiss = (id: string) => ask('dismiss', () => plugin.request('notices.dismiss', { id }))
79
+ const openAgent = (id: string) => ask('open', () => plugin.request('agents.open', { id }))
80
+
81
+ // Por dónde va la respuesta, cuando no es su terminal.
82
+ function ReplyHint({ notice }: { notice: NoticeItem }) {
83
+ if (notice.via === 'terminal') return null
84
+ return (
85
+ <Text muted size="xs">
86
+ {notice.via === 'run' ? VIA_RUN : NO_REPLY}
87
+ </Text>
88
+ )
89
+ }
90
+
91
+ function UnitBox({ unit }: { unit: PlanUnit }) {
92
+ const who = unit.model ? `${agentLabel(unit.agent)} · ${unit.model}` : agentLabel(unit.agent)
93
+ const level = unit.level ?? ''
94
+ const extras = [unit.files ? `ficheros: ${unit.files}` : null, unit.depends ? `depende de: ${unit.depends}` : null].filter(
95
+ (line): line is string => line !== null
96
+ )
97
+ return (
98
+ // Con título propio: sin él, Orca pone el de su tono («Advertencia», «Importante»).
99
+ <Callout tone={LEVEL_TONE[level] ?? 'neutral'} title={`${unit.id} · ${unit.title}`}>
100
+ <Box gap="xs">
101
+ <Row gap="xs" align="center" wrap>
102
+ {unit.role || unit.level ? (
103
+ <Badge tone={LEVEL_TONE[level] ?? 'neutral'}>{[unit.role, unit.level].filter(Boolean).join(' · ')}</Badge>
104
+ ) : null}
105
+ <AgentIcon agent={unit.agent} />
106
+ <Text size="sm">{who}</Text>
107
+ <Badge tone={RESOURCE_TONE[unit.resource] ?? 'neutral'}>{unit.resource}</Badge>
108
+ </Row>
109
+ {extras.length > 0 ? (
110
+ <Text muted size="xs">
111
+ {extras.join(' · ')}
112
+ </Text>
113
+ ) : null}
114
+ </Box>
115
+ </Callout>
116
+ )
117
+ }
118
+
119
+ function planFacts(plan: PlanCard) {
120
+ const facts = [
121
+ { label: 'Entrada', value: plan.source },
122
+ { label: 'Autonomía', value: plan.autonomy },
123
+ { label: 'Base', value: plan.base, code: true },
124
+ { label: 'Integración', value: plan.integration, code: true },
125
+ { label: 'Merge final', value: plan.merge, code: true }
126
+ ]
127
+ return facts.filter((fact) => fact.value !== null)
128
+ }
129
+
130
+ function Rounds({ plan }: { plan: PlanCard }) {
131
+ const rounds = [...new Set(plan.units.map(({ round }) => round))].sort((a, b) => a - b)
132
+ return (
133
+ <Stack gap="md">
134
+ {rounds.map((round) => (
135
+ <Stack gap="xs">
136
+ <Text weight="semibold" size="sm">{`Ronda ${round}`}</Text>
137
+ {plan.units
138
+ .filter((unit) => unit.round === round)
139
+ .map((unit) => (
140
+ <UnitBox unit={unit} />
141
+ ))}
142
+ </Stack>
143
+ ))}
144
+ </Stack>
145
+ )
146
+ }
147
+
148
+ function PlanNotice({ notice, plan }: { notice: NoticeItem; plan: PlanCard }) {
149
+ const working = read(busy) !== null
150
+ const change = draftOf(notice.id)
151
+ const facts = planFacts(plan)
152
+ return (
153
+ <Card title={`Plan de rondas · ${plan.run}`} description={`${plan.units.length} unidades`}>
154
+ <Stack gap="md">
155
+ <Row gap="xs" align="center" wrap>
156
+ <Badge tone={BLOCKED_BADGE.plan.tone}>{BLOCKED_BADGE.plan.text}</Badge>
157
+ <Text muted size="xs">
158
+ desde <RelativeTime at={notice.since} />
159
+ </Text>
160
+ </Row>
161
+ {facts.length > 0 ? <KeyValue label="Cabecera del plan" items={facts} /> : null}
162
+ <Rounds plan={plan} />
163
+ {plan.notes.length > 0 ? (
164
+ <Callout tone="accent" icon="info" title="Notas">
165
+ <Stack gap="xs">
166
+ {plan.notes.map((note) => (
167
+ <Text size="sm">{note}</Text>
168
+ ))}
169
+ </Stack>
170
+ </Callout>
171
+ ) : null}
172
+ <Button icon="check" disabled={working || !notice.canReply} onPress={() => reply(notice.id, 'sí')}>
173
+ Sí, lánzalo
174
+ </Button>
175
+ <Textarea
176
+ label="¿Qué cambio?"
177
+ rows={3}
178
+ maxLength={CHANGE_MAX}
179
+ value={change}
180
+ disabled={!notice.canReply}
181
+ onChange={(value) => setDraft(notice.id, value)}
182
+ />
183
+ <Row gap="xs" wrap>
184
+ <Button
185
+ variant="outline"
186
+ icon="next"
187
+ disabled={working || !notice.canReply || change.trim() === ''}
188
+ onPress={() => reply(notice.id, `cambia: ${change.trim()}`)}
189
+ >
190
+ Pedir cambio
191
+ </Button>
192
+ <Button variant="ghost" size="sm" icon="close" disabled={working} onPress={() => dismiss(notice.id)}>
193
+ Descartar
194
+ </Button>
195
+ </Row>
196
+ <ReplyHint notice={notice} />
197
+ </Stack>
198
+ </Card>
199
+ )
200
+ }
201
+
202
+ function AgentNotice({ notice }: { notice: NoticeItem }) {
203
+ const working = read(busy) !== null
204
+ const text = draftOf(notice.id)
205
+ const badge = BLOCKED_BADGE[notice.kind]
206
+ const where = [notice.unit, notice.workspace].filter((part): part is string => part !== null)
207
+ return (
208
+ <Card title={notice.title} description={where.length > 0 ? where.join(' · ') : undefined}>
209
+ <Stack gap="sm">
210
+ <Row gap="xs" align="center" wrap>
211
+ <AgentIcon agent={notice.agent} />
212
+ <Badge tone={badge.tone}>{badge.text}</Badge>
213
+ <Text muted size="xs">
214
+ desde <RelativeTime at={notice.since} />
215
+ </Text>
216
+ </Row>
217
+ {notice.context.length > 0 ? (
218
+ <Collapsible title="Lo último del terminal">
219
+ <Code block>{notice.context.join('\n')}</Code>
220
+ </Collapsible>
221
+ ) : null}
222
+ <Textarea
223
+ label={`Respuesta para ${notice.title}`}
224
+ rows={2}
225
+ maxLength={2000}
226
+ value={text}
227
+ disabled={!notice.canReply}
228
+ onChange={(value) => setDraft(notice.id, value)}
229
+ />
230
+ <Row gap="xs" wrap>
231
+ <Button
232
+ icon="next"
233
+ disabled={working || !notice.canReply || text.trim() === ''}
234
+ onPress={() => reply(notice.id, text)}
235
+ >
236
+ Enviar
237
+ </Button>
238
+ <Button variant="outline" icon="open-external" disabled={working} onPress={() => openAgent(notice.id)}>
239
+ Ir a su workspace
240
+ </Button>
241
+ <Button variant="ghost" size="sm" icon="close" disabled={working} onPress={() => dismiss(notice.id)}>
242
+ Descartar
243
+ </Button>
244
+ </Row>
245
+ <ReplyHint notice={notice} />
246
+ </Stack>
247
+ </Card>
248
+ )
249
+ }
250
+
251
+ export function Notices() {
252
+ const items = read(notices)
253
+ if (items === null) {
254
+ return (
255
+ <Card title="Avisos" description="Lo que espera tu respuesta.">
256
+ <Text muted>Cargando…</Text>
257
+ </Card>
258
+ )
259
+ }
260
+ if (items.length === 0) {
261
+ return (
262
+ <Card title="Avisos" description="Lo que espera tu respuesta.">
263
+ <EmptyState icon="bell" title="Nada pendiente" description="Aquí aparecen los planes por confirmar y los agentes que esperan." />
264
+ </Card>
265
+ )
266
+ }
267
+ return (
268
+ <Stack gap="md">
269
+ {items.map((notice) =>
270
+ notice.plan ? <PlanNotice notice={notice} plan={notice.plan} /> : <AgentNotice notice={notice} />
271
+ )}
272
+ </Stack>
273
+ )
274
+ }
@@ -0,0 +1,130 @@
1
+ // La pestaña Worktrees tal como la dibuja Orca, con el worker sustituido por respuestas fijas.
2
+ import { afterEach, assert, mockHost, mount, test, type TestPanel } from 'orca/testing'
3
+ import type { AgentsView, WorktreeGroup } from '../protocol.ts'
4
+ import * as panel from '../panel.tsx'
5
+
6
+ const NO_AGENTS: AgentsView = { text: 'MAW', tone: 'neutral', tooltip: 'ninguno', groups: [] }
7
+
8
+ const GROUPS: WorktreeGroup[] = [
9
+ {
10
+ run: '20261112-auth',
11
+ title: 'RUN 20261112-auth',
12
+ worktrees: [
13
+ {
14
+ workspaceId: 'w2',
15
+ name: 'u1-login',
16
+ branch: 'feat/u1-login',
17
+ unit: 'U1 — Login',
18
+ agents: [
19
+ { id: 't:t1', agent: 'claude', title: 'U1 · Proteo — Login', state: 'esperando', blocked: false, model: 'sonnet', canSetModel: true }
20
+ ]
21
+ },
22
+ {
23
+ workspaceId: 'w3',
24
+ name: 'u2-pagos',
25
+ branch: 'feat/u2-pagos',
26
+ unit: 'U2 — Pagos',
27
+ agents: [
28
+ { id: 't:t2', agent: 'claude', title: 'U2 · Proteo — Pagos', state: 'trabajando', blocked: false, model: null, canSetModel: true },
29
+ { id: 'p:chat', agent: 'claude', title: 'claude', state: 'bloqueado', blocked: true, model: null, canSetModel: false }
30
+ ]
31
+ }
32
+ ]
33
+ },
34
+ {
35
+ run: null,
36
+ title: 'Otros worktrees con agentes',
37
+ worktrees: [{ workspaceId: 'w4', name: 'otro', branch: null, unit: null, agents: [] }]
38
+ }
39
+ ]
40
+
41
+ let view: TestPanel | undefined
42
+ afterEach(async () => {
43
+ await view?.unmount()
44
+ view = undefined
45
+ })
46
+
47
+ const open = async (groups: WorktreeGroup[] = GROUPS) => {
48
+ const calls: { name: string; input: unknown }[] = []
49
+ const host = mockHost({
50
+ settings: {},
51
+ requests: {
52
+ 'agents.summary': () => NO_AGENTS,
53
+ // Las demás pestañas también piden su lista al montar el panel.
54
+ 'notices.list': () => ({ items: [] }),
55
+ 'history.list': () => ({ items: [] }),
56
+ 'worktrees.list': () => ({ groups }),
57
+ 'worktrees.open': (input: { workspaceId: string }) => {
58
+ calls.push({ name: 'worktrees.open', input })
59
+ return { message: 'Abierto.' }
60
+ },
61
+ 'worktrees.model': (input: { id: string; model: string }) => {
62
+ calls.push({ name: 'worktrees.model', input })
63
+ return { message: 'Pedido.' }
64
+ }
65
+ }
66
+ })
67
+ view = await mount(panel, { host })
68
+ await view.select({ label: 'Secciones' }, 'worktrees')
69
+ return { view, calls }
70
+ }
71
+
72
+ const clean = (v: TestPanel) => {
73
+ assert.deepEqual(v.errors, [])
74
+ assert.deepEqual(v.warnings, [])
75
+ assert.deepEqual(v.refusals, [])
76
+ }
77
+
78
+ test('una tarjeta por run con sus worktrees, agentes, estado y modelo', async () => {
79
+ const { view } = await open()
80
+ const text = JSON.stringify(view.tree())
81
+ assert.match(text, /RUN 20261112-auth/)
82
+ assert.match(text, /Otros worktrees con agentes/)
83
+ assert.match(text, /feat\/u1-login · U1 — Login/)
84
+ // El bloqueado sale abierto: se ve su fila sin pulsar nada.
85
+ assert.match(text, /bloqueado/)
86
+ assert.match(text, /modelo no informado/)
87
+ clean(view)
88
+ })
89
+
90
+ test('abrir un worktree pide su id al worker', async () => {
91
+ const { view, calls } = await open()
92
+ await view.press({ text: 'Abrir worktree' })
93
+ assert.equal(calls[0]?.name, 'worktrees.open')
94
+ clean(view)
95
+ })
96
+
97
+ test('cambiar el modelo de quien espera manda el elegido', async () => {
98
+ const { view, calls } = await open()
99
+ await view.toggle({ label: 'u1-login' })
100
+ assert.equal(view.valueOf({ label: 'Modelo de U1 · Proteo — Login' }), 'sonnet')
101
+ await view.select({ label: 'Modelo de U1 · Proteo — Login' }, 'opus')
102
+ await view.press({ text: 'Cambiar modelo' })
103
+ assert.deepEqual(calls.filter((c) => c.name === 'worktrees.model'), [
104
+ { name: 'worktrees.model', input: { id: 't:t1', model: 'opus' } }
105
+ ])
106
+ clean(view)
107
+ })
108
+
109
+ test('trabajando no se puede cambiar el modelo y lo explica; un chat de Orca, tampoco', async () => {
110
+ const { view } = await open()
111
+ const text = JSON.stringify(view.tree())
112
+ assert.match(text, /Espera a que termine su turno/)
113
+ assert.match(text, /Es un chat de Orca: cambia el modelo desde su chat/)
114
+ const buttons = view.findAll({ type: 'Button', text: /Cambiar modelo/ })
115
+ assert.equal(buttons.length, 1)
116
+ assert.equal(buttons[0]?.props.disabled, true)
117
+ clean(view)
118
+ })
119
+
120
+ test('sin worktrees enseña el vacío', async () => {
121
+ const { view } = await open([])
122
+ assert.match(view.summary().join(' '), /Ningún worktree/)
123
+ clean(view)
124
+ })
125
+
126
+ test('se actualiza cuando el worker envía otros worktrees', async () => {
127
+ const { view } = await open([])
128
+ await view.post('worktrees.changed', { groups: GROUPS })
129
+ assert.match(JSON.stringify(view.tree()), /RUN 20261112-auth/)
130
+ })