Skip to content

fix(skill): use FC temp OSS for skill code packages#18

Open
117503445 wants to merge 3 commits into
mainfrom
create-agentrun-skill
Open

fix(skill): use FC temp OSS for skill code packages#18
117503445 wants to merge 3 commits into
mainfrom
create-agentrun-skill

Conversation

@117503445

Copy link
Copy Markdown
Collaborator

Summary

  • Change ar skill create --code-dir to upload the skill ZIP to FC TempBucket OSS and create a SKILL/CODE_PACKAGE tool.
  • Implement FC 2016 tempBucketToken signing with Authorization: FC ... instead of POP/CommonRequest auth.
  • Send codeConfiguration.ossBucketName/ossObjectName/language/command and stop sending inline zipFile for normal create.
  • Add placeholder main.py injection for skill directories that do not contain an entrypoint.
  • Add unit/integration coverage and update English/Chinese docs.

Real verification

Ran a real 149 cn-hangzhou smoke test with the patched CLI:

tool_name: codeclaw-cli-fc-temp-skill-20260702195801
tool_id: 7af864e0-37c0-493d-b032-a167ee820334
status: READY

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

ruff check src/ tests/
ruff format --check src/ tests/
mypy src/agentrun_cli
pytest tests/unit tests/integration --cov=agentrun_cli --cov-fail-under=95

Result: 584 passed, total coverage 95.27%.

Signed-off-by: 117503445 <t117503445@gmail.com>
Copilot AI review requested due to automatic review settings July 2, 2026 14:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/command in codeConfiguration for 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.

Comment on lines +129 to +131
raise click.ClickException(
"创建 Skill 需要配置 access_key_id、access_key_secret、account_id 和 region"
) from exc
Comment on lines +133 to +136
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"
)
Comment thread src/agentrun_cli/commands/skill_cmd.py Outdated
Comment on lines +186 to +189
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
Comment thread src/agentrun_cli/commands/skill_cmd.py Outdated
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"))
Comment thread src/agentrun_cli/commands/skill_cmd.py Outdated
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}")
117503445 added 2 commits July 2, 2026 22:42
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里新增了对 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--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 并补对应集成测试。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants