Repository navigation
Description
uf.unleash: move deterministic instruction from command markdown into plugin tools
Summary
An audit of internal/scaffold/assets/opencode/commands/uf.unleash.md
(791 lines, mirrored byte-identically at .opencode/commands/uf.unleash.md)
identified deterministic instruction that belongs in plugin tools under
internal/scaffold/assets/opencode/plugins/, following the established
patterns of uf-workflow, uf-finale, review-dispatch, and
invoke-agent.
Motivation: deterministic logic in command markdown is (a) re-interpreted
by the LLM on every run instead of executed, (b) reconstructed from
memory after context compression (the existing OUTPUT FIDELITY /
SESSION-RESUME guards exist to fight this), and (c) untestable. Plugin
tools make the behavior structural and covered by make plugin-test.
Findings by command section
| Section | Verdict | Proposal |
|---|---|---|
| 1. Branch Safety Gate | 100% movable | New uf_unleash_branch_gate tool |
| 2. Resumability Detection | Not OBE; movable | New uf_unleash_detect_resume tool |
| 3. Step 1 -- Clarify | ~60% movable | scan_clarifications + resolve_clarification; query formulation/evaluation stays with LLM |
| 4. Step 2 -- Plan | 100% movable | New uf_delegate_command tool |
| 5. Step 3 -- Tasks | 100% movable | Same uf_delegate_command tool (parameterized) |
| 6. Step 4 -- Spec Review | Replaceable with existing tools | Direct dispatch calls; no new tool required |
| 7. Step 5 -- Implement | Partial | Granular tools; orchestration loop stays in command |
| 8. Step 6 -- Code Review | Replaceable with existing tools | Same direct dispatch sequence, mode: code |
1. Branch Safety Gate
Every element is deterministic: git rev-parse, branch pattern match
(main / opsx/* / NNN-*), FEATURE_DIR derivation, tasks.md existence
check, .specify/scripts/bash/check-prerequisites.sh --json --require-spec execution + JSON parsing. uf_finale_startup
(uf-finale/index.ts:63-78) already implements the identical branch
classification — extract to a shared lib helper. New
uf_unleash_branch_gate returns { ok, branch, workflow_tier, feature_dir, change_name } or a failure envelope carrying the exact STOP
messages. ~55 lines collapse to ~3.
Caveat: do not fold Step 0 (worktree cleanup) into this tool —
forge_worktree_* are Replicator MCP tools, callable by the LLM but not
from plugin code.
2. Resumability Detection — NOT OBE
checkpoint state and filesystem probing are complementary:
- Checkpoint only records steps
/uf.unleashitself completed. A first
run on a branch where/speckit.clarify,/speckit.plan,
/speckit.tasks, or/opsx-proposealready created artifacts has no
checkpoint state, yet must skip Steps 1-3. - Progress state is cleared on completion and can be lost.
The section's logic is fully deterministic though: uf_unleash_detect_resume
parses spec.md markers, checks plan.md/tasks.md existence, counts
unchecked task boxes, merges get_progress for spec-review/code-review,
and returns { step_statuses, resume_from, all_complete }. ~55 lines →
1 call; also deduplicates the redundant get_progress calls.
3. Clarify
Movable mechanics: marker scanning/extraction and resolution application
(remove marker, insert answer, append the Q: -> A: entry to
## Clarifications). Judgment that stays: Dewey query formulation
(explicitly not verbatim marker text) and answer-sufficiency evaluation.
4/5. Plan and Tasks
Structurally identical: read command file → delegate to
cobalt-crush-dev with feature dir → verify artifact created → STOP on
failure. One uf_delegate_command(agent, command_path, feature_dir, expected_artifact) tool serves both; ~45 lines → 2 calls.
invoke_agent cannot be reused for this: AgentSchema enforces
^divisor-[a-z0-9-]+$ and validateReviewAgent requires
.uf/reviewer-capabilities.yaml membership with capability: review
(invoke-agent/index.ts:45, 111-121). This gate is deliberate
review-council policy. The new tool reuses executeAgentSession from
lib/agent-executor.ts (host model resolution, parenting, abort,
timeout) without the review-manifest gate. Alternative: keep Task-tool
delegation in command text and drop this proposal branch.
6/8. Spec Review and Code Review — direct tool calls, no new tools
The dispatch machinery fully supports both modes. uf.unleash can call
directly:
resolve_base_ref(existing)- Bash: resolve head SHA, compute + save diff (
git diff <base_sha>+
untracked viagit ls-files --others;uncommitted: truepath per
review-council's Resolve Immutable Input Context section) - Enumerate reviewers from
.uf/reviewer-capabilities.yaml plan_review_dispatch(mode: specs|code, ...)dispatch_review_runs(mode, command: review-council, input_context, diff_path, changed_files, plan_entries, session_metadata)consolidate_dispatch
This eliminates the driver layer: today cobalt-crush-dev is spawned
only to read the 1,145-line uf.review-council.md and drive these tools.
The actual reviewers are the divisor-* agents spawned by
dispatch_review_runs — unchanged. uf.review-council.md remains as-is
for standalone invocations.
Delegation still worth keeping inside the review loops: code-fix
application (Step 6 iterations) → cobalt-crush-dev; spec fixes (Step
4) stay in the parent (lightweight, human-gated).
Optional follow-on optimization: uf_prepare_review(mode) tool to
absorb the bash diff-capture surface (~70 lines of input-resolution
instructions). Not a prerequisite.
7. Implement — partial decomposition
Movable: parse_tasks(feature_dir) (phases, sequential vs [P] split),
mark_task_complete(feature_dir, task_id) (checkbox edits),
scan_conflict_markers(files) (note: git_conflict_files is
insufficient — it reads git diff --diff-filter=U, not cherry-pick
residue), per-task delegation via uf_delegate_command.
Stays in command: phase iteration, batch-of-4, failure-stop, comms
reservation (interleaves Replicator MCP calls, not callable from
plugins), pre-flight hard-gate (already skill-encapsulated). A
whole-phase mega-tool risks tool timeouts (dispatch tools bound at 30
min; phases run longer).
Defects discovered during the audit
- Unleash-summary artifact is never written.
uf_finale_pr_contextreads.uf/artifacts/unleash-summary/<slug>.json
(uf-finale/index.ts:427-443) but nothing inuf.unleash.mdwrites it
—/uf.finale's unleash-summary context is always null. Add a
write_unleash_summarytool at the retrospective/demo step. - Spec auto-fix gate contradiction.
uf.unleashStep 4 says
"If only LOW and MEDIUM findings exist: auto-fix them," but
uf.review-council.mdspec mode has a CRITICAL RULE to never apply
spec auto-fixes without explicit human confirmation via the question
tool. Under unleash's "NEVER pause between steps" guardrail, the
delegated child agent receives contradictory directives. Moving to
direct calls forcesuf.unleashto own this policy explicitly (e.g.,
an autonomy flag or a legitimate exit reason).
Additional opportunities
- Checkpoint ceremony: 10+ "CHECKPOINT: call checkpoint…"
blockquotes (~50 lines). If each step tool auto-records its checkpoint
on success, they all disappear. - Exit/demo template formatters: the 5 repeated
"## /uf.unleash paused at:" blocks, the Step 10 OUTPUT FIDELITY
GUARD, and the "re-read before composing" instructions exist to fight
LLM reconstruction-from-memory.format_unleash_exit(...)/
format_unleash_demo(tier, ...)tools make verbatim output structural
instead of instructed. - DRY: branch classification shared between
uf_finale_startupand
the new branch-gate tool vialib/. - Robustness:
speckit.plan.md/speckit.tasks.mdare
Speckit-scaffolded, not uf assets —uf_delegate_commandshould take
the path as a parameter rather than assume it.
Execution constraints
- Any command/plugin change must be made byte-identical in both
.opencode/andinternal/scaffold/assets/opencode/(drift tests in
internal/scaffold/scaffold_test.go:144). make plugin-test(TypeScript) +make test(Go drift) must pass.- Requires a spec workflow first; at this scope (5+ new tools across 2
plugins + command rewrite) this is Speckit tier rather than OpenSpec. - Phase boundaries: spec artifacts before implementation.
Suggested increment ordering
- Increment 1 (no new tools): rewrite Steps 4/6 as direct dispatch
calls;uf.unleashowns the fix-gate/iteration policy (resolves
defect 2). - Increment 2:
uf_unleash_branch_gate+uf_delegate_command
(Steps 1, 2, 3). - Increment 3:
uf_unleash_detect_resume+ checkpoint
auto-recording (removes ceremony blockquotes). - Increment 4: formatters,
write_unleash_summary(resolves
defect 1), clarify scan/resolve. - Increment 5: implement-step granular tools + optional
uf_prepare_review.
Acceptance criteria
- Deterministic branch/scope/resume decisions execute in tools, not
LLM interpretation - Review steps call dispatch tools directly (no cobalt-crush-dev
driver layer) - Spec auto-fix policy contradiction resolved explicitly
- Unleash-summary artifact written and consumed by
/uf.finale - All mirrors byte-identical;
make plugin-testandmake test
pass - Command shrinks materially (target: majority of section text
replaced by tool calls)
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
feat(commands): dispatch review councils directly in uf.unleash
feat(commands): dispatch review councils directly in uf.unleash
jflowers commentedon Oct 17, 2026
#716 closure reconciliation for the 'command shrinks materially' acceptance criterion: the literal size target is not met — the command grows 1006 → 1087 lines (+81) and 4852 → 4857 words (task 7.4 record). The substance target is met: ceremony blockquotes fall 15 → 2 (the two review-loop iteration checkpoints remain by design), and the migrated sections now execute as 11 tested tool calls — the Principle VI outcome (majority of procedural text replaced by tool calls) holds. The growth is the spec-mandated rendered examples at consuming decision points and payload-shape documentation. Recording the criterion explicitly reconciled as substance-met / literal-size-not-met ahead of this issue closing via PR #745.
jflowers commentedon Oct 18, 2026
closed by #745