orca-multiagent-kit 1.5.0 → 1.7.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 (110) hide show
  1. package/AI_INSTALL.md +4 -3
  2. package/CHANGELOG.md +70 -1
  3. package/GUIA.html +11 -9
  4. package/README.md +23 -23
  5. package/VERSION +1 -1
  6. package/bin/backup.js +44 -0
  7. package/bin/fetch.js +243 -0
  8. package/bin/hooks.js +187 -0
  9. package/bin/omk.js +134 -51
  10. package/bin/run/cleanup.js +402 -0
  11. package/bin/run/git.js +641 -0
  12. package/bin/run/glob.js +193 -0
  13. package/bin/run/ledger.js +243 -0
  14. package/bin/run/plan.js +328 -0
  15. package/bin/run/units.js +101 -0
  16. package/bin/run/util.js +116 -0
  17. package/bin/run.js +224 -0
  18. package/bin/setup.js +81 -8
  19. package/bin/sync.js +222 -0
  20. package/bin/team.js +353 -0
  21. package/bin/ui.js +8 -4
  22. package/bin/update.js +169 -0
  23. package/core/AGENTS.md +7 -7
  24. package/docs/EJECUTABLE.md +5 -4
  25. package/docs/MANUAL.md +16 -3
  26. package/docs/ORQUESTADOR.md +59 -1
  27. package/docs/PLUGIN-ORCA.md +131 -24
  28. package/hooks/orca-gate.cjs +402 -0
  29. package/install.sh +26 -13
  30. package/orca-plugin/README.md +7 -1
  31. package/orca-plugin/assets/logos/README.md +10 -0
  32. package/orca-plugin/assets/logos/agent.png +0 -0
  33. package/orca-plugin/assets/logos/aider.png +0 -0
  34. package/orca-plugin/assets/logos/amp.png +0 -0
  35. package/orca-plugin/assets/logos/antigravity.png +0 -0
  36. package/orca-plugin/assets/logos/claude.png +0 -0
  37. package/orca-plugin/assets/logos/cline.png +0 -0
  38. package/orca-plugin/assets/logos/codex.png +0 -0
  39. package/orca-plugin/assets/logos/copilot.png +0 -0
  40. package/orca-plugin/assets/logos/cursor.png +0 -0
  41. package/orca-plugin/assets/logos/devin.png +0 -0
  42. package/orca-plugin/assets/logos/droid.png +0 -0
  43. package/orca-plugin/assets/logos/gemini.png +0 -0
  44. package/orca-plugin/assets/logos/goose.png +0 -0
  45. package/orca-plugin/assets/logos/grok.png +0 -0
  46. package/orca-plugin/assets/logos/kimi.png +0 -0
  47. package/orca-plugin/assets/logos/kiro.png +0 -0
  48. package/orca-plugin/assets/logos/opencode.png +0 -0
  49. package/orca-plugin/assets/logos/qwen-code.png +0 -0
  50. package/orca-plugin/orca-plugin.json +25 -7
  51. package/orca-plugin/src/icons.test.ts +14 -0
  52. package/orca-plugin/src/icons.ts +30 -0
  53. package/orca-plugin/src/kit.test.ts +491 -22
  54. package/orca-plugin/src/kit.ts +687 -37
  55. package/orca-plugin/src/models.test.ts +28 -0
  56. package/orca-plugin/src/models.ts +29 -0
  57. package/orca-plugin/src/node.d.ts +40 -0
  58. package/orca-plugin/src/panel-state.ts +36 -0
  59. package/orca-plugin/src/panel.check.ts +71 -0
  60. package/orca-plugin/src/panel.test.tsx +296 -33
  61. package/orca-plugin/src/panel.tsx +501 -81
  62. package/orca-plugin/src/plan-card.test.ts +99 -0
  63. package/orca-plugin/src/plan-card.ts +107 -0
  64. package/orca-plugin/src/protocol.ts +205 -5
  65. package/orca-plugin/src/tabs/autonomy.tsx +72 -0
  66. package/orca-plugin/src/tabs/history.test.tsx +79 -0
  67. package/orca-plugin/src/tabs/history.tsx +119 -0
  68. package/orca-plugin/src/tabs/notices.test.tsx +184 -0
  69. package/orca-plugin/src/tabs/notices.tsx +274 -0
  70. package/orca-plugin/src/tabs/worktrees.test.tsx +131 -0
  71. package/orca-plugin/src/tabs/worktrees.tsx +138 -0
  72. package/orca-plugin/src/ui/action-card.tsx +112 -0
  73. package/orca-plugin/src/ui/agent-icon.tsx +13 -0
  74. package/orca-plugin/src/worker/actions.test.ts +288 -0
  75. package/orca-plugin/src/worker/actions.ts +292 -0
  76. package/orca-plugin/src/worker/context.test.ts +32 -0
  77. package/orca-plugin/src/worker/context.ts +95 -0
  78. package/orca-plugin/src/worker/history.test.ts +149 -0
  79. package/orca-plugin/src/worker/history.ts +181 -0
  80. package/orca-plugin/src/worker/notices.test.ts +356 -0
  81. package/orca-plugin/src/worker/notices.ts +288 -0
  82. package/orca-plugin/src/worker/system.test.ts +58 -0
  83. package/orca-plugin/src/worker/system.ts +122 -0
  84. package/orca-plugin/src/worker/worktrees.test.ts +177 -0
  85. package/orca-plugin/src/worker/worktrees.ts +188 -0
  86. package/orca-plugin/src/worker.test.ts +285 -24
  87. package/orca-plugin/src/worker.ts +344 -64
  88. package/output-styles/csr-minimal.md +1 -0
  89. package/package.json +3 -3
  90. package/rules/50-done-gate.md +1 -1
  91. package/rules/95-multi-agent.md +13 -3
  92. package/skills/kit-init/SKILL.md +16 -4
  93. package/skills/orca/SKILL.md +28 -5
  94. package/skills/orca/references/adapters/artifact.md +2 -0
  95. package/skills/orca/references/adapters/chat.md +2 -0
  96. package/skills/orca/references/adapters/native-plan.md +6 -0
  97. package/skills/orca/references/adapters/plan-file.md +2 -0
  98. package/skills/orca/references/engine-manual.md +7 -5
  99. package/skills/orca/references/engine-orca.md +1 -0
  100. package/skills/orca/references/engine-subagents.md +4 -4
  101. package/skills/orca/references/integrate.md +14 -2
  102. package/skills/orca/references/ledger.md +1 -1
  103. package/skills/orca/references/olimpo.md +2 -1
  104. package/skills/orca/references/plan-card.md +45 -0
  105. package/skills/orca/references/plan.md +2 -1
  106. package/skills/orca/references/units.md +1 -1
  107. package/skills/orca/references/worker-contract.md +2 -2
  108. package/templates/AGENTS.md +2 -2
  109. package/templates/CLAUDE.md +1 -1
  110. package/templates/claude-settings.json +25 -0
