@jiggai/recipes 0.4.37 → 0.4.38

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.
@@ -2,7 +2,7 @@
2
2
  "id": "recipes",
3
3
  "name": "Recipes",
4
4
  "description": "Markdown recipes that scaffold agents and teams (workspace-local).",
5
- "version": "0.4.37",
5
+ "version": "0.4.38",
6
6
  "configSchema": {
7
7
  "type": "object",
8
8
  "additionalProperties": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jiggai/recipes",
3
- "version": "0.4.37",
3
+ "version": "0.4.38",
4
4
  "description": "ClawRecipes plugin for OpenClaw (markdown recipes -> scaffold agents/teams)",
5
5
  "main": "index.ts",
6
6
  "type": "commonjs",
@@ -3,6 +3,29 @@ import * as fs from 'fs';
3
3
  import { MediaDriver, MediaDriverInvokeOpts, MediaDriverResult, DurationConstraints, parseDuration } from './types';
4
4
  import { findSkillDir, runScript, parseMediaOutput } from './utils';
5
5
 
6
+ /**
7
+ * Map aspect ratios to Kling's supported values: 16:9, 9:16, 1:1
8
+ */
9
+ function mapToKlingAspectRatio(ratio: string): string {
10
+ const normalized = ratio.toLowerCase().trim();
11
+
12
+ // Direct matches
13
+ if (normalized === '16:9' || normalized === '9:16' || normalized === '1:1') {
14
+ return normalized;
15
+ }
16
+
17
+ // Map common ratios to closest Kling equivalent
18
+ const mappings: Record<string, string> = {
19
+ '4:3': '1:1', // 4:3 (1.33) → 1:1 (1.00) closest square-ish
20
+ '3:4': '9:16', // 3:4 (0.75) → 9:16 (0.56) closest vertical
21
+ '21:9': '16:9', // 21:9 (2.33) → 16:9 (1.78) closest widescreen
22
+ '2:1': '16:9', // 2:1 (2.00) → 16:9 (1.78) closest widescreen
23
+ '1:2': '9:16', // 1:2 (0.50) → 9:16 (0.56) closest vertical
24
+ };
25
+
26
+ return mappings[normalized] || '16:9'; // default fallback
27
+ }
28
+
6
29
  /**
7
30
  * Kling AI video driver — uses official `klingai` ClawHub skill.
8
31
  *
@@ -39,6 +62,10 @@ export class KlingVideo implements MediaDriver {
39
62
  const rawDuration = Math.max(3, Math.min(15, Number(parseDuration(config))));
40
63
  const duration = String(rawDuration);
41
64
 
65
+ // Kling only supports 16:9, 9:16, 1:1 — map other ratios to closest match
66
+ const rawAspectRatio = String(config?.aspect_ratio ?? config?.size ?? '16:9');
67
+ const aspectRatio = mapToKlingAspectRatio(rawAspectRatio);
68
+
42
69
  const skillDir = await findSkillDir(this.slug);
43
70
  if (!skillDir) {
44
71
  throw new Error(
@@ -58,7 +85,7 @@ export class KlingVideo implements MediaDriver {
58
85
  '--prompt', prompt,
59
86
  '--output_dir', outputDir,
60
87
  '--duration', duration,
61
- '--aspect_ratio', String(config?.aspect_ratio ?? config?.size ?? '16:9'),
88
+ '--aspect_ratio', aspectRatio,
62
89
  '--mode', 'pro',
63
90
  ],
64
91
  env: {
@@ -1,6 +1,6 @@
1
1
  import * as fs from 'fs/promises';
2
2
  import * as path from 'path';
3
- import { execSync } from 'child_process';
3
+ import { execFileSync } from 'child_process';
4
4
 
5
5
  /**
6
6
  * Find a skill directory by searching common skill roots
@@ -96,13 +96,9 @@ export interface RunScriptOpts {
96
96
 
97
97
  export function runScript(opts: RunScriptOpts): string {
98
98
  const { runner, script, args = [], stdin, env, cwd, timeout } = opts;
99
-
100
- const command = args.length > 0
101
- ? `${runner} ${JSON.stringify(script)} ${args.map(arg => JSON.stringify(arg)).join(' ')}`
102
- : `${runner} ${JSON.stringify(script)}`;
103
99
 
104
100
  try {
105
- return execSync(command, {
101
+ return execFileSync(runner, [script, ...args], {
106
102
  cwd,
107
103
  timeout,
108
104
  encoding: 'utf8',