@tool 工具源文件更新
update-tool
更新 workspace/capabilities/ 目录下现有的 @tool 源文件,并按 major/minor/patch 规则递增其语义化版本(semver)。
- License 许可
- Apache-2.0
- 最近更新
- 2026-10-22
- Stars
- ★ 3
- Forks
- 0
01 前言 Front Matter
- name
- update-tool
- tools
- [ "read", "update_tool", "reload" ]
- version
- 1.0.0
- triggers
- [ "fix the tool", "the tool has a bug", "change behavior of", "bump the version of", "update the tool" ]
- description
- Update an existing @tool source file in workspace/capabilities/, bumping its semver per major/minor/patch.
02 资源文件 1
- 脚本scripts/validate.py1.2 KB
03 SKILL.md 正文
Resources
(auto-filled by the loader)
Contract
Inputs you must have:
- The tool's
name(matches the file basename inworkspace/capabilities/). - The full
new_sourcebody —update_tooloverwrites, it does not patch. - A clear judgment about which version segment to bump.
Outputs the agent must produce:
- The replaced file with a bumped semver in its
@tool(version=...)argument. - A
reload()call after the update succeeds.
Knowledge
update_tool is a wholesale replacement. There is no partial edit — read the file with read, modify the source string in place, then call update_tool(name, new_source, version_bump). The new source MUST contain the bumped version string (e.g. version="1.2.4" for a patch bump from 1.2.3); the validator rejects mismatched versions.
Semver judgment (D-357 — LLM owns this call):
- patch — bug fix that doesn't change the function signature, return shape, or success/error contract. The LLM caller's existing prompts continue to work unchanged. Examples: fix a typo in an error message, handle an edge case that previously raised, narrow a regex, fix an off-by-one.
- minor — additive change. New optional parameters with safe defaults, new fields in the return string, broader input acceptance. The LLM's existing prompts still work; new prompts can use new functionality.
- major — breaking change. Required parameter renamed, return format restructured, behavior of an existing input changed. Any existing LLM prompt may break.
When in doubt, bump higher. A surprised caller is worse than a redundant version bump.
Steps
- Read the existing source:
read(file_path="<workspace>/capabilities/<name>.py"). - Decide the bump level based on the semver rules above. If the change is anything more than a typo fix, prefer minor over patch.
- Compose the new source — copy the existing body, apply the change, update the
version="..."in the@tool(...)decorator to the bumped value. - Call
update_tool(name=..., new_source=..., version_bump="<patch|minor|major>"). If it returnsError: must declare version="...", the version literal in your source doesn't match the bump — fix and retry. - Call
reload(). The diff should mention~1 replaced (<name> <old>→<new>). - Invoke the updated tool with sample arguments to confirm the change works.
Anti Patterns
- Don't call
update_toolwithout first reading the existing file. You'll lose context on what already worked. - Don't bump patch when you've changed an argument signature. That's a major.
- Don't skip the reload — your update is on disk but the registry still serves the old version.
- Don't forget to update the
version="..."literal inside the source. The validator rejects mismatches. - Don't re-create with
create_toolto "fix" something. Useupdate_toolso the version trail is preserved.
Examples
# Bug fix: missing-file path returns a confusing message
old_source = await read(file_path="capabilities/word_count.py")
new_source = old_source.replace(
"Error: not a file:",
"Error: file not found in workspace:",
).replace(
'version="1.0.0"',
'version="1.0.1"',
)
await update_tool(name="word_count", new_source=new_source, version_bump="patch")
await reload()
Validation
update_toolreturnedUpdated tool ... <old>→<new>.reload()returned a diff containing~1 replaced (<name> <old>→<new>).- Live invocation with the previous-failing input now returns the new behavior.
04 同仓库更多 Skills
笔记读取
notes
使用 notes_echo 工具回读笔记内容。
ArcFlow 工作流构建
workflow-builder
将对话中描述的可重复业务流程,转化为经过命名和验证的 ArcFlow 工作流草稿。
update-skill
Update an existing skill's SKILL.md body in workspace/capabilities/skills/, bumping its frontmatter semver.
create-tool
Author a new @tool-decorated Python file in the agent workspace, validate it, and register it via reload().
create-skill
Scaffold a new skill folder under workspace/capabilities/skills/ with frontmatter and the seven required sections.
sqlite
Use the SQLite connector to read the operator's semantic layer and make bounded typed reads of an approved database file. Trigger for questions about data in a connected SQLite database; skip for writes, schema changes, or raw SQL.