Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .opencode/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
bun.lock
package-lock.json
.vitest/
coverage/
57 changes: 57 additions & 0 deletions .opencode/agents/model-matrix-classifier.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
name: model-matrix-classifier
description: "Internal to the model-matrix selection layer. Investigates the task context and responds with a JSON pack classification."
mode: subagent
hidden: true
permission:
edit: deny
bash: deny
webfetch: deny
---
<!-- scaffolded by uf vdev -->

# Role: Model-Matrix Classifier

You are the internal classifier of the model-matrix selection layer.
You are spawned exclusively by the delegation tool's classifier
cascade — never invoked directly by a human. Your single job:
investigate a delegated task's context and classify the task into
exactly one UF convention pack.

You operate under a least-privilege, read-only contract (mirroring
the divisor reviewer agents): you never edit files, never run
commands, never fetch the web. You read context and respond —
nothing else.

## Protocol: investigate, then decide

1. Read the feature directory's `spec.md`, `plan.md`, and
`tasks.md` when the prompt names a feature directory — those
artifacts define the nature of the work.
2. Read the relevant code, command, or config files the task
touches when the prompt names them. The delegated task's own
text usually carries enough signal; investigate further only
when it does not.
3. Decide the single pack whose capability the task's primary work
matches, from the candidate pack names the prompt lists. Do not
invent pack names outside that list.

## Response contract (strict)

Respond with ONLY a JSON object — the complete text of your reply,
nothing before or after it:

{"pack": "<name>", "confidence": <0.0-1.0>, "reasoning": "<optional>"}

- `pack` — exactly one candidate pack name from the prompt's list.
- `confidence` — honest confidence from 0.0 to 1.0. The caller
discards results below its threshold and falls back to a static
default, so a wrong confident answer is worse than an honest
low one.
- `reasoning` — optional, one short sentence.

The following are contract violations:

- No markdown fences around the JSON.
- No prose before or after the JSON.
- Never ask questions — investigate with what you have and decide.
693 changes: 451 additions & 242 deletions .opencode/commands/uf.address-feedback.md

Large diffs are not rendered by default.

63 changes: 35 additions & 28 deletions .opencode/commands/uf.finale.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,13 @@ changes. Use `$ARGUMENTS` as hint if non-empty. Append:

>>> MANDATORY GATE <<<

- **Stage Dewey knowledge artifacts**: Dewey learnings and
compiled articles produced during this change are knowledge
artifacts that belong in the feature PR. They capture
patterns, decisions, and gotchas discovered during the
workflow and are essential for team knowledge continuity.

```bash
git add .uf/dewey/learnings/ .uf/dewey/compiled/ 2>/dev/null
```

Do NOT skip this step. Even though `git add .` may have
already staged these files, this explicit step ensures
Dewey artifacts are never accidentally excluded from the
commit.
- **Keep Dewey learnings off the branch**: `uf_finale_stage`
stages everything except `.uf/dewey/learnings/`. Learnings
stay untracked and reach `main` through a separate
`chore/dewey-learnings-*` PR (see the Commit scope rule in
`AGENTS.md`). Compiled articles under `.uf/dewey/compiled/`
still belong in the feature PR, and `uf_finale_stage` stages
them.

