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
@@ -1,36 +1,62 @@
1
1
  // Worker del plugin: comandos de paleta del kit, referencia al contrato del worker en los
2
- // despachos de orquestación, un resumen de agentes en la barra de estado y las peticiones del panel.
2
+ // despachos de orquestación, la skill orca en los prompts de arranque, los agentes con nombre en
3
+ // la barra de estado y el panel, sus avisos, y las peticiones del panel (acciones, equipo y repartir).
4
+ // Las pestañas Avisos, Worktrees e Historial y el seguimiento de la acción en curso viven en
5
+ // src/worker/: este núcleo oye a Orca una sola vez y les reparte los sucesos (src/worker/context.ts).
3
6
  // Orca transpila este fichero al cargarlo: no hay paso de build.
4
7
  import type { OrcaWorkerApi } from 'orca/worker'
5
8
  import {
6
- INSTALL_HINT,
7
- agentLines,
9
+ EXIT_MARKER_FLAG,
10
+ TASK_MAX,
11
+ blockedNotice,
12
+ cleanLabel,
8
13
  describeAgents,
14
+ agentFromPaneKey,
15
+ autonomyCommand,
16
+ canonicalWorkspaceId,
17
+ forgetRunUnit,
18
+ groupAgents,
19
+ indexWorkspaces,
20
+ isAutonomy,
9
21
  isKitAction,
10
- isMissingCommand,
11
22
  isValidAgentId,
23
+ orchestratePrompt,
12
24
  parseContractHintMode,
13
- pollUntil,
25
+ parseDispatch,
26
+ parseTeam,
14
27
  resolveFocusedWorkspaceId,
15
28
  summarizeAgents,
29
+ teamCommand,
30
+ trackRun,
16
31
  withContractHint,
32
+ withOrchestrateHint,
17
33
  type ContractHintMode,
18
34
  type KitAction,
19
- type TrackedAgent
35
+ type Notice,
36
+ type RunProgress,
37
+ type TrackedAgent,
38
+ type WorkspaceEntry,
39
+ type WorkspaceIndex
20
40
  } from './kit.ts'
21
41
  import type { AgentsView } from './protocol.ts'
42
+ import { registerActions } from './worker/actions.ts'
43
+ import { createBus, type KitContext, type TerminalInfo } from './worker/context.ts'
44
+ import { createNodeSystem, type KitSystem } from './worker/system.ts'
45
+ import { registerHistory } from './worker/history.ts'
46
+ import { registerNotices } from './worker/notices.ts'
47
+ import { registerWorktrees } from './worker/worktrees.ts'
22
48
 
23
49
  const STATUS_ITEM = 'agents'
24
50
  const INIT_PROMPT = 'inicializa el proyecto'
25
51
  const DEFAULT_INIT_AGENT = 'claude'
26
- // `omk verify` tarda poco; si en ~15 s no hay error de "comando no encontrado", existe.
27
- const MISSING_CHECK = { attempts: 10, delayMs: 1500 }
52
+ // Terminales de los que se recuerda qué agente y qué unidad llevan; los más antiguos se olvidan.
53
+ const TERMINALS_MAX = 200
28
54
  const NO_WORKSPACE =
29
55
  'No identifico el workspace activo. Abre el proyecto en Orca y vuelve a lanzar el comando.'
30
56
 
31
57
  type OmkSubcommand = 'verify' | 'update'
32
58
 
33
- // Esperas pendientes de las comprobaciones de `omk`: `deactivate` las cancela al parar el worker.
59
+ // Esperas pendientes del seguimiento de acciones: `deactivate` las cancela al parar el worker.
34
60
  const pendingTimers = new Set<ReturnType<typeof setTimeout>>()
35
61
  const sleep = (ms: number) =>
36
62
  new Promise<void>((resolve) => {
@@ -41,6 +67,9 @@ const sleep = (ms: number) =>
41
67
  pendingTimers.add(timer)
42
68
  })
43
69
 
