@aiyiran/myclaw 1.0.210 → 1.0.212

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.
@@ -49,9 +49,8 @@
49
49
 
50
50
  // ═══ 构建预览 URL ═══
51
51
  function buildPreviewUrl(data, assetPath) {
52
- var wsName = data.workspace_id || '';
53
- var wsPrefix = wsName === 'main' ? 'workspace' : 'workspace-' + wsName;
54
- return window.location.origin + '/cmd/api/preview?path=' + wsPrefix + '/' + assetPath;
52
+ var wsName = data.workspace_id || 'main';
53
+ return window.location.origin + '/' + wsName + '/' + assetPath;
55
54
  }
56
55
 
57
56
  // ═══ 创建按钮 ═══
@@ -191,7 +190,7 @@
191
190
 
192
191
  // ═══ 请求数据 ═══
193
192
  function getArtifactsUrl() {
194
- var agentName = getAgentName();
193
+ var agentName = getAgentName() || 'main';
195
194
  var wsPrefix = agentName === 'main' ? 'workspace' : 'workspace-' + agentName;
196
195
  return window.location.origin + '/cmd/api/preview?path=' + wsPrefix + '/.myclaw/__MY_ARTIFACTS__.json';
197
196
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.0.210",
3
+ "version": "1.0.212",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
package/publish.sh CHANGED
@@ -1,19 +1,29 @@
1
1
  #!/bin/bash
2
2
  set -e # 遇到错误即停止
3
3
 
4
+ # 解析参数
5
+ GIT_MODE=false
6
+ for arg in "$@"; do
7
+ case $arg in
8
+ --git) GIT_MODE=true ;;
9
+ esac
10
+ done
11
+
4
12
  echo "📦 准备发布新版本..."
5
13
 
6
14
  # patch-manifest.json 由手动维护,不再自动构建
7
15
 
8
- # 1. 添加所有变动
9
- git add .
10
-
11
- # 2. 检查是否有未提交的代码,如果有则先提交
12
- if ! git diff-index --quiet HEAD; then
13
- echo "📝 发现有修改的内容,正在自动提交..."
14
- git commit -m "chore: auto update before publish"
15
- else
16
- echo "✅ 工作区很干净,不需要额外提交代码。"
16
+ if [ "$GIT_MODE" = true ]; then
17
+ # 1. 添加所有变动
18
+ git add .
19
+
20
+ # 2. 检查是否有未提交的代码,如果有则先提交
21
+ if ! git diff-index --quiet HEAD; then
22
+ echo "📝 发现有修改的内容,正在自动提交..."
23
+ git commit -m "chore: auto update before publish"
24
+ else
25
+ echo "✅ 工作区很干净,不需要额外提交代码。"
26
+ fi
17
27
  fi
18
28
 
19
29
  # 3. 自动更新最小版本号 (npm version patch 会自动再做一个改 package.json 的 commit 并且打上 Tag)
@@ -24,10 +34,12 @@ npm version patch
24
34
  echo "🚀 优先发布到 npm 仓库..."
25
35
  npm publish
26
36
 
27
- # 5. 推送代码和 Tag GitHub
28
- echo "☁️ 推送代码和版本 Tag 到 GitHub..."
29
- git push origin main || echo "⚠️ Git 推送失败 (网络问题),但不影响 npm 发布!请后续手动检查。"
30
- git push origin --tags || true
37
+ if [ "$GIT_MODE" = true ]; then
38
+ # 5. 推送代码和 Tag 到 GitHub
39
+ echo "☁️ 推送代码和版本 Tag GitHub..."
40
+ git push origin main || echo "⚠️ Git 推送失败 (网络问题),但不影响 npm 发布!请后续手动检查。"
41
+ git push origin --tags || true
42
+ fi
31
43
 
32
44
  VERSION=$(node -p "require('./package.json').version")
33
45
  echo "🎉 发布流执行完成!当前发布 NPM 版本号:v${VERSION}"
