cli-302ai 1.0.2b1__tar.gz

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.
Files changed (99) hide show
  1. cli_302ai-1.0.2b1/.github/workflows/publish-pypi.yml +57 -0
  2. cli_302ai-1.0.2b1/.github/workflows/publish-testpypi.yml +57 -0
  3. cli_302ai-1.0.2b1/.gitignore +81 -0
  4. cli_302ai-1.0.2b1/AGENTS.md +65 -0
  5. cli_302ai-1.0.2b1/CLAUDE.md +1 -0
  6. cli_302ai-1.0.2b1/PKG-INFO +325 -0
  7. cli_302ai-1.0.2b1/README.md +315 -0
  8. cli_302ai-1.0.2b1/ai302/__init__.py +3 -0
  9. cli_302ai-1.0.2b1/ai302/__main__.py +14 -0
  10. cli_302ai-1.0.2b1/ai302/api/__init__.py +5 -0
  11. cli_302ai-1.0.2b1/ai302/api/file.py +231 -0
  12. cli_302ai-1.0.2b1/ai302/api/http_client.py +75 -0
  13. cli_302ai-1.0.2b1/ai302/api/image.py +117 -0
  14. cli_302ai-1.0.2b1/ai302/api/record.py +16 -0
  15. cli_302ai-1.0.2b1/ai302/api/search.py +73 -0
  16. cli_302ai-1.0.2b1/ai302/api/sfx.py +42 -0
  17. cli_302ai-1.0.2b1/ai302/api/song.py +230 -0
  18. cli_302ai-1.0.2b1/ai302/api/stt.py +52 -0
  19. cli_302ai-1.0.2b1/ai302/api/three_d.py +127 -0
  20. cli_302ai-1.0.2b1/ai302/api/tts.py +82 -0
  21. cli_302ai-1.0.2b1/ai302/api/video.py +68 -0
  22. cli_302ai-1.0.2b1/ai302/assets/CLAUDE.md +201 -0
  23. cli_302ai-1.0.2b1/ai302/assets/commands/302ai-media-studio/apply.md +25 -0
  24. cli_302ai-1.0.2b1/ai302/assets/commands/302ai-media-studio/propose.md +25 -0
  25. cli_302ai-1.0.2b1/ai302/assets/commands/302ai-media-studio/result.md +25 -0
  26. cli_302ai-1.0.2b1/ai302/assets/docs/.gitkeep +0 -0
  27. cli_302ai-1.0.2b1/ai302/assets/docs/302ai-cli-agent-guide/cli-agent-guide.md +206 -0
  28. cli_302ai-1.0.2b1/ai302/assets/docs/302ai-cli-agent-guide/commands/file.md +116 -0
  29. cli_302ai-1.0.2b1/ai302/assets/docs/302ai-cli-agent-guide/commands/history.md +82 -0
  30. cli_302ai-1.0.2b1/ai302/assets/docs/302ai-cli-agent-guide/commands/image.md +134 -0
  31. cli_302ai-1.0.2b1/ai302/assets/docs/302ai-cli-agent-guide/commands/model.md +111 -0
  32. cli_302ai-1.0.2b1/ai302/assets/docs/302ai-cli-agent-guide/commands/record.md +72 -0
  33. cli_302ai-1.0.2b1/ai302/assets/docs/302ai-cli-agent-guide/commands/sfx.md +125 -0
  34. cli_302ai-1.0.2b1/ai302/assets/docs/302ai-cli-agent-guide/commands/song.md +272 -0
  35. cli_302ai-1.0.2b1/ai302/assets/docs/302ai-cli-agent-guide/commands/stt.md +76 -0
  36. cli_302ai-1.0.2b1/ai302/assets/docs/302ai-cli-agent-guide/commands/task.md +87 -0
  37. cli_302ai-1.0.2b1/ai302/assets/docs/302ai-cli-agent-guide/commands/tts.md +189 -0
  38. cli_302ai-1.0.2b1/ai302/assets/docs/302ai-cli-agent-guide/commands/video.md +101 -0
  39. cli_302ai-1.0.2b1/ai302/assets/docs/302ai-workflow-guide/workflow-guide.md +716 -0
  40. cli_302ai-1.0.2b1/ai302/assets/docs/cli-guide.md +72 -0
  41. cli_302ai-1.0.2b1/ai302/assets/docs/tasks.yaml +53 -0
  42. cli_302ai-1.0.2b1/ai302/assets/model_params.json +2083 -0
  43. cli_302ai-1.0.2b1/ai302/assets/skills/302ai-media-studio-apply/SKILL.md +221 -0
  44. cli_302ai-1.0.2b1/ai302/assets/skills/302ai-media-studio-apply/references/audio.md +72 -0
  45. cli_302ai-1.0.2b1/ai302/assets/skills/302ai-media-studio-apply/references/image.md +20 -0
  46. cli_302ai-1.0.2b1/ai302/assets/skills/302ai-media-studio-apply/references/video.md +44 -0
  47. cli_302ai-1.0.2b1/ai302/assets/skills/302ai-media-studio-propose/SKILL.md +290 -0
  48. cli_302ai-1.0.2b1/ai302/assets/skills/302ai-media-studio-propose/references/audio.md +645 -0
  49. cli_302ai-1.0.2b1/ai302/assets/skills/302ai-media-studio-propose/references/image.md +391 -0
  50. cli_302ai-1.0.2b1/ai302/assets/skills/302ai-media-studio-propose/references/testing.md +36 -0
  51. cli_302ai-1.0.2b1/ai302/assets/skills/302ai-media-studio-propose/references/video.md +307 -0
  52. cli_302ai-1.0.2b1/ai302/assets/skills/302ai-media-studio-result/SKILL.md +197 -0
  53. cli_302ai-1.0.2b1/ai302/assets/skills/302ai-media-studio-result/references/audio.md +204 -0
  54. cli_302ai-1.0.2b1/ai302/assets/skills/302ai-media-studio-result/references/image.md +88 -0
  55. cli_302ai-1.0.2b1/ai302/assets/skills/302ai-media-studio-result/references/video.md +87 -0
  56. cli_302ai-1.0.2b1/ai302/assets/skills/302ai-search/SKILL.md +170 -0
  57. cli_302ai-1.0.2b1/ai302/assets/skills/302ai-search/scripts/302ai-search.py +407 -0
  58. cli_302ai-1.0.2b1/ai302/assets/stt_models.json +80 -0
  59. cli_302ai-1.0.2b1/ai302/cli/__init__.py +0 -0
  60. cli_302ai-1.0.2b1/ai302/cli/app.py +84 -0
  61. cli_302ai-1.0.2b1/ai302/cli/common.py +50 -0
  62. cli_302ai-1.0.2b1/ai302/cli/file.py +315 -0
  63. cli_302ai-1.0.2b1/ai302/cli/history.py +47 -0
  64. cli_302ai-1.0.2b1/ai302/cli/image.py +499 -0
  65. cli_302ai-1.0.2b1/ai302/cli/init_skills.py +48 -0
  66. cli_302ai-1.0.2b1/ai302/cli/model.py +59 -0
  67. cli_302ai-1.0.2b1/ai302/cli/record.py +49 -0
  68. cli_302ai-1.0.2b1/ai302/cli/search.py +131 -0
  69. cli_302ai-1.0.2b1/ai302/cli/sfx.py +197 -0
  70. cli_302ai-1.0.2b1/ai302/cli/song.py +762 -0
  71. cli_302ai-1.0.2b1/ai302/cli/stt.py +119 -0
  72. cli_302ai-1.0.2b1/ai302/cli/task.py +58 -0
  73. cli_302ai-1.0.2b1/ai302/cli/three_d.py +300 -0
  74. cli_302ai-1.0.2b1/ai302/cli/tts.py +292 -0
  75. cli_302ai-1.0.2b1/ai302/cli/video.py +273 -0
  76. cli_302ai-1.0.2b1/ai302/core/__init__.py +0 -0
  77. cli_302ai-1.0.2b1/ai302/core/config.py +54 -0
  78. cli_302ai-1.0.2b1/ai302/core/errors.py +13 -0
  79. cli_302ai-1.0.2b1/ai302/core/history.py +85 -0
  80. cli_302ai-1.0.2b1/ai302/core/models.py +70 -0
  81. cli_302ai-1.0.2b1/ai302/core/redact.py +21 -0
  82. cli_302ai-1.0.2b1/ai302/core/snapshot.py +71 -0
  83. cli_302ai-1.0.2b1/ai302/core/task_store.py +59 -0
  84. cli_302ai-1.0.2b1/ai302/core/tts_cache.py +86 -0
  85. cli_302ai-1.0.2b1/ai302/core/yaml_edit.py +268 -0
  86. cli_302ai-1.0.2b1/doc/302ai-cli-agent-guide/cli-agent-guide.md +206 -0
  87. cli_302ai-1.0.2b1/doc/302ai-cli-agent-guide/commands/file.md +116 -0
  88. cli_302ai-1.0.2b1/doc/302ai-cli-agent-guide/commands/history.md +82 -0
  89. cli_302ai-1.0.2b1/doc/302ai-cli-agent-guide/commands/image.md +134 -0
  90. cli_302ai-1.0.2b1/doc/302ai-cli-agent-guide/commands/model.md +111 -0
  91. cli_302ai-1.0.2b1/doc/302ai-cli-agent-guide/commands/record.md +72 -0
  92. cli_302ai-1.0.2b1/doc/302ai-cli-agent-guide/commands/sfx.md +125 -0
  93. cli_302ai-1.0.2b1/doc/302ai-cli-agent-guide/commands/stt.md +76 -0
  94. cli_302ai-1.0.2b1/doc/302ai-cli-agent-guide/commands/task.md +87 -0
  95. cli_302ai-1.0.2b1/doc/302ai-cli-agent-guide/commands/tts.md +189 -0
  96. cli_302ai-1.0.2b1/doc/302ai-cli-agent-guide/commands/video.md +101 -0
  97. cli_302ai-1.0.2b1/doc/api.md +1303 -0
  98. cli_302ai-1.0.2b1/main.py +5 -0
  99. cli_302ai-1.0.2b1/pyproject.toml +27 -0
