@cliptude/cli 0.1.1 → 0.1.3

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 CHANGED
@@ -19,17 +19,17 @@ cliptude auth login
19
19
 
20
20
  ```bash
21
21
  cliptude templates
22
- cliptude generate --template "Finance vector weekly" --title "Why index funds win" --prompt "…"
22
+ cliptude generate --template "Finance vector weekly" --title "Why index funds win" --prompt "why most retail traders underperform the S&P over 10 years, keep it for beginners" --duration 3-4
23
23
  cliptude generate --template "Finance vector weekly" --title "Why index funds win" --script-file script.txt
24
24
  cliptude status <job-id>
25
25
  ```
26
26
 
27
- `--title` is required. `generate` returns immediately (`queued`). Poll `status`.
27
+ `--title` is required. Optional `--duration` is a wizard bucket (`3-4`, `6-8`, `10-12`, …). Omit it to use the template duration, or the word-count estimate when you pass `--script`. `generate` returns immediately (`queued`). Poll `status`.
28
28
 
29
29
  Faceless bring-your-own coding:
30
30
 
31
31
  ```bash
32
- cliptude generate --template "My Faceless" --title "…" --prompt "…" --faceless-coding external
32
+ cliptude generate --template "My Faceless" --title "Why index funds win" --prompt "why most retail traders underperform the S&P over 10 years, keep it for beginners" --faceless-coding external
33
33
  cliptude kit <job-id> --out ./kit.zip
34
34
  cliptude submit-project <job-id> ./project.zip
35
35
  ```
@@ -63,7 +63,17 @@ def _run_auth(auth_cmd: str) -> None:
63
63
 
64
64
 
65
65
  def main(argv: list[str] | None = None) -> None:
66
- parser = argparse.ArgumentParser(prog="cliptude", description="Cliptude jobs CLI")
66
+ parser = argparse.ArgumentParser(
67
+ prog="cliptude",
68
+ description="Cliptude jobs CLI",
69
+ formatter_class=argparse.RawDescriptionHelpFormatter,
70
+ epilog=(
71
+ "example:\n"
72
+ ' cliptude generate --template "Finance vector weekly" --title "Why index funds win" '
73
+ '--prompt "why most retail traders underperform the S&P over 10 years, keep it for beginners" '
74
+ '--duration 3-4'
75
+ ),
76
+ )
67
77
  sub = parser.add_subparsers(dest="cmd", required=True)
68
78
 
69
79
  auth = sub.add_parser("auth", help="Sign in with a browser")
@@ -76,10 +86,24 @@ def main(argv: list[str] | None = None) -> None:
76
86
  t.add_argument("--limit", type=int, default=20)
77
87
  t.add_argument("--offset", type=int, default=0)
78
88
 
79
- g = sub.add_parser("generate", help="Start a job")
89
+ g = sub.add_parser(
90
+ "generate",
91
+ help="Start a job",
92
+ formatter_class=argparse.RawDescriptionHelpFormatter,
93
+ epilog=(
94
+ "example:\n"
95
+ ' cliptude generate --template "Finance vector weekly" --title "Why index funds win" '
96
+ '--prompt "why most retail traders underperform the S&P over 10 years, keep it for beginners" '
97
+ '--duration 3-4'
98
+ ),
99
+ )
80
100
  g.add_argument("--template", required=True, help="Template name or UUID")
81
101
  g.add_argument("--title", required=True)
82
- g.add_argument("--prompt", default="")
102
+ g.add_argument(
103
+ "--prompt",
104
+ default="",
105
+ help='Topic or brief, e.g. "why most retail traders underperform the S&P over 10 years, keep it for beginners"',
106
+ )
83
107
  g.add_argument("--script", default="")
84
108
  g.add_argument("--script-file", default="")
85
109
  g.add_argument(
@@ -87,6 +111,11 @@ def main(argv: list[str] | None = None) -> None:
87
111
  default="",
88
112
  help="external = you author Faceless storyboard/HTML; omit for Cliptude coding",
89
113
  )