@@ -1,31 +1,30 @@
1
1
  ---
2
2
  name: yiran-skill-media
3
- description: 统一多媒体生成技能。支持图片和音乐生成,按资源类型自动路由到最优 provider,支持主备切换。生成文件保存在当前 workspace 的 media/ 目录。
3
+ description: 统一多媒体生成技能。支持图片和音乐生成,按资源类型自动路由到最优 provider,支持主备切换。资源生成规范:所有生成的资源必须存放在当前工作目录下,调用时通过 --output-dir 传入当前工作目录的绝对路径。
4
4
  ---
5
5
 
6
6
  # 统一多媒体生成
7
7
 
8
- ## 环境变量
8
+ ## 资源生成规范(必须遵守)
9
9
 
10
- | 变量 | 默认值 | 说明 |
11
- |------|--------|------|
12
- | `WORKSPACE_NAME` | `main` | workspace 名称 |
13
- | `OPENCLAW_HOME` | `~/.openclaw` | OpenClaw 安装目录(可选,用于覆盖默认路径) |
14
- | `VAPI_API_KEY` | - | VAPI 图片 API Key(备 provider) |
10
+ **`--output-dir` 为必填参数,必须传入绝对路径。**
15
11
 
16
- ## 输出路径规则
12
+ **规范:所有生成的资源文件必须存放在当前工作目录下。你在哪个目录工作,就把该目录的绝对路径传给 `--output-dir`。**
17
13
 
18
- - 生成文件保存在**当前 workspace 的 media/ 目录**
19
- - 文件名:`image_{时间戳}.png` / `music_{时间戳}.mp3`
14
+ 例如:
15
+ - 你当前在 `/root/.openclaw/workspace` → 传入 `--output-dir /root/.openclaw/workspace`
16
+ - 你当前在 `/root/.openclaw/workspace-dev` → 传入 `--output-dir /root/.openclaw/workspace-dev`
17
+
18
+ 这是硬性规范,不允许省略,不允许猜测路径。
20
19
 
21
20
  ## 一键脚本
22
21
 
23
22
  ```bash
24
- # 图片生成
25
- WORKSPACE_NAME=main ./image.sh "描述" [--aspect-ratio 16:9]
23
+ # 图片生成 — 传入当前工作目录的绝对路径
24
+ ./image.sh --output-dir "$(pwd)" "描述" [--aspect-ratio 16:9]
26
25
 
27
26
  # 音乐生成
28
- WORKSPACE_NAME=main ./music.sh "描述" [--lyrics "歌词"] [--instrumental]
27
+ ./music.sh --output-dir "$(pwd)" "描述" [--lyrics "歌词"] [--instrumental]
29
28
  ```
30
29
 
31
30
  ## 参数说明
@@ -34,6 +33,7 @@ WORKSPACE_NAME=main ./music.sh "描述" [--lyrics "歌词"] [--instrumental]
34
33
 
35
34
  | 参数 | 必填 | 说明 |
36
35
  |------|------|------|
36
+ | `--output-dir` | 是 | 输出目录的绝对路径,传入当前工作目录 |
37
37
  | `prompt` | 是 | 图片描述 |
38
38
  | `--aspect-ratio` | 否 | 比例,默认 1:1。可选:16:9, 9:16, 4:3 等 |
39
39
 
@@ -41,6 +41,7 @@ WORKSPACE_NAME=main ./music.sh "描述" [--lyrics "歌词"] [--instrumental]
41
41
 
42
42
  | 参数 | 必填 | 说明 |
43
43
  |------|------|------|
44
+ | `--output-dir` | 是 | 输出目录的绝对路径,传入当前工作目录 |
44
45
  | `prompt` | 是 | 音乐风格/情绪描述 |
45
46
  | `--lyrics` | 否 | 歌词文本 |
46
47
  | `--instrumental` | 否 | 纯音乐模式 |