@@ -0,0 +1,57 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ build-and-publish:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: read
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - uses: actions/setup-python@v5
17
+ with:
18
+ python-version: "3.12"
19
+
20
+ - name: Install build tools
21
+ run: python -m pip install --upgrade pip build twine
22
+
23
+ - name: Validate tag matches pyproject version
24
+ env:
25
+ GITHUB_REF_NAME: ${{ github.ref_name }}
26
+ run: |
27
+ python - <<'PY'
28
+ import os
29
+ import re
30
+ from pathlib import Path
31
+
32
+ tag = os.environ["GITHUB_REF_NAME"]
33
+ m = re.fullmatch(r"v(\d+\.\d+\.\d+(?:a|b|rc|\.dev)?\d*)", tag)
34
+ if not m:
35
+ raise SystemExit(f"Unexpected tag format: {tag} (expected vX.Y.Z or PEP 440 pre-release like vX.Y.Zb1)")
36
+ tag_version = m.group(1)
37
+
38
+ text = Path("pyproject.toml").read_text(encoding="utf-8")
39
+ m2 = re.search(r"(?m)^version\s*=\s*\"([^\"]+)\"\s*$", text)
40
+ if not m2:
41
+ raise SystemExit("Could not find version = \"...\" in pyproject.toml")
42
+ project_version = m2.group(1)
43
+
44
+ if tag_version != project_version:
45
+ raise SystemExit(f"Tag version {tag_version} != pyproject.toml version {project_version}")
46
+
47
+ print(f"OK: {tag} matches pyproject.toml version {project_version}")
48
+ PY
49
+
50
+ - name: Build
51
+ run: python -m build
52
+
53
+ - name: Publish
54
+ env:
55
+ TWINE_USERNAME: __token__
56
+ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
57
+ run: python -m twine upload dist/*
@@ -0,0 +1,57 @@
1
+ name: Publish to TestPyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "test-v*"
7
+
8
+ jobs:
9
+ build-and-publish:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: read
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - uses: actions/setup-python@v5
17
+ with:
18
+ python-version: "3.12"
19
+
20
+ - name: Install build tools
21
+ run: python -m pip install --upgrade pip build twine
22
+
23
+ - name: Validate tag matches pyproject version
24
+ env:
25
+ GITHUB_REF_NAME: ${{ github.ref_name }}
26
+ run: |
27
+ python - <<'PY'
28
+ import os
29
+ import re
30
+ from pathlib import Path
31
+
32
+ tag = os.environ["GITHUB_REF_NAME"]
33
+ m = re.fullmatch(r"test-v(\d+\.\d+\.\d+(?:a|b|rc|\.dev)?\d*)", tag)
34
+ if not m:
35
+ raise SystemExit(f"Unexpected tag format: {tag} (expected test-vX.Y.Z or PEP 440 pre-release like test-vX.Y.Zb1)")
36
+ tag_version = m.group(1)
37
+
38
+ text = Path("pyproject.toml").read_text(encoding="utf-8")
39
+ m2 = re.search(r"(?m)^version\s*=\s*\"([^\"]+)\"\s*$", text)
40
+ if not m2:
41
+ raise SystemExit("Could not find version = \"...\" in pyproject.toml")
42
+ project_version = m2.group(1)
43
+
44
+ if tag_version != project_version:
45
+ raise SystemExit(f"Tag version {tag_version} != pyproject.toml version {project_version}")
46
+
47
+ print(f"OK: {tag} matches pyproject.toml version {project_version}")
48
+ PY
49
+
50
+ - name: Build
51
+ run: python -m build
52
+
53
+ - name: Publish
54
+ env:
55
+ TWINE_USERNAME: __token__
56
+ TWINE_PASSWORD: ${{ secrets.TESTPYPI_API_TOKEN }}
57
+ run: python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*
@@ -0,0 +1,81 @@
1
+ # --- Secrets / local config ---
2
+ .env
3
+ .env.*
4
+ *.env
5
+ *.key
6
+ *.pem
7
+ *.p12
8
+ *.pfx
9
+ *.crt
10
+ *.cer
11
+ *.der
12
+ *.jks
13
+ credentials.json
14
+ secrets*.json
15
+ *secret*
16
+ *token*
17
+
18
+ # Local user config produced by this CLI (default: ~/.ai302)
19
+ # Kept here in case user overrides AI302_CONFIG_DIR into the repo
20
+ .ai302/
21
+ **/.ai302/
22
+ **/history.jsonl
23
+ **/tasks/
24
+ **/config.json
25
+
26
+ # --- Python ---
27
+ __pycache__/
28
+ *.py[cod]
29
+ *$py.class
30
+ .pytest_cache/
31
+ .coverage
32
+ .coverage.*
33
+ htmlcov/
34
+ .mypy_cache/
35
+ .pytype/
36
+ .ruff_cache/
37
+ .pyre/
38
+
39
+ # Virtual environments
40
+ .venv/
41
+ venv/
42
+ ENV/
43
+
44
+ # Build / packaging
45
+ build/
46
+ dist/
47
+ *.egg-info/
48
+ .eggs/
49
+
50
+ # Jupyter
51
+ .ipynb_checkpoints/
52
+
53
+ # IDEs / editors
54
+ .vscode/
55
+ .idea/
56
+ *.iml
57
+
58
+ # OS files
59
+ .DS_Store
60
+ Thumbs.db
61
+
62
+ # Claude Code / local tooling
63
+ .claude/
64
+ .env
65
+ .env.*
66
+ !.env.example
67
+
68
+ __pycache__/
69
+ *.py[cod]
70
+ *.pyo
71
+ *.pyd
72
+
73
+ .venv/
74
+ venv/
75
+
76
+ .idea/
77
+ .vscode/
78
+
79
+ *.log
80
+
81
+ .claude
@@ -0,0 +1,65 @@
1
+ Behavioral guidelines to reduce common LLM coding mistakes. Merge with project-specific instructions as needed.
2
+
3
+ **Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment.
4
+
5
+ ## 1. Think Before Coding
6
+
7
+ **Don't assume. Don't hide confusion. Surface tradeoffs.**
8
+
9
+ Before implementing:
10
+ - State your assumptions explicitly. If uncertain, ask.
11
+ - If multiple interpretations exist, present them - don't pick silently.
12
+ - If a simpler approach exists, say so. Push back when warranted.
13
+ - If something is unclear, stop. Name what's confusing. Ask.
14
+
15
+ ## 2. Simplicity First
16
+
17
+ **Minimum code that solves the problem. Nothing speculative.**
18
+
19
+ - No features beyond what was asked.
20
+ - No abstractions for single-use code.
21
+ - No "flexibility" or "configurability" that wasn't requested.
22
+ - No error handling for impossible scenarios.
23
+ - If you write 200 lines and it could be 50, rewrite it.
24
+
25
+ Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.
26
+
27
+ ## 3. Surgical Changes
28
+
29
+ **Touch only what you must. Clean up only your own mess.**
30
+
31
+ When editing existing code:
32
+ - Don't "improve" adjacent code, comments, or formatting.
33
+ - Don't refactor things that aren't broken.
34
+ - Match existing style, even if you'd do it differently.
35
+ - If you notice unrelated dead code, mention it - don't delete it.
36
+
37
+ When your changes create orphans:
38
+ - Remove imports/variables/functions that YOUR changes made unused.
39
+ - Don't remove pre-existing dead code unless asked.
40
+
41
+ The test: Every changed line should trace directly to the user's request.
42
+
43
+ ## 4. Goal-Driven Execution
44
+
45
+ **Define success criteria. Loop until verified.**
46
+
47
+ Transform tasks into verifiable goals:
48
+ - "Add validation" → "Write tests for invalid inputs, then make them pass"
49
+ - "Fix the bug" → "Write a test that reproduces it, then make it pass"
50
+ - "Refactor X" → "Ensure tests pass before and after"
51
+
52
+ For multi-step tasks, state a brief plan:
53
+ ```
54
+ 1. [Step] → verify: [check]
55
+ 2. [Step] → verify: [check]
56
+ 3. [Step] → verify: [check]
57
+ ```
58
+
59
+ Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.
60
+
61
+ ## Project-Specific Guidelines
62
+
63
+ ---
64
+
65
+ **These guidelines are working if:** fewer unnecessary changes in diffs, fewer rewrites due to overcomplication, and clarifying questions come before implementation rather than after mistakes.
@@ -0,0 +1 @@
1
+ @AGENTS.md
@@ -0,0 +1,325 @@
1
+ Metadata-Version: 2.4
2
+ Name: cli-302ai
3
+ Version: 1.0.2b1
4
+ Summary: 302.ai unified CLI
5
+ Requires-Python: >=3.10
6
+ Requires-Dist: httpx>=0.27
7
+ Requires-Dist: ruamel-yaml>=0.18
8
+ Requires-Dist: typer>=0.12
9
+ Description-Content-Type: text/markdown
10
+
11
+ # ai302 CLI
12
+
13
+ 302.ai 统一命令行工具(输出均为单行 JSON,方便脚本处理)。
14
+
15
+ ## Project architecture
16
+
17
+ 代码按职责拆分为三层:
18
+
19
+ - `ai302/cli/`:Typer CLI 命令层(参数解析、统一 JSON 输出、写 history/快照)
20
+ - `ai302/cli/app.py`:CLI 根入口(挂载 model/video/image/tts/history 子命令)
21
+ - `ai302/cli/common.py`:公共工具(`resolve_api_key` / `print_json` / `parse_extra`)
22
+ - `ai302/cli/model.py`:默认模型配置(set/list)
23
+ - `ai302/cli/video.py`:视频异步任务(create/fetch)
24
+ - `ai302/cli/image.py`:图片同步生成(generate)
25
+ - `ai302/cli/tts.py`:TTS(refresh/providers/voices/create/fetch)
26
+ - `ai302/cli/history.py`:本地 history 查询(path/list)
27
+
28
+ - `ai302/api/`:HTTP API 封装层(只负责请求/返回 JSON,不做 CLI 交互)
29
+ - `ai302/api/http_client.py`:httpx 客户端、重试、统一错误 `AI302ApiError`、Base URL(`AI302_BASE_URL`)
30
+ - `ai302/api/video.py`:视频 create/fetch 请求封装
31
+ - `ai302/api/image.py`:图片 generate 请求封装
32
+ - `ai302/api/tts.py`:TTS provider/create/fetch 请求封装
33
+
34
+ - `ai302/core/`:本地能力层(配置/模型表/history/快照/缓存)
35
+ - `ai302/core/config.py`:本地配置读写(`$AI302_CONFIG_DIR/config.json`,默认模型等)
36
+ - `ai302/core/models.py`:内置 `SUPPORTED_MODELS` 静态表
37
+ - `ai302/core/history.py`:`history.jsonl` 追加与查询
38
+ - `ai302/core/task_store.py`:任务快照 `tasks/<taskid>.json` 写入/更新
39
+ - `ai302/core/tts_cache.py`:TTS providers 缓存读写与 voices 扁平化
40
+
41
+ 入口文件:
42
+ - `ai302/__main__.py`:支持 `python -m ai302 ...`
43
+ - `pyproject.toml`:安装后命令 `ai302 ...` 的脚本入口(同时也是 `-v/--version` 的版本来源)
44
+
45
+ ## Release (GitHub Actions → TestPyPI/PyPI)
46
+
47
+ 发布版本号以 `pyproject.toml` 的 `version = "X.Y.Z"` 为准,**发版前务必先更新它**。
48
+
49
+ 一次完整发版流程:
50
+
51
+ ```bash
52
+ # 1) 修改版本号(必须)
53
+ # 编辑 pyproject.toml,把 [project].version 改成目标版本,例如 0.1.8
54
+
55
+ # 2) 提交并推送到远程分支(示例:remote=302ai, 本地 master → 远程 dev)
56
+
57
+ # 3) 先发布到 TestPyPI(触发 CI)
58
+ # tag 必须是 test-vX.Y.Z,并且 X.Y.Z 必须与 pyproject.toml 的 version 一致
59
+ git tag test-v0.1.8
60
+ git push 302ai test-v0.1.8
61
+
62
+ # 4) TestPyPI 验证通过后,再发布到 PyPI(触发 CI)
63
+ # tag 必须是 vX.Y.Z,并且 X.Y.Z 必须与 pyproject.toml 的 version 一致
64
+ git tag v0.1.8
65
+ git push 302ai v0.1.8
66
+ ```
67
+
68
+ GitHub Secrets 需要配置:
69
+ - `TESTPYPI_API_TOKEN`:TestPyPI token
70
+ - `PYPI_API_TOKEN`:PyPI token
71
+
72
+ ## Skills / Claude Code integration
73
+
74
+ 本项目内置了一组 Claude Code skills/commands 模板,用于把 302ai 的媒体能力接入 Claude Code 工作流。
75
+
76
+ - 源模板目录:
77
+ - `ai302/assets/skills/`
78
+ - `ai302/assets/commands/`
79
+ - `ai302/assets/docs/`
80
+ - `ai302/assets/CLAUDE.md`
81
+
82
+ 初始化(把模板复制到指定目录;同时会把 docs/ 与 CLAUDE.md 写到 `/home/user/workspace/...`):
83
+
84
+ ```bash
85
+ ai302 skills init <dest>
86
+ # 例如:ai302 skills init ~/.claude
87
+ ```
88
+
89
+ ## Install (dev)
90
+
91
+ ```bash
92
+ python -m pip install -U pip
93
+ python -m pip install -e .
94
+ ```
95
+
96
+ ## Run (no install)
97
+
98
+ ```bash
99
+ python -m ai302 -h
100
+ ```
101
+
102
+ ## Environment
103
+
104
+ - API Key:`AI302_KEY`(也可以每次传 `--api_key`)
105
+ - Base URL:`AI302_BASE_URL`(默认 `https://api.302.ai`)
106
+ - Config dir:`AI302_CONFIG_DIR`(默认 `~/.ai302`)
107
+
108
+ PowerShell:
109
+
110
+ ```powershell
111
+ $env:AI302_KEY="YOUR_KEY"
112
+ ```
113
+
114
+ ## Models
115
+
116
+ 模型按任务类型分组:
117
+ - 视频:`t2v` / `i2v`
118
+ - 图片:`t2i` / `i2i`
119
+
120
+ 查看当前内置支持模型:
121
+
122
+ ```bash
123
+ python -m ai302 model list t2v
124
+ python -m ai302 model get t2v --random
125
+ python -m ai302 model list t2i
126
+ ```
127
+
128
+ 设置默认模型(写入本地配置):
129
+
130
+ ```bash
131
+ ai302 model set t2v minimaxi-t2v-01
132
+ ai302 model set i2v minimaxi-hailuo-2.3-fast
133
+ ai302 model set t2i flux-kontext-max-t2i
134
+ ai302 model set i2i wan2.6-image
135
+ ```
136
+
137
+ ## CLI status enums
138
+
139
+ 异步任务(video / tts)状态枚举固定为:
140
+ - `pending`:准备/排队中
141
+ - `processing`:处理中
142
+ - `completed`:完成
143
+ - `failed`:失败
144
+
145
+ 同步接口(image)只会返回:
146
+ - `completed`:完成
147
+ - `failed`:失败
148
+
149
+
150
+ ## Video
151
+
152
+ 视频模块提供 **异步视频生成任务**(text-to-video / image-to-video),支持创建任务与查询任务结果。
153
+
154
+ 创建任务:
155
+
156
+ ```bash
157
+ ai302 video create --prompt "a cat run" --model minimaxi-t2v-01 --api_key "sk-..."
158
+ ```
159
+
160
+ 返回字段补充:`request` 会包含本次请求的 method/url/headers(仅脱敏 Authorization)/params/body。
161
+
162
+ 查询任务:
163
+
164
+ ```bash
165
+ ai302 video fetch <taskid> --api_key "sk-..."
166
+ # 使用 --short 仅返回关键状态和结果 URL
167
+ ai302 video fetch <taskid> --short
168
+ ```
169
+
170
+ ## TTS
171
+
172
+ 首次使用建议先刷新 provider/model/voice 信息到本地缓存(会写入 `$AI302_CONFIG_DIR/tts/providers.json`):
173
+
174
+ ```bash
175
+ ai302 tts refresh --api_key "sk-..."
176
+ ```
177
+
178
+ 查看可用 provider:
179
+
180
+ ```bash
181
+ ai302 tts providers
182
+ ai302 tts providers-get --random
183
+ ```
184
+
185
+ 查看可用 voices(建议用 `--provider` 过滤):
186
+
187
+ ```bash
188
+ ai302 tts voices --provider openai
189
+ ai302 tts voices-get openai --random
190
+ ```
191
+
192
+ 创建 TTS 任务(异步):
193
+
194
+ ```bash
195
+ ai302 tts create --text "生活就像海洋,只有意志坚强的人才能到达彼岸" --provider openai --voice alloy --api_key "sk-..."
196
+ ```
197
+
198
+ 返回字段补充:`request` 会包含本次请求的 method/url/headers(仅脱敏 Authorization)/params/body。
199
+
200
+ 查询任务结果:
201
+
202
+ ```bash
203
+ ai302 tts fetch <taskid> --api_key "sk-..."
204
+ # 使用 --short 仅返回关键状态和结果 URL
205
+ ai302 tts fetch <taskid> --short
206
+ ```
207
+
208
+ ## Image (sync)
209
+
210
+ 同步生图:
211
+
212
+ ```bash
213
+ ai302 image generate --prompt "sky city" --model flux-kontext-max-t2i --api_key "sk-..."
214
+ ```
215
+
216
+ 返回字段补充:`request` 会包含本次请求的 method/url/headers(仅脱敏 Authorization)/params/body。
217
+
218
+ ## Image (async)
219
+
220
+ 异步生图(创建任务):
221
+
222
+ ```bash
223
+ ai302 image create --prompt "sky city" --model flux-kontext-max-t2i --api_key "sk-..."
224
+ ```
225
+
226
+ 查询任务结果:
227
+
228
+ ```bash
229
+ ai302 image fetch <taskid> --api_key "sk-..."
230
+ # 使用 --short 仅返回关键状态和结果 URL
231
+ ai302 image fetch <taskid> --short
232
+ ```
233
+
234
+ 图生图(可重复传 `--image`):
235
+
236
+ ```bash
237
+ ai302 image generate --prompt "添加墨镜" --image "https://..." --api_key "sk-..."
238
+ ## Task (YAML editor)
239
+
240
+ 默认目录:`ai302/templates/workspace/tasks`(文件名按时间倒序取最新的 `*.yaml`)。
241
+
242
+ 支持字段编辑、数组元素添加与移除,以及通过 `--path` 指定特定文件:
243
+
244
+ ```bash
245
+ # 修改默认最新文件的字段
246
+ ai302 task edit --set "workflow.steps[step=2].parameters.prompt=生成一只更可爱的小猫"
247
+
248
+ # 指定特定文件进行编辑
249
+ ai302 task edit --path "./tasks/my_task.yaml" --set "a=b"
250
+
251
+ # 添加数组元素
252
+ ai302 task edit --add "workflow.running_steps=Node_C"
253
+ ...
254
+ ```
255
+
256
+ 参数说明:
257
+ - `--set`:设置值,支持 `+=`, `-=` 语法
258
+ - `--add`:追加元素到数组
259
+ - `--remove`:从数组移除元素
260
+ - `--path`:指定要编辑的 YAML 文件路径(如果不提供,则自动寻找默认目录下最新的文件)
261
+
262
+ # 或者使用 += 语法
263
+ ai302 task edit --set "workflow.running_steps+=Node_C"
264
+
265
+ # 移除数组元素 (支持精确值匹配)
266
+ ai302 task edit --remove "workflow.pending_steps=Node_C"
267
+ # 或者使用 -= 语法
268
+ ai302 task edit --set "workflow.pending_steps-=Node_C"
269
+
270
+ # 移除数组元素 (支持对象字段匹配)
271
+ ai302 task edit --remove "workflow.steps=step=1"
272
+ ```
273
+
274
+ `@json=` 用法:当值是数组/对象时,用 `@json` 让 CLI 把值按 JSON 解析,并写回为 YAML 的 **flow style**(数组 `[...]` / 对象 `{...}`)。
275
+
276
+ - list:`depends_on@json=[1,3]` → `depends_on: [1, 3]`
277
+ - object:`parameters.extra@json={"a":1,"b":[2,3]}` → `extra: {a: 1, b: [2, 3]}`
278
+
279
+ 路径语法:
280
+ - dotted:`a.b.c=...`
281
+ - 列表下标:`steps[0].parameters.prompt=...`
282
+ - 列表筛选(按字段匹配):`steps[step=2].parameters.prompt=...`
283
+
284
+ 运算符说明:
285
+ - `=`:设置值(默认)
286
+ - `+=`:向数组追加元素
287
+ - `-=`:从数组中移除匹配的元素(值匹配或字段筛选匹配)
288
+
289
+ ## History / Local files
290
+
291
+ ## File
292
+
293
+ - snapshot
294
+
295
+ ```bash
296
+ ai302 file snapshot --dir "./asset" --out before.json
297
+ ```
298
+
299
+ - diff
300
+
301
+ ```bash
302
+ ai302 file diff before.json after.json
303
+ ```
304
+
305
+ - upload
306
+
307
+ ```bash
308
+ ai302 file upload ./a.png --url "https://your-upload-endpoint" --prefix img
309
+ ```
310
+
311
+
312
+ - History(JSONL):`$AI302_CONFIG_DIR/history.jsonl`
313
+ - Video task snapshots:`$AI302_CONFIG_DIR/tasks/<taskid>.json`
314
+
315
+ 查看 history 路径:
316
+
317
+ ```bash
318
+ ai302 history path
319
+ ```
320
+
321
+ 按条件查询(输出匹配的 jsonl 行):
322
+
323
+ ```bash
324
+ ai302 history list --kind video --op fetch --limit 20
325
+ ```