@@ -0,0 +1,99 @@
1
+ import { assert, test } from 'orca/testing'
2
+ import { parsePlan, planPathRun } from './plan-card.ts'
3
+
4
+ const unit = (extra: Record<string, unknown> = {}) => ({
5
+ round: 1,
6
+ id: 'U2',
7
+ title: 'recarga con tarjeta (P1)',
8
+ role: 'Ariadna',
9
+ level: 'alto',
10
+ agent: 'claude',
11
+ model: null,
12
+ resource: 'worker',
13
+ files: '11',
14
+ depends: 'U0',
15
+ ...extra
16
+ })
17
+ const plan = (extra: Record<string, unknown> = {}) => ({
18
+ version: 1,
19
+ run: '20261107-recargas',
20
+ source: 'spec-kit 003-recargas',
21
+ autonomy: 'semi',
22
+ base: null,
23
+ integration: 'feat/003-recargas',
24
+ merge: 'feat/003-recargas → main',
25
+ units: [unit()],
26
+ notes: ['modelos: nuevo'],
27
+ ...extra
28
+ })
29
+
30
+ test('un plan válido sale tal cual, con lo que falte a null', () => {
31
+ const parsed = parsePlan(plan())
32
+ assert.equal(parsed?.run, '20261107-recargas')
33
+ assert.equal(parsed?.base, null)
34
+ assert.deepEqual(parsed?.units[0], unit())
35
+ assert.deepEqual(parsed?.notes, ['modelos: nuevo'])
36
+ const minimal = parsePlan({ version: 1, run: 'r1', units: [] })
37
+ assert.deepEqual(minimal, { run: 'r1', source: null, autonomy: null, base: null, integration: null, merge: null, units: [], notes: [], orcaRun: null })
38
+ })
39
+
40
+ test('limpia los textos y los acota a 200 caracteres', () => {
41
+ const parsed = parsePlan(plan({ source: `a\u001b[31m\nb ${'x'.repeat(300)}` }))
42
+ assert.equal(parsed?.source?.length, 200)
43
+ assert.equal(/[\u0000-\u001f]/.test(parsed?.source ?? ''), false)
44
+ })
45
+
46
+ test('lo que no encaje da null, nunca lanza', () => {
47
+ const invalid: unknown[] = [
48
+ null,
49
+ 'texto',
50
+ [],
51
+ plan({ version: 2 }),
52
+ plan({ version: undefined }),
53
+ plan({ run: undefined }),
54
+ plan({ run: 'con espacios' }),
55
+ plan({ run: '..' }),
56
+ plan({ run: 'a'.repeat(81) }),
57
+ plan({ units: 'U1' }),
58
+ plan({ units: [null] }),
59
+ plan({ units: [unit({ round: '1' })] }),
60
+ plan({ units: [unit({ round: -1 })] }),
61
+ plan({ units: [unit({ round: 1.5 })] }),
62
+ plan({ units: [unit({ id: 3 })] }),
63
+ plan({ units: [unit({ title: '' })] }),
64
+ plan({ units: [unit({ role: 7 })] }),
65
+ plan({ units: [unit({ resource: undefined })] }),
66
+ plan({ notes: 'una' }),
67
+ plan({ notes: [1] }),
68
+ plan({ merge: 4 })
69
+ ]
70
+ for (const value of invalid) assert.equal(parsePlan(value), null, JSON.stringify(value))
71
+ })
72
+
73
+ test('60 unidades caben; 61 se rechazan; las notas se quedan en 10', () => {
74
+ assert.equal(parsePlan(plan({ units: Array.from({ length: 60 }, () => unit()) }))?.units.length, 60)
75
+ assert.equal(parsePlan(plan({ units: Array.from({ length: 61 }, () => unit()) })), null)
76
+ assert.equal(parsePlan(plan({ notes: Array.from({ length: 15 }, (_, i) => `n${i}`) }))?.notes.length, 10)
77
+ })
78
+
79
+ test('el run de la ruta de un plan.json, con / o con \\', () => {
80
+ assert.equal(planPathRun('/repo/.work/runs/r1/plan.json'), 'r1')
81
+ assert.equal(planPathRun('C:\\repo\\.work\\runs\\20261112-x.y\\plan.json'), '20261112-x.y')
82
+ assert.equal(planPathRun('.work/runs/r1/plan.json'), 'r1')
83
+ for (const path of [
84
+ '/repo/.work/runs/r1/run.md',
85
+ '/repo/.work/runs/plan.json',
86
+ '/repo/.work/runs/../plan.json',
87
+ '/repo/x.work/runs/r1/plan.json',
88
+ '/repo/.work/runs/r 1/plan.json',
89
+ '/repo/.work/runs/r1/sub/plan.json',
90
+ ''
91
+ ]) {
92
+ assert.equal(planPathRun(path), null, path)
93
+ }
94
+ })
95
+
96
+ test('el número de ficheros vale también como número', () => {
97
+ assert.equal(parsePlan(plan({ units: [unit({ files: 7 })] }))?.units[0]?.files, '7')
98
+ assert.equal(parsePlan(plan({ units: [unit({ files: Number.NaN })] })), null)
99
+ })
@@ -0,0 +1,107 @@
1
+ // El `plan.json` de la skill orca (skills/orca/references/plan-card.md, versión 1) como PlanCard.
2
+ // Es un fichero que escribe un agente: se valida campo a campo y lo que no encaje se rechaza entero
3
+ // con `null`, nunca se lanza.
4
+ import { cleanLabel } from './kit.ts'
5
+ import { ORCA_RUN } from './worker/system.ts'
6
+ import type { PlanCard, PlanUnit } from './protocol.ts'
7
+
8
+ export const PLAN_UNITS_MAX = 60
9
+ export const PLAN_NOTES_MAX = 10
10
+ export const PLAN_TEXT_MAX = 200
11
+ const ROUND_MAX = 999
12
+
13
+ // Un id de run, que nunca es «.» ni «..».
14
+ const RUN = /^(?!\.+$)[\w.-]{1,80}$/
15
+ const PLAN_PATH = /(?:^|\/)\.work\/runs\/([^/]+)\/plan\.json$/
16
+
17
+ const isRecord = (value: unknown): value is Record<string, unknown> =>
18
+ typeof value === 'object' && value !== null && !Array.isArray(value)
19
+
20
+ /** El run de una ruta `…/.work/runs/<run>/plan.json` (barras `/` o `\`), o `null`. */
21
+ export function planPathRun(path: string): string | null {
22
+ const run = PLAN_PATH.exec(path.replace(/\\/g, '/'))?.[1]
23
+ return run !== undefined && RUN.test(run) ? run : null
24
+ }
25
+
26
+ type Field = { ok: true; value: string | null } | { ok: false }
27
+
28
+ // Un texto opcional: ausente o `null` es `null`; un texto, limpio y acotado; otro tipo no encaja.
29
+ function optionalText(value: unknown): Field {
30
+ if (value === undefined || value === null) return { ok: true, value: null }
31
+ if (typeof value !== 'string') return { ok: false }
32
+ return { ok: true, value: cleanLabel(value, PLAN_TEXT_MAX) }
33
+ }
34
+
35
+ function requiredText(value: unknown): string | null {
36
+ return typeof value === 'string' ? cleanLabel(value, PLAN_TEXT_MAX) : null
37
+ }
38
+
39
+ function parseUnit(value: unknown): PlanUnit | null {
40
+ if (!isRecord(value)) return null
41
+ const { round } = value
42
+ if (typeof round !== 'number' || !Number.isInteger(round) || round < 0 || round > ROUND_MAX) return null
43
+ const id = requiredText(value.id)
44
+ const title = requiredText(value.title)
45
+ const agent = requiredText(value.agent)
46
+ const resource = requiredText(value.resource)
47
+ if (id === null || title === null || agent === null || resource === null) return null
48
+ const role = optionalText(value.role)
49
+ const level = optionalText(value.level)
50
+ const model = optionalText(value.model)
51
+ // La tabla del plan da un número de ficheros: se acepta también como número.
52
+ const files = optionalText(typeof value.files === 'number' && Number.isFinite(value.files) ? String(value.files) : value.files)
53
+ const depends = optionalText(value.depends)
54
+ if (!role.ok || !level.ok || !model.ok || !files.ok || !depends.ok) return null
55
+ return {
56
+ round,
57
+ id,
58
+ title,
59
+ role: role.value,
60
+ level: level.value,
61
+ agent,
62
+ model: model.value,
63
+ resource,
64
+ files: files.value,
65
+ depends: depends.value
66
+ }
67
+ }
68
+
69
+ /** El plan de rondas de un `plan.json`, o `null` si no es la versión 1 o algo no encaja. */
70
+ export function parsePlan(value: unknown): PlanCard | null {
71
+ if (!isRecord(value) || value.version !== 1) return null
72
+ const { run, units: rawUnits, notes: rawNotes } = value
73
+ if (typeof run !== 'string' || !RUN.test(run)) return null
74
+ if (!Array.isArray(rawUnits) || rawUnits.length > PLAN_UNITS_MAX) return null
75
+ const units: PlanUnit[] = []
76
+ for (const raw of rawUnits) {
77
+ const unit = parseUnit(raw)
78
+ if (unit === null) return null
79
+ units.push(unit)
80
+ }
81
+ let notes: string[] = []
82
+ if (rawNotes !== undefined && rawNotes !== null) {
83
+ if (!Array.isArray(rawNotes) || !rawNotes.every((note) => typeof note === 'string')) return null
84
+ notes = rawNotes
85
+ .map((note) => cleanLabel(note, PLAN_TEXT_MAX))
86
+ .filter((note): note is string => note !== null)
87
+ .slice(0, PLAN_NOTES_MAX)
88
+ }
89
+ const source = optionalText(value.source)
90
+ const autonomy = optionalText(value.autonomy)
91
+ const base = optionalText(value.base)
92
+ const integration = optionalText(value.integration)
93
+ const merge = optionalText(value.merge)
94
+ if (!source.ok || !autonomy.ok || !base.ok || !integration.ok || !merge.ok) return null
95
+ return {
96
+ run,
97
+ source: source.value,
98
+ autonomy: autonomy.value,
99
+ base: base.value,
100
+ integration: integration.value,
101
+ merge: merge.value,
102
+ units,
103
+ notes,
104
+ // Un id que no tiene la forma de uno de Orca se ignora: sin él, se responde en el chat.
105
+ orcaRun: typeof value.orcaRun === 'string' && ORCA_RUN.test(value.orcaRun) ? value.orcaRun : null
106
+ }
107
+ }
@@ -1,18 +1,218 @@
1
- // Contrato entre el panel (src/panel.tsx) y el worker (src/worker.ts), declarado una sola vez.
2
- import type { AgentLine, AgentSummary, KitAction } from './kit.ts'
1
+ // Contrato entre el panel (src/panel.tsx y src/tabs/) y el worker (src/worker.ts y src/worker/),
2
+ // declarado una sola vez.
3
+ import type { AgentGroup, AgentSummary, Autonomy, KitAction, TaskSource, Team } from './kit.ts'
3
4
 