@@ -2,8 +2,8 @@
2
2
  """
3
3
  统一资源生成调度器
4
4
  用法:
5
- python3 generate.py image "prompt" [--aspect-ratio 16:9] [--output path]
6
- python3 generate.py music "prompt" [--lyrics "歌词"] [--instrumental] [--output path]
5
+ python3 generate.py image "prompt" --output-dir /abs/path [--aspect-ratio 16:9] [--output path]
6
+ python3 generate.py music "prompt" --output-dir /abs/path [--lyrics "歌词"] [--instrumental] [--output path]
7
7
  """
8
8
  import argparse
9
9
  import json
@@ -22,25 +22,15 @@ def load_config():
22
22
  return json.load(f)
23
23
 
24
24
 
25
- def get_output_dir():
26
- """Resolve output directory. Fallback to /tmp/media/ if primary is unwritable."""
27
- workspace = os.environ.get("WORKSPACE_NAME", "main")
28
- openclaw_home = os.environ.get("OPENCLAW_HOME", os.path.join(os.path.expanduser("~"), ".openclaw"))
29
-
30
- if workspace == "main":
31
- base = os.path.join(openclaw_home, "workspace")
32
- else:
33
- base = os.path.join(openclaw_home, f"workspace-{workspace}")
34
-
35
- out_dir = os.path.join(base, "media")
25
+ def ensure_output_dir(path):
26
+ """Ensure output directory exists and is writable. Fallback to /tmp/media/ if not."""
36
27
  try:
37
- os.makedirs(out_dir, exist_ok=True)
38
- return out_dir
28
+ os.makedirs(path, exist_ok=True)
29
+ return path
39
30
  except OSError:
40
- # Primary dir unwritable (e.g. /root on macOS) → fallback to tmp
41
31
  fallback = os.path.join(tempfile.gettempdir(), "media")
42
32
  os.makedirs(fallback, exist_ok=True)
43
- print(f"[warn] {out_dir} not writable, using {fallback}", file=sys.stderr)
33
+ print(f"[warn] {path} not writable, using {fallback}", file=sys.stderr)
44
34
  return fallback
45
35
 
46
36
 
@@ -157,9 +147,10 @@ def main():
157
147
  parser.add_argument("--lyrics", default=None, help="Lyrics text (music only)")
158
148
  parser.add_argument("--instrumental", action="store_true", help="Instrumental mode (music only)")
159
149
  parser.add_argument("--output", default=None, help="Output file path")
150
+ parser.add_argument("--output-dir", required=True, help="Absolute path to output directory (required)")
160
151
  args = parser.parse_args()
161
152
 
162
- out_dir = get_output_dir()
153
+ out_dir = ensure_output_dir(args.output_dir)
163
154
 
164
155
  # Prepare kwargs
165
156
  if args.type == "image":
@@ -1,32 +1,39 @@
1
1
  #!/bin/bash
2
2
  # 图片生成入口
3
- # 用法: WORKSPACE_NAME=main ./image.sh "描述" [--aspect-ratio 16:9]
3
+ # 用法: ./image.sh --output-dir /abs/path "描述" [--aspect-ratio 16:9]
4
4
  set -euo pipefail
5
5
 
6
- PROMPT="${1:-}"
7
- shift 2>/dev/null || true
8
-
9
- if [ -z "$PROMPT" ]; then
10
- echo "用法: WORKSPACE_NAME=xxx ./image.sh \"描述\" [--aspect-ratio 16:9]"
11
- echo "示例: WORKSPACE_NAME=main ./image.sh \"a cute cat\" --aspect-ratio 16:9"
12
- exit 1
13
- fi
14
-
6
+ OUTPUT_DIR=""
7
+ PROMPT=""
15
8
  ASPECT_RATIO=""
16
9
 
17
10
  while [ $# -gt 0 ]; do
18
11
  case "$1" in
12
+ --output-dir) OUTPUT_DIR="$2"; shift 2 ;;
19
13
  --aspect-ratio) ASPECT_RATIO="$2"; shift 2 ;;
