agentcut 0.2.18 → 0.2.20

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.
@@ -0,0 +1,10 @@
1
+ import type { WorkspacePaths } from "./workspace.js";
2
+ export declare const resizeRunning: () => boolean;
3
+ export declare const resizeSlug: () => string | null;
4
+ export declare function cancelResize(): void;
5
+ export declare function resizeSource(paths: WorkspacePaths, slug: string, path: string): string;
6
+ export declare function resizeRender(paths: WorkspacePaths, slug: string, path: string, resolutionValue: unknown, qualityValue: unknown): Promise<{
7
+ path: string;
8
+ bytes: number;
9
+ originalBytes: number;
10
+ }>;
@@ -0,0 +1,96 @@
1
+ import { spawn } from "node:child_process";
2
+ import { randomUUID } from "node:crypto";
3
+ import { mkdirSync, realpathSync, renameSync, statSync, unlinkSync } from "node:fs";
4
+ import { basename, join, sep } from "node:path";
5
+ import { ensureFfmpeg } from "./references.js";
6
+ import { projectDir, uniquePath } from "./projects.js";
7
+ import { exportResolution } from "./export-resolution.js";
8
+ import { exportQuality } from "./export-quality.js";
9
+ import { saveRenderDuration } from "./render-metadata.js";
10
+ import { debugLog } from "../log.js";
11
+ let busy = false;
12
+ let activeSlug = null;
13
+ let child = null;
14
+ let cancelled = false;
15
+ export const resizeRunning = () => busy;
16
+ export const resizeSlug = () => activeSlug;
17
+ export function cancelResize() { cancelled = true; child?.kill(); }
18
+ export function resizeSource(paths, slug, path) {
19
+ if (!/^renders\/[^/\\:\x00]+\.mp4$/i.test(path))
20
+ throw new Error("Choose an MP4 in this project's renders folder.");
21
+ const project = realpathSync(projectDir(paths, slug));
22
+ if (!project.startsWith(realpathSync(paths.projects) + sep))
23
+ throw new Error("The project must be inside the workspace.");
24
+ const root = realpathSync(join(project, "renders"));
25
+ const source = realpathSync(join(project, path));
26
+ if (!root.startsWith(project + sep) || !source.startsWith(root + sep) || !statSync(source).isFile()) {
27
+ throw new Error("The video must be inside this project's renders folder.");
28
+ }
29
+ return source;
30
+ }
31
+ export async function resizeRender(paths, slug, path, resolutionValue, qualityValue) {
32
+ if (busy)
33
+ throw new Error("A smaller copy is already being created. Wait for it to finish.");
34
+ const resolution = exportResolution(resolutionValue);
35
+ if (resolution === "project")
36
+ throw new Error("Choose 1080p or 720p for the smaller copy.");
37
+ const quality = exportQuality(qualityValue);
38
+ const source = resizeSource(paths, slug, path);
39
+ const originalBytes = statSync(source).size;
40
+ busy = true;
41
+ activeSlug = slug;
42
+ cancelled = false;
43
+ const started = performance.now();
44
+ const workDir = join(paths.internal, "resize");
45
+ const temp = join(workDir, `${randomUUID()}.mp4`);
46
+ try {
47
+ mkdirSync(workDir, { recursive: true });
48
+ const ffmpeg = await ensureFfmpeg();
49
+ if (cancelled)
50
+ throw new Error("Resize cancelled.");
51
+ const limit = resolution === "1080p" ? 1080 : 720;
52
+ const factor = `min(1,${limit}/min(iw,ih))`;
53
+ const filter = `scale=w='max(2,trunc(iw*${factor}/2)*2)':h='max(2,trunc(ih*${factor}/2)*2)'`;
54
+ await new Promise((resolve, reject) => {
55
+ child = spawn(ffmpeg, ["-hide_banner", "-nostdin", "-loglevel", "error", "-n", "-i", source,
56
+ "-map", "0:v:0", "-map", "0:a?", "-vf", filter, "-c:v", "libx264", "-crf", quality === "maximum" ? "18" : "20",
57
+ "-preset", "slow", "-threads", "4", "-pix_fmt", "yuv420p", "-c:a", "copy", "-movflags", "+faststart", temp], { windowsHide: true, stdio: ["ignore", "ignore", "pipe"] });
58
+ let error = "";
59
+ child.stderr?.on("data", (chunk) => { error = (error + String(chunk)).slice(-2000); });
60
+ const timeout = setTimeout(() => { cancelled = true; child?.kill(); }, 2 * 60 * 60_000);
61
+ child.on("error", (err) => { clearTimeout(timeout); reject(err); });
62
+ child.on("close", (code) => {
63
+ clearTimeout(timeout);
64
+ if (cancelled)
65
+ reject(new Error("Resize stopped. The original video is unchanged."));
66
+ else if (code !== 0)
67
+ reject(new Error(`Could not resize the video: ${error}`));
68
+ else
69
+ resolve();
70
+ });
71
+ });
72
+ const bytes = statSync(temp).size;
73
+ if (!bytes || bytes >= originalBytes)
74
+ throw new Error("These settings did not make a smaller file. Try 720p or High quality, smaller file. The original is unchanged.");
75
+ const output = uniquePath(join(projectDir(paths, slug), "renders", `${basename(source).replace(/\.mp4$/i, "")}-${resolution}-smaller.mp4`));
76
+ renameSync(temp, output);
77
+ try {
78
+ saveRenderDuration(output, performance.now() - started);
79
+ }
80
+ catch (error) {
81
+ // Timing is optional; the completed video must still be returned.
82
+ debugLog(`Could not save resize time: ${String(error)}`);
83
+ }
84
+ return { path: `renders/${basename(output)}`, bytes, originalBytes };
85
+ }
86
+ finally {
87
+ try {
88
+ unlinkSync(temp);
89
+ }
90
+ catch { }
91
+ child = null;
92
+ busy = false;
93
+ activeSlug = null;
94
+ }
95
+ }
96
+ //# sourceMappingURL=resize-render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resize-render.js","sourceRoot":"","sources":["../../src/studio/resize-render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,IAAI,IAAI,GAAG,KAAK,CAAC;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AG,IAAI,CAAC;QACb,IAAI,GAAG,KAAK,CAAC;QACb,UAAU,GAAG,IAAI,CAAC;IACpB,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentcut",
3
- "version": "0.2.18",
3
+ "version": "0.2.20",
4
4
  "description": "Local helper for Agentcut: runs your coding agent (Claude Code or Codex), your video workspace and live preview bundles for the Agentcut studio page.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -5,6 +5,13 @@ description: "Create and edit videos in an Agentcut workspace, including website