114
+ g.add_argument(
115
+ "--duration",
116
+ default="",
117
+ help="Wizard duration bucket, e.g. 3-4 or 6-8. Default: template duration (or estimated from --script)",
118
+ )
90
119
 
91
120
  k = sub.add_parser("kit", help="Download Faceless coding kit zip")
92
121
  k.add_argument("job_id")
@@ -129,6 +158,7 @@ def main(argv: list[str] | None = None) -> None:
129
158
  prompt=args.prompt or None,
130
159
  script=script or None,
131
160
  faceless_coding=(args.faceless_coding or None),
161
+ duration=(args.duration or None),
132
162
  ))
133
163
  elif args.cmd == "kit":
134
164
  dest = Path(args.out)
@@ -144,6 +144,7 @@ class CliptudeClient:
144
144
  prompt: str | None = None,
145
145
  script: str | None = None,
146
146
  faceless_coding: str | None = None,
147
+ duration: str | None = None,
147
148
  ) -> Any:
148
149
  body: dict[str, Any] = {"template_id": template_id, "title": title}
149
150
  if prompt:
@@ -152,6 +153,8 @@ class CliptudeClient:
152
153
  body["script"] = script
153
154
  if faceless_coding:
154
155
  body["faceless_coding"] = faceless_coding
156
+ if duration:
157
+ body["duration"] = duration
155
158
  return self.request("POST", "/api/v1/jobs", json_body=body)
156
159
 
157
160
  def get_job(self, job_id: str) -> Any:
@@ -92,6 +92,10 @@ def build_server(*, with_http_auth: bool = False):
92
92
  str | None,
93
93
  Field(description='Use "external" for Faceless Explainer BYO HTML. Omit for Cliptude coding.'),
94
94
  ] = None,
95
+ duration: Annotated[
96
+ str | None,
97
+ Field(description="Wizard duration bucket such as 3-4 or 6-8. Omit to use the template (or estimate from script)."),
98
+ ] = None,
95
99
  ) -> dict[str, Any]:
96
100
  """Start generation and return a job id immediately. Do not wait for the MP4. Poll get_job. Provide prompt and/or script."""
97
101
  try:
@@ -101,6 +105,7 @@ def build_server(*, with_http_auth: bool = False):
101
105
  prompt=prompt,
102
106
  script=script,
103
107
  faceless_coding=faceless_coding,
108
+ duration=duration,
104
109
  )
105
110
  except Exception as exc:
106
111
  return _err(exc)
@@ -3,10 +3,13 @@
3
3
 
4
4
  const { spawnSync } = require("child_process");
5
5
  const fs = require("fs");
6
+ const os = require("os");
6
7
  const path = require("path");
7
8
 
8
9
  const pkgRoot = path.resolve(__dirname, "..", "..");
9
10
  const args = process.argv.slice(2);
11
+ const venvDir =
12
+ process.env.CLIPTUDE_VENV || path.join(os.homedir(), ".cliptude", "venv");
10
13
 
