Skip to content

Commit b226fce

Browse files
committed
chore(toolkit): re-scaffold with uf 0.23.0
Ran by gh-hud toolkit scaffold: unbound-force init Toolkit-Scaffold: uf 0.23.0
1 parent f09ec54 commit b226fce

8 files changed

Lines changed: 493 additions & 56 deletions

File tree

‎.opencode/commands/uf.agent-brief.md‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,18 @@ Insert this verbatim:
205205
```markdown
206206
## Specification Workflow
207207

208-
All non-trivial changes MUST be preceded by a spec workflow.
208+
Every change follows a workflow tier chosen for that change's
209+
scope and risk — no single tier is mandatory. `/uf.unleash`
210+
picks the tier automatically through the `tier-routing` skill
211+
when a change starts on `main` or an unrecognized branch (a
212+
tier-named branch missing its artifacts stops instead); agents
213+
working by hand apply the same rubric.
209214

210215
| Tier | Tool | When | Artifacts |
211216
|------|------|------|-----------|
212217
| Strategic | Speckit | >= 3 stories, cross-repo | `specs/NNN-*/` |
213218
| Tactical | OpenSpec | < 3 stories, single-repo | `openspec/changes/*/` |
219+
| Quick | `/uf.unleash` routing | trivial fixes, chores, docs | `quick/<name>` branch |
214220

215221
Pipeline: `constitution → specify → clarify → plan → tasks →
216222
analyze → checklist → implement`
@@ -220,19 +226,21 @@ before tasks. Tasks before implementation. Spec artifacts MUST
220226
be committed/pushed before implementation begins.
221227

222228
**Branches**: Speckit: `NNN-<name>`. OpenSpec: `opsx/<name>`.
229+
Quick: `quick/<name>` (no spec artifacts, full quality gates).
223230

224231
**Task bookkeeping**: Mark checkboxes `[x]` immediately on
225232
completion. `[P]` marks parallel-eligible tasks.
226233

227-
**When in doubt**: Start with OpenSpec. Escalate to Speckit if
228-
scope grows beyond 3 stories or crosses repo boundaries.
234+
**When in doubt**: Choose the heavier of two adjacent tiers.
235+
Escalate OpenSpec to Speckit if scope grows beyond 3 stories or
236+
crosses repo boundaries.
229237

230-
**What requires a spec**: New features, refactoring that changes
231-
signatures, test additions across multiple functions, agent
232-
changes, CI changes, data model changes.
238+
**Risk floors** (escalate only): security-sensitive code,
239+
authentication/authorization flows, data-loss paths, or a
240+
public API break MUST use OpenSpec at minimum — never Quick.
233241

234-
**Exempt**: Constitution amendments, typo fixes, emergency
235-
hotfixes (retroactively documented).
242+
**Quality gates apply to every tier**: Quick skips spec
243+
artifacts, not review — CI and code review still gate merge.
236244
```
237245

238246
#### Section 8: Knowledge Retrieval (verbatim template, conditional)

‎.opencode/commands/uf.review-council.md‎

Lines changed: 70 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -615,13 +615,66 @@ Review the current codebase for compliance with the Behavioral Constraints in `A
615615

616616
1. **Run local quality gates before delegating to
617617
council agents.** This step has three phases that
618-
MUST execute in order. All three phases apply only
619-
to Code Review Mode -- Spec Review Mode skips them.
618+
MUST execute in order, preceded for PR input by the
619+
Phase 1 head root block. All of it applies only to
620+
Code Review Mode -- Spec Review Mode skips it.
621+
622+
#### Phase 1 head root (PR input only)
623+
624+
When the resolved input context is `kind: pr`, the local
625+
gates in Phases 1a and 1b MUST judge the PR's frozen head,
626+
never the agent's own checkout (issue #1204). Before Phase
627+
1a, call the `review_head_root` plugin tool once:
628+
`{action: "prepare", pr_number: <pr_number>, base_sha: <base_sha>, head_sha: <head_sha>}`.
629+
It reuses the current checkout when it is a clean
630+
checkout of `head_sha`, and otherwise adds a detached
631+
worktree at `head_sha` under `.uf/review-head/`. It never
632+
switches, stashes, or modifies the user's branch, index,
633+
or working tree. A success looks like:
634+
635+
```json
636+
{"status":"ok","data":{"root":"/repo/.uf/review-head/k3v9x2qa","head_sha":"<40-hex>","base_sha":"<40-hex>","method":"worktree","created":true,"config_sha":"<40-hex>","config_dirty":false,"provenance_line":"Gates ran at: <40-hex> (worktree); config from <40-hex>","gaze_skip_note":"Gaze skipped: the PR head is in a temporary worktree and gaze-reporter has no root argument","changed_files":["internal/a.go"]}}
637+
```
638+
639+
On `status: "error"`, do NOT run local gates anywhere.
640+
Phase 1a stays mandatory, so every code takes the Phase
641+
1a FAIL path (step c below) even though no pre-flight
642+
verdict exists: report the code and message as a
643+
CRITICAL finding, skip Phases 1a, 1b, and 1c, dispatch
644+
no reviewer children, and run only the non-child
645+
planning and finalization portions of the shared
646+
protocol to record coverage `FAIL`, terminal skipped
647+
runs, and failing `INCONCLUSIVE`. Then stop. The codes:
648+
- `UNTRUSTED_HEAD`: a fork PR whose author lacks write
649+
access. Its code is not fetched or run. The message
650+
names the opt-in: check out the head yourself
651+
(`gh pr checkout <N>`) and re-run, which takes the
652+
reuse path.
653+
- `HEAD_MOVED`: the PR's head is no longer the frozen
654+
`head_sha` (it was pushed since); re-run the council.
655+
- `HEAD_UNAVAILABLE`: no remote names the base
656+
repository, or a fetch or `gh` lookup failed.
657+
- `WORKTREE_FAILED`: `git worktree add` failed; the
658+
message carries git's error.
659+
- `REVIEW_HEAD_ROOT_ERROR`: an unexpected tool error; the
660+
message carries the detail.
661+
662+
On success, pass the whole prepare result to Phase 1a. After Phase 1b (or on any
663+
STOP after a successful prepare), call `review_head_root`
664+
once with `{action: "release", root: <root>}`. No later
665+
step reads the root. A release failure is a warning in
666+
the final report and never changes the verdict.
667+
668+
Local and uncommitted input skips this block: Phases 1a
669+
and 1b run in the current checkout, as before.
620670

621671
#### Phase 1a -- Pre-flight Checks (mandatory, soft gate)
622672

623673
Load the `pre-flight` skill and run in `soft-gate`
624-
mode:
674+
mode, passing the whole prepare result (`root`,
675+
`changed_files`, `base_sha`, and the provenance fields
676+
`head_sha`, `method`, `config_sha`, `config_dirty`) when
677+
the Phase 1 head root block prepared it:
625678

626679
a. Invoke the `skill` tool with name `pre-flight` to
627680
load the shared pre-flight check instructions.
@@ -638,15 +691,17 @@ Review the current codebase for compliance with the Behavioral Constraints in `A
638691
tools in soft-gate mode (do NOT stop on first
639692
failure; record all results)
640693
5. Baseline Establishment (Phase 4a) — if any
641-
tools failed, establish a baseline for `main`
642-
using the two-tier strategy (CI API first,
694+
tools failed, establish a baseline for the base
695+
(the PR's `base_sha` in PR mode, else the default
696+
branch) using the two-tier strategy (CI API first,
643697
worktree fallback)
644698
6. Causality Classification (Phase 4b) — classify
645699
each failure as branch-caused, pre-existing,
646700
or unknown
647701

648702
c. **If the pre-flight verdict is FAIL
649-
(branch-caused)**: **STOP immediately.** Report
703+
(branch-caused), or the Phase 1 head root prepare
704+
returned `status: "error"`**: **STOP immediately.** Report
650705
each branch-caused failure as a CRITICAL finding
651706
with the full error output. Do NOT proceed to
652707
Phase 1b, Phase 1c, or child delegation.
@@ -667,6 +722,15 @@ Review the current codebase for compliance with the Behavioral Constraints in `A
667722

668723
#### Phase 1b -- Gaze Quality Analysis (conditional)
669724

725+
For PR input whose prepare result carries a
726+
`gaze_skip_note` (method `worktree`), skip this phase
727+
with that rendered note verbatim — "Gaze skipped: the
728+
PR head is in a temporary worktree and gaze-reporter
729+
has no root argument" — and proceed. Running Gaze from
730+
the agent's checkout would score the wrong code. With
731+
`method: "checkout"` (or local input), `gaze_skip_note`
732+
is null; continue below.
733+
670734
a. Check if `gaze` is available:
671735
```bash
672736
which gaze

‎.opencode/commands/uf.review-pr.md‎

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,47 @@ This is the reviewed diff. Pass it to every child agent prompt.
252252

253253
### 3.7. Pre-flight Checks (ci-aware, soft gate)
254254

255-
Load the `pre-flight` skill and run in `ci-aware` mode:
256-
257-
1. Invoke the `skill` tool with name `pre-flight` to
258-
load the shared pre-flight check instructions.
255+
Local gates run against the PR's frozen head commit, never
256+
the agent's own checkout (issue #1203).
257+
258+
1. **Prepare the head root.** Call the `review_head_root`
259+
plugin tool once:
260+
`{action: "prepare", pr_number: <PR_NUMBER>, base_sha: <base_sha>, head_sha: <head_sha>}`.
261+
It reuses the current checkout when it is a clean
262+
checkout of `head_sha`, and otherwise adds a detached
263+
worktree at `head_sha` under `.uf/review-head/`. It never
264+
switches, stashes, or modifies the user's branch, index,
265+
or working tree. A success looks like:
266+
267+
```json
268+
{"status":"ok","data":{"root":"/repo/.uf/review-head/k3v9x2qa","head_sha":"<40-hex>","base_sha":"<40-hex>","method":"worktree","created":true,"config_sha":"<40-hex>","config_dirty":false,"provenance_line":"Gates ran at: <40-hex> (worktree); config from <40-hex>","gaze_skip_note":"Gaze skipped: the PR head is in a temporary worktree and gaze-reporter has no root argument","changed_files":["internal/a.go"]}}
269+
```
259270

260-
2. Execute the pre-flight skill's phases in order:
271+
On `status: "error"`, do NOT run local tools anywhere.
272+
Record the failure envelope's rendered `not_run_line`
273+
verbatim as the Step 3.7 result (e.g. `Local gates: not
274+
run (<code>): <message>`), skip items 2-3, and continue
275+
with CI evidence only:
276+
- `UNTRUSTED_HEAD`: a fork PR whose author lacks write
277+
access. Its code is not fetched or run. The message
278+
names the opt-in (check out the head yourself and
279+
re-run).
280+
- `HEAD_MOVED`: the PR's head is no longer the
281+
`head_sha` Step 2 froze (it was pushed since); re-running
282+
the review picks up the new head.
283+
- `HEAD_UNAVAILABLE`: no remote names the base
284+
repository, or a fetch or `gh` lookup failed.
285+
- `WORKTREE_FAILED`: `git worktree add` failed; the
286+
message carries git's error.
287+
- `REVIEW_HEAD_ROOT_ERROR`: an unexpected tool error; the
288+
message carries the detail.
289+
290+
2. **Run pre-flight.** Invoke the `skill` tool with name
291+
`pre-flight`, in `ci-aware` mode, passing the whole
292+
prepare result (`root`, `changed_files`, `base_sha`, and
293+
the provenance fields `head_sha`, `method`, `config_sha`,
294+
`config_dirty`). Execute
295+
its phases in order:
261296
a. CI Workflow Parsing — discover commands from `.github/workflows/`
262297
b. Local Tool Detection — check for config files and verify binary availability
263298
c. CI Coverage Matrix — build the matrix using the CI check results from Step 3. Apply ci-aware decision rules:
@@ -267,9 +302,21 @@ Load the `pre-flight` skill and run in `ci-aware` mode:
267302
- No CI checks at all → MUST run ALL detected local tools
268303
d. Execution — run only tools marked "Yes" in the coverage matrix. Do NOT stop on first failure.
269304

270-
3. **Record results**: CI Coverage Matrix, Execution Results, Verdict.
271-
If tools pass, skip those categories in the AI review.
272-
If tools fail, include the failure output as context.
305+
3. **Release the head root.** Call `review_head_root` once
306+
with `{action: "release", root: <root>}` as soon as item 2
307+
finishes, and before any STOP after a successful
308+
prepare. No later step reads the root: the light check
309+
and the reviewers read the PR diff through `gh`. A
310+
release failure is a warning in the report and never
311+
changes the verdict.
312+
313+
**Record results**: the prepare result's rendered
314+
`provenance_line` (or the failure envelope's rendered
315+
`not_run_line`, which ends in `: <message>`), verbatim, CI
316+
Coverage Matrix,
317+
Execution Results, and Verdict. If tools pass, skip those
318+
categories in the AI review. If tools fail, include the
319+
failure output as context.
273320

274321
### 3.8. Discover Review Context
275322

@@ -710,7 +757,7 @@ Present the findings in this structured format:
710757
| <name> | PASS/FAIL | PR-caused / Pre-existing / N/A |
711758

712759
### Local Tool Results
713-
<Table showing which tools ran, pass/fail status, and summary of failures if any>
760+
<provenance_line from the prepare result, or its not_run_line from the failure envelope, verbatim; then a table showing which tools ran, pass/fail status, and summary of failures if any>
714761

715762
### Walkthrough
716763
| File | Change | Focus |

‎.opencode/lib/agent-executor.ts‎

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,14 @@ export interface InvokeAgentResult {
287287
* length policy to non-empty (truncated) runs (RD-FR-060).
288288
*/
289289
readonly finish_reason?: string | null
290+
/**
291+
* Name of the child's message error (for example
292+
* `MessageAbortedError`), present only on `child_message_error`
293+
* failures (delegate-abort-recovery D2, DAR-FR-002). The executor's
294+
* own `retryable` value is unchanged; callers that can read durable
295+
* state decide whether the abort is resumable.
296+
*/
297+
readonly message_error_name?: string
290298
}
291299

