teqo-backup/tests/unit/opencodeCommands.unit.spec.ts
Francisco Solla 8504b3b13a feat(C196): skill /reels-tutoriais — captura mobile + composição de vídeo
- skill + command finos: shot list é a fonte única; ajuste regenera, nada publica
- scripts/build-reel.mjs + scripts/lib/reel*.mjs: captura CDP com timestamps de
  parede (sem drift), cursor/halo DOM-injected, zoompan do log de cliques,
  legendas queimadas, capa 1080x1350-safe, concat H.264 1080x1920/30fps
- ffmpeg: FFMPEG_PATH -> PATH -> @ffmpeg-installer (registry-only) com probe fail-closed
- kit oficial da campanha: public/campaign-kit (marcas positiva/negativa, numero,
  estrela) + manual em docs/campaign-kit + README de regras; skill e agente de
  design referenciam o material
- 26 testes unit novos + pin do command; changelog 2026-09-18-c196

Closes #1155
2026-09-18 21:50:28 -03:00

51 lines
2 KiB
TypeScript

import { existsSync, readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import { describe, expect, it } from 'vitest'
// Programmatic guard for the OPS25 coupling: each `.opencode/commands/<name>.md`
// must keep pointing at the skill of the same name (`.agents/skills/<name>/SKILL.md`).
// The command body deliberately does NOT transcribe the skill — the canonical
// source is the SKILL.md. If a skill is renamed, this spec fails the build so the
// command is renamed together instead of breaking silently at the `/` prompt.
const repoRoot = process.cwd()
const commands = [
'work-issue',
'plan-issue',
'testing-audit',
'bug-fix',
'relatorio-cidade',
'dossie-solla-cidade',
'dossie-solla-instituicao',
'dossie-solla-tema',
'reels-tutoriais',
] as const
describe('opencode commands couple to their skill by exact name', () => {
it.each(commands)('command /%s references the existing skill of the same name', (name) => {
const commandPath = resolve(repoRoot, `.opencode/commands/${name}.md`)
const skillPath = resolve(repoRoot, `.agents/skills/${name}/SKILL.md`)
expect(existsSync(commandPath), 'command file must exist').toBe(true)
expect(existsSync(skillPath), 'referenced skill must exist').toBe(true)
const content = readFileSync(commandPath, 'utf8')
expect(content, 'command must reference the skill by exact name').toContain(`\`${name}\``)
expect(content, 'command must pass arguments through').toContain('$ARGUMENTS')
expect(content, 'command must point at the canonical skill file').toContain(
`.agents/skills/${name}/SKILL.md`,
)
const frontmatter = content.match(/^---\n([\s\S]*?)\n---/)
expect(frontmatter, 'frontmatter must be delimited by ---').not.toBeNull()
expect(frontmatter![1], 'frontmatter must declare a TUI description').toMatch(
/^description: .+$/m,
)
expect(
frontmatter![1],
'frontmatter must NOT pin a model — the command inherits the session model (OPS101)',
).not.toMatch(/^\s*["']?model["']?\s*:/m)
})
})