5
5
 
6
6
  # Agentcut
7
7
 
8
+ ## Phone editing modes
9
+
10
+ For phone requests with Social video or Light cleanup selected, read
11
+ `references/social-video.md`. Its scope and format rules apply to that phone job.
12
+ The written request takes priority over mode and visual style. Desktop edits keep their
13
+ existing defaults unless the user selects this workflow.
14
+
8
15
  ## External MCP agents
9
16
 
10
17
  Use the same creative and review workflow whether you work inside Agentcut or through MCP.
@@ -0,0 +1,60 @@
1
+ # Phone editing modes
2
+
3
+ Use this guide when the phone edit prompt selects Social video or Light cleanup.
4
+ The user's written request sets the scope and overrides the mode and visual style.
5
+ For “only trim the end”, trim the end and check that cut. Do not apply a full makeover.
6
+ Keep source media, cuts, captions and graphics editable in the existing project format.
7
+ Use the selected output size; the helper scales the render. Keep the source aspect ratio
8
+ unless the user asks for a different format. Do not create extra formats by default.
9
+
10
+ ## Social video
11
+
12
+ Read the transcript and inspect the footage before choosing cuts. Reuse the built-in
13
+ transcription cache and follow references/transcription.md and references/footage.md.
14
+ Find one clear message. Choose a strong, complete opening already present in the footage.
15
+ Reorder only when the meaning and context remain accurate. Do not invent a claim or hook.
16
+ Remove verified false starts, repeated takes, recording directions and long empty gaps.
17
+ Confirm ambiguous words and suspected mistakes by listening before removing them.
18
+ Keep natural breaths, complete words and enough pauses to understand the speaker.
19
+ Do not impose a fixed cut interval, duration, zoom pattern or number of effects.
20
+
21
+ Use readable captions for speech, unless the user says otherwise. Fix transcription
22
+ errors from the audio. Anchor each cue to the exact word occurrence, not the first match
23
+ for a repeated word. Re-map source times after cuts; check that cues follow the kept take.
24
+ Add graphics only when they explain the current idea. Keep faces and important content
25
+ visible and place text inside safe areas. Use relevant real assets. Do not force b-roll,
26
+ music, intro cards, a call to action, or a split-screen layout into every video.
27
+ Use music only when it helps and an available licensed track fits. Keep speech clear.
28
+
29
+ ## Light cleanup
30
+
31
+ Preserve the sequence and visual treatment. Remove clear mistakes, duplicate takes and
32
+ excessive empty gaps. Keep natural pauses. Do not add captions, graphics, music or a new
33
+ opening unless requested. The style choice affects only visuals the user requests.
34
+
35
+ ## Visual style
36
+
37
+ - Automatic: choose a restrained treatment that suits the footage and existing project.
38
+ - Clean: simple type, few accents, quiet transitions, limited motion.
39
+ - Bold: strong type and contrast, selective emphasis on key words; avoid constant motion.
40
+
41
+ These are directions, not saved style IDs. If the user names an existing saved style,
42
+ read references/editing-styles.md and use that style within the requested scope.
43
+ Mode controls the editing decisions; style controls their appearance.
44
+
45
+ ## Final review
46
+
47
+ Review the edited timeline with the available audio and visual tools, not only the source.
48
+ Listen across changed speech boundaries and check the start and end for clipped words.
49
+ Check caption timing after cuts, repeated words, readability and safe areas. Inspect
50
+ frames at graphics transitions and the opening and ending. Check audio levels and that
51
+ music does not mask speech. Inspect the final project at its selected aspect ratio.
52
+ Follow references/craft.md for the available capture and sound checks.
53
+
54
+ Write a short review in notes.md: what changed, checks actually performed, timeline
55
+ timestamps for evidence, and any unresolved issue. Mark checks that could not be performed
56
+ as unverified. Fix material defects and check again. If a required check cannot be performed
57
+ or a material defect remains, write a failed phone-edit-result.json with the reason.
58
+ Only write the complete receipt after the requested edit and required checks succeed.
59
+ Do not assign a viral score or promise engagement. This review records evidence, not a
60
+ guarantee of audience performance.