292300
/** Injected dependencies for the shared executor's child session lifecycle. */
@@ -372,7 +380,19 @@ export function errorText(error: unknown): string {
372380
* @returns A bounded message safe to retain in invocation provenance.
373381
*/
374382
export function sanitizeInvocationError(message: string): string {
375-
const sanitized = message
383+
return redactInvocationText(message).slice(0, MAX_ERROR_LENGTH)
384+
}
385+
386+
/**
387+
* Redacts credentials, bearer values, URL queries, and absolute home
388+
* paths without bounding the length (delegate-abort-recovery D4): the
389+
* shared redaction behind sanitizeInvocationError, for callers that apply
390+
* their own bound.
391+
* @param message Untrusted provider, runtime, or child-session text.
392+
* @returns The redacted text, unbounded.
393+
*/
394+
export function redactInvocationText(message: string): string {
395+
return message
376396
.replace(/\bBearer\s+[^\s,;"']+/gi, "Bearer [REDACTED]")
377397
.replace(
378398
/\b(api[-_ ]?key|access[-_ ]?token|refresh[-_ ]?token|token|secret|password|credential)s?\b(\s*[:=]\s*)(?:"[^"]*"|'[^']*'|[^\s,;"']+)/gi,
@@ -381,7 +401,6 @@ export function sanitizeInvocationError(message: string): string {
381401
.replace(/(https?:\/\/[^\s?#]+)\?[^\s#]*/gi, "$1?[REDACTED]")
382402
.replace(/(?:\/Users|\/home)\/[^/\s]+(?:\/[^\s,;:"']*)?/g, "~/[REDACTED]")
383403
.replace(/[A-Za-z]:\\+Users\\+[^\\\s]+(?:\\+[^\s,;:"']*)?/g, "~\\[REDACTED]")
384-
return sanitized.slice(0, MAX_ERROR_LENGTH)
385404
}
386405

387406
export function responseFailure(label: string, response: ResponseErrorLike): string {
@@ -913,8 +932,8 @@ export async function executeAgentSession(
913932
const finishReason = responseFinishReason(prompted.data.parts)
914933

915934
if (prompted.data.info.error !== undefined) {
916-
return withChild(
917-
failedResult(
935+
return withChild({
936+
...failedResult(
918937
provenance,
919938
"child_message_error",
920939
errorText(prompted.data.info.error),
@@ -925,7 +944,8 @@ export async function executeAgentSession(
925944
text,
926945
usage,
927946
),
928-
)
947+
message_error_name: prompted.data.info.error.name,
948+
})
929949
}
930950
// Fail-closed guard (RD-FR-059, design D1): a child whose final text is
931951
// empty after trimming did not complete its response — including the

0 commit comments

Comments
 (0)