@esquadrao/cli 1.7.0 → 1.8.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 +18 -7
- package/assets/broll-catalog.json +11905 -0
- package/bin/cli.js +5 -0
- package/package.json +5 -4
- package/scripts/cutout.py +83 -15
- package/scripts/dag_validator.js +38 -3
- package/scripts/lint.js +47 -7
- package/scripts/merkle_verify.js +6 -1
- package/skill-media-producer/SKILL.md +2 -0
- package/skill-media-producer/references/composicoes-especiais.md +4 -4
- package/skill-media-producer/references/configuracao-inicial.md +26 -12
- package/skill-media-producer/references/llm-agent-guide.md +4 -8
- package/src/binaries.js +74 -0
- package/src/captionTemplates.js +2 -1
- package/src/commands/onboard.js +7 -16
- package/src/commands/setup.js +22 -20
package/bin/cli.js
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
import { parseArgs } from 'node:util';
|
|
3
3
|
import { existsSync, readFileSync } from 'node:fs';
|
|
4
4
|
import process from 'node:process';
|
|
5
|
+
import { ensureBundledPath } from '../src/binaries.js';
|
|
6
|
+
|
|
7
|
+
// FFmpeg/ffprobe embutidos: injeta no PATH antes de qualquer comando.
|
|
8
|
+
ensureBundledPath();
|
|
5
9
|
|
|
6
10
|
if (typeof process.loadEnvFile === 'function' && existsSync('.env')) {
|
|
7
11
|
try { process.loadEnvFile(); } catch {}
|
|
@@ -9,6 +13,7 @@ if (typeof process.loadEnvFile === 'function' && existsSync('.env')) {
|
|
|
9
13
|
|
|
10
14
|
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
11
15
|
|
|
16
|
+
|
|
12
17
|
const { values: flags, positionals } = parseArgs({
|
|
13
18
|
args: process.argv.slice(2),
|
|
14
19
|
options: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esquadrao/cli",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.8.0",
|
|
4
|
+
"description": "Esquadrão CLI and autonomous skill orchestration framework for AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"esquadrao": "bin/cli.js"
|
|
@@ -52,8 +52,9 @@
|
|
|
52
52
|
"cli"
|
|
53
53
|
],
|
|
54
54
|
"license": "MIT",
|
|
55
|
-
"dependencies": {},
|
|
56
55
|
"optionalDependencies": {
|
|
57
|
-
"@xenova/transformers": "^2.17.2"
|
|
56
|
+
"@xenova/transformers": "^2.17.2",
|
|
57
|
+
"ffmpeg-static": "5.2.0",
|
|
58
|
+
"ffprobe-static": "^3.1.0"
|
|
58
59
|
}
|
|
59
60
|
}
|
package/scripts/cutout.py
CHANGED
|
@@ -30,6 +30,26 @@ def has_audio(path: str) -> bool:
|
|
|
30
30
|
return False
|
|
31
31
|
|
|
32
32
|
|
|
33
|
+
def fg_height_for(requested, out_h: int, src_w: int, src_h: int) -> int:
|
|
34
|
+
"""Altura do primeiro plano composto.
|
|
35
|
+
|
|
36
|
+
Entrada vertical entra em tela cheia (não encolhe as laterais); horizontal
|
|
37
|
+
mantém o recorte de 1000 px do protótipo. --fg-height explícito manda.
|
|
38
|
+
"""
|
|
39
|
+
if requested is None:
|
|
40
|
+
requested = out_h if src_w > 0 and src_h >= src_w else min(1000, out_h)
|
|
41
|
+
return max(1, min(requested, out_h))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def erode_kernel(min_side: int) -> int:
|
|
45
|
+
"""Núcleo de erosão ~4,5% do lado menor (49 px em 1080p), sempre ímpar.
|
|
46
|
+
|
|
47
|
+
GC_FGD fica estritamente dentro da silhueta; o halo de 15-50 px do u2net
|
|
48
|
+
permanece como GC_PR_FGD para o GrabCut refinar.
|
|
49
|
+
"""
|
|
50
|
+
return max(31, int(min_side * 0.045) | 1)
|
|
51
|
+
|
|
52
|
+
|
|
33
53
|
def main() -> int:
|
|
34
54
|
ap = argparse.ArgumentParser()
|
|
35
55
|
ap.add_argument('--input', required=True)
|
|
@@ -38,7 +58,7 @@ def main() -> int:
|
|
|
38
58
|
ap.add_argument('--fps', type=float, default=15.0)
|
|
39
59
|
ap.add_argument('--width', type=int, default=1080)
|
|
40
60
|
ap.add_argument('--height', type=int, default=1920)
|
|
41
|
-
ap.add_argument('--fg-height', type=int, default=
|
|
61
|
+
ap.add_argument('--fg-height', type=int, default=None)
|
|
42
62
|
ap.add_argument('--fg-y', type=int, default=None)
|
|
43
63
|
ap.add_argument('--model', default='u2net_human_seg')
|
|
44
64
|
ap.add_argument('--crf', type=int, default=20)
|
|
@@ -87,7 +107,11 @@ def main() -> int:
|
|
|
87
107
|
raise RuntimeError('falha ao ler frame do pack de fundo')
|
|
88
108
|
return cv2.resize(bg, (args.width, args.height), interpolation=cv2.INTER_AREA)
|
|
89
109
|
|
|
90
|
-
fg_h =
|
|
110
|
+
fg_h = fg_height_for(
|
|
111
|
+
args.fg_height, args.height,
|
|
112
|
+
int(cap.get(cv2.CAP_PROP_FRAME_WIDTH) or 0),
|
|
113
|
+
int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT) or 0),
|
|
114
|
+
)
|
|
91
115
|
fg_y = args.height - fg_h if args.fg_y is None else max(0, min(args.fg_y, args.height - fg_h))
|
|
92
116
|
|
|
93
117
|
audio = has_audio(args.input)
|
|
@@ -108,19 +132,34 @@ def main() -> int:
|
|
|
108
132
|
'-shortest', '-movflags', '+faststart', args.output,
|
|
109
133
|
]
|
|
110
134
|
|
|
111
|
-
|
|
112
|
-
session = new_session(args.model)
|
|
113
|
-
ff = subprocess.Popen(cmd, stdin=subprocess.PIPE)
|
|
114
|
-
started = time.time()
|
|
135
|
+
ff = None
|
|
115
136
|
written = 0
|
|
116
|
-
|
|
137
|
+
success = False
|
|
138
|
+
started = time.time()
|
|
117
139
|
try:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
140
|
+
print(f'Carregando modelo {args.model} (primeira execução pode baixar ~176 MB)...', file=sys.stderr, flush=True)
|
|
141
|
+
session = new_session(args.model)
|
|
142
|
+
ff = subprocess.Popen(cmd, stdin=subprocess.PIPE)
|
|
143
|
+
|
|
144
|
+
src_idx = 0
|
|
145
|
+
last = None
|
|
146
|
+
while written < out_frames:
|
|
147
|
+
# Amostragem sequencial: grab avança sem decodificar. Seek por
|
|
148
|
+
# CAP_PROP_POS_MSEC erra em H.264 com B-frames e trunca o vídeo.
|
|
149
|
+
target = int(round(written * src_fps / args.fps))
|
|
150
|
+
while src_idx < target:
|
|
151
|
+
if not cap.grab():
|
|
152
|
+
break
|
|
153
|
+
src_idx += 1
|
|
154
|
+
if last is not None and src_idx > target:
|
|
155
|
+
frame = last # fps de saída acima do da origem: repete o quadro
|
|
156
|
+
else:
|
|
157
|
+
ok, frame = cap.read()
|
|
158
|
+
if not ok:
|
|
159
|
+
break
|
|
160
|
+
src_idx += 1
|
|
161
|
+
last = frame
|
|
162
|
+
bg = read_bg(written)
|
|
124
163
|
cut = remove(
|
|
125
164
|
Image.fromarray(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)),
|
|
126
165
|
session=session,
|
|
@@ -134,7 +173,8 @@ def main() -> int:
|
|
|
134
173
|
# da cabeça); sem refino, esse fundo vira um halo escuro no composto.
|
|
135
174
|
mask = (fg[:, :, 3] > 127).astype(np.uint8) * 255
|
|
136
175
|
try:
|
|
137
|
-
|
|
176
|
+
k_erode = erode_kernel(min(frame.shape[:2]))
|
|
177
|
+
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (k_erode, k_erode))
|
|
138
178
|
core = cv2.erode(mask, kernel)
|
|
139
179
|
outside = cv2.bitwise_not(cv2.dilate(mask, kernel))
|
|
140
180
|
gc = np.full(mask.shape, cv2.GC_PR_BGD, np.uint8)
|
|
@@ -171,15 +211,43 @@ def main() -> int:
|
|
|
171
211
|
written += 1
|
|
172
212
|
if written % 100 == 0:
|
|
173
213
|
print(f'{written}/{out_frames} frames — {time.time() - started:.1f}s', file=sys.stderr, flush=True)
|
|
214
|
+
|
|
215
|
+
if written == 0:
|
|
216
|
+
print('nenhum frame da entrada foi decodificado', file=sys.stderr)
|
|
217
|
+
return 1
|
|
218
|
+
if written < out_frames:
|
|
219
|
+
print(f'decodificação interrompida em {written}/{out_frames} frames', file=sys.stderr)
|
|
220
|
+
return 1
|
|
174
221
|
ff.stdin.close()
|
|
175
222
|
rc = ff.wait()
|
|
176
223
|
if rc != 0:
|
|
177
224
|
print(f'ffmpeg falhou (exit {rc})', file=sys.stderr)
|
|
178
|
-
return
|
|
225
|
+
return 1
|
|
226
|
+
success = True
|
|
227
|
+
except KeyboardInterrupt:
|
|
228
|
+
print('cutout interrompido pelo usuário', file=sys.stderr)
|
|
229
|
+
return 130
|
|
179
230
|
except BrokenPipeError:
|
|
180
231
|
print('ffmpeg encerrou antes do fim dos frames', file=sys.stderr)
|
|
181
232
|
return 1
|
|
233
|
+
except Exception as exc: # noqa: BLE001 — falha do motor vira exit != 0
|
|
234
|
+
print(f'falha no cutout: {exc}', file=sys.stderr)
|
|
235
|
+
return 1
|
|
182
236
|
finally:
|
|
237
|
+
if ff is not None:
|
|
238
|
+
try:
|
|
239
|
+
ff.stdin.close()
|
|
240
|
+
except (OSError, BrokenPipeError, ValueError):
|
|
241
|
+
pass
|
|
242
|
+
if ff.poll() is None:
|
|
243
|
+
ff.terminate()
|
|
244
|
+
try:
|
|
245
|
+
ff.wait(timeout=5)
|
|
246
|
+
except subprocess.TimeoutExpired:
|
|
247
|
+
ff.kill()
|
|
248
|
+
ff.wait()
|
|
249
|
+
if not success:
|
|
250
|
+
Path(args.output).unlink(missing_ok=True)
|
|
183
251
|
cap.release()
|
|
184
252
|
pack.release()
|
|
185
253
|
|
package/scripts/dag_validator.js
CHANGED
|
@@ -4,9 +4,39 @@ import { resolve } from 'node:path';
|
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import process from 'node:process';
|
|
6
6
|
|
|
7
|
+
const INVALID_INPUT = 'DAG must be an array of tasks or an object with a tasks array';
|
|
8
|
+
|
|
7
9
|
// ponytail: in-memory Kahn algorithm; upgrade to streaming DAG for 100k+ nodes
|
|
8
|
-
export function validateDAG(
|
|
9
|
-
|
|
10
|
+
export function validateDAG(input = []) {
|
|
11
|
+
const tasks = Array.isArray(input) ? input : (Array.isArray(input?.tasks) ? input.tasks : null);
|
|
12
|
+
if (!tasks) return { valid: false, cycles: [], missing_dependencies: [], waves: [], errors: [INVALID_INPUT] };
|
|
13
|
+
|
|
14
|
+
const errors = [];
|
|
15
|
+
const seen = new Set();
|
|
16
|
+
tasks.forEach((t, i) => {
|
|
17
|
+
if (!t || typeof t !== 'object' || Array.isArray(t)) {
|
|
18
|
+
errors.push(`Task ${i}: must be an object`);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (typeof t.id !== 'string' || t.id.trim().length === 0) {
|
|
22
|
+
errors.push(`Task ${i}: id must be a non-empty string`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (seen.has(t.id)) errors.push(`Task ${i}: duplicate id "${t.id}"`);
|
|
26
|
+
seen.add(t.id);
|
|
27
|
+
if (t.depends_on === undefined) return;
|
|
28
|
+
if (!Array.isArray(t.depends_on)) {
|
|
29
|
+
errors.push(`Task "${t.id}": depends_on must be an array of strings`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
t.depends_on.forEach((dep) => {
|
|
33
|
+
if (typeof dep !== 'string' || dep.trim().length === 0) {
|
|
34
|
+
errors.push(`Task "${t.id}": depends_on must contain non-empty strings`);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
if (errors.length > 0) return { valid: false, cycles: [], missing_dependencies: [], waves: [], errors };
|
|
10
40
|
|
|
11
41
|
const inDegree = new Map();
|
|
12
42
|
const dependents = new Map();
|
|
@@ -48,7 +78,7 @@ export function validateDAG(tasks = []) {
|
|
|
48
78
|
const valid = processed === tasks.length && missing_dependencies.length === 0;
|
|
49
79
|
const cycles = valid ? [] : tasks.filter((t) => (inDegree.get(t.id) || 0) > 0).map((t) => t.id);
|
|
50
80
|
|
|
51
|
-
return { valid, cycles, missing_dependencies, waves };
|
|
81
|
+
return { valid, cycles, missing_dependencies, waves, errors };
|
|
52
82
|
}
|
|
53
83
|
|
|
54
84
|
export default validateDAG;
|
|
@@ -66,6 +96,11 @@ Validates DAG acyclicity and computes topological execution waves.`);
|
|
|
66
96
|
process.exit(0);
|
|
67
97
|
}
|
|
68
98
|
|
|
99
|
+
if (!process.argv[2] && process.stdin.isTTY) {
|
|
100
|
+
console.error('Usage: node scripts/dag_validator.js <tasks.json> (or pipe JSON via stdin)');
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
|
|
69
104
|
try {
|
|
70
105
|
const raw = process.argv[2] ? readFileSync(process.argv[2], 'utf8') : readFileSync(0, 'utf8');
|
|
71
106
|
const result = validateDAG(JSON.parse(raw));
|
package/scripts/lint.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import
|
|
4
|
+
import os from 'node:os';
|
|
5
5
|
import process from 'node:process';
|
|
6
|
+
import { execFileSync } from 'node:child_process';
|
|
6
7
|
import { fileURLToPath } from 'node:url';
|
|
7
8
|
|
|
8
9
|
const repoRoot = fileURLToPath(new URL('..', import.meta.url));
|
|
9
10
|
const targetDirs = ['bin', 'src', 'scripts', 'tests'];
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
// ponytail: synchronous recursive walk; upgrade to stream/worker pipeline for repos >100k files
|
|
13
|
+
function collectFiles(dir, suffix) {
|
|
12
14
|
const fullPath = path.join(repoRoot, dir);
|
|
13
15
|
if (!fs.existsSync(fullPath)) return [];
|
|
14
16
|
const entries = fs.readdirSync(fullPath, { withFileTypes: true });
|
|
@@ -16,18 +18,20 @@ function collectJsFiles(dir) {
|
|
|
16
18
|
for (const entry of entries) {
|
|
17
19
|
const entryPath = path.join(fullPath, entry.name);
|
|
18
20
|
if (entry.isDirectory()) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
if (['node_modules', '__pycache__', '.git'].includes(entry.name)) continue;
|
|
22
|
+
files.push(...collectFiles(path.relative(repoRoot, entryPath), suffix));
|
|
23
|
+
} else if (entry.isFile() && entry.name.endsWith(suffix)) {
|
|
21
24
|
files.push(entryPath);
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
27
|
return files;
|
|
25
28
|
}
|
|
26
29
|
|
|
27
|
-
const
|
|
30
|
+
const jsFiles = targetDirs.flatMap((dir) => collectFiles(dir, '.js'));
|
|
31
|
+
const pyFiles = targetDirs.flatMap((dir) => collectFiles(dir, '.py'));
|
|
28
32
|
|
|
29
33
|
let failed = 0;
|
|
30
|
-
for (const file of
|
|
34
|
+
for (const file of jsFiles) {
|
|
31
35
|
try {
|
|
32
36
|
execFileSync(process.execPath, ['--check', file], { stdio: 'inherit' });
|
|
33
37
|
} catch {
|
|
@@ -35,9 +39,45 @@ for (const file of allJsFiles) {
|
|
|
35
39
|
}
|
|
36
40
|
}
|
|
37
41
|
|
|
42
|
+
function findPython() {
|
|
43
|
+
for (const cmd of ['python3', 'python']) {
|
|
44
|
+
try {
|
|
45
|
+
execFileSync(cmd, ['--version'], { stdio: 'ignore' });
|
|
46
|
+
return cmd;
|
|
47
|
+
} catch {}
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const python = pyFiles.length > 0 ? findPython() : null;
|
|
53
|
+
if (python) {
|
|
54
|
+
// py_compile grava bytecode; o prefixo mantém a árvore limpa.
|
|
55
|
+
const pycache = path.join(os.tmpdir(), 'esquadrao-lint-pycache');
|
|
56
|
+
for (const file of pyFiles) {
|
|
57
|
+
try {
|
|
58
|
+
execFileSync(python, ['-m', 'py_compile', file], {
|
|
59
|
+
stdio: 'inherit',
|
|
60
|
+
env: { ...process.env, PYTHONPYCACHEPREFIX: pycache },
|
|
61
|
+
});
|
|
62
|
+
} catch {
|
|
63
|
+
failed++;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
38
68
|
if (failed > 0) {
|
|
39
69
|
console.error(`Lint check failed: ${failed} file(s) with syntax errors.`);
|
|
40
70
|
process.exit(1);
|
|
41
71
|
}
|
|
42
72
|
|
|
43
|
-
|
|
73
|
+
if (pyFiles.length > 0 && !python && process.env.CI) {
|
|
74
|
+
console.error(`Lint check failed: Python interpreter not found; cannot validate ${pyFiles.length} .py file(s).`);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
console.log(`Lint passed: verified ${jsFiles.length} files with node --check.`);
|
|
79
|
+
if (python) {
|
|
80
|
+
console.log(`Lint passed: verified ${pyFiles.length} Python files with py_compile.`);
|
|
81
|
+
} else if (pyFiles.length > 0) {
|
|
82
|
+
console.warn(`Lint skipped: Python interpreter not found; ${pyFiles.length} .py file(s) not checked.`);
|
|
83
|
+
}
|
package/scripts/merkle_verify.js
CHANGED
|
@@ -14,7 +14,7 @@ export function canonicalStringify(val) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export function computeBlockHash(block) {
|
|
17
|
-
if (!block || typeof block !== 'object') return '';
|
|
17
|
+
if (!block || typeof block !== 'object' || Array.isArray(block)) return '';
|
|
18
18
|
const { hash: _, ...payload } = block;
|
|
19
19
|
return createHash('sha256').update(canonicalStringify(payload)).digest('hex');
|
|
20
20
|
}
|
|
@@ -71,6 +71,11 @@ Validates cryptographic hash continuity and payload integrity across blocks.`);
|
|
|
71
71
|
process.exit(0);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
if (!process.argv[2] && process.stdin.isTTY) {
|
|
75
|
+
console.error('Usage: node scripts/merkle_verify.js <ledger.json> (or pipe JSON via stdin)');
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
|
|
74
79
|
try {
|
|
75
80
|
const raw = process.argv[2] ? readFileSync(process.argv[2], 'utf8') : readFileSync(0, 'utf8');
|
|
76
81
|
const result = verifyLedger(JSON.parse(raw));
|
|
@@ -69,6 +69,8 @@ O usuário escolhe uma pasta no computador para ser seu repositório/workspace p
|
|
|
69
69
|
# Dentro da pasta do seu projeto/workspace
|
|
70
70
|
esquadrao setup
|
|
71
71
|
```
|
|
72
|
+
> **Persistência de Perfil:** O perfil do workspace fica em `<workspace>/.esquadrao/profile.json` (espelho em `studio.json`). Sem `--dest`, o CLI descobre o workspace subindo a partir do diretório atual até encontrar `studio.json`.
|
|
73
|
+
|
|
72
74
|
> **Acervo de Apoio:** Os packs de vídeos e imagens adquiridos na plataforma devem ser descompactados e mantidos dentro dessa mesma pasta de trabalho (ex.: `./packs/`), garantindo acesso imediato aos agentes para cortes e B-rolls.
|
|
73
75
|
|
|
74
76
|
### Passo 4: Inicialização do Estúdio
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Composições especiais: split permanente e recorte de pessoa
|
|
2
2
|
|
|
3
|
-
Status: **implementado no CLI 1.
|
|
3
|
+
Status: **implementado no CLI 1.7.0**. O split permanente está operacional; o recorte de pessoa é experimental e depende de Python.
|
|
4
4
|
|
|
5
5
|
## 1. Split permanente (orador no topo + pack na base)
|
|
6
6
|
|
|
@@ -52,7 +52,7 @@ esquadrao studio cutout entrada.mp4 \
|
|
|
52
52
|
Pré-requisitos no interpretador Python escolhido:
|
|
53
53
|
|
|
54
54
|
```bash
|
|
55
|
-
python3 -m pip install "rembg[cpu]" onnxruntime opencv-python-headless numpy
|
|
55
|
+
python3 -m pip install "rembg[cpu]" onnxruntime opencv-python-headless numpy pillow
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
Regras:
|
|
@@ -88,7 +88,7 @@ Critérios de aceite:
|
|
|
88
88
|
|
|
89
89
|
## 3. Regra de comunicação
|
|
90
90
|
|
|
91
|
-
- Pode afirmar que o CLI 1.
|
|
91
|
+
- Pode afirmar que o CLI 1.7.0 faz split permanente e cutout, **desde que** qualifique o cutout como experimental e informe as dependências Python e o custo de CPU.
|
|
92
92
|
- Não prometa tempo real, qualidade de estúdio ou ausência total de halo.
|
|
93
93
|
- `split_top` e ducking dinâmico foram entregues em 1.7.0; o cutout segue experimental.
|
|
94
94
|
|
|
@@ -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: 96 testes (94 aprovados + 2 skips condicionais), lint em 40 arquivos.
|
|
@@ -4,22 +4,16 @@ Guia para Windows / PowerShell: instalar, escolher proporção, configurar corte
|
|
|
4
4
|
|
|
5
5
|
## 1. Pré-requisitos e instalação
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Basta Node.js 18 ou superior. O FFmpeg e o ffprobe vêm embutidos no pacote: não instale
|
|
8
|
+
nada por `winget`/`choco`, não edite o PATH e não abra outro terminal.
|
|
8
9
|
|
|
9
10
|
```powershell
|
|
10
11
|
node --version
|
|
11
12
|
npm --version
|
|
12
|
-
|
|
13
|
-
ffprobe -version
|
|
13
|
+
npx @esquadrao/cli setup
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
```powershell
|
|
19
|
-
winget install --id Gyan.FFmpeg -e
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
Abra um novo PowerShell após instalar para atualizar o PATH.
|
|
16
|
+
O `setup` confirma o ambiente e mostra se o FFmpeg embutido está disponível.
|
|
23
17
|
|
|
24
18
|
Se você já tem o repositório clonado, defina o caminho absoluto para `bin\cli.js`:
|
|
25
19
|
|
|
@@ -176,9 +170,29 @@ $plano.captions[1].timeline_start_ms = 4000
|
|
|
176
170
|
$plano.captions[1].duration_ms = 4000
|
|
177
171
|
```
|
|
178
172
|
|
|
179
|
-
Use frases curtas de até 200 caracteres, sem HTML, com início e duração dentro do vídeo final.
|
|
173
|
+
Use frases curtas de até 200 caracteres, sem HTML, com início e duração dentro do vídeo final. As legendas ficam gravadas na imagem; o modo `dark` posiciona seus textos no centro da tela.
|
|
174
|
+
|
|
175
|
+
O `EditPlan` aceita `"caption_template": "<id>"` na raiz como padrão e `"template": "<id>"` em cada item de `captions[]` como sobrescrita. Exemplo:
|
|
176
|
+
|
|
177
|
+
```json
|
|
178
|
+
{
|
|
179
|
+
"caption_template": "mrbeast-yellow",
|
|
180
|
+
"captions": [
|
|
181
|
+
{
|
|
182
|
+
"text": "Sua primeira frase",
|
|
183
|
+
"timeline_start_ms": 0,
|
|
184
|
+
"duration_ms": 4000,
|
|
185
|
+
"template": "heavy-white"
|
|
186
|
+
}
|
|
187
|
+
]
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Os nove presets têm os nomes de referência `mrbeast_yellow`, `tiktok_white`, `gold_stroke`, `green_stroke`, `neon_glitch`, `minimal_lower_third`, `red_stroke`, `heavy_white` e `mono_clean`. No CLI 1.7.0, os IDs canônicos retornados e aceitos usam hífen: `mrbeast-yellow`, `tiktok-white`, `gold-stroke`, `green-stroke`, `neon-glitch`, `minimal-lower-third`, `red-stroke`, `heavy-white` e `mono-clean`. Consulte o catálogo real com `node $cli studio caption-templates --json`.
|
|
192
|
+
|
|
193
|
+
O renderizador usa as fontes Anton, Bebas Neue e Poppins empacotadas em `assets/fonts`, com fallback para fontes do sistema quando necessário. Os templates aplicam quebra automática de linha e mantêm o bloco vertical compacto: a linha seguinte fica em `lineGap * font_size`, sem abrir um vão proporcional à altura do vídeo.
|
|
180
194
|
|
|
181
|
-
|
|
195
|
+
Este guia demonstra a montagem manual do `editplan.json`. A importação de `.srt` por `--captions <arquivo.srt>` já está disponível, assim como a transcrição automática por `studio transcribe` e `studio auto-clip` com `--local` ou, mediante a escolha explícita do usuário e `OPENAI_API_KEY`, `--openai`.
|
|
182
196
|
|
|
183
197
|
Para remover as legendas, use `$plano.captions = @()`.
|
|
184
198
|
|
|
@@ -24,16 +24,12 @@ Envie uma mensagem amigável e direta coletando as decisões essenciais:
|
|
|
24
24
|
> *3. Qual é o arquivo de vídeo que vamos usar de fonte?"*
|
|
25
25
|
|
|
26
26
|
### Fase 2: Checagem de Ambiente
|
|
27
|
-
Antes de criar arquivos,
|
|
27
|
+
Antes de criar arquivos, confirme apenas o Node.js:
|
|
28
28
|
```bash
|
|
29
29
|
node -v
|
|
30
|
-
|
|
31
|
-
ffprobe -version
|
|
30
|
+
esquadrao setup --json
|
|
32
31
|
```
|
|
33
|
-
|
|
34
|
-
- **Windows:** `winget install Gyan.FFmpeg`
|
|
35
|
-
- **macOS:** `brew install ffmpeg`
|
|
36
|
-
- **Linux:** `sudo apt update && sudo apt install -y ffmpeg`
|
|
32
|
+
O FFmpeg e o ffprobe vêm embutidos no pacote (`ffmpeg-static` 5.2.0 e `ffprobe-static`) e são resolvidos automaticamente. **Nunca instrua o usuário a instalar FFmpeg**, usar `sudo`, `brew`, `winget` ou `apt`: o `setup` reporta a origem resolvida (`bundled`, `cache` ou `system`).
|
|
37
33
|
|
|
38
34
|
### Fase 3: Preparação do Workspace
|
|
39
35
|
Execute no terminal:
|
|
@@ -122,7 +118,7 @@ O comando emite o resumo com total de silêncio expurgado, quantidade de cortes
|
|
|
122
118
|
|
|
123
119
|
| Erro Observado | Causa Raiz | Ação Corretiva Determinística |
|
|
124
120
|
| :--- | :--- | :--- |
|
|
125
|
-
| `ffmpeg is not installed` | Binário
|
|
121
|
+
| `ffmpeg is not installed` | Binário embutido não resolvido (pacote corrompido ou instalação parcial) | Reinstalar o pacote (`npm install -g @esquadrao/cli`) e rodar `esquadrao setup`; nunca instalar FFmpeg no sistema. |
|
|
126
122
|
| `out_ms exceeds asset duration` | Ponto de saída além do arquivo | Obter duração real com `studio import` e recalcular `out_ms`. |
|
|
127
123
|
| `Missing audio stream in artifact` | Fonte sem áudio ou falha de mix | Garantir `anullsrc` para vídeo mudo ou verificar se o arquivo original tem áudio. |
|
|
128
124
|
| `Caption special characters error` | Caracteres `%` ou `'` na legenda | O motor trata com `\%` e `\'`. Não usar tags HTML em legendas. |
|
package/src/binaries.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Resolve ffmpeg/ffprobe sem exigir instalação manual nem edição de PATH.
|
|
2
|
+
//
|
|
3
|
+
// Ordem: variável de ambiente -> cache do usuário -> binário embutido no pacote
|
|
4
|
+
// (optionalDependencies ffmpeg-static/ffprobe-static) -> PATH do sistema.
|
|
5
|
+
// O diretório encontrado é injetado no PATH do processo, então todo spawn
|
|
6
|
+
// existente continua funcionando sem mudanças.
|
|
7
|
+
|
|
8
|
+
import fs from 'node:fs';
|
|
9
|
+
import os from 'node:os';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { createRequire } from 'node:module';
|
|
12
|
+
|
|
13
|
+
const require = createRequire(import.meta.url);
|
|
14
|
+
const EXE = process.platform === 'win32' ? '.exe' : '';
|
|
15
|
+
const TARGET = `${process.platform}-${process.arch}`;
|
|
16
|
+
|
|
17
|
+
export const BINARY_CACHE = path.join(os.homedir(), '.esquadrao', 'bin', TARGET);
|
|
18
|
+
|
|
19
|
+
const ENV_KEYS = { ffmpeg: 'ESQUADRAO_FFMPEG', ffprobe: 'ESQUADRAO_FFPROBE' };
|
|
20
|
+
|
|
21
|
+
function fromPackage(name) {
|
|
22
|
+
try {
|
|
23
|
+
if (name === 'ffmpeg') {
|
|
24
|
+
const resolved = require('ffmpeg-static');
|
|
25
|
+
return typeof resolved === 'string' && fs.existsSync(resolved) ? resolved : null;
|
|
26
|
+
}
|
|
27
|
+
const resolved = require('ffprobe-static');
|
|
28
|
+
return resolved?.path && fs.existsSync(resolved.path) ? resolved.path : null;
|
|
29
|
+
} catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Caminho utilizável para um binário, com a origem da resolução. */
|
|
35
|
+
export function resolveBinary(name) {
|
|
36
|
+
if (!ENV_KEYS[name]) throw new Error(`Binário desconhecido: ${name}`);
|
|
37
|
+
|
|
38
|
+
const override = process.env[ENV_KEYS[name]];
|
|
39
|
+
if (override && fs.existsSync(override)) return { path: override, source: 'env' };
|
|
40
|
+
|
|
41
|
+
const cached = path.join(BINARY_CACHE, `${name}${EXE}`);
|
|
42
|
+
if (fs.existsSync(cached)) return { path: cached, source: 'cache' };
|
|
43
|
+
|
|
44
|
+
const bundled = fromPackage(name);
|
|
45
|
+
if (bundled) return { path: bundled, source: 'bundled' };
|
|
46
|
+
|
|
47
|
+
return { path: name, source: 'path' };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Injeta os binários embutidos no PATH do processo. Silencioso e idempotente. */
|
|
51
|
+
export function ensureBundledPath() {
|
|
52
|
+
const dirs = new Set();
|
|
53
|
+
for (const name of ['ffmpeg', 'ffprobe']) {
|
|
54
|
+
const { path: binary, source } = resolveBinary(name);
|
|
55
|
+
if (source !== 'path') dirs.add(path.dirname(binary));
|
|
56
|
+
}
|
|
57
|
+
if (dirs.size === 0) return null;
|
|
58
|
+
|
|
59
|
+
const prefix = [...dirs].join(path.delimiter);
|
|
60
|
+
if (!process.env.PATH?.startsWith(prefix)) {
|
|
61
|
+
process.env.PATH = `${prefix}${path.delimiter}${process.env.PATH || ''}`;
|
|
62
|
+
}
|
|
63
|
+
return prefix;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Relatório curto para `setup`/`doctor`, sem executar os binários. */
|
|
67
|
+
export function binaryReport() {
|
|
68
|
+
return Object.fromEntries(
|
|
69
|
+
['ffmpeg', 'ffprobe'].map((name) => {
|
|
70
|
+
const resolved = resolveBinary(name);
|
|
71
|
+
return [name, resolved.source === 'path' ? { source: 'system', path: null } : resolved];
|
|
72
|
+
})
|
|
73
|
+
);
|
|
74
|
+
}
|
package/src/captionTemplates.js
CHANGED
|
@@ -149,7 +149,8 @@ export const CAPTION_TEMPLATES = Object.freeze([
|
|
|
149
149
|
]);
|
|
150
150
|
|
|
151
151
|
export function getCaptionTemplate(id) {
|
|
152
|
-
|
|
152
|
+
// Accept the underscore spelling documented in the guides (mrbeast_yellow) as an alias of the canonical id.
|
|
153
|
+
const key = String(id || '').trim().toLowerCase().replace(/_/g, '-');
|
|
153
154
|
const template = CAPTION_TEMPLATES.find((item) => item.id === key);
|
|
154
155
|
if (!template) {
|
|
155
156
|
throw new Error(`Unknown caption template '${id}'. Available: ${CAPTION_TEMPLATES.map((item) => item.id).join(', ')}`);
|
package/src/commands/onboard.js
CHANGED
|
@@ -9,6 +9,7 @@ import { stdin as defaultInput, stdout as defaultOutput } from 'node:process';
|
|
|
9
9
|
import {
|
|
10
10
|
checkBinary,
|
|
11
11
|
findSystemFont,
|
|
12
|
+
findWorkspaceDir,
|
|
12
13
|
run as studioRun,
|
|
13
14
|
buildCaptionFilters,
|
|
14
15
|
buildClipFilters,
|
|
@@ -17,14 +18,8 @@ import {
|
|
|
17
18
|
import { tryAutoInstallFfmpeg } from './setup.js';
|
|
18
19
|
import { validateEditPlan } from '../roles/mediaProducer.js';
|
|
19
20
|
|
|
20
|
-
export function getFfmpegInstallInstructions(
|
|
21
|
-
|
|
22
|
-
return 'winget install Gyan.FFmpeg (or: choco install ffmpeg)';
|
|
23
|
-
}
|
|
24
|
-
if (platform === 'darwin') {
|
|
25
|
-
return 'brew install ffmpeg';
|
|
26
|
-
}
|
|
27
|
-
return 'sudo apt install ffmpeg (Debian/Ubuntu) or your package manager';
|
|
21
|
+
export function getFfmpegInstallInstructions() {
|
|
22
|
+
return 'o FFmpeg já vem embutido no Esquadrão. Rode "esquadrao setup" para restaurá-lo.';
|
|
28
23
|
}
|
|
29
24
|
|
|
30
25
|
export function detectEnvironment() {
|
|
@@ -34,21 +29,17 @@ export function detectEnvironment() {
|
|
|
34
29
|
}
|
|
35
30
|
|
|
36
31
|
let hasFfmpeg = checkBinary('ffmpeg') && checkBinary('ffprobe');
|
|
37
|
-
|
|
38
|
-
if (!hasFfmpeg) {
|
|
39
|
-
autoInstalledFfmpeg = tryAutoInstallFfmpeg();
|
|
40
|
-
hasFfmpeg = checkBinary('ffmpeg') && checkBinary('ffprobe');
|
|
41
|
-
}
|
|
32
|
+
if (!hasFfmpeg) hasFfmpeg = tryAutoInstallFfmpeg();
|
|
42
33
|
|
|
43
34
|
if (!hasFfmpeg) {
|
|
44
35
|
const missing = [!checkBinary('ffmpeg') && 'ffmpeg', !checkBinary('ffprobe') && 'ffprobe'].filter(Boolean).join(' and ');
|
|
45
36
|
throw new Error(
|
|
46
|
-
`${missing}
|
|
37
|
+
`${missing} não foi encontrado. ${getFfmpegInstallInstructions()}`
|
|
47
38
|
);
|
|
48
39
|
}
|
|
49
40
|
|
|
50
41
|
const font = findSystemFont();
|
|
51
|
-
return { nodeVersion: process.versions.node, ffmpeg: true,
|
|
42
|
+
return { nodeVersion: process.versions.node, ffmpeg: true, font };
|
|
52
43
|
}
|
|
53
44
|
|
|
54
45
|
export function loadProfile(dir) {
|
|
@@ -344,7 +335,7 @@ Options:
|
|
|
344
335
|
try {
|
|
345
336
|
// 2. Directory Resolution
|
|
346
337
|
let targetDir = flags.dest || positionals[0];
|
|
347
|
-
const cwdProfile = loadProfile(
|
|
338
|
+
const cwdProfile = loadProfile(findWorkspaceDir());
|
|
348
339
|
|
|
349
340
|
if (!targetDir && cwdProfile?.default_dir) {
|
|
350
341
|
targetDir = cwdProfile.default_dir;
|