@pippit-dev/cli 1.0.0 → 1.0.2
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 +37 -5
- package/checksums.txt +6 -6
- package/cmd/download_result.go +57 -0
- package/cmd/generate_video/generate_video.go +48 -0
- package/cmd/generate_video/query_result.go +58 -0
- package/cmd/generate_video_test.go +468 -0
- package/cmd/get_thread.go +59 -0
- package/cmd/list_thread_file.go +51 -0
- package/cmd/root.go +30 -1
- package/cmd/short_drama/short_drama.go +12 -133
- package/cmd/short_drama_test.go +76 -49
- package/cmd/update/update.go +8 -8
- package/internal/common/client.go +29 -21
- package/internal/common/download_results.go +21 -15
- package/internal/common/error_log.go +62 -1
- package/internal/common/error_log_test.go +33 -3
- package/internal/common/get_thread.go +29 -15
- package/internal/common/get_thread_test.go +74 -0
- package/internal/common/json.go +18 -0
- package/internal/common/list_thread_file.go +7 -7
- package/internal/common/submit_run.go +29 -0
- package/internal/common/upload_file.go +22 -18
- package/internal/config/config.go +1 -1
- package/internal/generate_video/generate_video.go +199 -0
- package/internal/generate_video/query_result.go +291 -0
- package/internal/generate_video/query_result_test.go +31 -0
- package/internal/short_drama/submit_run.go +8 -28
- package/package.json +1 -1
- package/skills/short-drama/SKILL.md +34 -34
- package/skills/xyq-nest-skill/scripts/download_results.py +3 -1
- package/skills/xyq-nest-skill/scripts/upload_file.py +2 -2
- package/skills/xyq-nest-skill/scripts/xyq_common.py +4 -3
package/README.md
CHANGED
|
@@ -197,21 +197,53 @@ export XYQ_ACCESS_KEY="<access-key>"
|
|
|
197
197
|
pippit-tool-cli --version
|
|
198
198
|
pippit-tool-cli short-drama +submit-run --message "写一个赛博朋克短剧开头"
|
|
199
199
|
pippit-tool-cli short-drama +upload-file --path ./reference.doc
|
|
200
|
-
pippit-tool-cli
|
|
201
|
-
pippit-tool-cli
|
|
200
|
+
pippit-tool-cli get-thread --thread-id thread_123 --run-id run_456
|
|
201
|
+
pippit-tool-cli list-thread-file --thread-id thread_123 --page-num 1 --page-size 200
|
|
202
|
+
pippit-tool-cli download-result --output-path ./thread_123/results/result.mp4 --url URL --updated-at 1779716734
|
|
202
203
|
```
|
|
203
204
|
|
|
204
205
|
`+submit-run`: 输出 `thread_id`、`run_id` 和 `web_thread_link`;其中 `--message` 为必填参数。
|
|
205
|
-
|
|
206
|
+
`get-thread`: 请求中带 `version=v2`,并输出 `readable_text`。
|
|
207
|
+
`list-thread-file`: 输出会话文件列表、分页提示和可直接传给下载命令的 `file_path`。
|
|
206
208
|
`+upload-file`: 输出返回的 `asset_id`。 当前仅支持 `.doc`、`.docx` 和 `.txt` 文件。
|
|
207
|
-
|
|
209
|
+
`download-result`: 会把结果 URL 下载到 `--output-path` 指定的文件路径;传入 `--updated-at` 后,如果本地文件早于该时间戳会覆盖更新,否则跳过。
|
|
208
210
|
|
|
209
211
|
短剧命令的错误日志会追加写入本地每日日志文件:`~/.pippit_tool_cli/logs/yyyy-mm-dd.log`。日志路径会基于当前用户主目录和系统路径分隔符生成,因此可在 macOS、Linux 和 Windows 上使用。
|
|
210
212
|
|
|
213
|
+
## 生视频 CLI
|
|
214
|
+
|
|
215
|
+
`generate-video` 会上传本地参考图片和视频,然后向视频片段 Agent 提交生视频请求:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
pippit-tool-cli generate-video \
|
|
219
|
+
--prompt "做个小猫视频" \
|
|
220
|
+
--image "~/images/cat1.jpg" \
|
|
221
|
+
--image "~/images/cat2.jpg" \
|
|
222
|
+
--video "~/images/video1.mp4" \
|
|
223
|
+
--video "~/images/video2.mp4" \
|
|
224
|
+
--duration 5 \
|
|
225
|
+
--ratio "9:16" \
|
|
226
|
+
--model "seedance2.0_direct" \
|
|
227
|
+
--resolution "720p"
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
命令输出 `thread_id`、`run_id` 和 `web_thread_link`。提交生视频 HTTP 请求时,参考图和参考视频会使用上传接口返回的 `pippit_asset_id`。图片最多 9 张,支持 `.jpg`、`.jpeg`、`.png`、`.gif`、`.bmp`、`.webp`、`.svg`;视频最多 3 个,支持 `.mp4`、`.avi`、`.mov`、`.wmv`、`.flv`、`.webm`、`.mkv`、`.m4v`。普通用户支持模型 `seedance2.0_direct` 和 `seedance2.0_fast_direct`;VIP 用户额外支持 `seedance2.0_vision` 和 `seedance2.0_fast_vision`。模型、比例、分辨率、素材数量等参数的语义校验当前预留在后续实现。
|
|
231
|
+
|
|
232
|
+
查询并下载生视频结果:
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
pippit-tool-cli query-result \
|
|
236
|
+
--thread-id "skill_xxx" \
|
|
237
|
+
--run-id "skill_xxx" \
|
|
238
|
+
--download-dir "./output"
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
`query-result` 会查询指定 Run;Run 完成后下载视频产物并输出本地结果路径,未完成时输出当前状态和重试提示。
|
|
242
|
+
|
|
211
243
|
## HTTP 客户端
|
|
212
244
|
|
|
213
245
|
命令模块通过 `common.Runner` 发起服务调用。运行时配置,例如基础地址、HTTP 超时时间和接口路径,由 `internal/config` 加载,并在运行器中与 `common.Client` 组合使用。
|
|
214
246
|
|
|
215
247
|
## 鉴权
|
|
216
248
|
|
|
217
|
-
`short-drama +submit-run`、`
|
|
249
|
+
`short-drama +submit-run`、`get-thread`、`list-thread-file`、`short-drama +upload-file` 以及 `xyq-skill` Python 脚本都使用 `Authorization: Bearer <XYQ_ACCESS_KEY>` 鉴权。OAuth 命令代码仍保留在仓库中,但短剧运行时请求不使用 OAuth。
|
package/checksums.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
2674fbc4cf095e321dcba42a0e7ed44ecb50c14236a07c97dbc522227c8819e1 pippit-tool-cli-1.0.2-darwin-amd64.tar.gz
|
|
2
|
+
f58a8babc317bef904699938b69574bb26d28cf191fff5123be305be77e27c3b pippit-tool-cli-1.0.2-darwin-arm64.tar.gz
|
|
3
|
+
3b33fbf6bc66f77b54e1436c5e231f355fe10787d41fe1310b6575b36e7c7cee pippit-tool-cli-1.0.2-linux-amd64.tar.gz
|
|
4
|
+
f5e73a43c79d5d4a35872a05ad9d14c1260753042a004ef358c475e7e7c4e764 pippit-tool-cli-1.0.2-linux-arm64.tar.gz
|
|
5
|
+
36f48c0db0f6524d43fd49d2e2cea014166c9dad85834f1cd498c2e8ebfeafd4 pippit-tool-cli-1.0.2-windows-amd64.zip
|
|
6
|
+
b45999f5e9412a2d7728e538b9cedbb715f4ffc397c667e610bcb964311db8f0 pippit-tool-cli-1.0.2-windows-arm64.zip
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
package cmd
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
"io"
|
|
6
|
+
"strconv"
|
|
7
|
+
"strings"
|
|
8
|
+
|
|
9
|
+
"github.com/Pippit-dev/pippit-cli/internal/common"
|
|
10
|
+
"github.com/spf13/cobra"
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
func newDownloadResultCommand(stdout, stderr io.Writer, runner *common.Runner) *cobra.Command {
|
|
14
|
+
var opts common.DownloadResultOptions
|
|
15
|
+
|
|
16
|
+
cmd := &cobra.Command{
|
|
17
|
+
Use: "download-result",
|
|
18
|
+
Short: "Download a generated result URL",
|
|
19
|
+
Args: cobra.NoArgs,
|
|
20
|
+
RunE: withErrorLog("download-result", func() map[string]string {
|
|
21
|
+
fields := map[string]string{
|
|
22
|
+
"output_path": opts.OutputPath,
|
|
23
|
+
"has_url": strconv.FormatBool(strings.TrimSpace(opts.URL) != ""),
|
|
24
|
+
"workers": strconv.Itoa(opts.Workers),
|
|
25
|
+
}
|
|
26
|
+
if opts.UpdatedAt > 0 {
|
|
27
|
+
fields["updated_at"] = strconv.FormatInt(opts.UpdatedAt, 10)
|
|
28
|
+
}
|
|
29
|
+
return fields
|
|
30
|
+
}, func(cmd *cobra.Command, _ []string) error {
|
|
31
|
+
opts.OutputPath = strings.TrimSpace(opts.OutputPath)
|
|
32
|
+
if opts.OutputPath == "" {
|
|
33
|
+
return fmt.Errorf("--output-path is required")
|
|
34
|
+
}
|
|
35
|
+
opts.URL = strings.TrimSpace(opts.URL)
|
|
36
|
+
if opts.URL == "" {
|
|
37
|
+
return fmt.Errorf("--url is required")
|
|
38
|
+
}
|
|
39
|
+
if opts.Workers <= 0 {
|
|
40
|
+
return fmt.Errorf("--workers must be greater than 0")
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
result, err := common.DownloadResult(cmd.Context(), opts, runner)
|
|
44
|
+
if err != nil {
|
|
45
|
+
return err
|
|
46
|
+
}
|
|
47
|
+
return common.WriteJSON(stdout, result)
|
|
48
|
+
}),
|
|
49
|
+
}
|
|
50
|
+
cmd.SetOut(stdout)
|
|
51
|
+
cmd.SetErr(stderr)
|
|
52
|
+
cmd.Flags().StringVar(&opts.URL, "url", "", "URL to download")
|
|
53
|
+
cmd.Flags().StringVar(&opts.OutputPath, "output-path", "", "local output file path")
|
|
54
|
+
cmd.Flags().Int64Var(&opts.UpdatedAt, "updated-at", 0, "remote file update time as a Unix timestamp")
|
|
55
|
+
cmd.Flags().IntVar(&opts.Workers, "workers", 5, "parallel download workers")
|
|
56
|
+
return cmd
|
|
57
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
package generate_video
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"io"
|
|
5
|
+
"strconv"
|
|
6
|
+
|
|
7
|
+
"github.com/Pippit-dev/pippit-cli/internal/common"
|
|
8
|
+
internalgen "github.com/Pippit-dev/pippit-cli/internal/generate_video"
|
|
9
|
+
"github.com/spf13/cobra"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
// NewCommand builds the generate-video command.
|
|
13
|
+
func NewCommand(stdout, stderr io.Writer, runner *common.Runner) *cobra.Command {
|
|
14
|
+
opts := &internalgen.Options{}
|
|
15
|
+
var durationSec int
|
|
16
|
+
|
|
17
|
+
cmd := &cobra.Command{
|
|
18
|
+
Use: "generate-video",
|
|
19
|
+
Short: "Generate a video with the video part agent",
|
|
20
|
+
Args: cobra.NoArgs,
|
|
21
|
+
RunE: func(cmd *cobra.Command, args []string) error {
|
|
22
|
+
if cmd.Flags().Changed("duration") {
|
|
23
|
+
opts.DurationSec = &durationSec
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
result, err := internalgen.Run(cmd.Context(), opts, runner)
|
|
27
|
+
if err != nil {
|
|
28
|
+
_ = common.AppendDailyErrorLog("generate-video", err, map[string]string{
|
|
29
|
+
"image_count": strconv.Itoa(len(opts.ImagePaths)),
|
|
30
|
+
"video_count": strconv.Itoa(len(opts.VideoPaths)),
|
|
31
|
+
})
|
|
32
|
+
return err
|
|
33
|
+
}
|
|
34
|
+
return common.WriteJSON(stdout, result)
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
cmd.SetOut(stdout)
|
|
38
|
+
cmd.SetErr(stderr)
|
|
39
|
+
flags := cmd.Flags()
|
|
40
|
+
flags.StringVar(&opts.Prompt, "prompt", "", "video generation prompt")
|
|
41
|
+
flags.StringArrayVar(&opts.ImagePaths, "image", nil, "local reference image path; repeat for multiple images, up to 9")
|
|
42
|
+
flags.StringArrayVar(&opts.VideoPaths, "video", nil, "local reference video path; repeat for multiple videos, up to 3")
|
|
43
|
+
flags.IntVar(&durationSec, "duration", 0, "video duration in seconds")
|
|
44
|
+
flags.StringVar(&opts.Ratio, "ratio", "", "video ratio, such as 9:16, 16:9, 3:4, 4:3")
|
|
45
|
+
flags.StringVar(&opts.Model, "model", "", "video model; normal users: seedance2.0_direct, seedance2.0_fast_direct; VIP users: seedance2.0_direct, seedance2.0_fast_direct, seedance2.0_vision, seedance2.0_fast_vision")
|
|
46
|
+
flags.StringVar(&opts.Resolution, "resolution", "", "video resolution, such as 720p, 1080p")
|
|
47
|
+
return cmd
|
|
48
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
package generate_video
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
"io"
|
|
6
|
+
"strings"
|
|
7
|
+
|
|
8
|
+
"github.com/Pippit-dev/pippit-cli/internal/common"
|
|
9
|
+
internalgen "github.com/Pippit-dev/pippit-cli/internal/generate_video"
|
|
10
|
+
"github.com/spf13/cobra"
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
// NewQueryResultCommand builds the query-result command.
|
|
14
|
+
func NewQueryResultCommand(stdout, stderr io.Writer, runner *common.Runner) *cobra.Command {
|
|
15
|
+
opts := &internalgen.QueryResultOptions{}
|
|
16
|
+
|
|
17
|
+
cmd := &cobra.Command{
|
|
18
|
+
Use: "query-result",
|
|
19
|
+
Short: "Query a generate-video run result and download completed videos",
|
|
20
|
+
Args: cobra.NoArgs,
|
|
21
|
+
RunE: func(cmd *cobra.Command, _ []string) error {
|
|
22
|
+
result, err := internalgen.QueryResult(cmd.Context(), opts, runner)
|
|
23
|
+
if err != nil {
|
|
24
|
+
_ = common.AppendDailyErrorLog("query-result", err, map[string]string{
|
|
25
|
+
"thread_id": strings.TrimSpace(opts.ThreadID),
|
|
26
|
+
"run_id": strings.TrimSpace(opts.RunID),
|
|
27
|
+
"download_dir": strings.TrimSpace(opts.DownloadDir),
|
|
28
|
+
})
|
|
29
|
+
return err
|
|
30
|
+
}
|
|
31
|
+
if !result.Completed {
|
|
32
|
+
_, err = fmt.Fprintf(stdout, "Run 尚未完成,当前状态:%d\n请稍后重试 query-result。\n", result.State)
|
|
33
|
+
return err
|
|
34
|
+
}
|
|
35
|
+
_, err = fmt.Fprintln(stdout, "Run 已完成,产物已下载:")
|
|
36
|
+
if err != nil {
|
|
37
|
+
return err
|
|
38
|
+
}
|
|
39
|
+
for i, path := range result.OutputPaths {
|
|
40
|
+
if _, err := fmt.Fprintln(stdout, path); err != nil {
|
|
41
|
+
return err
|
|
42
|
+
}
|
|
43
|
+
if i < len(result.DownloadURLs) && strings.TrimSpace(result.DownloadURLs[i]) != "" {
|
|
44
|
+
if _, err := fmt.Fprintf(stdout, "download_url: %s\n", result.DownloadURLs[i]); err != nil {
|
|
45
|
+
return err
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return nil
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
cmd.SetOut(stdout)
|
|
53
|
+
cmd.SetErr(stderr)
|
|
54
|
+
cmd.Flags().StringVar(&opts.ThreadID, "thread-id", "", "thread_id from generate-video output")
|
|
55
|
+
cmd.Flags().StringVar(&opts.RunID, "run-id", "", "run_id from generate-video output")
|
|
56
|
+
cmd.Flags().StringVar(&opts.DownloadDir, "download-dir", "", "directory to download completed videos into")
|
|
57
|
+
return cmd
|
|
58
|
+
}
|