70
+ /** Disco y CLI de Orca que usan las pestañas; los tests ponen aquí un doble antes de montar el worker. */
71
+ export const hostSystem: { current: KitSystem } = { current: createNodeSystem() }
72
+
44
73
  export function deactivate(): void {
45
74
  for (const timer of pendingTimers) clearTimeout(timer)
46
75
  pendingTimers.clear()
@@ -49,16 +78,28 @@ export function deactivate(): void {
49
78
  const describeError = (error: unknown) =>
50
79
  error instanceof Error ? `${(error as { code?: string }).code ?? 'error'}: ${error.message}` : String(error)
51
80
 
81
+ const running = (command: string) => `Ejecutando \`${command}\` en un terminal nuevo del workspace activo.`
82
+
52
83
  // Un `code` de error del host llega tal cual al panel (`plugin.request` lo rechaza con él).
53
- const invalidParams = (message: string) => Object.assign(new Error(message), { code: 'invalid_params' })
84
+ const failure = (code: string, message: string) => Object.assign(new Error(message), { code })
85
+ const invalidParams = (message: string) => failure('invalid_params', message)
54
86
 
55
87
  export default async function activate(orca: OrcaWorkerApi): Promise<void> {
56
88
  const { host } = orca
57
89
  let contractHint: ContractHintMode = 'kit'
58
90
  let statusBarEnabled = true
91
+ let notifyEnabled = true
92
+ let autoOrchestrate = true
59
93
  let initAgent: unknown = DEFAULT_INIT_AGENT
60
94
  const agents = new Map<string, TrackedAgent>()
95
+ const terminals = new Map<string, TerminalInfo>()
96
+ let workspaces: WorkspaceIndex = indexWorkspaces([])
97
+ // Ids que `workspace.list` no trajo: no se vuelve a pedir la lista por ellos.
98
+ const unnamedWorkspaces = new Set<string>()
99
+ const runs: RunProgress = new Map()
100
+ let refreshing: Promise<void> | null = null
61
101
  let postedView = ''
102
+ const bus = createBus((message) => orca.log(message))
62
103
 
63
104
  const notify = (title: string, body: string) => {
64
105
  void host.call('notifications.show', { title, body }).catch((error: unknown) => {
@@ -66,8 +107,20 @@ export default async function activate(orca: OrcaWorkerApi): Promise<void> {
66
107
  })
67
108
  }
68
109
 
69
- // Un fallo de Orca en un comando se cuenta al usuario; nunca se queda en silencio.
70
- const guarded = (label: string, run: () => Promise<string>) => async () => {
110
+ const announce = (notice: Notice | null) => {
111
+ if (notice && notifyEnabled) notify(notice.title, notice.body)
112
+ }
113
+
114
+ // Una unidad cambia de estado en su run; si con ella terminan todas, se avisa y se cuenta.
115
+ const progress = (run: string, key: string, state: TrackedAgent['state'], at: number) => {
116
+ const notice = trackRun(runs, run, key, state)
117
+ announce(notice)
118
+ if (notice) bus.emit('runDone', { run, notice, at })
119
+ }
120
+
121
+ // Desde la paleta no hay panel que enseñe el error: un fallo se notifica y es lo que responde
122
+ // el comando; nunca se queda en silencio.
123
+ const fromPalette = (label: string, run: () => Promise<string>) => async () => {
71
124
  try {
72
125
  return await run()
73
126
  } catch (error) {
@@ -78,18 +131,43 @@ export default async function activate(orca: OrcaWorkerApi): Promise<void> {
78
131
  }
79
132
  }
80
133
 
134
+ // Desde el panel el error vuelve a él con su `code` y lo enseña; aquí solo queda en el log.
135
+ const fromPanel = async (label: string, run: () => Promise<string>) => {
136
+ try {
137
+ return { message: await run() }
138
+ } catch (error) {
139
+ orca.log(`${label}: ${describeError(error)}`)
140
+ throw error
141
+ }
142
+ }
143
+
144
+ const canonical = (workspaceId: string | null) =>
145
+ workspaceId === null ? null : canonicalWorkspaceId(workspaceId, workspaces)
146
+
147
+ // Con la lista nueva, los agentes que llegaron con el id en otro formato pasan al de la lista.
148
+ const rememberWorkspaces = (
149
+ list: readonly (WorkspaceEntry & { path: string; kind?: string | null })[]
150
+ ) => {
151
+ workspaces = indexWorkspaces(list)
152
+ for (const [key, agent] of agents) {
153
+ const workspaceId = canonical(agent.workspaceId)
154
+ if (workspaceId !== agent.workspaceId) agents.set(key, { ...agent, workspaceId })
155
+ }
156
+ }
157
+
81
158
  const focusedWorkspaceId = async () => {
82
159
  const [focused, list] = await Promise.all([
83
160
  host.call('workspace.readContext'),
84
161
  host.call('workspace.list')
85
162
  ])
163
+ rememberWorkspaces(list.workspaces)
86
164
  return resolveFocusedWorkspaceId(focused, list.workspaces)
87
165
  }
88
166
 
89
- const agentsView = (): AgentsView => ({
90
- ...summarizeAgents(agents.values()),
91
- agents: agentLines(agents.values())
92
- })
167
+ const agentsView = (): AgentsView => {
168
+ const groups = groupAgents(agents, workspaces.byId)
169
+ return { ...summarizeAgents(agents.values(), groups), groups }
170
+ }
93
171
 
94
172
  // Los paneles abiertos reciben el resumen solo cuando cambia: los eventos de estado llegan a
95
173
  // ráfagas y Orca limita los envíos (200 cada 10 s).
@@ -111,105 +189,307 @@ export default async function activate(orca: OrcaWorkerApi): Promise<void> {
111
189
  })
112
190
  }
113
191
 
192
+ const refreshWorkspaces = () => {
193
+ refreshing ??= host
194
+ .call('workspace.list')
195
+ .then((list) => rememberWorkspaces(list.workspaces))
196
+ .catch((error: unknown) => orca.log(`nombres de workspace no leídos: ${describeError(error)}`))
197
+ .finally(() => {
198
+ refreshing = null
199
+ renderStatus()
200
+ })
201
+ return refreshing
202
+ }
203
+
204
+ // El nombre que se conoce ya; si el id es nuevo, se pide la lista una vez y se repinta.
205
+ const workspaceName = (workspaceId: string | null) => {
206
+ if (!workspaceId) return null
207
+ const name = workspaces.byId.get(workspaceId)?.name
208
+ if (name === undefined && !unnamedWorkspaces.has(workspaceId)) {
209
+ unnamedWorkspaces.add(workspaceId)
210
+ void refreshWorkspaces().then(() => {
211
+ if (!workspaces.byId.has(canonical(workspaceId) ?? '')) {
212
+ orca.log(`workspace.list no trae ${workspaceId}: sus agentes salen sin nombre de workspace`)
213
+ }
214
+ })
215
+ }
216
+ return name ?? null
217
+ }
218
+
219
+ const rememberTerminal = (terminalId: string, info: TerminalInfo) => {
220
+ const merged = { ...terminals.get(terminalId), ...info }
221
+ terminals.delete(terminalId)
222
+ terminals.set(terminalId, merged)
223
+ if (terminals.size > TERMINALS_MAX) {
224
+ const oldest = terminals.keys().next().value
225
+ if (oldest !== undefined) terminals.delete(oldest)
226
+ }
227
+ }
228
+
229
+ // Un despacho del kit da nombre a su terminal: unidad, rol y run.
230
+ const learnPrompt = (terminalId: string, agent: string | null, prompt: string) => {
231
+ const unit = parseDispatch(prompt)
232
+ const id = agent ? cleanLabel(agent, 40) : null
233
+ if (!unit && !id) return
234
+ rememberTerminal(terminalId, { ...(id ? { agent: id } : {}), ...(unit ? { unit } : {}) })
235
+ const key = `t:${terminalId}`
236
+ if (unit) bus.emit('dispatch', { key, terminalId, unit, agent: id, at: Date.now() })
237
+ const tracked = agents.get(key)
238
+ if (!tracked) return
239
+ agents.set(key, { ...tracked, agent: id ?? tracked.agent ?? null, unit: unit ?? tracked.unit ?? null })
240
+ if (unit) progress(unit.run, key, tracked.state, Date.now())
241
+ renderStatus()
242
+ }
243
+
114
244
  const loadSettings = async () => {
115
245
  try {
116
246
  const settings = await orca.settings.get()
117
247
  contractHint = parseContractHintMode(settings.contractHint)
118
248
  statusBarEnabled = settings.statusBar !== false
249
+ notifyEnabled = settings.notify !== false
250
+ autoOrchestrate = settings.autoOrchestrate !== false
119
251
  initAgent = settings.initAgent ?? DEFAULT_INIT_AGENT
120
252
  } catch (error) {
121
253
  orca.log(`ajustes no leídos, uso los valores por defecto: ${describeError(error)}`)
122
254
  }
123
255
  }
124
256
 
125
- const warnIfOmkMissing = async (terminalId: string) => {
126
- const missing = await pollUntil(
127
- async () => (await host.call('terminal.read', { terminalId, maxLines: 40 })).lines,
128
- (lines) => isMissingCommand(lines),
129
- { ...MISSING_CHECK, sleep }
130
- )
131
- if (missing) notify('omk no está instalado', INSTALL_HINT)
257
+ const ctx: KitContext = {
258
+ host,
259
+ panels: orca.panels,
260
+ storage: orca.storage,
261
+ system: hostSystem.current,
262
+ log: (message) => orca.log(message),
263
+ notify: (title, body) => {
264
+ if (notifyEnabled) notify(title, body)
265
+ },
266
+ agents,
267
+ terminals,
268
+ workspaces: () => workspaces,
269
+ workspaceName,
270
+ refreshWorkspaces,
271
+ ...bus
132
272
  }
273
+ const tracker = registerActions(ctx, sleep)
133
274
 
134
- const runOmk = (subcommand: OmkSubcommand) =>
135
- guarded(`omk ${subcommand}`, async () => {
136
- const workspaceId = await focusedWorkspaceId()
137
- if (!workspaceId) {
138
- notify('Orca Multiagent Kit', NO_WORKSPACE)
139
- return NO_WORKSPACE
140
- }
141
- // Literal fijo: nunca se interpola texto del usuario ni de terceros en el terminal.
142
- const command = `omk ${subcommand}`
143
- const { terminalId } = await host.call('terminal.create', { workspaceId, title: command, command })
144
- void warnIfOmkMissing(terminalId).catch((error: unknown) => {
145
- orca.log(`no pude leer la salida de ${command}: ${describeError(error)}`)
146
- })
147
- return `Ejecutando \`${command}\` en un terminal nuevo del workspace activo.`
275
+ const activeWorkspaceId = async () => {
276
+ const workspaceId = await focusedWorkspaceId()
277
+ if (!workspaceId) throw failure('unavailable', NO_WORKSPACE)
278
+ return workspaceId
279
+ }
280
+
281
+ // Abre un terminal con `command` y lo sigue hasta que acaba (src/worker/actions.ts). `command`
282
+ // es siempre un literal o sale de `teamCommand` (ids validados): nunca se interpola texto libre
283
+ // del usuario ni de terceros en el terminal. Lanza si no hay workspace o si Orca falla.
284
+ const runOmk = async (title: string, command: string) => {
285
+ const workspaceId = await activeWorkspaceId()
286
+ const { terminalId } = await host.call('terminal.create', {
287
+ workspaceId,
288
+ title,
289
+ command: `${command} ${EXIT_MARKER_FLAG}`
148
290
  })
291
+ tracker.omk(terminalId, title)
292
+ return running(command)
293
+ }
294
+
295
+ const subcommand = (name: OmkSubcommand) => () => runOmk(`omk ${name}`, `omk ${name}`)
149
296
 
150
- const initProject = guarded('inicializar proyecto', async () => {
297
+ // Lanza un agente con `prompt` y lo sigue. Lanza si no hay workspace o si Orca falla.
298
+ const launchAgent = async (title: string, agent: string, prompt: string, done: string) => {
299
+ const workspaceId = await activeWorkspaceId()
300
+ const { terminalId } = await host.call('agent.launch', { workspaceId, agent, prompt })
301
+ tracker.agent(terminalId, title)
302
+ return done
303
+ }
304
+
305
+ const initProject = async () => {
151
306
  if (!isValidAgentId(initAgent)) {
152
- const message = `El ajuste «Agente para inicializar» no es un id de agente válido: ${String(initAgent)}`
153
- notify('Orca Multiagent Kit', message)
154
- return message
155
- }
156
- const workspaceId = await focusedWorkspaceId()
157
- if (!workspaceId) {
158
- notify('Orca Multiagent Kit', NO_WORKSPACE)
159
- return NO_WORKSPACE
307
+ throw invalidParams(`El ajuste «Agente para inicializar» no es un id de agente válido: ${String(initAgent)}`)
160
308
  }
161
- await host.call('agent.launch', { workspaceId, agent: initAgent, prompt: INIT_PROMPT })
162
- return `Lanzado ${initAgent} con «${INIT_PROMPT}» (skill kit-init) en el workspace activo.`
163
- })
309
+ return launchAgent(
310
+ `Inicializar proyecto · ${initAgent}`,
311
+ initAgent,
312
+ INIT_PROMPT,
313
+ `Lanzado ${initAgent} con «${INIT_PROMPT}» (skill kit-init) en el workspace activo.`
314
+ )
315
+ }
164
316
 
165
- // El hook no deniega nunca: si no aplica, el prompt pasa intacto. Un fallo o un timeout
166
- // también lo dejan pasar (`onError: "pass"`): es una ayuda al worker, no un control.
317
+ // Los hooks no deniegan nunca: si no aplican, el prompt o el lanzamiento pasan intactos. Un
318
+ // fallo o un timeout también (`onError: "pass"`): son una ayuda, no un control.
319
+ // Un despacho lleva el contrato del worker; un prompt de arranque, la indicación de pasar por la
320
+ // skill orca. Son excluyentes: cada uno mira un `inputKind` distinto.
167
321
  orca.hooks.on('agent.prompt.before', (event, next) => {
168
- const prompt = withContractHint(event.prompt, event.inputKind, contractHint)
322
+ learnPrompt(event.terminalId, event.agent, event.prompt)
323
+ const prompt =
324
+ withContractHint(event.prompt, event.inputKind, contractHint) ??
325
+ withOrchestrateHint(event.prompt, event.inputKind, autoOrchestrate)
169
326
  return prompt === null ? undefined : next({ ...event, prompt })
170
327
  })
171
328
 
329
+ orca.hooks.on('agent.launch.before', (event) => {
330
+ if (!event.terminalId) return
331
+ const agent = cleanLabel(event.agent, 40)
332
+ rememberTerminal(event.terminalId, {
333
+ ...(agent ? { agent } : {}),
334
+ ...(event.workspaceId ? { workspaceId: event.workspaceId } : {})
335
+ })
336
+ if (agent) {
337
+ const { terminalId, workspaceId, command } = event
338
+ bus.emit('launch', { terminalId, agent, workspaceId, command, at: Date.now() })
339
+ }
340
+ })
341
+
342
+ // Solo observa: Orca no espera a este hook.
343
+ orca.hooks.on('agent.tool.after', (event) => {
344
+ bus.emit('tool', {
345
+ agent: event.agent,
346
+ workspaceId: event.workspaceId,
347
+ terminalId: event.terminalId ?? null,
348
+ tool: event.tool,
349
+ input: event.input,
350
+ at: Date.now()
351
+ })
352
+ })
353
+
172
354
  const actions: Record<KitAction, () => Promise<string>> = {
173
- verify: runOmk('verify'),
174
- update: runOmk('update'),
355
+ verify: subcommand('verify'),
356
+ update: subcommand('update'),
175
357
  init: initProject
176
358
  }
177
359
 
178
- orca.commands.register('kit.verify', actions.verify)
179
- orca.commands.register('kit.update', actions.update)
180
- orca.commands.register('kit.init', actions.init)
181
- orca.commands.register('agents.status', async () => describeAgents(agents.values()))
360
+ orca.commands.register('kit.verify', fromPalette('omk verify', actions.verify))
361
+ orca.commands.register('kit.update', fromPalette('omk update', actions.update))
362
+ orca.commands.register('kit.init', fromPalette('inicializar proyecto', actions.init))
363
+ orca.commands.register('agents.status', async () => describeAgents(groupAgents(agents, workspaces.byId)))
182
364
 
183
365
  // El panel solo elige entre las acciones fijas de arriba; cualquier otro valor se rechaza.
184
366
  orca.panels.handle('kit.run', async (input) => {
185
367
  const action: unknown = input?.action
186
368
  if (!isKitAction(action)) throw invalidParams(`acción desconocida: ${String(action)}`)
187
- return { message: await actions[action]() }
369
+ return fromPanel(`kit.run ${action}`, actions[action])
188
370
  })
189
371
  orca.panels.handle('agents.summary', () => agentsView())
190
372
 
373
+ orca.panels.handle('agents.open', async (input) => {
374
+ const id: unknown = input?.id
375
+ const agent = typeof id === 'string' ? agents.get(id) : undefined
376
+ if (!agent?.workspaceId) throw invalidParams('ese agente ya no está activo o no tiene workspace')
377
+ await host.call('workspace.open', { workspaceId: agent.workspaceId })
378
+ return { message: `Abierto ${workspaceName(agent.workspaceId) ?? 'su workspace'}.` }
379
+ })
380
+
381
+ orca.panels.handle('team.apply', async (input) => {
382
+ const team = parseTeam(input?.team)
383
+ if (!team) throw invalidParams('equipo no válido: revisa los proveedores y los roles')
384
+ const command = teamCommand(team)
385
+ if (command === null) {
386
+ throw invalidParams('el equipo no cabe en una orden de terminal: quita roles propios o acorta sus textos')
387
+ }
388
+ return fromPanel('team.apply', () => runOmk('omk team set', command))
389
+ })
390
+
391
+ orca.panels.handle('team.show', () => fromPanel('team.show', () => runOmk('omk team', 'omk team')))
392
+
393
+ // Solo uno de los tres niveles llega a la orden: `autonomyCommand` no interpola nada más.
394
+ orca.panels.handle('team.autonomy', async (input) => {
395
+ const level: unknown = input?.autonomy
396
+ if (!isAutonomy(level)) throw invalidParams(`autonomía desconocida: ${String(level)}`)
397
+ const command = autonomyCommand(level)
398
+ const result = await fromPanel('team.autonomy', () => runOmk(command, command))
399
+ bus.emit('action', { kind: 'autonomy', title: `Autonomía del proyecto → ${level}`, detail: null, agentKey: null, run: null, at: Date.now() })
400
+ return result
401
+ })
402
+
403
+ orca.panels.handle('team.orchestrate', async (input) => {
404
+ const agent: unknown = input?.agent
405
+ if (!isValidAgentId(agent)) throw invalidParams('el coordinador no es un id de agente válido')
406
+ const autonomy: unknown = input?.autonomy ?? null
407
+ const prompt = orchestratePrompt(input?.task, input?.source, autonomy)
408
+ if (prompt === null) {
409
+ throw invalidParams(`falta la tarea, pasa de ${TASK_MAX} caracteres, o la entrada o la autonomía no existen`)
410
+ }
411
+ const done = `Lanzado ${agent} con la skill orca en el workspace activo.`
412
+ const result = await fromPanel('team.orchestrate', () => launchAgent(`Repartir · ${agent}`, agent, prompt, done))
413
+ const task = cleanLabel(typeof input?.task === 'string' ? input.task : '', 120)
414
+ const title = isAutonomy(autonomy) ? `Repartir con ${agent} (autonomía ${autonomy})` : `Repartir con ${agent}`
415
+ bus.emit('action', { kind: 'orchestrate', title, detail: task, agentKey: null, run: null, at: Date.now() })
416
+ return result
417
+ })
418
+
191
419
  orca.events.on('agent.status.changed', (event) => {
192
420
  const key = event.terminalId ? `t:${event.terminalId}` : `p:${event.paneKey}`
193
- if (event.state === 'done') agents.delete(key)
194
- else agents.set(key, { workspaceId: event.workspaceId, title: event.title ?? null, state: event.state })
421
+ const previous = agents.get(key)
422
+ const info = event.terminalId ? terminals.get(event.terminalId) : undefined
423
+ const agent: TrackedAgent = {
424
+ workspaceId: canonical(event.workspaceId ?? previous?.workspaceId ?? info?.workspaceId ?? null),
425
+ // Orca no siempre manda el título: el que ya se conocía no se pierde.
426
+ title: cleanLabel(event.title ?? '') ?? previous?.title ?? null,
427
+ state: event.state,
428
+ agent: info?.agent ?? previous?.agent ?? (event.terminalId ? null : agentFromPaneKey(event.paneKey)),
429
+ unit: info?.unit ?? previous?.unit ?? null,
430
+ since: previous?.state === event.state ? (previous.since ?? null) : event.receivedAt,
431
+ // Sin terminal y con panel de chat: es un chat de Orca. Sin ninguno de los dos, no se sabe.
432
+ terminalId: event.terminalId ?? (agentFromPaneKey(event.paneKey) ? null : previous?.terminalId),
433
+ outcome: event.mainAgent?.outcome ?? previous?.outcome ?? null,
434
+ updatedAt: event.receivedAt
435
+ }
436
+ if (agent.state === 'done') agents.delete(key)
437
+ else agents.set(key, agent)
438
+ announce(blockedNotice(previous?.state, agent, workspaceName(agent.workspaceId)))
439
+ if (agent.unit) progress(agent.unit.run, key, agent.state, event.receivedAt)
440
+ bus.emit('agent', {
441
+ key,
442
+ previous,
443
+ agent: agent.state === 'done' ? null : agent,
444
+ state: agent.state,
445
+ outcome: agent.outcome ?? null,
446
+ at: event.receivedAt
447
+ })
195
448
  renderStatus()
196
449
  })
197
450
 
198
451
  orca.events.on('workspace.removed', (event) => {
199
- for (const [key, agent] of agents) if (agent.workspaceId === event.workspaceId) agents.delete(key)
452
+ const removed = new Set([event.workspaceId, canonical(event.workspaceId)])
453
+ for (const [key, agent] of agents) {
454
+ if (agent.workspaceId === null || !removed.has(agent.workspaceId)) continue
455
+ agents.delete(key)
456
+ forgetRunUnit(runs, key)
457
+ }
458
+ for (const [terminalId, info] of terminals) {
459
+ if (info.workspaceId !== undefined && removed.has(canonical(info.workspaceId))) terminals.delete(terminalId)
460
+ }
461
+ bus.emit('workspaceRemoved', { workspaceId: canonical(event.workspaceId) ?? event.workspaceId, at: Date.now() })
200
462
  renderStatus()
201
463
  })
202
464
 
465
+ registerNotices(ctx)
466
+ registerWorktrees(ctx)
467
+ registerHistory(ctx)
468
+
203
469
  orca.settings.onDidChange(() => {
204
470
  void loadSettings().then(renderStatus)
205
471
  })
206
472
 
207
473
  await loadSettings()
208
474
  try {
209
- const { agents: current } = await host.call('agents.list')
475
+ // `agents.list` solo da los del workspace enfocado: son de ese workspace.
476
+ const [{ agents: current }, workspaceId] = await Promise.all([
477
+ host.call('agents.list'),
478
+ focusedWorkspaceId().catch((error: unknown) => {
479
+ orca.log(`workspace enfocado no leído; los agentes iniciales quedan sin workspace: ${describeError(error)}`)
480
+ return null
481
+ })
482
+ ])
210
483
  for (const agent of current) {
211
484
  if (agent.terminalId && agent.state !== 'done') {
212
- agents.set(`t:${agent.terminalId}`, { workspaceId: null, title: agent.title, state: agent.state })
485
+ agents.set(`t:${agent.terminalId}`, {
486
+ workspaceId,
487
+ title: cleanLabel(agent.title ?? ''),
488
+ state: agent.state,
489
+ agent: agent.agent ? cleanLabel(agent.agent, 40) : null,
490
+ since: agent.stateStartedAt,
491
+ terminalId: agent.terminalId
492
+ })
213
493
  }
214
494
  }
215
495
  } catch (error) {
@@ -8,6 +8,7 @@ Eres un ingeniero senior. Tu razonamiento y tu código son exhaustivos; tu prosa
8
8
  - Primera línea = resultado o estado. Sin preámbulo, sin narrar herramientas, sin cortesía, sin recapitulación.
9
9
  - ≤4 líneas de prosa por turno. Código, diffs, tablas de gates y comandos no cuentan.
10
10
  - El resto del protocolo (prefijos, excepciones, disparadores de detalle) está en `~/.agents/AGENTS.md` §2 y en `~/.agents/rules/10-communication.md`. Aplícalo; no lo repitas.
11
+ - Puerta de reparto (`~/.agents/AGENTS.md` §6): en un trabajo con ≥2 entregables separables, la línea `ORCA: …` de la skill `orca` se escribe en el chat antes de la primera edición, aunque no sea el mensaje final; si reparte, va con el plan de rondas. Esa línea, el plan de rondas y sus confirmaciones no son prosa que recortar ni preguntas que ahorrarse.
11
12
  - El ahorro es solo de salida en prosa. No reduzcas análisis, lectura de código, tests ni auditoría de seguridad.
12
13
  - Antes de declarar algo terminado: `~/.agents/rules/50-done-gate.md` y tabla de gates. Un comando no ejecutado se reporta `SKIPPED (motivo)`, nunca `PASS`.
13
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orca-multiagent-kit",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "Una sola fuente de reglas y skills (CSR + MAW) para Claude Code, Antigravity, Codex, Copilot y Cursor, con orquestación multiagente.",
5
5
  "license": "MIT",
6
6
  "author": "Fernando Baquero (https://github.com/FernandoBaqueroo)",
@@ -13,14 +13,14 @@
13
13
  "orca-multiagent-kit": "bin/omk.js"
14
14
  },
15
15
  "files": [
16
- "bin/", "speckit-extension/", "core/", "rules/", "skills/", "templates/", "output-styles/", "docs/", "orca-plugin/",
16
+ "bin/", "hooks/", "speckit-extension/", "core/", "rules/", "skills/", "templates/", "output-styles/", "docs/", "orca-plugin/",
17
17
  "install.sh", "VERSION", "GUIA.html", "AI_INSTALL.md", "CHANGELOG.md", "LICENSE", "README.md"
18
18
  ],
19
19
  "engines": { "node": ">=18" },
20
20
  "os": ["darwin", "linux", "win32"],
21
21
  "keywords": ["ai-agents", "claude-code", "antigravity", "gemini", "codex", "copilot", "cursor", "orca", "agent-skills", "multi-agent", "worktrees", "spec-kit", "agents-md"],
22
22
  "scripts": {
23
- "test": "bash scripts/check.sh && bash tests/test_install.sh && bash tests/test_cli.sh && bash tests/test_orca.sh && bash tests/test_speckit.sh",
23
+ "test": "bash scripts/check.sh && bash tests/test_install.sh && bash tests/test_cli.sh && bash tests/test_team.sh && bash tests/test_orca.sh && bash tests/test_update.sh && bash tests/test_gate.sh && bash tests/test_run.sh && bash tests/test_run_plan.sh && bash tests/test_run_git.sh && bash tests/test_run_cleanup.sh && bash tests/test_speckit.sh",
24
24
  "build:exe": "node scripts/build-exe.js"
25
25
  }
26
26
  }
@@ -59,7 +59,7 @@ build | pnpm build | PASS
59
59
  test | pnpm test | PASS 128/128
60
60
  coverage | pnpm test:cov | 86% cambiado
61
61
  sec-scan | semgrep --config=auto| SKIPPED (no instalado: semgrep)
62
- deps | npm audit | SKIPPED (sin red)
62
+ deps-audit | npm audit | SKIPPED (sin red)
63
63
  RISK: <si aplica>
64
64
  DEFERRED: <si aplica>
65
65
  ```
@@ -2,21 +2,31 @@
2
2
 
3
3
  > El núcleo (`~/.agents/AGENTS.md` §6) enuncia las invariantes. Este fichero añade criterio y casos. No las repite.
4
4
 
5
+ ## Puerta de reparto (cuándo se evalúa)
6
+ La evaluación no es opcional ni depende de la vía de entrada: todo trabajo de implementación con ≥2 entregables separables pasa por la skill `orca` antes de la primera edición (núcleo §6) y deja una línea `ORCA: …`. Contar entregables es barato y se hace siempre; los criterios de abajo los aplica la skill, con las unidades delante, no el agente de memoria antes de cargarla.
7
+ | Entrada | Qué la dispara |
8
+ |---|---|
9
+ | spec-kit | Hook `before_implement` de `/speckit.implement` (skill `speckit-orca-implement`) |
10
+ | Prompt de chat, ticket, «implementa `planes/x.md`», artefacto | Núcleo §6; en Claude Code, además, el hook `UserPromptSubmit` del kit lo recuerda en cada mensaje |
11
+ | Plan nativo aprobado | La sección `Reparto` del propio plan (núcleo §6); en Claude Code, además, el hook `PostToolUse` sobre `ExitPlanMode` |
12
+ | Agente arrancado por Orca con una tarea | Plugin del kit en Orca («Repartir siempre») |
13
+ Un entregable solo, una pregunta o un worker con su unidad no pasan por la puerta.
14
+
5
15
  ## Cuándo paralelizar (y cuándo no)
6
16
  Paraleliza solo si **todo** se cumple:
7
17
  - Hay ≥2 unidades sin dependencia entre sí.
8
18
  - Sus conjuntos de ficheros de escritura no se cortan (ver §Solapes).
9
- - Cada unidad tiene ≥ ~15 min de trabajo. Por debajo, el coste de worktree + revisión + merge supera la ganancia.
19
+ - Cada unidad tiene ≥ ~15 min de trabajo. Por debajo, el coste de worktree + revisión + merge supera la ganancia. Mídelo por talla (§Tamaño de unidad), no a ojo: una unidad `M` o `L` cumple; una `S` no.
10
20
  - Puedes verificar cada unidad por separado (tests, build o comprobación visual concreta).
11
21
  Si falla cualquiera: secuencial en un solo agente (motor `inline`). Decláralo: `ORCA: secuencial — <motivo>`.
12
22
 
13
23
  ### Cuenta rápida (cuando dudes)
14
24
  ```
15
25
  ahorro = Σ t(unidades de la ronda) − max t(unidad) # lo que ganas por ronda
16
- coste = 10 min × unidades + 10 min × rondas # brief + revisión + merge + gates del conjunto
26
+ coste = 5 min × unidades + 5 min × rondas # brief + revisión + merge + gates del conjunto
17
27
  compensa si Σ ahorro > coste y ningún ahorro depende de una unidad L sin dividir
18
28
  ```
19
- Estimaciones en minutos de agente, no humanos. Penaliza (+10 min por fichero) cada fichero `shared` que obligue a serializar o a pasarlo a `U0`. Si el resultado es dudoso, secuencial: la orquestación fallida cuesta más que la que no se hizo.
29
+ Estimaciones en minutos de agente, no humanos. Penaliza (+10 min por fichero) cada fichero `shared` que obligue a serializar o a pasarlo a `U0`. Con dos unidades `M` de ficheros disjuntos la cuenta sale a favor (30 + 30 min: ahorro 30, coste 15): se reparten. Secuencial solo si la cuenta sale en contra o si alguna condición de arriba falla; ante un empate, reparte.
20
30
 
21
31
  ## Tamaño de unidad
22
32
  | Talla | Orientación | Presupuesto orientativo | Qué hacer |