4
- /** Lo que el panel muestra de los agentes: el resumen de la barra y cada agente activo. */
5
- export type AgentsView = AgentSummary & { agents: AgentLine[] }
5
+ /** Lo que el panel muestra de los agentes: el resumen de la barra y los activos, agrupados. */
6
+ export type AgentsView = AgentSummary & { groups: AgentGroup[] }
7
+
8
+ export type Tone = 'neutral' | 'accent' | 'success' | 'warning' | 'danger'
9
+
10
+ /**
11
+ * Una fila del plan de rondas de la skill `orca` (SKILL.md §3), tal como la escribe en
12
+ * `.work/runs/<run>/plan.json` (skills/orca/references/plan-card.md).
13
+ */
14
+ export type PlanUnit = {
15
+ round: number
16
+ /** «U2», «U2r». */
17
+ id: string
18
+ title: string
19
+ /** Rol de Olimpo: «Ariadna». */
20
+ role: string | null
21
+ /** Nivel de modelo: alto, medio o bajo. */
22
+ level: string | null
23
+ /** Quién la hace: un id de agente o «coordinador». */
24
+ agent: string
25
+ model: string | null
26
+ /** inline, subagente, worker o manual. */
27
+ resource: string
28
+ files: string | null
29
+ depends: string | null
30
+ }
31
+
32
+ /** El plan de rondas que espera la confirmación 1, para pintarlo como tarjeta. */
33
+ export type PlanCard = {
34
+ run: string
35
+ /** De dónde sale el trabajo: «spec-kit 003-recargas», «chat». */
36
+ source: string | null
37
+ autonomy: string | null
38
+ /** «origin/main @ 1a2b3c4 (main local iba 3 commits por detrás)». */
39
+ base: string | null
40
+ integration: string | null
41
+ /** «feat/003-recargas → main». */
42
+ merge: string | null
43
+ units: PlanUnit[]
44
+ /** Líneas sueltas del plan: `modelos:`, `ficha:`, avisos. */
45
+ notes: string[]
46
+ /** El run de Orca del coordinador (`run_…`): por su buzón le llega la respuesta si corre como chat. */
47
+ orcaRun: string | null
48
+ }
49
+
50
+ /**
51
+ * Algo que espera a la persona: un plan de rondas por confirmar, un agente bloqueado (pide permiso
52
+ * o una respuesta) o uno que espera instrucciones.
53
+ */
54
+ export type NoticeKind = 'plan' | 'blocked' | 'waiting'
55
+
56
+ export type NoticeItem = {
57
+ /** Clave del aviso en el worker: el panel la devuelve para responder o descartarlo. */
58
+ id: string
59
+ kind: NoticeKind
60
+ title: string
61
+ /** Id del agente (claude, codex…), si se sabe. */
62
+ agent: string | null
63
+ workspace: string | null
64
+ /** «U2 · Ariadna — Pagos», si es una unidad del kit. */
65
+ unit: string | null
66
+ since: number
67
+ /** Las últimas líneas del terminal, limpias y acotadas: qué pregunta el agente. */
68
+ context: string[]
69
+ /** Si se le puede escribir desde el panel. */
70
+ canReply: boolean
71
+ /**
72
+ * Por dónde va la respuesta: a su terminal, o al buzón del run de Orca, que la entrega en el chat
73
+ * del coordinador. `null` si no hay camino (un chat que no es el coordinador de un run).
74
+ */
75
+ via: 'terminal' | 'run' | null
76
+ plan: PlanCard | null
77
+ }
78
+
79
+ export type WorktreeAgent = {
80
+ /** Clave del agente en el worker (la de `AgentLine.id`). */
81
+ id: string
82
+ agent: string | null
83
+ title: string
84
+ state: string
85
+ blocked: boolean
86
+ /** El modelo con el que se lanzó o al que se cambió, si se sabe. */
87
+ model: string | null
88
+ /** Si el panel puede cambiarle el modelo (hoy, Claude Code con terminal). */
89
+ canSetModel: boolean
90
+ }
91
+
92
+ export type WorktreeItem = {
93
+ workspaceId: string
94
+ name: string
95
+ branch: string | null
96
+ /** La unidad del kit que trabaja en él, si se sabe. */
97
+ unit: string | null
98
+ agents: WorktreeAgent[]
99
+ }
100
+
101
+ /** Los worktrees de un mismo run del kit o, sin run, los demás que ha creado la orquestación. */
102
+ export type WorktreeGroup = { run: string | null; title: string; worktrees: WorktreeItem[] }
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
+
131
+ export type HistoryKind =
132
+ | 'kit'
133
+ | 'dispatch'
134
+ | 'state'
135
+ | 'outcome'
136
+ | 'run'
137
+ | 'plan'
138
+ | 'orchestrate'
139
+ | 'reply'
140
+ | 'model'
141
+ | 'autonomy'
142
+
143
+ export type HistoryEntry = {
144
+ id: string
145
+ at: number
146
+ kind: HistoryKind
147
+ tone: Tone
148
+ title: string
149
+ detail: string | null
150
+ run: string | null
151
+ unit: string | null
152
+ agent: string | null
153
+ workspace: string | null
154
+ }
155
+
156
+ type Message = { message: string }
6
157
 