**Session-resume guard**: Re-present and re-confirm if
resumed.
Expand Down Expand Up @@ -175,10 +168,10 @@ aheadBy, behindBy}`.
**Push state failure** (`retryable: true`, code `PUSH_SYNC_COUNT`):
**soft gate** — warn that the branch's upstream state and
divergence are unknown, then present the gate with a safe push
mode: `git_push_force_with_lease` after a step-4 rebase (the
lease protects any existing remote branch), else `git_push` with
`{setUpstream: true, branch}` (safe whether or not an upstream
exists). Never block on a push-state check.
mode: `git_push_force_with_lease` with `{branch}` after a step-4
rebase (the lease protects any existing remote branch), else
`git_push` with `{setUpstream: true, branch}` (safe whether or
not an upstream exists). Never block on a push-state check.

>>> MANDATORY GATE <<<

Expand All @@ -188,13 +181,26 @@ resumed. Warn if `diverged` is true.
**Push mode selection** — read the step-4 `sync-base`
checkpoint `{behindBy, rebased}` and `upstreamExists`:
- A step-4 rebase occurred AND `upstreamExists`: "Push to
remote" MUST call `git_push_force_with_lease`. The gate
remote" MUST call `git_push_force_with_lease` with
`{branch}`. The gate
copy MUST state why: the rebase rewrote history, so the
remote branch must be replaced under lease protection.
- A step-4 rebase occurred AND `!upstreamExists` (first
push): call `git_push` with `{setUpstream: true, branch}`.
- No rebase occurred: call `git_push` exactly as before
(with `{setUpstream: true, branch}` if `!upstreamExists`).
- No rebase occurred: call `git_push` with `{branch}` (add
`setUpstream: true` if `!upstreamExists`).

Every push call in this command passes `branch` (the feature
branch). Both push tools refuse with `BRANCH_MISMATCH` when the
checkout is on another branch — **STOP** and report; never
switch branches to retry. On success they return `{remote, ref,
old_sha, new_sha, updated}`: report the ref and SHAs, and treat
`updated: false` as "already up to date", not as a new push.
Without `expected_sha`, `git_push_force_with_lease` leases on
the remote-tracking ref with `--force-if-includes`, so a
collaborator's commit that a fetch pulled in but the rebase did
not include is never overwritten: on a lease rejection,
**STOP** and report — never retry with `--force`.

Use **question tool**: `["Push to remote",
"Abort -- keep commits local"]`.
Expand Down Expand Up @@ -317,14 +323,15 @@ Checkpoint `step: "conflict-option"`,
>>> END GATE <<<

**Option 1 — Merge**: `git_fetch` → `git_merge`. If no
conflict: `git_push`, then `uf_finale_ci_poll`. If
conflicted: `git_merge_abort`, report files, **STOP**.
conflict: `git_push` with `{branch}`, then
`uf_finale_ci_poll`. If conflicted: `git_merge_abort`, report
files, **STOP**.

**Option 2 — Rebase**: Warn force push may be blocked.
`git_fetch` → `git_rebase`. If no conflict:
`git_push_force_with_lease` (if fails, suggest Option 1,
**STOP**); on success, `uf_finale_ci_poll`. If
conflicted: `git_rebase_abort`, report files, **STOP**.
`git_push_force_with_lease` with `{branch}` (if fails,
suggest Option 1, **STOP**); on success, `uf_finale_ci_poll`.
If conflicted: `git_rebase_abort`, report files, **STOP**.

**Option 3 — Stop**: Report conflict, **STOP**.

Expand All @@ -342,8 +349,8 @@ After return, `git_conflict_files` again. If unresolved:
show staged diff. Use **question tool**:
`["Approve, commit, and push", "Request edits",
"Abort (discard resolution)"]`.
- **Approve**: `git_commit_no_edit` → `git_push` →
`uf_finale_ci_poll`.
- **Approve**: `git_commit_no_edit` → `git_push` with
`{branch}` → `uf_finale_ci_poll`.
- **Edits**: User edits, re-show diff, re-present menu.
- **Abort**: `git_merge_abort`, return to 5-option menu.

Expand Down
23 changes: 20 additions & 3 deletions .opencode/commands/uf.fix-ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ Record (each value from the tool's output fields):

- `STATE` — `state` (`OPEN`, `CLOSED`, `MERGED`)
- `HEAD_REF` — `head_ref`
- `HEAD_SHA` — `head_sha` (the remote head before any fetch; the
Phase 4 force-push lease)
- `BASE_BRANCH` — `base_ref`
- `MERGEABLE`, `MERGE_STATE` — `mergeable` and `merge_state_status`
as returned (Phase 3 selects the rebase path when the PR is
Expand Down Expand Up @@ -274,9 +276,9 @@ If the output is not empty: **STOP** with stash guidance:
> "Working tree has uncommitted changes. Commit or stash them (`git stash push -u` includes untracked files) and re-invoke `/uf.fix-ci <PR_NUMBER>`. A clean tree is required before any rebase."

Phase 1 hands downstream phases: `PR_NUMBER`, `STATE`, `HEAD_REF`,
`BASE_BRANCH`, `MERGEABLE`, `MERGE_STATE`, `HEAD_REPOSITORY`,
`BASE_REPOSITORY`, `IS_FORK`, `BASE_REMOTE`, `HEAD_REMOTE`, and the
failing check list.
`HEAD_SHA`, `BASE_BRANCH`, `MERGEABLE`, `MERGE_STATE`,
`HEAD_REPOSITORY`, `BASE_REPOSITORY`, `IS_FORK`, `BASE_REMOTE`,
`HEAD_REMOTE`, and the failing check list.

> **CHECKPOINT**: Call `checkpoint` with
> `command: "uf.fix-ci"`, `step: "pr-resolved"`,
Expand Down Expand Up @@ -972,6 +974,21 @@ checkpoint (`REBASED`):
rejected and unbounded `--force` is forbidden;
force-with-lease is the only rewrite-safe push.

Either tool takes `{branch: <HEAD_REF>, remote: <HEAD_REMOTE>}`
and pushes the HEAD commit to `refs/heads/<HEAD_REF>` with an
explicit refspec. `git_push_force_with_lease` also takes
`expected_sha`: pass `<HEAD_SHA>` on the first force-push of
the invocation, then the `new_sha` the previous push returned.
Phase 3's fetch may have moved the remote-tracking ref to a
collaborator's commit, and a fork PR has no tracking ref, so
the lease MUST NOT rely on it. A `BRANCH_MISMATCH` refusal
means the checkout left `<HEAD_REF>`: **STOP** and report it —
never switch branches to retry. A lease rejection means the
remote head moved: **STOP** — never refresh the lease to
retry. Success returns `{remote, ref, old_sha, new_sha,
updated}`; report the SHAs, and treat `updated: false` as
nothing pushed (CI will not re-run).

The command MUST NEVER merge base into head — no push path
substitutes a merge, and no option offers it (design D2). Only
the PR's own head branch is pushed, to `<HEAD_REMOTE>`;
Expand Down
2 changes: 1 addition & 1 deletion .opencode/commands/uf.init.md
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ For each file:
the current Git remote. NEVER create issues in
unrelated repositories.
- **Content portability**: Issue titles and bodies MUST
use language appropriate to the target repository's
use language that matches the target repository's
language and project type. Read README.md or AGENTS.md
to determine the project type. MUST NOT reference
tools or concepts specific to a different repository
Expand Down
48 changes: 25 additions & 23 deletions .opencode/commands/uf.rebase-pr.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ identifiers MUST NOT be hardcoded.
## Phase 2: Fetch the PR

```bash
gh pr view <PR_NUMBER> --json number,title,state,headRefName,baseRefName,mergeable,mergeStateStatus,baseRepository,headRepository
gh pr view <PR_NUMBER> --json number,title,state,headRefName,headRefOid,baseRefName,mergeable,mergeStateStatus,baseRepository,headRepository
```

**If the PR does not exist**: **STOP** with the `gh` error output.
Expand All @@ -79,6 +79,7 @@ gh pr view <PR_NUMBER> --json number,title,state,headRefName,baseRefName,mergeab

Record:
- `HEAD_BRANCH` = `headRefName` (the branch that needs the conflict resolved)
- `HEAD_SHA` = `headRefOid` (the head commit before the rebase; the Phase 5 push lease)
- `BASE_BRANCH` = `baseRefName` (the branch to rebase onto)
- `BASE_REPO` = `<baseRepository.owner.login>/<baseRepository.name>` (the repository the PR targets)
- `HEAD_REPO` = `<headRepository.owner.login>/<headRepository.name>` (the repository holding the head branch; may differ from `BASE_REPO` for fork PRs)
Expand Down Expand Up @@ -166,28 +167,29 @@ report the situation rather than forcing a bad resolution.

The rebase rewrites history, so the head branch must be force-pushed
to the PR's head repository — under lease protection, with the push
target verified first. The `git_push_force_with_lease` plugin tool
takes no refspec: it pushes the current branch to its configured
upstream, which is not guaranteed to be the head remote (the Phase 3
checkout fallback leaves no upstream configured, and a pre-existing
local branch may carry stale tracking).

Verify the checked-out branch's upstream:

```bash
git rev-parse --abbrev-ref @{u}
```

- If the upstream is exactly `<HEAD_REMOTE>/<HEAD_BRANCH>`: call the
`git_push_force_with_lease` plugin tool — it pushes the current
branch to the verified upstream under lease protection.
- If the command reports no upstream, or any other remote or branch:
fall back to the explicit refspec command, which pins the push
target regardless of tracking state:

```bash
git push --force-with-lease <HEAD_REMOTE> <HEAD_BRANCH>
```
target pinned. Call the `git_push_force_with_lease` plugin tool with
`{branch: <HEAD_BRANCH>, remote: <HEAD_REMOTE>, expected_sha:
<HEAD_SHA>}`. It pushes `HEAD:refs/heads/<HEAD_BRANCH>` to
`<HEAD_REMOTE>` with an explicit refspec, independent of any
configured upstream (the Phase 3 checkout fallback leaves none, and
a pre-existing local branch may carry stale tracking), and leases on
`<HEAD_SHA>`, the head the PR reported before the rebase.

- `BRANCH_MISMATCH`: the checkout is not on a local branch named
`<HEAD_BRANCH>` (for example, `gh pr checkout` chose another local
name, or the checkout was switched). **STOP** and report the
current branch — never switch branches or push another ref to
recover.
- Lease rejection (`GIT_PUSH_FORCE_ERROR`, stale info): the remote
head moved since Phase 2. **STOP** and report; never retry with a
refreshed lease or `--force`.
- `EXPECTED_SHA_UNKNOWN`: `<HEAD_SHA>` is not a local commit, so
nothing was pushed and the remote may not have moved. Fetch the
head ref from `HEAD_REPO` (as in Phase 3) and call again with the
same `<HEAD_SHA>`.
- Success returns `{remote, ref, old_sha, new_sha, updated}`. Report
them; `updated: false` means the remote already held the rebased
head, and nothing was pushed.

MUST use `--force-with-lease`, never `--force`. Push only to
`HEAD_REMOTE` (the remote resolved for `HEAD_REPO`) and the PR's head
Expand Down
Loading
Loading