@esquadrao/cli 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/assets/studio-ui/index.html +512 -0
- package/bin/cli.js +5 -1
- package/package.json +1 -1
- package/skill-media-producer/SKILL.md +30 -0
- package/skill-media-producer/references/composicoes-especiais.md +1 -1
- package/skill-media-producer/references/llm-agent-guide.md +27 -0
- package/src/commands/onboard.js +4 -0
- package/src/commands/studio.js +48 -1
- package/src/studio/jobTelemetry.js +239 -0
- package/src/studio/planSummary.js +76 -0
- package/src/studio/previewCache.js +90 -0
- package/src/studio/server.js +457 -0
- package/src/studio/stateDir.js +132 -0
package/README.md
CHANGED
|
@@ -80,6 +80,9 @@ esquadrao studio render <editplan.json>
|
|
|
80
80
|
esquadrao studio batch <dir> [--dest <path>] [--stop-on-error] [--json]
|
|
81
81
|
esquadrao studio qa <artifact.mp4> [--plan <editplan.json>]
|
|
82
82
|
esquadrao studio cutout <video.mp4> --background <pack.mp4> [--python <interpretador>] [--fps 15]
|
|
83
|
+
|
|
84
|
+
# Companion visual local (CLI-15): observa os jobs da LLM e permite disparar 1 job pela UI
|
|
85
|
+
esquadrao studio serve [--port 4310] [--dest <workspace>] [--no-open] [--json]
|
|
83
86
|
```
|
|
84
87
|
|
|
85
88
|
## Primeiro acesso
|
|
@@ -141,6 +144,17 @@ workspace/
|
|
|
141
144
|
└── studio.json # Manifesto do estúdio e inventário de assets registrados
|
|
142
145
|
```
|
|
143
146
|
|
|
147
|
+
## Companion visual local (CLI-15)
|
|
148
|
+
|
|
149
|
+
O `studio serve` mantém a LLM no terminal e o usuário no navegador, no mesmo workspace:
|
|
150
|
+
|
|
151
|
+
1. A LLM roda `esquadrao studio import`, `auto-clip`, `render` ou `batch` normalmente.
|
|
152
|
+
2. O usuário abre `esquadrao studio serve` (ou apenas observa, se o job foi disparado pela LLM) e vê os nove templates de legenda, os packs do `.esquadrao/broll-catalog.json` e o progresso do job em tempo real.
|
|
153
|
+
3. A página mostra o estágio atual (`queued` → `importing` → `detecting_silence` → `transcribing` → `planning` → `rendering` → `qa` → `done`/`failed`/`canceled`), um resumo humano do `EditPlan` e o vídeo final assim que o QA aprova.
|
|
154
|
+
4. Opcionalmente, a UI dispara **um job por vez** no workspace autorizado — sempre em `127.0.0.1`, com token efêmero de sessão.
|
|
155
|
+
|
|
156
|
+
O servidor é Node stdlib (`dependencies: {}`), não usa Next.js, banco ou nuvem e não lê `OPENAI_API_KEY`, Supabase ou Stripe. Contrato completo e critérios de aceite: [`SPEC.md §2.2.16`](./SPEC.md#2216-companion-visual-local-e-observabilidade-ao-vivo-esquadrao-studio-serve).
|
|
157
|
+
|
|
144
158
|
## Exemplos de EditPlan por Modo
|
|
145
159
|
|
|
146
160
|
### 1. Modo `dark` (zero footage, textos/overlays):
|
|
@@ -360,6 +374,7 @@ All scripts run directly with Node.js stdlib (zero dependencies):
|
|
|
360
374
|
- **Enquadramento de fonte widescreen:** uma fonte 16:9 em saída 9:16 é ajustada com `scale=decrease` + `pad` (tarjas); não há recorte inteligente com tracking de rosto.
|
|
361
375
|
- **Legendas palavra por palavra:** timestamps reais por palavra vêm de `--openai` ou `--local`; com `--captions` SRT, o tempo é distribuído linearmente entre as palavras do bloco.
|
|
362
376
|
- **Recorte de pessoa com troca de fundo:** `studio cutout` é experimental e exige Python com `rembg`, `onnxruntime`, `opencv-python-headless` e `numpy`; sem isso, falha com instrução. Saída 9:16, 15 fps por padrão, ~18–20 min de CPU por 60 s. Sem cache de máscaras ou GPU nesta versão. Detalhes em [`skill-media-producer/references/composicoes-especiais.md`](./skill-media-producer/references/composicoes-especiais.md).
|
|
377
|
+
- **Companion visual:** `studio serve` (CLI-15) abre a UI apenas em `127.0.0.1`, com token efêmero e allowlist de workspaces; não há túnel, exposição de rede nem leitura de chaves. Previews são gerados sob demanda (5 s por template) e cacheados em `<stateDir>/previews/`.
|
|
363
378
|
|
|
364
379
|
## Testing
|
|
365
380
|
|
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="pt-BR">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title>Esquadrão Studio — Companion local</title>
|
|
7
|
+
<style>
|
|
8
|
+
:root {
|
|
9
|
+
color-scheme: dark;
|
|
10
|
+
--bg: #0a0b0d;
|
|
11
|
+
--panel: #121418;
|
|
12
|
+
--panel-2: #171a1f;
|
|
13
|
+
--line: #262a31;
|
|
14
|
+
--fg: #e9ecf1;
|
|
15
|
+
--muted: #9aa3af;
|
|
16
|
+
--accent: #ffe600;
|
|
17
|
+
--accent-ink: #12130a;
|
|
18
|
+
--ok: #3ddc97;
|
|
19
|
+
--warn: #ffb020;
|
|
20
|
+
--err: #ff5c6c;
|
|
21
|
+
--radius: 14px;
|
|
22
|
+
}
|
|
23
|
+
* { box-sizing: border-box; }
|
|
24
|
+
html, body { margin: 0; background: var(--bg); color: var(--fg); }
|
|
25
|
+
body { font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif; }
|
|
26
|
+
a { color: var(--accent); }
|
|
27
|
+
header {
|
|
28
|
+
position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px;
|
|
29
|
+
padding: 14px 22px; border-bottom: 1px solid var(--line); background: rgba(10, 11, 13, .92);
|
|
30
|
+
backdrop-filter: blur(6px);
|
|
31
|
+
}
|
|
32
|
+
.brand { font-weight: 700; letter-spacing: -.01em; margin-right: 10px; }
|
|
33
|
+
.brand span { color: var(--accent); }
|
|
34
|
+
nav { display: flex; gap: 6px; flex-wrap: wrap; }
|
|
35
|
+
nav button {
|
|
36
|
+
appearance: none; border: 1px solid transparent; background: transparent; color: var(--muted);
|
|
37
|
+
padding: 8px 14px; border-radius: 999px; cursor: pointer; font: inherit; font-weight: 600;
|
|
38
|
+
}
|
|
39
|
+
nav button:hover { color: var(--fg); background: var(--panel-2); }
|
|
40
|
+
nav button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
|
|
41
|
+
main { max-width: 1180px; margin: 0 auto; padding: 26px 22px 80px; }
|
|
42
|
+
section[hidden] { display: none; }
|
|
43
|
+
h1 { font-size: 26px; letter-spacing: -.02em; margin: 4px 0 6px; }
|
|
44
|
+
h2 { font-size: 18px; margin: 0 0 12px; letter-spacing: -.01em; }
|
|
45
|
+
p.lead { color: var(--muted); margin: 0 0 22px; max-width: 72ch; }
|
|
46
|
+
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
|
|
47
|
+
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
|
|
48
|
+
.card h3 { margin: 0 0 2px; font-size: 14.5px; }
|
|
49
|
+
.card .meta { color: var(--muted); font-size: 12px; font-family: ui-monospace, Menlo, Consolas, monospace; }
|
|
50
|
+
.card video { width: 100%; aspect-ratio: 9/16; border-radius: 10px; background: #000; margin: 10px 0; object-fit: cover; }
|
|
51
|
+
.pack { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
|
|
52
|
+
.pack:last-child { border-bottom: 0; }
|
|
53
|
+
.pack small { color: var(--muted); display: block; }
|
|
54
|
+
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
|
|
55
|
+
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
|
|
56
|
+
label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 6px; font-weight: 700; }
|
|
57
|
+
select, input, textarea {
|
|
58
|
+
width: 100%; background: var(--panel-2); color: var(--fg); border: 1px solid var(--line);
|
|
59
|
+
border-radius: 10px; padding: 10px 12px; font: inherit;
|
|
60
|
+
}
|
|
61
|
+
textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; min-height: 64px; resize: vertical; }
|
|
62
|
+
.actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
|
|
63
|
+
button.primary {
|
|
64
|
+
background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px;
|
|
65
|
+
padding: 11px 18px; font: inherit; font-weight: 700; cursor: pointer;
|
|
66
|
+
}
|
|
67
|
+
button.primary:disabled { opacity: .45; cursor: not-allowed; }
|
|
68
|
+
button.ghost {
|
|
69
|
+
background: transparent; color: var(--fg); border: 1px solid var(--line); border-radius: 10px;
|
|
70
|
+
padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer;
|
|
71
|
+
}
|
|
72
|
+
button.danger { color: var(--err); border-color: rgba(255, 92, 108, .4); }
|
|
73
|
+
.hint { color: var(--muted); font-size: 12.5px; }
|
|
74
|
+
.stages { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 6px; }
|
|
75
|
+
.stage {
|
|
76
|
+
font-size: 12px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line);
|
|
77
|
+
color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace;
|
|
78
|
+
}
|
|
79
|
+
.stage.active { border-color: var(--accent); color: var(--accent); }
|
|
80
|
+
.stage.done { border-color: rgba(61, 220, 151, .45); color: var(--ok); }
|
|
81
|
+
.stage.failed, .stage.canceled { border-color: rgba(255, 92, 108, .5); color: var(--err); }
|
|
82
|
+
.summary { margin: 12px 0 0; padding: 11px 14px; border: 1px solid rgba(255, 230, 0, .35); border-left: 3px solid var(--accent); border-radius: 8px; background: rgba(255, 230, 0, .06); font-size: 13.5px; }
|
|
83
|
+
pre.log {
|
|
84
|
+
background: #07080a; border: 1px solid var(--line); border-radius: 10px; padding: 12px;
|
|
85
|
+
height: 260px; overflow: auto; font: 12.5px/1.5 ui-monospace, Menlo, Consolas, monospace;
|
|
86
|
+
white-space: pre-wrap; margin: 12px 0 0;
|
|
87
|
+
}
|
|
88
|
+
.pill { display: inline-block; font-size: 11.5px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
|
|
89
|
+
.pill.ok { color: var(--ok); border-color: rgba(61, 220, 151, .4); }
|
|
90
|
+
.pill.err { color: var(--err); border-color: rgba(255, 92, 108, .4); }
|
|
91
|
+
.job { border-bottom: 1px solid var(--line); padding: 12px 0; }
|
|
92
|
+
.job:last-child { border-bottom: 0; }
|
|
93
|
+
.job-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
|
|
94
|
+
.job video { width: 100%; max-height: 420px; border-radius: 10px; background: #000; margin-top: 10px; }
|
|
95
|
+
.empty { color: var(--muted); padding: 24px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
|
|
96
|
+
.toast { position: fixed; right: 18px; bottom: 18px; background: #1b1f26; border: 1px solid var(--line); padding: 12px 16px; border-radius: 10px; max-width: 380px; }
|
|
97
|
+
.toast.err { border-color: rgba(255, 92, 108, .5); color: var(--err); }
|
|
98
|
+
@media (max-width: 720px) { .row { grid-template-columns: 1fr; } main { padding: 18px 14px 60px; } }
|
|
99
|
+
</style>
|
|
100
|
+
</head>
|
|
101
|
+
<body>
|
|
102
|
+
<header>
|
|
103
|
+
<div class="brand">Esquadrão <span>Studio</span></div>
|
|
104
|
+
<nav role="tablist" aria-label="Telas">
|
|
105
|
+
<button role="tab" data-screen="catalog" aria-selected="true">Catálogo Visual</button>
|
|
106
|
+
<button role="tab" data-screen="run" aria-selected="false">Execução Ao Vivo</button>
|
|
107
|
+
<button role="tab" data-screen="result" aria-selected="false">Resultado & QA</button>
|
|
108
|
+
</nav>
|
|
109
|
+
</header>
|
|
110
|
+
|
|
111
|
+
<main>
|
|
112
|
+
<section id="screen-catalog">
|
|
113
|
+
<h1>Catálogo Visual</h1>
|
|
114
|
+
<p class="lead">Nove templates de legenda com preview de 5 s gerado localmente, e os packs descritos no catálogo semântico do workspace. Tudo lido da sua máquina.</p>
|
|
115
|
+
<h2>Templates de legenda</h2>
|
|
116
|
+
<div id="templates" class="grid"><div class="empty">Carregando templates…</div></div>
|
|
117
|
+
<h2 style="margin-top:30px">Packs locais</h2>
|
|
118
|
+
<div class="panel" id="packs"><div class="empty">Nenhum pack carregado.</div></div>
|
|
119
|
+
</section>
|
|
120
|
+
|
|
121
|
+
<section id="screen-run" hidden>
|
|
122
|
+
<h1>Execução Ao Vivo</h1>
|
|
123
|
+
<p class="lead">Dispare um job no workspace autorizado e acompanhe os estágios. A fila da interface aceita um job por vez; execuções feitas pela LLM no terminal aparecem apenas como observação.</p>
|
|
124
|
+
<div class="panel">
|
|
125
|
+
<div class="row">
|
|
126
|
+
<div>
|
|
127
|
+
<label for="workspace">Workspace</label>
|
|
128
|
+
<select id="workspace"></select>
|
|
129
|
+
</div>
|
|
130
|
+
<div>
|
|
131
|
+
<label for="command">Comando</label>
|
|
132
|
+
<select id="command">
|
|
133
|
+
<option value="render">studio render <editplan.json></option>
|
|
134
|
+
<option value="auto-clip">studio auto-clip <video></option>
|
|
135
|
+
<option value="batch">studio batch <dir></option>
|
|
136
|
+
<option value="cutout">studio cutout <video> --background <pack></option>
|
|
137
|
+
<option value="onboard">onboard</option>
|
|
138
|
+
</select>
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
<div style="margin-top:14px">
|
|
142
|
+
<label for="args">Argumentos (separados por espaço)</label>
|
|
143
|
+
<textarea id="args" placeholder="packages/editplan.json --caption-template mrbeast-yellow"></textarea>
|
|
144
|
+
<p class="hint">Sem <code>--openai</code>: a UI nunca lê ou repassa <code>OPENAI_API_KEY</code>. Para transcrição remota, rode no terminal.</p>
|
|
145
|
+
</div>
|
|
146
|
+
<div class="actions">
|
|
147
|
+
<button class="primary" id="start">Iniciar job</button>
|
|
148
|
+
<button class="ghost danger" id="cancel" disabled>Cancelar job</button>
|
|
149
|
+
<button class="ghost" id="goto-result" hidden>Ver resultado & QA</button>
|
|
150
|
+
<span class="hint" id="run-status">Nenhum job em execução.</span>
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
<div class="panel" style="margin-top:16px">
|
|
154
|
+
<h2>Estágios</h2>
|
|
155
|
+
<div class="stages" id="stages"></div>
|
|
156
|
+
<div class="summary" id="summary" hidden></div>
|
|
157
|
+
<pre class="log" id="log" aria-live="polite"></pre>
|
|
158
|
+
</div>
|
|
159
|
+
</section>
|
|
160
|
+
|
|
161
|
+
<section id="screen-result" hidden>
|
|
162
|
+
<h1>Resultado & QA</h1>
|
|
163
|
+
<p class="lead">Histórico local de jobs. Quando o QA aprova, o MP4 final aparece aqui para revisão antes de publicar.</p>
|
|
164
|
+
<div class="panel" id="jobs"><div class="empty">Nenhum job registrado.</div></div>
|
|
165
|
+
</section>
|
|
166
|
+
</main>
|
|
167
|
+
|
|
168
|
+
<script>
|
|
169
|
+
(() => {
|
|
170
|
+
'use strict';
|
|
171
|
+
const STAGES = ['queued','importing','detecting_silence','transcribing','planning','rendering','qa','done','failed','canceled'];
|
|
172
|
+
const LABELS = {
|
|
173
|
+
queued: 'na fila', importing: 'importando', detecting_silence: 'detectando silêncio',
|
|
174
|
+
transcribing: 'transcrevendo', planning: 'planejando', rendering: 'renderizando',
|
|
175
|
+
qa: 'verificando QA', done: 'concluído', failed: 'falhou', canceled: 'cancelado'
|
|
176
|
+
};
|
|
177
|
+
const hash = new URLSearchParams(location.hash.replace(/^#/, ''));
|
|
178
|
+
let token = hash.get('t') || sessionStorage.getItem('esq.token') || '';
|
|
179
|
+
if (token) sessionStorage.setItem('esq.token', token);
|
|
180
|
+
let activeJob = null;
|
|
181
|
+
let streamAbort = null;
|
|
182
|
+
let observedJobId = null;
|
|
183
|
+
let blobs = [];
|
|
184
|
+
|
|
185
|
+
const el = (id) => document.getElementById(id);
|
|
186
|
+
|
|
187
|
+
function toast(message, isError = false) {
|
|
188
|
+
const node = document.createElement('div');
|
|
189
|
+
node.className = 'toast' + (isError ? ' err' : '');
|
|
190
|
+
node.textContent = message;
|
|
191
|
+
document.body.appendChild(node);
|
|
192
|
+
setTimeout(() => node.remove(), 6000);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
async function api(path, options = {}) {
|
|
196
|
+
if (!token) throw new Error('Token ausente: abra a URL impressa pelo comando serve (com #t=...).');
|
|
197
|
+
const res = await fetch(path, {
|
|
198
|
+
...options,
|
|
199
|
+
headers: { 'X-Esquadrao-Token': token, ...(options.body ? { 'Content-Type': 'application/json' } : {}), ...(options.headers || {}) },
|
|
200
|
+
});
|
|
201
|
+
if (!res.ok) {
|
|
202
|
+
let detail = {};
|
|
203
|
+
try { detail = await res.json(); } catch {}
|
|
204
|
+
throw new Error(detail.error || ('HTTP ' + res.status));
|
|
205
|
+
}
|
|
206
|
+
return res;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function show(screen) {
|
|
210
|
+
for (const button of document.querySelectorAll('nav button')) {
|
|
211
|
+
button.setAttribute('aria-selected', String(button.dataset.screen === screen));
|
|
212
|
+
}
|
|
213
|
+
for (const section of document.querySelectorAll('main section')) {
|
|
214
|
+
section.hidden = section.id !== 'screen-' + screen;
|
|
215
|
+
}
|
|
216
|
+
if (screen === 'result') loadJobs();
|
|
217
|
+
if (screen === 'run') loadWorkspaces();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
async function loadTemplates() {
|
|
221
|
+
const box = el('templates');
|
|
222
|
+
try {
|
|
223
|
+
const data = await (await api('/api/catalog')).json();
|
|
224
|
+
if (!data.templates.length) { box.innerHTML = '<div class="empty">Nenhum template disponível.</div>'; return; }
|
|
225
|
+
box.innerHTML = '';
|
|
226
|
+
for (const template of data.templates) {
|
|
227
|
+
const card = document.createElement('article');
|
|
228
|
+
card.className = 'card';
|
|
229
|
+
const title = document.createElement('h3');
|
|
230
|
+
title.textContent = template.name;
|
|
231
|
+
const meta = document.createElement('div');
|
|
232
|
+
meta.className = 'meta';
|
|
233
|
+
meta.textContent = template.id + ' · ' + template.font + ' · ' + template.font_size + 'px';
|
|
234
|
+
const video = document.createElement('video');
|
|
235
|
+
video.muted = true; video.loop = true; video.playsInline = true; video.autoplay = true;
|
|
236
|
+
video.setAttribute('aria-label', 'Preview do template ' + template.name);
|
|
237
|
+
card.append(title, meta, video);
|
|
238
|
+
box.appendChild(card);
|
|
239
|
+
api('/api/previews/' + encodeURIComponent(template.id) + '.mp4')
|
|
240
|
+
.then((res) => res.blob())
|
|
241
|
+
.then((blob) => { const url = URL.createObjectURL(blob); blobs.push(url); video.src = url; })
|
|
242
|
+
.catch(() => { meta.textContent += ' · preview indisponível'; });
|
|
243
|
+
}
|
|
244
|
+
const packs = el('packs');
|
|
245
|
+
if (!data.items.length) {
|
|
246
|
+
packs.innerHTML = '<div class="empty">Nenhum pack em .esquadrao/broll-catalog.json neste workspace.</div>';
|
|
247
|
+
} else {
|
|
248
|
+
packs.innerHTML = '';
|
|
249
|
+
for (const item of data.items.slice(0, 200)) {
|
|
250
|
+
const row = document.createElement('div');
|
|
251
|
+
row.className = 'pack';
|
|
252
|
+
const left = document.createElement('div');
|
|
253
|
+
const name = document.createElement('div');
|
|
254
|
+
name.textContent = item.filename || item.id;
|
|
255
|
+
const desc = document.createElement('small');
|
|
256
|
+
desc.textContent = [item.pack, item.description, (item.tags || []).join(', ')].filter(Boolean).join(' · ');
|
|
257
|
+
left.append(name, desc);
|
|
258
|
+
const dur = document.createElement('span');
|
|
259
|
+
dur.className = 'pill';
|
|
260
|
+
dur.textContent = item.duration_ms ? (item.duration_ms / 1000).toFixed(1) + ' s' : (item.pack || 'pack');
|
|
261
|
+
row.append(left, dur);
|
|
262
|
+
packs.appendChild(row);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
} catch (err) {
|
|
266
|
+
box.innerHTML = '<div class="empty">' + err.message + '</div>';
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
async function loadWorkspaces() {
|
|
271
|
+
const select = el('workspace');
|
|
272
|
+
try {
|
|
273
|
+
const data = await (await api('/api/workspaces')).json();
|
|
274
|
+
select.innerHTML = '';
|
|
275
|
+
for (const workspace of data.workspaces) {
|
|
276
|
+
const option = document.createElement('option');
|
|
277
|
+
option.value = workspace.path;
|
|
278
|
+
option.textContent = workspace.name + ' — ' + workspace.path;
|
|
279
|
+
option.selected = workspace.path === data.active;
|
|
280
|
+
select.appendChild(option);
|
|
281
|
+
}
|
|
282
|
+
if (!data.workspaces.length) {
|
|
283
|
+
const option = document.createElement('option');
|
|
284
|
+
option.textContent = 'Nenhum workspace autorizado';
|
|
285
|
+
select.appendChild(option);
|
|
286
|
+
}
|
|
287
|
+
} catch (err) {
|
|
288
|
+
select.innerHTML = '<option>' + err.message + '</option>';
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function splitArgs(text) {
|
|
293
|
+
const source = String(text || '').trim();
|
|
294
|
+
if (!source) return [];
|
|
295
|
+
const args = [];
|
|
296
|
+
const pattern = /"([^"]*)"|'([^']*)'|(\S+)/g;
|
|
297
|
+
let match;
|
|
298
|
+
while ((match = pattern.exec(source))) {
|
|
299
|
+
args.push(match[1] !== undefined ? match[1] : (match[2] !== undefined ? match[2] : match[3]));
|
|
300
|
+
}
|
|
301
|
+
return args;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function renderStages(current, terminal) {
|
|
305
|
+
const box = el('stages');
|
|
306
|
+
box.innerHTML = '';
|
|
307
|
+
const currentIndex = STAGES.indexOf(current);
|
|
308
|
+
for (const stage of STAGES) {
|
|
309
|
+
const chip = document.createElement('span');
|
|
310
|
+
chip.className = 'stage';
|
|
311
|
+
chip.textContent = LABELS[stage] || stage;
|
|
312
|
+
if (stage === current || (terminal && stage === current)) chip.classList.add(stage === 'failed' || stage === 'canceled' ? stage : 'active');
|
|
313
|
+
else if (!terminal && currentIndex > -1 && STAGES.indexOf(stage) < currentIndex && !['done','failed','canceled'].includes(stage)) chip.classList.add('done');
|
|
314
|
+
box.appendChild(chip);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function appendLog(line) {
|
|
319
|
+
const log = el('log');
|
|
320
|
+
log.textContent += line + '\n';
|
|
321
|
+
log.scrollTop = log.scrollHeight;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
async function follow(jobId, options = {}) {
|
|
325
|
+
if (streamAbort) streamAbort.abort();
|
|
326
|
+
const controller = new AbortController();
|
|
327
|
+
streamAbort = controller;
|
|
328
|
+
el('log').textContent = '';
|
|
329
|
+
el('summary').hidden = true;
|
|
330
|
+
el('summary').textContent = '';
|
|
331
|
+
el('goto-result').hidden = true;
|
|
332
|
+
activeJob = jobId;
|
|
333
|
+
el('cancel').disabled = false;
|
|
334
|
+
el('start').disabled = false;
|
|
335
|
+
el('run-status').textContent = options.external
|
|
336
|
+
? 'Observando execução externa (' + (options.command || jobId) + ')'
|
|
337
|
+
: 'Job ' + jobId + ' em execução.';
|
|
338
|
+
try {
|
|
339
|
+
const res = await fetch('/api/jobs/' + encodeURIComponent(jobId) + '/events', {
|
|
340
|
+
headers: { 'X-Esquadrao-Token': token }, signal: controller.signal,
|
|
341
|
+
});
|
|
342
|
+
if (!res.ok || !res.body) throw new Error('SSE indisponível (HTTP ' + res.status + ')');
|
|
343
|
+
const reader = res.body.getReader();
|
|
344
|
+
const decoder = new TextDecoder();
|
|
345
|
+
let buffer = '';
|
|
346
|
+
for (;;) {
|
|
347
|
+
const { value, done } = await reader.read();
|
|
348
|
+
if (done) break;
|
|
349
|
+
buffer += decoder.decode(value, { stream: true });
|
|
350
|
+
const frames = buffer.split('\n\n');
|
|
351
|
+
buffer = frames.pop() || '';
|
|
352
|
+
for (const frame of frames) {
|
|
353
|
+
const dataLine = frame.split('\n').find((l) => l.startsWith('data: '));
|
|
354
|
+
if (!dataLine) continue;
|
|
355
|
+
let event;
|
|
356
|
+
try { event = JSON.parse(dataLine.slice(6)); } catch { continue; }
|
|
357
|
+
if (event.type === 'stage') {
|
|
358
|
+
renderStages(event.stage, ['done','failed','canceled'].includes(event.stage));
|
|
359
|
+
appendLog('[' + event.stage + '] ' + (LABELS[event.stage] || ''));
|
|
360
|
+
if (['done','failed','canceled'].includes(event.stage)) {
|
|
361
|
+
el('cancel').disabled = true;
|
|
362
|
+
el('start').disabled = false;
|
|
363
|
+
el('run-status').textContent = options.external
|
|
364
|
+
? 'Execução externa (' + (options.command || jobId) + '): ' + (LABELS[event.stage] || event.stage) + '.'
|
|
365
|
+
: 'Job ' + jobId + ': ' + (LABELS[event.stage] || event.stage) + '.';
|
|
366
|
+
if (event.stage === 'done') el('goto-result').hidden = false;
|
|
367
|
+
controller.abort();
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
} else if (event.type === 'log') {
|
|
371
|
+
appendLog(String(event.payload && event.payload.line || ''));
|
|
372
|
+
} else if (event.type === 'plan_summary') {
|
|
373
|
+
const text = String(event.payload && event.payload.text || '');
|
|
374
|
+
const box = el('summary');
|
|
375
|
+
box.textContent = text;
|
|
376
|
+
box.hidden = !text;
|
|
377
|
+
appendLog('Resumo: ' + text);
|
|
378
|
+
} else if (event.type === 'artifact') {
|
|
379
|
+
appendLog('Artefato: ' + (event.payload && event.payload.path || ''));
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
} catch (err) {
|
|
384
|
+
if (err.name !== 'AbortError') {
|
|
385
|
+
appendLog('Erro no stream: ' + err.message);
|
|
386
|
+
toast(err.message, true);
|
|
387
|
+
}
|
|
388
|
+
} finally {
|
|
389
|
+
if (streamAbort === controller) {
|
|
390
|
+
streamAbort = null;
|
|
391
|
+
activeJob = null;
|
|
392
|
+
el('start').disabled = false;
|
|
393
|
+
el('cancel').disabled = true;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
async function pollExternal() {
|
|
399
|
+
if (!token || activeJob) return;
|
|
400
|
+
try {
|
|
401
|
+
const data = await (await api('/api/jobs')).json();
|
|
402
|
+
const job = data.jobs.find((j) => (j.status === 'running' || j.status === 'queued') && j.id !== observedJobId);
|
|
403
|
+
if (!job) return;
|
|
404
|
+
observedJobId = job.id;
|
|
405
|
+
show('run');
|
|
406
|
+
el('run-status').textContent = 'Observando execução externa (' + job.command + ')';
|
|
407
|
+
await follow(job.id, { external: true, command: job.command });
|
|
408
|
+
} catch {}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
async function startJob() {
|
|
412
|
+
const workspace = el('workspace').value;
|
|
413
|
+
const command = el('command').value;
|
|
414
|
+
const args = splitArgs(el('args').value);
|
|
415
|
+
el('start').disabled = true;
|
|
416
|
+
activeJob = 'pending';
|
|
417
|
+
try {
|
|
418
|
+
const res = await api('/api/jobs', { method: 'POST', body: JSON.stringify({ command, workspace, args }) });
|
|
419
|
+
const data = await res.json();
|
|
420
|
+
renderStages('queued', false);
|
|
421
|
+
await follow(data.job_id);
|
|
422
|
+
} catch (err) {
|
|
423
|
+
activeJob = null;
|
|
424
|
+
toast(err.message, true);
|
|
425
|
+
el('start').disabled = false;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
async function cancelJob() {
|
|
430
|
+
if (!activeJob) return;
|
|
431
|
+
try {
|
|
432
|
+
await api('/api/jobs/' + encodeURIComponent(activeJob) + '/cancel', { method: 'POST' });
|
|
433
|
+
toast('Cancelamento enviado (SIGINT).');
|
|
434
|
+
} catch (err) {
|
|
435
|
+
toast(err.message, true);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
async function loadJobs() {
|
|
440
|
+
const box = el('jobs');
|
|
441
|
+
try {
|
|
442
|
+
const data = await (await api('/api/jobs')).json();
|
|
443
|
+
if (!data.jobs.length) { box.innerHTML = '<div class="empty">Nenhum job registrado.</div>'; return; }
|
|
444
|
+
box.innerHTML = '';
|
|
445
|
+
for (const job of data.jobs.slice(0, 30)) {
|
|
446
|
+
const row = document.createElement('div');
|
|
447
|
+
row.className = 'job';
|
|
448
|
+
const head = document.createElement('div');
|
|
449
|
+
head.className = 'job-head';
|
|
450
|
+
const left = document.createElement('div');
|
|
451
|
+
const title = document.createElement('div');
|
|
452
|
+
title.textContent = job.command + ' · ' + job.id;
|
|
453
|
+
const meta = document.createElement('div');
|
|
454
|
+
meta.className = 'meta';
|
|
455
|
+
meta.textContent = (job.workspace || '—') + ' · ' + (job.created_at || '');
|
|
456
|
+
left.append(title, meta);
|
|
457
|
+
const pill = document.createElement('span');
|
|
458
|
+
const status = job.status || 'unknown';
|
|
459
|
+
pill.className = 'pill ' + (status === 'done' ? 'ok' : (status === 'failed' || status === 'canceled' ? 'err' : ''));
|
|
460
|
+
pill.textContent = LABELS[status] || status;
|
|
461
|
+
head.append(left, pill);
|
|
462
|
+
row.appendChild(head);
|
|
463
|
+
if (job.artifact && job.artifact.id) {
|
|
464
|
+
const video = document.createElement('video');
|
|
465
|
+
video.controls = true; video.playsInline = true;
|
|
466
|
+
video.setAttribute('aria-label', 'Vídeo do job ' + job.id);
|
|
467
|
+
row.appendChild(video);
|
|
468
|
+
api('/api/artifacts/' + encodeURIComponent(job.artifact.id))
|
|
469
|
+
.then((res) => res.blob())
|
|
470
|
+
.then((blob) => { const url = URL.createObjectURL(blob); blobs.push(url); video.src = url; })
|
|
471
|
+
.catch(() => {});
|
|
472
|
+
}
|
|
473
|
+
box.appendChild(row);
|
|
474
|
+
}
|
|
475
|
+
} catch (err) {
|
|
476
|
+
box.innerHTML = '<div class="empty">' + err.message + '</div>';
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
for (const button of document.querySelectorAll('nav button')) {
|
|
481
|
+
button.addEventListener('click', () => show(button.dataset.screen));
|
|
482
|
+
}
|
|
483
|
+
el('start').addEventListener('click', startJob);
|
|
484
|
+
el('cancel').addEventListener('click', cancelJob);
|
|
485
|
+
el('goto-result').addEventListener('click', () => show('result'));
|
|
486
|
+
el('command').addEventListener('change', () => {
|
|
487
|
+
const value = el('command').value;
|
|
488
|
+
const hint = {
|
|
489
|
+
render: 'packages/editplan.json --caption-template mrbeast-yellow',
|
|
490
|
+
'auto-clip': 'assets/AST-xxxxxxxx.mp4 --no-captions --format 9:16',
|
|
491
|
+
batch: 'packages --stop-on-error',
|
|
492
|
+
cutout: 'assets/AST-xxxxxxxx.mp4 --background packs/pack.mp4',
|
|
493
|
+
onboard: '--mode dark --dest .',
|
|
494
|
+
}[value] || '';
|
|
495
|
+
el('args').value = hint;
|
|
496
|
+
});
|
|
497
|
+
window.addEventListener('beforeunload', () => { for (const url of blobs) URL.revokeObjectURL(url); });
|
|
498
|
+
|
|
499
|
+
if (!token) {
|
|
500
|
+
const input = prompt('Token da sessão (aparece no fragmento #t= da URL impressa pelo serve):');
|
|
501
|
+
if (input) { token = input.trim(); sessionStorage.setItem('esq.token', token); }
|
|
502
|
+
}
|
|
503
|
+
if (token) {
|
|
504
|
+
loadTemplates();
|
|
505
|
+
renderStages('queued', false);
|
|
506
|
+
pollExternal();
|
|
507
|
+
setInterval(pollExternal, 1500);
|
|
508
|
+
}
|
|
509
|
+
})();
|
|
510
|
+
</script>
|
|
511
|
+
</body>
|
|
512
|
+
</html>
|
package/bin/cli.js
CHANGED
|
@@ -45,6 +45,8 @@ const { values: flags, positionals } = parseArgs({
|
|
|
45
45
|
'min-dur': { type: 'string' },
|
|
46
46
|
'max-dur': { type: 'string' },
|
|
47
47
|
'stop-on-error': { type: 'boolean' },
|
|
48
|
+
port: { type: 'string' },
|
|
49
|
+
'no-open': { type: 'boolean' },
|
|
48
50
|
},
|
|
49
51
|
allowPositionals: true,
|
|
50
52
|
strict: false,
|
|
@@ -68,7 +70,7 @@ Usage:
|
|
|
68
70
|
Commands:
|
|
69
71
|
setup Instala os skills nos ambientes de agentes (.agents, .claude, .codex, .cursor)
|
|
70
72
|
role Lista, inspeciona e executa papéis canônicos da esteira
|
|
71
|
-
studio Estúdio local de vídeo: init, import, render, qa, batch, auto-clip, cutout, caption-templates
|
|
73
|
+
studio Estúdio local de vídeo: init, import, render, qa, batch, auto-clip, cutout, serve, caption-templates
|
|
72
74
|
onboard Guia interativo: da mídia bruta ao primeiro corte renderizado
|
|
73
75
|
version Exibe a versão do CLI
|
|
74
76
|
help Exibe mensagens de ajuda
|
|
@@ -77,6 +79,8 @@ Options:
|
|
|
77
79
|
-h, --help Show help
|
|
78
80
|
-v, --version Show version
|
|
79
81
|
--json Output results in JSON format
|
|
82
|
+
--port <n> Porta do companion visual (padrão: 4310)
|
|
83
|
+
--no-open Não abrir o navegador ao iniciar o studio serve
|
|
80
84
|
--dest <path> Custom destination directory for skills or workspace
|
|
81
85
|
--mode <mode> Video mode for onboarding (edit_only, dark, podcast_clip)
|
|
82
86
|
--file <path> Source media file for onboarding (can be repeated)
|
package/package.json
CHANGED
|
@@ -121,6 +121,35 @@ esquadrao studio auto-clip ./caminho/meu-video.mp4 --dest ./workspace --json
|
|
|
121
121
|
|
|
122
122
|
> **Templates de legenda:** o catálogo canônico tem nove presets em [`references/caption-templates.md`](references/caption-templates.md), disponíveis no CLI 1.5.0 via `--caption-template <id>` ou `captions[].template`. `--caption-style impact|word|full` permanece como legado.
|
|
123
123
|
|
|
124
|
+
### Acompanhamento visual no navegador (`studio serve` — CLI-15)
|
|
125
|
+
|
|
126
|
+
> **Confirme a versão antes de oferecer.** O subcomando existe desde o CLI-15; em instalações anteriores, `esquadrao studio serve --help` falha e você deve usar o caminho de terminal descrito no fim desta seção.
|
|
127
|
+
|
|
128
|
+
**Ofereça assim:**
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# Sobe o companion local no workspace atual (porta padrão 4310; abre o navegador)
|
|
132
|
+
esquadrao studio serve --dest ./workspace
|
|
133
|
+
|
|
134
|
+
# Sem abrir o navegador (para o usuário abrir a URL impressa) ou em porta alternativa
|
|
135
|
+
esquadrao studio serve --dest ./workspace --no-open --port 4310
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
- **O que o usuário vê:** os **nove templates de legenda** com preview de 5 s, os packs descritos no catálogo `.esquadrao/broll-catalog.json` (campo `pack`, `description` e `tags`), o job em andamento e o vídeo final aprovado pelo QA.
|
|
139
|
+
- **Modo híbrido:** a LLM continua executando `import`, `auto-clip`, `render` e `batch` no terminal; o servidor apenas observa. A UI pode disparar **um job por vez**, no workspace autorizado.
|
|
140
|
+
- **Estágios exibidos:** `queued` → `importing` → `detecting_silence` → `transcribing` → `planning` → `rendering` → `qa` → `done`/`failed`/`canceled`, com resumo humano do `EditPlan` e logs sem credenciais.
|
|
141
|
+
- **Segurança, diga em uma frase:** roda só em `127.0.0.1`, com token efêmero e allowlist de workspaces; não abre porta para a rede, não usa nuvem e não lê `OPENAI_API_KEY`, Supabase ou Stripe. Nunca peça ao usuário para expor a porta, criar túnel ou colar chaves para "habilitar a tela".
|
|
142
|
+
|
|
143
|
+
**Se a instalação for anterior ao CLI-15, entregue o mesmo acompanhamento por texto:**
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
esquadrao studio caption-templates --json # os nove presets e parâmetros
|
|
147
|
+
cat ./workspace/.esquadrao/broll-catalog.json # packs e descrições para escolher B-roll
|
|
148
|
+
esquadrao studio render ./workspace/packages/editplan.json --dest ./workspace --json
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Peça ao usuário para abrir o MP4 em `artifacts/` e relate estágio, artefato e resultado do QA em texto.
|
|
152
|
+
|
|
124
153
|
---
|
|
125
154
|
|
|
126
155
|
## 3. Modelos Canônicos de EditPlan v1 (Prontos para LLM sem Alucinação)
|
|
@@ -317,6 +346,7 @@ esquadrao studio auto-clip ./caminho/meu-video.mp4 --dest ./workspace --json
|
|
|
317
346
|
- **Split permanente:** `auto-clip --broll <pack> --layout split_bottom --overlay-duration full` mantém o orador no topo e o pack na base durante todo o clipe; o pack é repetido em loop e o áudio original é preservado.
|
|
318
347
|
- O layout `split_top` está implementado desde 1.7.0: orador na metade inferior e pack na metade superior, com loop (CLI-06).
|
|
319
348
|
- **Recorte de pessoa com troca de fundo:** disponível em `studio cutout <video> --background <pack> --python <interpretador>`, como experimental. Requer Python com `rembg`, `onnxruntime`, `opencv-python-headless`, `numpy` e Pillow; ~18–20 min de CPU por 60 s em 15 fps. Não prometa tempo real nem qualidade de estúdio. Detalhes em [`references/composicoes-especiais.md`](./references/composicoes-especiais.md).
|
|
349
|
+
- **Cutout não é layout:** `overlays[].layout` aceita exclusivamente `fullscreen`, `pip`, `split_bottom` e `split_top`. Recorte de pessoa é o subcomando separado `studio cutout`, com `--background`; nunca escreva `layout: "cutout"` em um EditPlan nem prometa corte de pessoa via `--layout`.
|
|
320
350
|
7. **Verificação Técnica Independente:** Sempre execute `studio qa` com `--plan` para validar integridade antes de concluir a tarefa.
|
|
321
351
|
8. **Renderização em Lote:** Para múltiplos planos, use `esquadrao studio batch <dir> --dest <workspace> --json`; o comando renderiza em sequência e agrega o QA (CLI-07).
|
|
322
352
|
9. **Onboarding Real:** O comando `esquadrao onboard --mode podcast_clip` usa o pipeline real de `auto-clip`; os modos `dark` e `edit_only` continuam gerando planos guiados.
|
|
@@ -96,4 +96,4 @@ Critérios de aceite:
|
|
|
96
96
|
|
|
97
97
|
- Split: `podpah-neymar-split-pack.mp4` (protótipo externo, 60 s, 1080×1920) e teste `split_bottom full loops a short b-roll`.
|
|
98
98
|
- Cutout: `podpah-neymar-cutout-pack.mp4` (protótipo externo, 60 s, 1080×1920, cor corrigida) e teste de contrato do comando.
|
|
99
|
-
- Suíte:
|
|
99
|
+
- Suíte: 129 testes (127 aprovados + 2 skips condicionais), lint em 50 arquivos.
|