11
14
  function pythonCandidates() {
12
15
  if (process.platform === "win32") {
@@ -29,37 +32,102 @@ function findPython() {
29
32
  return null;
30
33
  }
31
34
 
32
- function ensurePackage(py) {
35
+ function venvPython() {
36
+ if (process.platform === "win32") {
37
+ return path.join(venvDir, "Scripts", "python.exe");
38
+ }
39
+ return path.join(venvDir, "bin", "python");
40
+ }
41
+
42
+ function packageVersion() {
43
+ try {
44
+ return JSON.parse(fs.readFileSync(path.join(pkgRoot, "package.json"), "utf8"))
45
+ .version;
46
+ } catch {
47
+ return "";
48
+ }
49
+ }
50
+
51
+ function markerPath() {
52
+ return path.join(venvDir, ".cliptude-cli-version");
53
+ }
54
+
55
+ function importOk(py) {
33
56
  const check = spawnSync(py, ["-c", "import cliptude_mcp.cli"], {
34
57
  encoding: "utf8",
35
58
  });
36
- if (check.status === 0) {
37
- return;
59
+ return check.status === 0;
60
+ }
61
+
62
+ function installedVersionMatches(py) {
63
+ if (!importOk(py)) {
64
+ return false;
65
+ }
66
+ const want = packageVersion();
67
+ if (!want) {
68
+ return true;
38
69
  }
70
+ try {
71
+ return fs.readFileSync(markerPath(), "utf8").trim() === want;
72
+ } catch {
73
+ return false;
74
+ }
75
+ }
76
+
77
+ function run(py, argv) {
78
+ return spawnSync(py, argv, { stdio: "inherit" });
79
+ }
80
+
81
+ function ensureVenv(systemPy) {
82
+ const py = venvPython();
83
+ if (fs.existsSync(py) && installedVersionMatches(py)) {
84
+ return py;
85
+ }
86
+
87
+ fs.mkdirSync(path.dirname(venvDir), { recursive: true });
88
+ if (!fs.existsSync(py)) {
89
+ const created = run(systemPy, ["-m", "venv", venvDir]);
90
+ if (created.status !== 0 || !fs.existsSync(py)) {
91
+ console.error(
92
+ "Could not create a Python virtualenv at " +
93
+ venvDir +
94
+ ". Install Python 3.10+.",
95
+ );
96
+ process.exit(created.status ?? 1);
97
+ }
98
+ }
99
+
39
100
  const pyproject = path.join(pkgRoot, "pyproject.toml");
40
101
  if (!fs.existsSync(pyproject)) {
41
102
  console.error("Cliptude CLI package is missing pyproject.toml.");
42
103
  process.exit(1);
43
104
  }
44
- const install = spawnSync(
45
- py,
46
- ["-m", "pip", "install", "--quiet", pkgRoot],
47
- { stdio: "inherit" },
48
- );
105
+
106
+ let install = run(py, ["-m", "pip", "install", "--upgrade", "--quiet", pkgRoot]);
107
+ if (install.status !== 0) {
108
+ run(py, ["-m", "ensurepip", "--upgrade"]);
109
+ install = run(py, ["-m", "pip", "install", "--upgrade", "--quiet", pkgRoot]);
110
+ }
49
111
  if (install.status !== 0) {
50
- console.error("Could not install the Cliptude Python CLI. Install Python 3.10+ and pip.");
112
+ console.error("Could not install the Cliptude Python CLI into " + venvDir);
51
113
  process.exit(install.status ?? 1);
52
114
  }
115
+
116
+ const version = packageVersion();
117
+ if (version) {
118
+ fs.writeFileSync(markerPath(), version + "\n");
119
+ }
120
+ return py;
53
121
  }
54
122
 
55
- const py = findPython();
56
- if (!py) {
57
- console.error("Python 3.10+ is required. Install it, then re-run: npm i -g @cliptude/cli");
123
+ const systemPy = findPython();
124
+ if (!systemPy) {
125
+ console.error(
126
+ "Python 3.10+ is required. Install it, then re-run: npm i -g @cliptude/cli",
127
+ );
58
128
  process.exit(1);
59
129
  }
60
130
 
61
- ensurePackage(py);
62
- const result = spawnSync(py, ["-m", "cliptude_mcp.cli", ...args], {
63
- stdio: "inherit",
64
- });
131
+ const py = ensureVenv(systemPy);
132
+ const result = run(py, ["-m", "cliptude_mcp.cli", ...args]);
65
133
  process.exit(result.status ?? 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cliptude/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Cliptude CLI — generate videos from saved templates.",
5
5
  "homepage": "https://github.com/cliptude/cliptude#readme",
6
6
  "bin": {
package/pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "cliptude-mcp"
7
- version = "0.1.1"
7
+ version = "0.1.3"
8
8
  description = "Cliptude jobs CLI and MCP server (thin client of /api/v1)."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"