20
- *) shift ;;
14
+ *)
15
+ if [ -z "$PROMPT" ]; then
16
+ PROMPT="$1"
17
+ fi
18
+ shift
19
+ ;;
21
20
  esac
22
21
  done
23
22
 
23
+ if [ -z "$OUTPUT_DIR" ] || [ -z "$PROMPT" ]; then
24
+ echo "用法: ./image.sh --output-dir <绝对路径> \"描述\" [--aspect-ratio 16:9]"
25
+ echo "示例: ./image.sh --output-dir /root/.openclaw/workspace/media \"a cute cat\" --aspect-ratio 16:9"
26
+ echo "注意: --output-dir 必须是绝对路径,传入当前工作目录即可"
27
+ exit 1
28
+ fi
29
+
24
30
  SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
25
31
 
26
32
  # Build args for generate.py
27
33
  ARGS=()
28
34
  ARGS+=("image")
29
35
  ARGS+=("$PROMPT")
36
+ ARGS+=(--output-dir "$OUTPUT_DIR")
30
37
  [ -n "$ASPECT_RATIO" ] && ARGS+=(--aspect-ratio "$ASPECT_RATIO")
31
38
 
32
39
  python3 "$SCRIPT_DIR/generate.py" "${ARGS[@]}"
@@ -1,34 +1,41 @@
1
1
  #!/bin/bash
2
2
  # 音乐生成入口
3
- # 用法: WORKSPACE_NAME=main ./music.sh "描述" [--lyrics "歌词"] [--instrumental]
3
+ # 用法: ./music.sh --output-dir /abs/path "描述" [--lyrics "歌词"] [--instrumental]
4
4
  set -euo pipefail
5
5
 
6
- PROMPT="${1:-}"
7
- shift 2>/dev/null || true
8
-
9
- if [ -z "$PROMPT" ]; then
10
- echo "用法: WORKSPACE_NAME=xxx ./music.sh \"描述\" [--lyrics \"歌词\"] [--instrumental]"
11
- echo "示例: WORKSPACE_NAME=main ./music.sh \"relaxing guitar\" --instrumental"
12
- exit 1
13
- fi
14
-
6
+ OUTPUT_DIR=""
7
+ PROMPT=""
15
8
  LYRICS=""
16
9
  INSTRUMENTAL=false
17
10
 
18
11
  while [ $# -gt 0 ]; do
19
12
  case "$1" in
13
+ --output-dir) OUTPUT_DIR="$2"; shift 2 ;;
20
14
  --lyrics) LYRICS="$2"; shift 2 ;;
21
15
  --instrumental) INSTRUMENTAL=true; shift ;;
22
- *) shift ;;
16
+ *)
17
+ if [ -z "$PROMPT" ]; then
18
+ PROMPT="$1"
19
+ fi
20
+ shift
21
+ ;;
23
22
  esac
24
23
  done
25
24
 
25
+ if [ -z "$OUTPUT_DIR" ] || [ -z "$PROMPT" ]; then
26
+ echo "用法: ./music.sh --output-dir <绝对路径> \"描述\" [--lyrics \"歌词\"] [--instrumental]"
27
+ echo "示例: ./music.sh --output-dir /root/.openclaw/workspace/media \"relaxing guitar\" --instrumental"
28
+ echo "注意: --output-dir 必须是绝对路径,传入当前工作目录即可"
29
+ exit 1
30
+ fi
31
+
26
32
  SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
27
33
 
28
34
  # Build args for generate.py
29
35
  ARGS=()
30
36
  ARGS+=("music")
31
37
  ARGS+=("$PROMPT")
38
+ ARGS+=(--output-dir "$OUTPUT_DIR")
32
39
  [ -n "$LYRICS" ] && ARGS+=(--lyrics "$LYRICS")
33
40
  [ "$INSTRUMENTAL" = true ] && ARGS+=(--instrumental)
34
41