@pippit-dev/cli 0.0.16 → 0.0.17
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 +1 -1
- package/checksums.txt +6 -6
- package/cmd/short_drama/short_drama.go +2 -1
- package/cmd/short_drama_test.go +11 -12
- package/internal/common/upload_file.go +4 -3
- package/internal/short_drama/get_thread.go +1 -1
- package/package.json +1 -1
- package/skills/short-drama/SKILL.md +13 -10
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ go run . short-drama +download-result --output-path ./thread_123/results/result.
|
|
|
37
37
|
`/api/biz/v1/skill/get_thread` with `version=v2` and prints `readable_text`.
|
|
38
38
|
`+upload-file` calls `/api/biz/v1/skill/upload_file` with
|
|
39
39
|
`multipart/form-data` and prints the returned `asset_id`.
|
|
40
|
-
Only `.doc
|
|
40
|
+
Only `.doc`, `.docx`, and `.txt` file extensions are supported.
|
|
41
41
|
`+download-result` downloads the result URL to
|
|
42
42
|
the `--output-path` file path.
|
|
43
43
|
|
package/checksums.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
dc08d1d25fe9fb2d2ed4dc5c2dec42b999ffe9f42f7dfac723d50f85d9107099 pippit-tool-cli-0.0.17-darwin-amd64.tar.gz
|
|
2
|
+
f696c2aec0901638716b5037231fd47916c557b6157c1dcff559c894d7992c5a pippit-tool-cli-0.0.17-darwin-arm64.tar.gz
|
|
3
|
+
ee4386da9ba02e5dfd93786b319e42af2a41c1fa01c20151232b87ebc81ef343 pippit-tool-cli-0.0.17-linux-amd64.tar.gz
|
|
4
|
+
795c624e273acb9edb0f4851d767d4f58b947e8dc056a7246a64bbb30b085bc1 pippit-tool-cli-0.0.17-linux-arm64.tar.gz
|
|
5
|
+
0e3eb11d38fd04686317df1185195e12180265b9bd7bbb1de2b68a145d72f339 pippit-tool-cli-0.0.17-windows-amd64.zip
|
|
6
|
+
acccf51f98a58f3d887a6e2c9131b8acbbc246b6c518ebe8c26b28ad20ed0a54 pippit-tool-cli-0.0.17-windows-arm64.zip
|
|
@@ -138,7 +138,8 @@ func newShortDramaGetThreadCommand(stdout, stderr io.Writer, runner *common.Runn
|
|
|
138
138
|
if err != nil {
|
|
139
139
|
return err
|
|
140
140
|
}
|
|
141
|
-
|
|
141
|
+
_, err = fmt.Fprintln(stdout, result.ReadableText)
|
|
142
|
+
return err
|
|
142
143
|
},
|
|
143
144
|
}
|
|
144
145
|
cmd.SetOut(stdout)
|
package/cmd/short_drama_test.go
CHANGED
|
@@ -196,11 +196,11 @@ func TestShortDramaUploadFile(t *testing.T) {
|
|
|
196
196
|
if len(files) != 1 {
|
|
197
197
|
t.Fatalf("file parts = %d, want 1", len(files))
|
|
198
198
|
}
|
|
199
|
-
if files[0].Filename != "story.
|
|
200
|
-
t.Fatalf("filename = %q, want story.
|
|
199
|
+
if files[0].Filename != "story.docx" {
|
|
200
|
+
t.Fatalf("filename = %q, want story.docx", files[0].Filename)
|
|
201
201
|
}
|
|
202
|
-
if got := files[0].Header.Get("Content-Type"); got != "
|
|
203
|
-
t.Fatalf("Content-Type = %q, want
|
|
202
|
+
if got := files[0].Header.Get("Content-Type"); got != "application/vnd.openxmlformats-officedocument.wordprocessingml.document" {
|
|
203
|
+
t.Fatalf("Content-Type = %q, want docx content type", got)
|
|
204
204
|
}
|
|
205
205
|
file, err := files[0].Open()
|
|
206
206
|
if err != nil {
|
|
@@ -211,16 +211,16 @@ func TestShortDramaUploadFile(t *testing.T) {
|
|
|
211
211
|
if err != nil {
|
|
212
212
|
t.Fatalf("ReadAll multipart file: %v", err)
|
|
213
213
|
}
|
|
214
|
-
if string(data) != "
|
|
215
|
-
t.Fatalf("file content = %q, want
|
|
214
|
+
if string(data) != "docx-data" {
|
|
215
|
+
t.Fatalf("file content = %q, want docx-data", string(data))
|
|
216
216
|
}
|
|
217
217
|
_, _ = w.Write([]byte(`{"ret":"0","errmsg":"","data":{"pippit_asset_id":"asset_123"}}`))
|
|
218
218
|
}))
|
|
219
219
|
defer server.Close()
|
|
220
220
|
|
|
221
221
|
cwd := chdirTemp(t)
|
|
222
|
-
path := filepath.Join(cwd, "story.
|
|
223
|
-
if err := os.WriteFile(path, []byte("
|
|
222
|
+
path := filepath.Join(cwd, "story.docx")
|
|
223
|
+
if err := os.WriteFile(path, []byte("docx-data"), 0o644); err != nil {
|
|
224
224
|
t.Fatalf("WriteFile(): %v", err)
|
|
225
225
|
}
|
|
226
226
|
|
|
@@ -292,7 +292,7 @@ func TestShortDramaUploadFileRejectsUnsupportedFileType(t *testing.T) {
|
|
|
292
292
|
if err == nil {
|
|
293
293
|
t.Fatal("Execute() error = nil, want file type validation error")
|
|
294
294
|
}
|
|
295
|
-
if !strings.Contains(err.Error(), "only .doc and .txt uploads are supported") {
|
|
295
|
+
if !strings.Contains(err.Error(), "only .doc, .docx, and .txt uploads are supported") {
|
|
296
296
|
t.Fatalf("error = %q, want unsupported type validation", err)
|
|
297
297
|
}
|
|
298
298
|
}
|
|
@@ -591,9 +591,8 @@ func TestShortDramaGetThread(t *testing.T) {
|
|
|
591
591
|
t.Fatalf("Execute() error = %v, stderr = %s", err, stderr.String())
|
|
592
592
|
}
|
|
593
593
|
|
|
594
|
-
got :=
|
|
595
|
-
|
|
596
|
-
t.Fatalf("readable_text = %#v, want API readable text", got["readable_text"])
|
|
594
|
+
if got := stdout.String(); got != "Thread: thread_123\n [assistant] hello\n" {
|
|
595
|
+
t.Fatalf("stdout = %#v, want API readable text", got)
|
|
597
596
|
}
|
|
598
597
|
}
|
|
599
598
|
|
|
@@ -36,8 +36,9 @@ type uploadFileResponse struct {
|
|
|
36
36
|
const uploadFileFieldName = "file"
|
|
37
37
|
|
|
38
38
|
var allowedUploadExtensions = map[string]bool{
|
|
39
|
-
".doc":
|
|
40
|
-
".
|
|
39
|
+
".doc": true,
|
|
40
|
+
".docx": true,
|
|
41
|
+
".txt": true,
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
func UploadFile(ctx context.Context, opts UploadFileOptions, runner *Runner) (*UploadFileResult, error) {
|
|
@@ -62,7 +63,7 @@ func UploadFile(ctx context.Context, opts UploadFileOptions, runner *Runner) (*U
|
|
|
62
63
|
|
|
63
64
|
ext := strings.ToLower(filepath.Ext(path))
|
|
64
65
|
if !allowedUploadExtensions[ext] {
|
|
65
|
-
return nil, fmt.Errorf("unsupported file extension %q; only .doc and .txt uploads are supported", ext)
|
|
66
|
+
return nil, fmt.Errorf("unsupported file extension %q; only .doc, .docx, and .txt uploads are supported", ext)
|
|
66
67
|
}
|
|
67
68
|
fileName := filepath.Base(path)
|
|
68
69
|
contentType := mime.TypeByExtension(ext)
|
|
@@ -16,7 +16,7 @@ type GetThreadOptions struct {
|
|
|
16
16
|
RunID string `json:"run_id,omitempty"`
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
// GetThreadResult is the
|
|
19
|
+
// GetThreadResult is the parsed get_thread response used by `pippit-tool-cli short-drama +get-thread`.
|
|
20
20
|
type GetThreadResult struct {
|
|
21
21
|
ReadableText string `json:"readable_text"`
|
|
22
22
|
}
|
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@ metadata:
|
|
|
25
25
|
|
|
26
26
|
1. **提交短剧 Run 任务** - 创建新会话或向已有会话发送短剧创作需求。
|
|
27
27
|
2. **查询会话进展** - 根据 `thread_id` 和可选 `run_id` 拉取服务端 v2 `readable_text`,用于展示短剧任务进展、问题和结果。
|
|
28
|
-
3. **上传文件** - 上传本地 `.doc` / `.txt` 参考文件,得到 `asset_id`,供后续任务引用。
|
|
28
|
+
3. **上传文件** - 上传本地 `.doc` / `.docx` / `.txt` 参考文件,得到 `asset_id`,供后续任务引用。
|
|
29
29
|
4. **获取会话文件** - 根据 `thread_id` 拉取会话文件列表,得到 `file_path`、`download_url`。这和查询会话进展同等重要。
|
|
30
30
|
5. **下载重要资产** - 使用文件列表中的 `download_url` 下载资源,并按 `file_path` 写入用户本地目标文件路径。
|
|
31
31
|
|
|
@@ -65,7 +65,7 @@ pippit-tool-cli short-drama +get-thread --thread-id THREAD_ID --run-id RUN_ID
|
|
|
65
65
|
|
|
66
66
|
### 3. 上传文件
|
|
67
67
|
|
|
68
|
-
当用户提供短剧大纲、人物设定、世界观设定、已有分集或剧本等本地参考文件时,可先上传文件。`+upload-file` 当前只接收本地文件路径,并且只支持 `.doc` 和 `.txt` 后缀;不要把 `.md`、`.pdf`、图片、视频或 URL 传给该命令。
|
|
68
|
+
当用户提供短剧大纲、人物设定、世界观设定、已有分集或剧本等本地参考文件时,可先上传文件。`+upload-file` 当前只接收本地文件路径,并且只支持 `.doc`、`.docx` 和 `.txt` 后缀;不要把 `.md`、`.pdf`、图片、视频或 URL 传给该命令。
|
|
69
69
|
|
|
70
70
|
```bash
|
|
71
71
|
pippit-tool-cli short-drama +upload-file --path /path/to/outline.txt
|
|
@@ -140,7 +140,7 @@ pippit-tool-cli short-drama +download-result --url DOWNLOAD_URL --output-path FI
|
|
|
140
140
|
### 场景 2:用户提供参考文件要求创作
|
|
141
141
|
|
|
142
142
|
```
|
|
143
|
-
1. 检查用户提供的是一个本地 `.doc` 或 `.txt`
|
|
143
|
+
1. 检查用户提供的是一个本地 `.doc`、`.docx` 或 `.txt` 剧本文件路径;如果不是,告知当前上传命令只支持这三类文件,不要擅自转换或改写文件。
|
|
144
144
|
2. pippit-tool-cli short-drama +upload-file --path /path/to/file.txt
|
|
145
145
|
→ 拿到 asset_id
|
|
146
146
|
3. pippit-tool-cli short-drama +submit-run --message "用户的原始短剧需求" --asset-ids asset_id
|
|
@@ -194,10 +194,13 @@ pippit-tool-cli short-drama +download-result --url DOWNLOAD_URL --output-path FI
|
|
|
194
194
|
|
|
195
195
|
**+get-thread** 返回:
|
|
196
196
|
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
197
|
+
```text
|
|
198
|
+
Thread: thread_...
|
|
199
|
+
标题: ...
|
|
200
|
+
状态: ...
|
|
201
|
+
|
|
202
|
+
-- Run #1 --
|
|
203
|
+
[assistant] ...
|
|
201
204
|
```
|
|
202
205
|
|
|
203
206
|
**+upload-file** 返回:
|
|
@@ -208,7 +211,7 @@ pippit-tool-cli short-drama +download-result --url DOWNLOAD_URL --output-path FI
|
|
|
208
211
|
}
|
|
209
212
|
```
|
|
210
213
|
|
|
211
|
-
`+upload-file` 通过 `multipart/form-data` 上传文件,表单文件字段名为 `file`。本地文件必须存在、不能是目录,后缀必须是 `.doc` 或 `.txt`;不支持的后缀会直接报错。返回的 `asset_id` 来自服务端 `pippit_asset_id`,如果没有该字段才回退到 `asset_id`。
|
|
214
|
+
`+upload-file` 通过 `multipart/form-data` 上传文件,表单文件字段名为 `file`。本地文件必须存在、不能是目录,后缀必须是 `.doc`、`.docx` 或 `.txt`;不支持的后缀会直接报错。返回的 `asset_id` 来自服务端 `pippit_asset_id`,如果没有该字段才回退到 `asset_id`。
|
|
212
215
|
|
|
213
216
|
**+list-thread-file** 返回:
|
|
214
217
|
|
|
@@ -280,7 +283,7 @@ pippit-tool-cli short-drama +download-result --url DOWNLOAD_URL --output-path FI
|
|
|
280
283
|
|
|
281
284
|
你要做的只有三件事:
|
|
282
285
|
|
|
283
|
-
1. **上传**:如果用户给了本地 `.doc` / `.txt` 参考文件,先调用 `+upload-file`。
|
|
286
|
+
1. **上传**:如果用户给了本地 `.doc` / `.docx` / `.txt` 参考文件,先调用 `+upload-file`。
|
|
284
287
|
2. **提交任务**:首次创作时把用户原始短剧需求和唯一剧本 `asset_id` 通过 `+submit-run --asset-ids` 发给后端;同一 `thread_id` 后续续写或修改不再追加新的剧本文件。
|
|
285
288
|
3. **传话、取文件、下载资源**:根据 `+get-thread` 返回的 `readable_text` 展示进展、问题和结果;根据 `+list-thread-file` 获取文件列表;再根据 `download_url` 调用 `+download-result` 把缺失资源下载到用户本地。
|
|
286
289
|
|
|
@@ -298,7 +301,7 @@ pippit-tool-cli short-drama +download-result --url DOWNLOAD_URL --output-path FI
|
|
|
298
301
|
- `--message` 是用户的原始短剧需求,不能为空。
|
|
299
302
|
- 查询进展时优先使用 `+submit-run` 返回的 `thread_id` 和 `run_id`;如果需要查看整个会话,可以省略 `--run-id`。
|
|
300
303
|
- `+get-thread` 当前固定走服务端 v2 响应,输出字段是 `readable_text`;不要解析旧版 `messages` 数组。
|
|
301
|
-
- `+upload-file` 当前用于短剧场景文件上传链路,只支持本地 `.doc` / `.txt` 文件;`--path` 不能为空,路径必须指向真实文件,不能是目录。
|
|
304
|
+
- `+upload-file` 当前用于短剧场景文件上传链路,只支持本地 `.doc` / `.docx` / `.txt` 文件;`--path` 不能为空,路径必须指向真实文件,不能是目录。
|
|
302
305
|
- `+upload-file` 上传成功后只返回 `asset_id`;把该值原样作为 `+submit-run --asset-ids` 的参数。
|
|
303
306
|
- 单次创作会话中(相同 `thread_id`),`+submit-run` 只支持绑定一个剧本文件。不要在同一 `thread_id` 下重复上传并追加第二个剧本 `asset_id`;用户给多个剧本时,先让用户选择一个,或分别开启新的创作会话。
|
|
304
307
|
- `+list-thread-file` 只需要 `thread_id`;分页参数使用 `--page-num 1 --page-size 200` 起步,`total` 达到 200 时下一轮递增 `page-num`。
|