@mrc2204/opencode-bridge 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,658 @@
1
+ ---
2
+ name: opencode-orchestration
3
+ description: Use when an outer agent already has planning/tracking artifacts and needs to hand off a file-driven execution packet to OpenCode/OpenCodeKit; this skill is a bridge into the execution lane, not a governance or Jira orchestration skill.
4
+ version: 1.0.0
5
+ owner: asm-operating-layer
6
+ ---
7
+
8
+ # Opencode Orchestration
9
+
10
+ ## Objective
11
+
12
+ Bridge an already-defined implementation packet into the OpenCode/OpenCodeKit execution lane with a strict boundary:
13
+
14
+ - **Outer agent = governance layer** (clarify if needed, create Jira bug/task or Epic+tasks, prepare/own artifacts, verify evidence, sync/close tracking)
15
+ - **ASM = retrieval backend** (context/project memory/coding packet)
16
+ - **OpenCode / OpenCodeKit = execution system** (read artifacts, orchestrate internally, implement, update execution checklist artifacts)
17
+
18
+ Default rule: for long workflows, prefer a file-driven SDD handoff. Outer agents should not manually micromanage OpenCode slice-by-slice.
19
+
20
+ Do not modify ASM core in this skill workflow.
21
+
22
+ ## Hard Boundaries
23
+
24
+ This skill is a **handoff/bridge skill**, not a project orchestrator.
25
+
26
+ It must **not** redefine or absorb these responsibilities:
27
+
28
+ - Jira governance
29
+ - upfront planning ownership
30
+ - cross-functional governance orchestration
31
+ - outer-agent verification/closure
32
+
33
+ It exists only to pass a clean execution packet into OpenCode/OpenCodeKit and preserve execution-lane boundaries.
34
+
35
+ ---
36
+
37
+ ## Trigger Rules
38
+
39
+ Activate this skill when one of the following is true:
40
+
41
+ 1. The outer agent already produced execution artifacts and must hand off implementation to OpenCode/OpenCodeKit.
42
+ 2. The workflow is long enough that execution should be file-driven instead of manual outer-agent slice coordination.
43
+ 3. A structured execution packet is needed across `scrum`, `fullstack`, `assistant`, `creator`.
44
+ 4. There is real coordination need across multiple coding lanes inside the execution system.
45
+
46
+ Do not use this skill for research-only tasks that do not involve code edits.
47
+ Do not use this skill for:
48
+
49
+ - Jira creation/updates as the primary job
50
+ - design clarification or planning ownership
51
+ - `single-lane coding` with no need for packetized handoff
52
+ - small follow-up coding work
53
+ - routine coding tasks that OpenCode can execute directly without coordination overhead
54
+
55
+ ---
56
+
57
+ ## Standard Workflow Placement
58
+
59
+ Canonical file-driven flow:
60
+
61
+ 1. `using-superpowers` selects the workflow
62
+ 2. `brainstorming` clarifies/designs before planning when needed
63
+ 3. `writing-plans` prepares plan + management gate + execution artifacts
64
+ 4. outer agent automatically continues by creating/updating Jira, Epic/task breakdown, and artifacts when approval exists and no real blocker remains
65
+ 5. `opencode-orchestration` hands the packet into OpenCode/OpenCodeKit execution
66
+ 6. OpenCode/OpenCodeKit executes from artifacts as source of truth
67
+ 7. outer agent verifies evidence via `verification-before-completion`, then syncs/closes Jira
68
+
69
+ ## Pattern 3: Session/Server Mode
70
+
71
+ ### Session roles
72
+
73
+ - **Outer Session**: maintains governance, tracking, artifacts, acceptance, and final verification.
74
+ - **Execution Sessions**: each coding task maps to one dedicated OpenCode/OpenCodeKit execution session.
75
+ - **Server State**: execution state lives in artifacts/checkpoints, not in ad-hoc chat memory.
76
+
77
+ ### Task-to-session model
78
+
79
+ Each coding task must include:
80
+
81
+ - `task_id` (unique)
82
+ - `owner_agent` (executor)
83
+ - `session_key` (task-specific)
84
+ - `scope_claim` (intended files/modules)
85
+ - `state`: `queued | running | blocked_conflict | checkpoint_needed | done | failed | aborted`
86
+
87
+ Rules:
88
+
89
+ - 1 task ↔ 1 execution session
90
+ - Do not reuse an old session for a new task with a different primary scope
91
+ - The artifact packet is the source of truth for execution scope; outer governance owns lifecycle transitions
92
+
93
+ ---
94
+
95
+ ## Multi-agent applicability matrix
96
+
97
+ | Agent | Primary role | Can own coding task? | Notes |
98
+ | --------- | --------------------------------- | -------------------: | ---------------------------------------------------------------------------------------- |
99
+ | scrum | Outer governance + packet handoff | Yes (limited) | Owns planning/tracking/handoff, should not micromanage OpenCode execution slice-by-slice |
100
+ | fullstack | Main coding executor | Yes | Preferred execution owner for cross-layer/backend/frontend work |
101
+ | assistant | Support executor + synthesis | Yes | Small fixes, glue code, verification checklists inside execution lane |
102
+ | creator | UI/content implementation | Yes | Preferred for UI copy/layout/asset pipeline |
103
+
104
+ Rules:
105
+
106
+ - Only the outer governance layer should approve packet scope and acceptance before execution starts.
107
+ - Executors must not claim scope outside the coding packet.
108
+ - Executors do not read Jira directly; artifacts/packet are the execution source of truth.
109
+
110
+ ---
111
+
112
+ ## Serialized scheduling & conflict policy (MANDATORY)
113
+
114
+ ### 1) Serialized by default
115
+
116
+ - By default, all coding tasks run **sequentially**.
117
+ - Parallel execution is allowed only when all conflict-safety conditions below are satisfied.
118
+
119
+ ### 2) Conditions for parallel execution
120
+
121
+ Parallel is allowed only when orchestrator has evidence that:
122
+
123
+ 1. `file_paths` do not overlap, **and**
124
+ 2. `module_boundaries` do not share ripple-prone shared modules, **and**
125
+ 3. No shared critical lock group is touched simultaneously: `package manifests`, `shared config`, `global types/contracts`, `build pipeline files`.
126
+
127
+ If any condition is uncertain => fall back to sequential.
128
+
129
+ ### 3) Lock / release policy
130
+
131
+ When a task moves to `running`, it must acquire:
132
+
133
+ - `file_lock`: path-level lock
134
+ - `module_lock`: module/domain lock
135
+ - `shared_lock`: shared-critical lock group (if applicable)
136
+
137
+ Next tasks must wait if:
138
+
139
+ - path locks overlap, or
140
+ - modules have direct/shared dependency relations, or
141
+ - conflict risk has not been proven safe.
142
+
143
+ Release locks only when:
144
+
145
+ - task reports `done|failed|aborted` + checkpoint submitted,
146
+ - orchestrator confirms minimum artifact validity.
147
+
148
+ ### 4) Ownership policy
149
+
150
+ - At any time, each file/module has **exactly one active owner task**.
151
+ - Ownership transfer requires explicit handoff (checkpoint + lock transfer).
152
+ - No "steal edit" on files currently locked by another task.
153
+
154
+ ---
155
+
156
+ ## Coding packet schema (executor input)
157
+
158
+ Use the following minimal JSON packet (can be generated by `project_coding_packet` when available):
159
+
160
+ Preferred artifact set around the packet:
161
+
162
+ - `specs.md` or equivalent approved design artifact
163
+ - `tasks.md` with executable checklist
164
+ - `implement.md` or packet JSON for execution instructions
165
+
166
+ OpenCode/OpenCodeKit should execute from these artifacts, not from Jira directly.
167
+
168
+ ```json
169
+ {
170
+ "packet_version": "v1",
171
+ "task_id": "TASK-123",
172
+ "workstream": "feature|bugfix|refactor|test",
173
+ "owner_agent": "fullstack",
174
+ "session_key": "coding:TASK-123",
175
+ "objective": "Task objective",
176
+ "scope": {
177
+ "file_paths": ["src/a.ts", "src/b.ts"],
178
+ "module_boundaries": ["billing", "ui.checkout"],
179
+ "out_of_scope": ["infra/", "asm core"]
180
+ },
181
+ "conflict_policy": {
182
+ "mode": "sequential_default",
183
+ "parallel_allowed": false,
184
+ "required_locks": ["file:src/a.ts", "module:billing"]
185
+ },
186
+ "acceptance": ["AC1 ...", "AC2 ..."],
187
+ "validation": {
188
+ "commands": ["npm test -- ...", "npm run build -- ..."],
189
+ "must_include": ["test evidence", "changed files"]
190
+ },
191
+ "checkpoint_plan": {
192
+ "interval": "per milestone",
193
+ "required_events": ["start", "mid", "done_or_blocked"]
194
+ },
195
+ "retry_abort": {
196
+ "max_retries": 1,
197
+ "abort_on": ["conflict_unresolved", "scope_drift", "missing_context"]
198
+ }
199
+ }
200
+ ```
201
+
202
+ ---
203
+
204
+ ## Checkpoint/reporting protocol
205
+
206
+ Executors must report at these milestones:
207
+
208
+ 1. **START**: packet acknowledged + lock acquired
209
+ 2. **MID**: progress + diff summary + risk/conflict updates
210
+ 3. **END**: `done|failed|aborted` + evidence
211
+
212
+ Minimum report fields:
213
+
214
+ - `task_id`
215
+ - `state`
216
+ - `files_changed`
217
+ - `tests_run` + `results`
218
+ - `risks/blockers`
219
+ - `lock_release_request`
220
+
221
+ Outer governance may mark `done` only after END report includes all required fields and verification evidence is independently checked.
222
+
223
+ ---
224
+
225
+ ## Retry / Abort / Escalation rules
226
+
227
+ ### Retry
228
+
229
+ - Default max retry is 1 for transient failures (flake/tool timeout).
230
+ - Retry must keep the same scope lock; no silent scope expansion.
231
+
232
+ ### Abort
233
+
234
+ Abort immediately if:
235
+
236
+ - unresolved overlap conflict is detected,
237
+ - task drifts from objective,
238
+ - changes are required in `out_of_scope` (especially ASM core),
239
+ - required context is missing and cannot be inferred safely.
240
+
241
+ ### Escalation
242
+
243
+ Escalate to orchestrator (`scrum`/owner session) when:
244
+
245
+ - lock conflict exceeds SLA,
246
+ - acceptance criteria conflict,
247
+ - ownership transfer/handoff is required,
248
+ - someone requests bypass of sequential-by-default policy.
249
+
250
+ ---
251
+
252
+ ## Handoff rules across scrum/fullstack/assistant/creator
253
+
254
+ ### scrum -> fullstack
255
+
256
+ - Hand over packet/artifacts with explicit scope lock.
257
+ - Fullstack must not change AC unless outer governance approves.
258
+
259
+ ### fullstack -> assistant
260
+
261
+ - Use handoff for verification/test split or small follow-up fixes.
262
+ - Lock transfer must be explicit at file/module level.
263
+
264
+ ### fullstack -> creator
265
+
266
+ - Handoff only UI/content/assets within creator scope.
267
+ - Shared UI core overlap must be checked before lock release.
268
+
269
+ ### assistant/creator -> scrum
270
+
271
+ - Submit END report + evidence + suggested next task.
272
+ - Scrum/outer agent verifies and decides Jira/task closure or next scheduling.
273
+
274
+ ---
275
+
276
+ ## A2A language policy
277
+
278
+ - Agent-to-agent payloads (`sessions_spawn.task`, `sessions_send.message`, checkpoint/handoff payloads) **must be in Vietnamese**.
279
+ - Skill documentation can be English; runtime A2A payload policy remains Vietnamese.
280
+
281
+ ---
282
+
283
+ ## Minimal runtime bridge (v0-min)
284
+
285
+ To avoid ad-hoc `exec opencode ...`, use standard entrypoint:
286
+
287
+ - `node scripts/opencode-coding-runner.mjs --workstream coding_execution ...`
288
+
289
+ Bridge rules:
290
+
291
+ - Accept only `workstream=coding_execution`.
292
+ - Other workstreams are rejected with exit code `2`.
293
+ - Runner must always emit metadata JSON (stdout + `--out` file) with at least:
294
+ - `invocation.command/rendered`
295
+ - `opencode.agent/model`
296
+ - `process.exit_code`
297
+ - `result.status/error`
298
+ - `evidence.git_commit`
299
+
300
+ Suggested packet usage:
301
+
302
+ - `--packet <path-to-packet.json>` to auto-map `task_id`, `owner_agent`, `objective`.
303
+
304
+ ## OpenCode Bridge usage (current team standard)
305
+
306
+ Current team workflow after planning is:
307
+
308
+ 1. `using-superpowers`
309
+ 2. `brainstorming` (khi cần làm rõ design/spec)
310
+ 3. `writing-plans`
311
+ 4. `execute`
312
+ 5. `verification-before-completion`
313
+
314
+ Trong bước **execute**, nếu routing đi vào OpenCode lane thì phải ưu tiên dùng **`opencode-bridge`** / bridge contract hiện tại thay vì ad-hoc pattern cũ.
315
+
316
+ ### Current implementation status (important)
317
+ Bridge hiện đã chứng minh được các capability cốt lõi:
318
+ - routing envelope build
319
+ - callback payload build
320
+ - callback execution thật về `/hooks/agent`
321
+ - status artifact persistence
322
+ - mini listener runner / SSE probe ở mức PoC
323
+ - runtime assumption: **1 project = 1 OpenCode serve instance**
324
+
325
+ ### How to think about execution now
326
+ - **Do not** assume one shared `opencode serve` is safe for many projects.
327
+ - **Do** bind every coding task to:
328
+ - `project_id`
329
+ - `repo_root`
330
+ - `opencode_server_url`
331
+ - `task_id`
332
+ - `run_id`
333
+ - `agent_id`
334
+ - `session_key`
335
+ - **Do** treat `/hooks/agent` as callback primary.
336
+ - **Do not** use `cron` or `group:sessions` as the callback mechanism.
337
+
338
+ ### Practical guidance for agents
339
+ When handing off into OpenCode execution:
340
+ - mention the intended repo explicitly
341
+ - ensure the execution packet is file-driven
342
+ - ensure the repo binding uses `--dir <repo>` or an equivalent project-bound path
343
+ - prefer bridge-aware execution over free-form `opencode run` whenever the flow needs:
344
+ - callback
345
+ - task/run tracking
346
+ - serve/session registry
347
+ - multi-agent lane routing
348
+
349
+ ### Mandatory reporting after execution handoff
350
+ Outer agents should report:
351
+ - whether the task was handed to OpenCode direct path or bridge path
352
+ - the packet/artifacts used
353
+ - the target project/repo
354
+ - whether callback tracking is expected through `opencode-bridge`
355
+
356
+ ## Direct OpenCode invocation correctness (CRITICAL)
357
+
358
+ When using OpenCode directly via CLI, the invocation must load the intended project config correctly.
359
+
360
+ ### 1) Always pass the repo with `--dir`
361
+
362
+ Use:
363
+
364
+ - `opencode run --dir /absolute/path/to/repo ...`
365
+
366
+ Do **not** put the repo path inside the prompt/message body and assume OpenCode will infer project config from that text.
367
+ That mistake causes OpenCode to run outside the intended project context and can silently use the wrong resolved model/agent defaults.
368
+
369
+ ### 2) Verify resolved model by reading the run banner
370
+
371
+ When testing a direct run, inspect the first banner line:
372
+
373
+ - Example good: `> build · gpt-5.3-codex`
374
+ - If the banner shows a different model than expected, do not trust the agent alias/config until root cause is understood.
375
+
376
+ ### 3) Distinguish config intent vs runtime reality
377
+
378
+ Check in this order:
379
+
380
+ 1. `opencode debug config` — resolved config
381
+ 2. `opencode debug agent <name>` — resolved agent definition
382
+ 3. `opencode run --agent <name> --dir <repo> "..."` — actual runtime banner
383
+
384
+ The runtime banner is the final truth for what model actually executed.
385
+
386
+ ### 4) When model/agent resolution is unreliable, force the model explicitly
387
+
388
+ For high-confidence execution, prefer explicit `--model` over assumed alias mapping.
389
+ Recommended fallback pattern:
390
+
391
+ - coding pass: `opencode run --dir <repo> --model proxy/gpt-5.3-codex "..."`
392
+ - review pass: `opencode run --dir <repo> --model proxy/claude-opus-4-6-thinking "..."`
393
+
394
+ ### 5) Use `--agent` only for primary agents that actually resolve in runtime
395
+
396
+ Do not assume every named agent is runnable the same way in all contexts.
397
+ If `opencode run --agent <name>` falls back or ignores the intended model, treat that as a runtime/config problem and verify with `debug config`, `debug agent`, and explicit `--model`.
398
+
399
+ ### 6) Known verified fact from VAT repo (2026-03-18)
400
+
401
+ In `/Users/mrcagents/Work/projects/VAT`:
402
+
403
+ - calling `opencode run --agent build "/Users/.../VAT" "..."` (repo path in message) produced the wrong runtime model behavior
404
+ - calling `opencode run --agent build --dir /Users/mrcagents/Work/projects/VAT "..."` correctly resolved and executed `build · gpt-5.3-codex`
405
+
406
+ Operational rule:
407
+
408
+ - **No OpenCode direct-run guidance is considered correct unless it uses `--dir` for repo binding or another verified equivalent supported by runtime docs.**
409
+
410
+ ## Skill loading policy for OpenCode execution
411
+
412
+ ### 1) Do not rely on keyword superstition
413
+
414
+ OpenCode skill usage should not be reduced to brittle keyword-trigger rules.
415
+ The correct mental model is:
416
+
417
+ - global skill library exists
418
+ - `opencode-agent-skills` discovers skills from global + project locations
419
+ - OpenCode may auto-suggest/load relevant skills from context
420
+ - orchestrators still decide when a workflow is important enough to be stated explicitly
421
+
422
+ ### 2) Global plugin, local override
423
+
424
+ Recommended baseline:
425
+
426
+ - install `opencode-agent-skills` in the **global** OpenCode config
427
+ - keep shared reusable skills in the **global** skills directory
428
+ - allow project-local skills to live in the project overlay when repo-specific behavior is needed
429
+
430
+ Operationally:
431
+
432
+ - if a skill exists in both global and project-local scope with the same name, **project-local wins**
433
+ - therefore a global plugin still supports local project overrides correctly
434
+
435
+ ### 3) Auto skill loading is useful, but not a replacement for orchestration intent
436
+
437
+ Use this rule of thumb:
438
+
439
+ - **simple / common / routine coding work** -> let OpenCode auto-discover and load relevant skills
440
+ - **important workflows with strict execution shape** -> state the workflow explicitly in the prompt/handoff packet
441
+
442
+ Examples of workflows that should usually be explicit:
443
+
444
+ - `verification-before-completion`
445
+ - `writing-plans`
446
+ - `subagent-driven-development`
447
+ - `frontend-design`
448
+ - any repo-specific local skill that materially changes execution behavior
449
+
450
+ ### 4) Prompting policy
451
+
452
+ Do not force a literal `use_skill` string in every prompt.
453
+ Instead:
454
+
455
+ - write the task clearly
456
+ - mention the workflow/skill explicitly when it matters to execution quality
457
+ - let the plugin resolve local-vs-global skill precedence
458
+
459
+ Good:
460
+
461
+ - "Implement X, then follow verification-before-completion before claiming done"
462
+ - "Plan first using writing-plans, then execute"
463
+ - "Use the repo's local frontend-design guidance if applicable"
464
+
465
+ Bad:
466
+
467
+ - stuffing prompts with a mechanical list of skill names for every task
468
+ - depending purely on a single keyword to guarantee behavior
469
+
470
+ ### 5) Known verified fact (2026-03-18)
471
+
472
+ `opencode-agent-skills` is appropriate as a **global baseline plugin**.
473
+ When installed globally, it can still discover and use **project-local skills**, and project-local skills of the same name can override global ones.
474
+
475
+ ## OpenCode Bridge Operational Usage (current team standard)
476
+
477
+ This section explains how to use the current `opencode-bridge` plugin/runtime path in real work.
478
+
479
+ ### What is currently true
480
+
481
+ The current bridge stack already proves these capabilities:
482
+ - routing envelope construction
483
+ - callback payload construction for `/hooks/agent`
484
+ - callback execution into OpenClaw hook ingress
485
+ - run-status artifact persistence
486
+ - SSE probe path
487
+ - `listen_once` / `listen_loop` baseline for event-driven execution
488
+ - per-project serve registry baseline
489
+ - serve spawn / reuse / shutdown / idle-check baseline
490
+
491
+ ### What is **not** yet safe to assume
492
+
493
+ Do **not** assume all of the following are production-grade yet:
494
+ - fully autonomous long-running listener without further supervision
495
+ - fully hardened multi-agent production runtime manager
496
+ - complete serve fleet management with every edge case covered
497
+ - all future OpenCode events already normalized perfectly
498
+
499
+ Agents must describe these limits honestly and avoid over-claiming completion.
500
+
501
+ ### Execution lane assumptions (MANDATORY)
502
+
503
+ 1. **One project = one OpenCode serve instance**
504
+ - Do not assume one shared serve is safe for multiple repos.
505
+ - Always bind execution to a single project/repo root.
506
+
507
+ 2. **Callback primary = `/hooks/agent`**
508
+ - Do not use `cron`, `group:sessions`, or `/hooks/wake` as the primary callback path.
509
+ - `/hooks/wake` is only an auxiliary/system wake path, not the main execution callback route.
510
+
511
+ 3. **Session key convention**
512
+ - Use the convention:
513
+ - `hook:opencode:<agentId>:<taskId>`
514
+
515
+ 4. **Routing envelope fields are mandatory in bridge-aware execution**
516
+ - `task_id`
517
+ - `run_id`
518
+ - `agent_id`
519
+ - `session_key`
520
+ - `origin_session_key`
521
+ - `project_id`
522
+ - `repo_root`
523
+ - `opencode_server_url`
524
+
525
+ ### Bridge-aware checklist before handing work to OpenCode
526
+
527
+ Before handing a task into OpenCode lane, the outer agent must ensure:
528
+
529
+ - [ ] `writing-plans` (or equivalent approved execution artifact generation) is already done
530
+ - [ ] execution packet/artifacts exist and are the source of truth
531
+ - [ ] `project_id` is known
532
+ - [ ] `repo_root` is known
533
+ - [ ] `opencode_server_url` is known or can be resolved from the bridge registry
534
+ - [ ] `task_id` and `run_id` are assigned
535
+ - [ ] `agent_id` and `session_key` are explicit
536
+ - [ ] callback expectation is explicit (`/hooks/agent`)
537
+
538
+ If the agent cannot satisfy these items, it should not claim the bridge flow is ready.
539
+
540
+ ### Tool-by-tool usage (current bridge tools)
541
+
542
+ Use these tools deliberately:
543
+
544
+ #### `opencode_status`
545
+ Use to inspect the current bridge contract, assumptions, registry-related config, and lifecycle model.
546
+
547
+ #### `opencode_resolve_project`
548
+ Use when you need to resolve which OpenCode serve should be used for a given:
549
+ - `projectId`
550
+ - `repoRoot`
551
+
552
+ #### `opencode_build_envelope`
553
+ Use when you are about to delegate a concrete task into OpenCode lane and need the canonical routing envelope.
554
+
555
+ #### `opencode_build_callback`
556
+ Use when mapping a known OpenCode event into a callback payload for OpenClaw.
557
+
558
+ #### `opencode_execute_callback`
559
+ Use when executing the callback into `/hooks/agent` for a payload that has already been built.
560
+
561
+ #### `opencode_probe_sse`
562
+ Use when verifying that OpenCode serve is alive and emitting SSE events.
563
+
564
+ #### `opencode_listen_once`
565
+ Use for a small, single-shot proof that the bridge can:
566
+ - read an event
567
+ - normalize it
568
+ - callback
569
+ - write artifact
570
+
571
+ #### `opencode_listen_loop`
572
+ Use for baseline runtime-ops experiments where repeated event consumption and lifecycle handling are needed.
573
+ Treat it as baseline runtime manager logic, not a production-perfect daemon.
574
+
575
+ #### `opencode_run_status`
576
+ Use to inspect the artifact state of a previously handled run.
577
+
578
+ #### `opencode_callback_from_event`
579
+ Use when you already have a raw event and want to test the `normalize -> callback -> artifact` path directly.
580
+
581
+ #### `opencode_check_hook_policy`
582
+ Use to validate whether the current hook policy is compatible with the intended `agentId` and `sessionKey`.
583
+
584
+ #### `opencode_evaluate_lifecycle`
585
+ Use to evaluate lifecycle state from:
586
+ - last event kind
587
+ - last event timestamp
588
+ - soft/hard stall thresholds
589
+
590
+ #### `opencode_registry_get`
591
+ Use to read the current project -> serve registry.
592
+
593
+ #### `opencode_registry_upsert`
594
+ Use to create/update project -> serve registry entries.
595
+
596
+ #### `opencode_registry_cleanup`
597
+ Use to normalize and clean invalid/incomplete registry entries.
598
+
599
+ #### `opencode_serve_spawn`
600
+ Use to spawn an OpenCode serve for a project with dynamic port allocation and registry update.
601
+
602
+ #### `opencode_serve_idle_check`
603
+ Use to evaluate whether a serve should be shut down based on idle timeout.
604
+
605
+ #### `opencode_serve_shutdown`
606
+ Use to mark a serve as stopped and send shutdown for a project serve entry.
607
+
608
+ ### Recommended end-to-end bridge-aware flow
609
+
610
+ When a task must enter OpenCode execution lane, use this order:
611
+
612
+ 1. Prepare/verify execution packet via the outer workflow (`using-superpowers` → `brainstorming` if needed → `writing-plans`)
613
+ 2. Resolve project/server:
614
+ - `opencode_resolve_project`
615
+ - or spawn one via `opencode_serve_spawn`
616
+ 3. Build routing envelope:
617
+ - `opencode_build_envelope`
618
+ 4. Verify serve/event path as needed:
619
+ - `opencode_probe_sse`
620
+ - `opencode_listen_once`
621
+ 5. Build and/or execute callbacks:
622
+ - `opencode_build_callback`
623
+ - `opencode_execute_callback`
624
+ - or `opencode_callback_from_event`
625
+ 6. Check run artifact/status:
626
+ - `opencode_run_status`
627
+ 7. Only then proceed to outer verification:
628
+ - `verification-before-completion`
629
+
630
+ ### Reporting requirements
631
+
632
+ When handing work into OpenCode lane, the outer agent should report:
633
+ - whether it used direct OpenCode execution or bridge-aware execution
634
+ - which packet/artifact was used
635
+ - which `project_id` / `repo_root` / `opencode_server_url` was targeted
636
+ - whether callback tracking is expected through `opencode-bridge`
637
+
638
+ ### Do / Don't
639
+
640
+ #### Do
641
+ - Do keep OpenCode execution project-bound.
642
+ - Do keep callback/session routing explicit.
643
+ - Do use `opencode-orchestration` when coordination or bridge semantics matter.
644
+ - Do use `verification-before-completion` before claiming completion.
645
+
646
+ #### Don’t
647
+ - Don’t use ad-hoc `opencode run` when the work needs callback, lifecycle tracking, or registry-aware execution.
648
+ - Don’t assume a single serve is multi-project-safe.
649
+ - Don’t assume bridge/runtime-manager features are production-perfect without verification.
650
+ - Don’t over-claim that the bridge is fully autonomous when only PoC/baseline behavior has been verified.
651
+
652
+ ## Guardrails
653
+
654
+ - Do not modify ASM core while using this orchestration skill.
655
+ - Do not deploy production from this skill flow.
656
+ - Keep diffs minimal and within packet scope.
657
+ - Do not turn this skill into Jira governance, planning governance, or general project orchestration.
658
+ - Always verify before claiming completion.