7
158
  declare module 'orca' {
8
159
  interface PluginRequests {
9
160
  /** Ejecuta una acción del kit en el workspace activo y responde qué ha hecho. */
10
- 'kit.run': { input: { action: KitAction }; output: { message: string } }
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 }
11
171
  /** Los agentes activos, como los cuenta la barra de estado. */
12
172
  'agents.summary': { output: AgentsView }
173
+ /** Muestra el workspace de un agente (`id` de una `AgentLine`). */
174
+ 'agents.open': { input: { id: string }; output: Message }
175
+ /** Escribe el equipo en `ORCHESTRATION.md` del workspace activo con `omk team set`. */
176
+ 'team.apply': { input: { team: Team }; output: Message }
177
+ /** Enseña en un terminal el equipo que tiene el proyecto (`omk team`). */
178
+ 'team.show': { output: Message }
179
+ /** Escribe el nivel de autonomía en `ORCHESTRATION.md` §0 con `omk team set --autonomy`. */
180
+ 'team.autonomy': { input: { autonomy: Autonomy }; output: Message }
181
+ /**
182
+ * Lanza el coordinador con la skill `orca`, la entrada elegida y la tarea en el workspace
183
+ * activo. `autonomy` cambia el nivel solo para ese run; sin él, manda `ORCHESTRATION.md`.
184
+ */
185
+ 'team.orchestrate': {
186
+ input: { agent: string; task: string; source: TaskSource; autonomy?: Autonomy | null }
187
+ output: Message
188
+ }
189
+ /** Lo que espera a la persona, lo más urgente primero. */
190
+ 'notices.list': { output: { items: NoticeItem[] } }
191
+ /**
192
+ * Escribe `text` en el terminal del agente del aviso `id` y pulsa Intro, como si lo tecleara
193
+ * la persona. Una sola línea; el worker la limpia y la acota.
194
+ */
195
+ 'notices.reply': { input: { id: string; text: string }; output: Message }
196
+ /** Quita un aviso de la lista sin responderlo. */
197
+ 'notices.dismiss': { input: { id: string }; output: Message }
198
+ /** Los worktrees de la orquestación con sus agentes, agrupados por run. */
199
+ 'worktrees.list': { output: { groups: WorktreeGroup[] } }
200
+ /** Muestra un worktree en Orca. */
201
+ 'worktrees.open': { input: { workspaceId: string }; output: Message }
202
+ /** Cambia el modelo del agente `id` (de `WorktreeAgent.id`). */
203
+ 'worktrees.model': { input: { id: string; model: string }; output: Message }
204
+ /** El historial de tareas y runs, lo más reciente primero. */
205
+ 'history.list': { output: { items: HistoryEntry[] } }
206
+ /** Vacía el historial. */
207
+ 'history.clear': { output: Message }
13
208
  }
