fix(skill): use FC temp OSS for skill code packages#18
Conversation
Signed-off-by: 117503445 <t117503445@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the ar skill create --code-dir workflow to upload skill code as a ZIP to Function Compute (FC) TempBucket OSS and create the skill as a CODE_PACKAGE tool, rather than sending an inline zipFile. It also adds FC 2016-style request signing and improves skill packaging behavior by injecting a placeholder main.py when missing.
Changes:
- Implement FC TempBucket token retrieval + OSS upload flow, and pass
ossBucketName/ossObjectName/language/commandincodeConfigurationfor skill creation. - Add FC 2016
Authorization: FC ...signing and helper utilities (_fc_authorization, endpoint/object-name helpers). - Add unit/integration tests and update both English/Chinese skill docs to reflect the new code-package behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/agentrun_cli/commands/skill_cmd.py | Switch skill create to FC TempBucket OSS code-package flow; add signing/token/upload helpers; inject placeholder main.py when needed. |
| tests/unit/test_skill_cmd.py | Add unit coverage for ZIP placeholder injection and FC TempBucket signing/token/upload helpers; update create tests for CODE_PACKAGE body. |
| tests/integration/test_skill_cmd.py | Update integration coverage to assert CODE_PACKAGE request body and mock the FC TempBucket upload. |
| pyproject.toml | Add oss2 dependency required for OSS upload. |
| docs/en/skill.md | Document FC TempBucket upload + CODE_PACKAGE tool creation and placeholder main.py injection behavior. |
| docs/zh/skill.md | Same documentation update as English version (bilingual parity). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| raise click.ClickException( | ||
| "创建 Skill 需要配置 access_key_id、access_key_secret、account_id 和 region" | ||
| ) from exc |
| if not ak or not sk or not account_id or not region_id: | ||
| raise click.ClickException( | ||
| "创建 Skill 需要配置 access_key_id、access_key_secret、account_id 和 region" | ||
| ) |
| raise click.ClickException(f"获取 FC TempBucket token 失败: {detail}") from exc | ||
| except urllib.error.URLError as exc: | ||
| message = f"获取 FC TempBucket token 失败: {exc.reason}" | ||
| raise click.ClickException(message) from exc |
| except urllib.error.URLError as exc: | ||
| message = f"获取 FC TempBucket token 失败: {exc.reason}" | ||
| raise click.ClickException(message) from exc | ||
| return json.loads(raw.decode("utf-8")) |
| if value is None: | ||
| value = data.get(key[:1].upper() + key[1:]) | ||
| if not isinstance(value, str) or not value.strip(): | ||
| raise click.ClickException(f"FC TempBucket 响应缺少 {key}") |
Signed-off-by: 117503445 <t117503445@gmail.com>
Signed-off-by: 117503445 <t117503445@gmail.com>
| region: str | None, | ||
| ) -> _CodePackageLocation: | ||
| """Upload a Skill ZIP to FC TempBucket OSS and return its code location.""" | ||
| import oss2 |
There was a problem hiding this comment.
这里新增了对 oss2 的运行时依赖,但 agentrun.spec 仍然把 oss2 放在 EXCLUDES 里。CI 的 smoke 只做 make build,不会执行 ar skill create,所以 standalone 二进制会构建成功,但运行到这里时会报 ModuleNotFoundError: No module named 'oss2'。需要把 oss2 从 PyInstaller excludes 中移除(必要时加一个打包后二进制执行 skill create/导入的 smoke),否则发布出来的 dist/agentrun 无法创建 skill。
|
|
||
| if from_file: | ||
| payload = _load_json_option(from_file) | ||
| _reject_inline_code_fields(payload) |
There was a problem hiding this comment.
--from-file 现在会拒绝 zipFile/zip_file,但这个分支也不会调用 _upload_skill_archive_to_fc_temp_bucket,也不会补 create_method / artifact_type / code_configuration。也就是说用户即使传了必需的 --code-dir,最终也可能提交一个没有代码包位置和 CODE_PACKAGE 元数据的 payload(现有 from-file 测试就是这种形态),和文档里“目录会被上传并注册为代码包工具”的行为不一致,真实 API 也会缺少必填的 createMethod。建议要么把 --from-file 当作覆盖项但仍然上传 --code-dir 生成 codeConfiguration,要么明确要求 from-file 自带 CODE_PACKAGE + ossBucketName/ossObjectName 并补对应集成测试。
Summary
ar skill create --code-dirto upload the skill ZIP to FC TempBucket OSS and create aSKILL/CODE_PACKAGEtool.tempBucketTokensigning withAuthorization: FC ...instead of POP/CommonRequest auth.codeConfiguration.ossBucketName/ossObjectName/language/commandand stop sending inlinezipFilefor normal create.main.pyinjection for skill directories that do not contain an entrypoint.Real verification
Ran a real 149 cn-hangzhou smoke test with the patched CLI:
Review notes
Ran three Paseo sub-agent reviews with non-Codex providers:
claude/opus: found missing-account-id error handling gap; fixed and added regression test.claude/qwen3.7-max: suggested normalizing Date header lookup; fixed.claude/glm-5.2: suggested FC signature golden test; added.Tests
Result:
584 passed, total coverage95.27%.