chore(worktree): preset model do launcher via OPENCODE_WORKTREE_MODEL — fallback comum deepseek-v4-flash (alinhamento infra-solla/iara-pwa)
Some checks failed
CI (PR) / checks (pull_request) Failing after 1s
PR Ready + auto-merge / ready-automerge (pull_request) Failing after 18s
Main merge flips claimed issues to done + in-prod / issue-done (pull_request) Has been skipped
Promote plan-issue Related on main merge / plan-issue-ready (pull_request) Has been skipped

This commit is contained in:
Francisco Solla 2026-08-24 14:42:51 -03:00
parent c69376f3c2
commit c8a1f53904
2 changed files with 26 additions and 16 deletions

View file

@ -20,14 +20,17 @@ export const PLAN_BRANCH_PREFIX = 'plans/plan-issue'
export const WORKTREE_TERMINAL_ENV = 'TEQO_WORKTREE_TERMINAL'
/**
* Preset model for the opencode launch — change the preset by editing this
* constant. OPS78: routes through the Vercel AI Gateway (cache/stability/
* failover) instead of the direct provider. OPS82: the preset is the cheaper
* `-0731` flavor (input $0.076/M vs $0.13/M); the low/high/max variants are
* exposed by the `provider.vercel` override in the global opencode config
* (`~/.config/opencode/opencode.jsonc`, outside the repo — OPS89).
* Preset model for the opencode launch — fallback comum aos 3 repos do fluxo
* (infra-solla, teqo, iara-pwa). Override sem editar código: global via
* `export OPENCODE_WORKTREE_MODEL=…`, ou por repo na chave
* `OPENCODE_WORKTREE_MODEL` da `.forgejo/worktree.env`. Ex-OPS78/OPS82: o
* preset era o flavor `-0731` via Vercel AI Gateway; voltou ao provider
* direto porque o gateway está sem créditos (erros "positive credit balance"
* em 24/08/2026) e porque unificar o default reduz a sobrescrita confusa de
* seleção de modelo do TUI (opencode issues #8349/#13456).
*/
export const OPENCODE_PRESET_MODEL = 'vercel/deepseek/deepseek-v4-flash-0731'
export const OPENCODE_PRESET_MODEL =
process.env.OPENCODE_WORKTREE_MODEL || 'deepseek/deepseek-v4-flash'
/**
* Skill command sent as the launch's initial message per purpose. `next`

View file

@ -33,6 +33,13 @@ type TestIssue = {
meta?: { id?: string }
}
/**
* Valor esperado do preset no ambiente corrente: o fallback comum quando
* OPENCODE_WORKTREE_MODEL não está exportado (CI), ou o valor exportado
* (shell local) — o lib resolve exatamente nessa precedência.
*/
const presetInEffect = () => process.env.OPENCODE_WORKTREE_MODEL || 'deepseek/deepseek-v4-flash'
const issue = (over: Partial<TestIssue> = {}): TestIssue => ({
number: 1,
title: 'C15 — FullCalendar em /campanha/agenda',
@ -148,7 +155,7 @@ describe('opencodeLaunchDirective (terminal-only opencode launch, OPS26 + OPS33)
it('next launches with the preset model, --auto and the /work-issue command sent (value always quoted)', () => {
expect(opencodeLaunchDirective({ dir, purpose: 'next', terminal: true })).toBe(
`launch opencode ${dir} --model vercel/deepseek/deepseek-v4-flash-0731 --auto --prompt "/work-issue"`,
`launch opencode ${dir} --model ${presetInEffect()} --auto --prompt "/work-issue"`,
)
})
@ -156,33 +163,33 @@ describe('opencodeLaunchDirective (terminal-only opencode launch, OPS26 + OPS33)
expect(
opencodeLaunchDirective({ dir, purpose: 'next', terminal: true, issueNumber: 595 }),
).toBe(
`launch opencode ${dir} --model vercel/deepseek/deepseek-v4-flash-0731 --auto --prompt "/work-issue --issue 595"`,
`launch opencode ${dir} --model ${presetInEffect()} --auto --prompt "/work-issue --issue 595"`,
)
})
it('plan launches with the same presets and /plan-issue sent (OPS31, value quoted)', () => {
expect(opencodeLaunchDirective({ dir, purpose: 'plan', terminal: true })).toBe(
`launch opencode ${dir} --model vercel/deepseek/deepseek-v4-flash-0731 --auto --prompt "/plan-issue"`,
`launch opencode ${dir} --model ${presetInEffect()} --auto --prompt "/plan-issue"`,
)
})
it('new launches prompt-less too — "apenas conversar", no skill sent', () => {
expect(opencodeLaunchDirective({ dir, purpose: 'new', terminal: true })).toBe(
`launch opencode ${dir} --model vercel/deepseek/deepseek-v4-flash-0731 --auto`,
`launch opencode ${dir} --model ${presetInEffect()} --auto`,
)
})
it('plan/new ignore the issueNumber — only next carries the claimed issue', () => {
expect(opencodeLaunchDirective({ dir, purpose: 'plan', terminal: true, issueNumber: 7 })).toBe(
`launch opencode ${dir} --model vercel/deepseek/deepseek-v4-flash-0731 --auto --prompt "/plan-issue"`,
`launch opencode ${dir} --model ${presetInEffect()} --auto --prompt "/plan-issue"`,
)
expect(opencodeLaunchDirective({ dir, purpose: 'new', terminal: true, issueNumber: 7 })).toBe(
`launch opencode ${dir} --model vercel/deepseek/deepseek-v4-flash-0731 --auto`,
`launch opencode ${dir} --model ${presetInEffect()} --auto`,
)
})
it('pins the preset constants — changing the model is editing a constant', () => {
expect(OPENCODE_PRESET_MODEL).toBe('vercel/deepseek/deepseek-v4-flash-0731')
it('pins the preset constants — fallback comum deepseek-v4-flash, override via OPENCODE_WORKTREE_MODEL', () => {
expect(OPENCODE_PRESET_MODEL).toBe(presetInEffect())
expect(WORKTREE_TERMINAL_ENV).toBe('TEQO_WORKTREE_TERMINAL')
expect(OPENCODE_SKILL_COMMAND_BY_PURPOSE).toEqual({
next: '/work-issue',
@ -193,7 +200,7 @@ describe('opencodeLaunchDirective (terminal-only opencode launch, OPS26 + OPS33)
it('an unknown purpose degrades to a prompt-less launch (fail-safe direction)', () => {
expect(opencodeLaunchDirective({ dir, purpose: 'bogus', terminal: true })).toBe(
`launch opencode ${dir} --model vercel/deepseek/deepseek-v4-flash-0731 --auto`,
`launch opencode ${dir} --model ${presetInEffect()} --auto`,
)
})
})