14
209
  interface PluginPanelEvents {
15
210
  /** Se envía a los paneles abiertos cuando cambia lo que cuentan los agentes. */
16
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 }
214
+ 'notices.changed': { items: NoticeItem[] }
215
+ 'worktrees.changed': { groups: WorktreeGroup[] }
216
+ 'history.changed': { items: HistoryEntry[] }
17
217
  }
18
218
  }
@@ -0,0 +1,72 @@
1
+ // Autonomía de la skill orca: el nivel del proyecto (pestaña Equipo, `ORCHESTRATION.md` §0) y el
2
+ // que se quiera para un solo run (pestaña Repartir).
3
+ import { atom, Button, Card, plugin, read, Select, set, Stack, Text } from 'orca'
4
+ import { AUTONOMY_LEVELS, isAutonomy, type Autonomy } from '../kit.ts'
5
+ import { ask, busy } from '../panel-state.ts'
6
+
7
+ // Orca no admite una opción con valor vacío; este no puede ser un nivel.
8
+ const PROJECT_LEVEL = { value: '(proyecto)', label: 'La del proyecto (ORCHESTRATION.md)' }
9
+ const LEVEL_OPTIONS = AUTONOMY_LEVELS.map(({ id, label }) => ({ value: id, label }))
10
+
11
+ /** El nivel que se guardará en el proyecto; el panel lo recuerda entre sesiones. */
12
+ const projectAutonomy = atom<Autonomy>('autonomy', 'semi', {
13
+ persist: 'plugin',
14
+ version: 1,
15
+ migrate: (stored) => (isAutonomy(stored) ? stored : 'semi')
16
+ })
17
+
18
+ /** El nivel solo para el próximo run que se reparta; `null` = el del proyecto. */
19
+ export const runAutonomy = atom<Autonomy | null>(null)
20
+
21
+ const hint = (level: Autonomy) => AUTONOMY_LEVELS.find(({ id }) => id === level)?.hint ?? ''
22
+
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 })
26
+
27
+ export function AutonomyCard() {
28
+ const level = read(projectAutonomy)
29
+ const working = read(busy) !== null
30
+ return (
31
+ <Card
32
+ title="Autonomía"
33
+ description="Cuántas veces te pregunta el coordinador. Va a ORCHESTRATION.md §0 del proyecto activo."
34
+ >
35
+ <Stack gap="sm">
36
+ <Select
37
+ label="Nivel"
38
+ value={level}
39
+ options={LEVEL_OPTIONS}
40
+ onChange={(value) => {
41
+ if (isAutonomy(value)) set(projectAutonomy, value)
42
+ }}
43
+ />
44
+ <Text size="sm" muted>
45
+ {hint(level)} En ningún nivel se mergea a la rama por defecto, se hace push ni se borra nada sin preguntarte.
46
+ </Text>
47
+ <Button icon="check" disabled={working} onPress={saveAutonomy}>
48
+ {read(busy) === 'autonomy' ? 'Guardando…' : 'Guardar en el proyecto'}
49
+ </Button>
50
+ </Stack>
51
+ </Card>
52
+ )
53
+ }
54
+
55
+ export function AutonomyOverride() {
56
+ const level = read(runAutonomy)
57
+ return (
58
+ <Stack gap="xs">
59
+ <Select
60
+ label="Autonomía de este run"
61
+ value={level ?? PROJECT_LEVEL.value}
62
+ options={[PROJECT_LEVEL, ...LEVEL_OPTIONS]}
63
+ onChange={(value) => set(runAutonomy, isAutonomy(value) ? value : null)}
64
+ />
65
+ {level === null ? null : (
66
+ <Text size="xs" muted>
67
+ {hint(level)}
68
+ </Text>
69
+ )}
70
+ </Stack>
71
+ )
72
+ }
@@ -0,0 +1,79 @@
1
+ // La pestaña Historial tal como la dibuja Orca, con el worker sustituido.
2
+ import { afterEach, assert, mockHost, mount, test, type TestPanel } from 'orca/testing'
3
+ import type { AgentsView, HistoryEntry } from '../protocol.ts'
4
+ import * as panel from '../panel.tsx'
5
+
6
+ const NO_AGENTS: AgentsView = { text: 'MAW', tone: 'neutral', tooltip: 'ninguno', groups: [] }
7
+ const entry = (id: string, kind: HistoryEntry['kind'], title: string): HistoryEntry => ({
8
+ id,
9
+ at: Date.now(),
10
+ kind,
11
+ tone: 'accent',
12
+ title,
13
+ detail: 'detalle',
14
+ run: 'r1',
15
+ unit: 'U1',
16
+ agent: 'claude',
17
+ workspace: 'app'
18
+ })
19
+ const ITEMS = [entry('3', 'reply', 'Respondiste'), entry('2', 'dispatch', 'U1 despachado')]
20
+
21
+ let view: TestPanel | undefined
22
+ afterEach(async () => {
23
+ await view?.unmount()
24
+ view = undefined
25
+ })
26
+
27
+ const open = async (items: HistoryEntry[]) => {
28
+ const calls: string[] = []
29
+ const host = mockHost({
30
+ requests: {
31
+ 'agents.summary': () => NO_AGENTS,
32
+ 'kit.action': () => ({ action: null }),
33
+ // Las demás pestañas también piden su lista al montar el panel.
34
+ 'notices.list': () => ({ items: [] }),
35
+ 'worktrees.list': () => ({ groups: [] }),
36
+ 'history.list': () => ({ items }),
37
+ 'history.clear': () => {
38
+ calls.push('history.clear')
39
+ return { message: 'Historial vaciado.' }
40
+ }
41
+ }
42
+ })
43
+ view = await mount(panel, { host })
44
+ await view.select({ label: 'Secciones' }, 'history')
45
+ return { calls, host }
46
+ }
47
+ const clean = () => {
48
+ assert.deepEqual(view?.errors, [])
49
+ assert.deepEqual(view?.warnings, [])
50
+ assert.deepEqual(view?.refusals, [])
51
+ }
52
+
53
+ test('vacío enseña el estado vacío', async () => {
54
+ await open([])
55
+ assert.ok(view?.find({ label: 'Sin historial' }))
56
+ clean()
57
+ })
58
+
59
+ test('lista las entradas y filtra por tipo', async () => {
60
+ await open(ITEMS)
61
+ assert.ok(view?.find({ text: 'Respondiste' }))
62
+ assert.ok(view?.find({ text: 'U1 despachado' }))
63
+ await view?.select({ label: 'Mostrar' }, 'mine')
64
+ assert.ok(view?.find({ text: 'Respondiste' }))
65
+ assert.equal(view?.find({ text: 'U1 despachado' }), null)
66
+ await view?.select({ label: 'Mostrar' }, 'runs')
67
+ assert.equal(view?.find({ text: 'Respondiste' }), null)
68
+ assert.ok(view?.find({ text: 'U1 despachado' }))
69
+ clean()
70
+ })
71
+
72
+ test('vaciar pide confirmación en dos pasos', async () => {
73
+ const { calls } = await open(ITEMS)
74
+ await view?.press({ text: 'Vaciar historial' })
75
+ assert.deepEqual(calls, [])
76
+ await view?.press({ text: '¿Seguro? Vaciar' })
77
+ assert.deepEqual(calls, ['history.clear'])
78
+ clean()
79
+ })