@hadialmarzooq/agent-media-cli 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Hadi Almarzooq
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+
4
+ declare function createProgram(): Command;
5
+
6
+ export { createProgram };
package/dist/index.js ADDED
@@ -0,0 +1,178 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import { realpathSync } from "fs";
5
+ import { readFile, writeFile } from "fs/promises";
6
+ import { createRequire } from "module";
7
+ import { fileURLToPath } from "url";
8
+ import { Command } from "commander";
9
+ import {
10
+ MediaError,
11
+ parsePlan,
12
+ planMedia,
13
+ serializePlan,
14
+ verifyMedia
15
+ } from "@hadialmarzooq/agent-media-core";
16
+ import {
17
+ executePlan,
18
+ getCapabilities,
19
+ inspectMedia,
20
+ makeVertical,
21
+ optimizeForWeb,
22
+ normalize,
23
+ extractAudio,
24
+ extractFrame
25
+ } from "@hadialmarzooq/agent-media-ffmpeg";
26
+ var packageVersion = createRequire(import.meta.url)("../package.json").version;
27
+ function createProgram() {
28
+ const program = new Command();
29
+ program.name("agent-media").description("Deterministic semantic media transformations.").version(packageVersion);
30
+ program.command("inspect <input>").description("Inspect media metadata.").action(async (input) => print(await inspectMedia(input)));
31
+ program.command("capabilities").description("Detect local FFmpeg capabilities.").action(async () => print(await getCapabilities()));
32
+ program.command("plan <input>").description("Create a versioned semantic media plan.").option("--trim-start <seconds>", "trim start in seconds", Number).option("--duration <seconds>", "output duration in seconds", Number).option("--aspect <ratio>", "target aspect ratio, e.g. 9:16").option("--width <pixels>", "target width", Number).option("--height <pixels>", "target height", Number).option("--max-size <mb>", "maximum file size in MB", Number).option("--compatibility <level>", "high or balanced").option("--quality <level>", "high, balanced, or small").option("--remove-audio", "remove audio").option("--out <path>", "write the plan JSON to a file").action(async (input, options) => {
33
+ const plan = planMedia({
34
+ source: await inspectMedia(input),
35
+ goals: {
36
+ trimStartSeconds: options.trimStart,
37
+ durationSeconds: options.duration,
38
+ aspectRatio: options.aspect,
39
+ width: options.width,
40
+ height: options.height,
41
+ maxSizeMB: options.maxSize,
42
+ compatibility: options.compatibility,
43
+ quality: options.quality,
44
+ ...options.removeAudio ? { audio: "remove" } : {}
45
+ },
46
+ capabilities: await getCapabilities()
47
+ });
48
+ const serialized = serializePlan(plan);
49
+ if (options.out !== void 0) await writeFile(options.out, `${serialized}
50
+ `, "utf8");
51
+ print(plan);
52
+ });
53
+ program.command("vertical <input>").description("Create and verify a high-compatibility 9:16 video.").requiredOption("--output <path>", "output media path").option("--width <pixels>", "target width (requires --height)", Number).option("--height <pixels>", "target height (requires --width)", Number).option("--trim-start <seconds>", "trim start in seconds", Number).option("--duration <seconds>", "output duration in seconds", Number).option("--max-size <mb>", "maximum file size in MB", Number).option("--remove-audio", "remove audio").option("--overwrite", "allow output replacement").option("--progress", "write NDJSON progress events to stderr").action(async (input, options) => {
54
+ const onProgress = progressWriter(Boolean(options.progress));
55
+ print(
56
+ await makeVertical({
57
+ input,
58
+ output: options.output,
59
+ width: options.width,
60
+ height: options.height,
61
+ trimStartSeconds: options.trimStart,
62
+ durationSeconds: options.duration,
63
+ maxSizeMB: options.maxSize,
64
+ ...options.removeAudio ? { audio: "remove" } : {},
65
+ overwrite: options.overwrite,
66
+ ...onProgress === void 0 ? {} : { onProgress }
67
+ })
68
+ );
69
+ });
70
+ program.command("optimize <input>").description("Create and verify a web-optimized high-compatibility video.").requiredOption("--output <path>", "output media path").option("--trim-start <seconds>", "trim start in seconds", Number).option("--duration <seconds>", "output duration in seconds", Number).option("--max-size <mb>", "maximum file size in MB", Number).option("--quality <level>", "high, balanced, or small").option("--remove-audio", "remove audio").option("--overwrite", "allow output replacement").option("--progress", "write NDJSON progress events to stderr").action(async (input, options) => {
71
+ const onProgress = progressWriter(Boolean(options.progress));
72
+ print(
73
+ await optimizeForWeb({
74
+ input,
75
+ output: options.output,
76
+ trimStartSeconds: options.trimStart,
77
+ durationSeconds: options.duration,
78
+ maxSizeMB: options.maxSize,
79
+ ...options.quality === void 0 ? {} : { quality: options.quality },
80
+ ...options.removeAudio ? { audio: "remove" } : {},
81
+ overwrite: options.overwrite,
82
+ ...onProgress === void 0 ? {} : { onProgress }
83
+ })
84
+ );
85
+ });
86
+ program.command("normalize <input>").description("Create and verify a normalized high-compatibility copy.").requiredOption("--output <path>", "output media path").option("--trim-start <seconds>", "trim start in seconds", Number).option("--duration <seconds>", "output duration in seconds", Number).option("--remove-audio", "remove audio").option("--overwrite", "allow output replacement").option("--progress", "write NDJSON progress events to stderr").action(async (input, options) => {
87
+ const onProgress = progressWriter(Boolean(options.progress));
88
+ print(
89
+ await normalize({
90
+ input,
91
+ output: options.output,
92
+ trimStartSeconds: options.trimStart,
93
+ durationSeconds: options.duration,
94
+ ...options.removeAudio ? { audio: "remove" } : {},
95
+ overwrite: options.overwrite,
96
+ ...onProgress === void 0 ? {} : { onProgress }
97
+ })
98
+ );
99
+ });
100
+ program.command("extract-audio <input>").description("Extract and verify audio from any media source.").requiredOption("--output <path>", "output audio path").option("--format <format>", "m4a, mp3, or wav").option("--trim-start <seconds>", "trim start in seconds", Number).option("--duration <seconds>", "output duration in seconds", Number).option("--overwrite", "allow output replacement").option("--progress", "write NDJSON progress events to stderr").action(async (input, options) => {
101
+ const onProgress = progressWriter(Boolean(options.progress));
102
+ print(
103
+ await extractAudio({
104
+ input,
105
+ output: options.output,
106
+ ...options.format === void 0 ? {} : { format: options.format },
107
+ trimStartSeconds: options.trimStart,
108
+ durationSeconds: options.duration,
109
+ overwrite: options.overwrite,
110
+ ...onProgress === void 0 ? {} : { onProgress }
111
+ })
112
+ );
113
+ });
114
+ program.command("extract-frame <input>").description("Extract and verify a still frame from a video source.").requiredOption("--output <path>", "output frame path").option("--at <seconds>", "frame timestamp in seconds", Number).option("--format <format>", "jpg or png").option("--overwrite", "allow output replacement").option("--progress", "write NDJSON progress events to stderr").action(async (input, options) => {
115
+ const onProgress = progressWriter(Boolean(options.progress));
116
+ print(
117
+ await extractFrame({
118
+ input,
119
+ output: options.output,
120
+ ...options.at === void 0 ? {} : { atSeconds: options.at },
121
+ ...options.format === void 0 ? {} : { format: options.format },
122
+ overwrite: options.overwrite,
123
+ ...onProgress === void 0 ? {} : { onProgress }
124
+ })
125
+ );
126
+ });
127
+ program.command("execute <plan>").description("Execute a saved plan.").requiredOption("--output <path>", "output media path").option("--overwrite", "allow output replacement").option("--progress", "write NDJSON progress events to stderr").action(async (planPath, options) => {
128
+ const plan = parsePlan(await readFile(planPath, "utf8"));
129
+ const onProgress = progressWriter(Boolean(options.progress));
130
+ const result = await executePlan(plan, {
131
+ output: options.output,
132
+ overwrite: options.overwrite,
133
+ ...onProgress === void 0 ? {} : { onProgress }
134
+ });
135
+ print({
136
+ output: result.output,
137
+ verification: verifyMedia(await inspectMedia(result.output), plan.expectations)
138
+ });
139
+ });
140
+ program.command("verify <output>").description("Verify an output against a saved plan.").requiredOption("--against <plan>", "plan JSON path").action(async (outputPath, options) => {
141
+ const plan = parsePlan(await readFile(options.against, "utf8"));
142
+ print(verifyMedia(await inspectMedia(outputPath), plan.expectations));
143
+ });
144
+ return program;
145
+ }
146
+ function print(value) {
147
+ process.stdout.write(`${JSON.stringify(value, null, 2)}
148
+ `);
149
+ }
150
+ function progressWriter(enabled) {
151
+ if (!enabled) return void 0;
152
+ return (progress) => {
153
+ process.stderr.write(`${JSON.stringify({ type: "progress", ...progress })}
154
+ `);
155
+ };
156
+ }
157
+ if (isMainModule()) {
158
+ createProgram().parseAsync().catch((error) => {
159
+ const output = error instanceof MediaError ? error.toJSON() : {
160
+ code: "UNEXPECTED_ERROR",
161
+ message: error instanceof Error ? error.message : String(error)
162
+ };
163
+ process.stderr.write(`${JSON.stringify(output)}
164
+ `);
165
+ process.exitCode = 1;
166
+ });
167
+ }
168
+ function isMainModule() {
169
+ if (process.argv[1] === void 0) return false;
170
+ try {
171
+ return realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url));
172
+ } catch {
173
+ return false;
174
+ }
175
+ }
176
+ export {
177
+ createProgram
178
+ };
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@hadialmarzooq/agent-media-cli",
3
+ "version": "0.1.0",
4
+ "description": "JSON-first CLI for deterministic, verified media workflows.",
5
+ "keywords": [
6
+ "media",
7
+ "agents",
8
+ "ffmpeg",
9
+ "cli",
10
+ "automation"
11
+ ],
12
+ "homepage": "https://github.com/HadiAlMarzooq/agent-media#readme",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/HadiAlMarzooq/agent-media.git",
16
+ "directory": "packages/cli"
17
+ },
18
+ "bugs": {
19
+ "url": "https://github.com/HadiAlMarzooq/agent-media/issues"
20
+ },
21
+ "license": "MIT",
22
+ "engines": {
23
+ "node": ">=22.0.0"
24
+ },
25
+ "type": "module",
26
+ "bin": {
27
+ "agent-media": "./dist/index.js"
28
+ },
29
+ "main": "./dist/index.js",
30
+ "types": "./dist/index.d.ts",
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "dependencies": {
38
+ "commander": "15.0.0",
39
+ "@hadialmarzooq/agent-media-core": "0.1.0",
40
+ "@hadialmarzooq/agent-media-ffmpeg": "0.1.0"
41
+ },
42
+ "scripts": {
43
+ "build": "tsup src/index.ts --format esm --dts",
44
+ "typecheck": "tsc --noEmit"
45
+ }
46
+ }