Support loading bundled Skill resource files - #19031
Merged
Merged
Conversation
Member
|
建议补充 UTF-8 校验后再合并。 当前 建议:
|
Contributor
Author
|
已修改 |
Member
|
感谢你的贡献,思源有你更精彩! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feat/skill multifile resources | 支持 Skill 导入资源文件
问题与需求
SiYuan 能够安装多文件 Skill,但
skill.load只返回SKILL.md,Agent 无法从激活结果中发现和读取随 Skill 安装的资源。本次变更按照 Agent Skills 客户端实现指南和 Agent Skills 规范补充按需加载资源的能力。
方案
激活 Skill 时,将资源清单写入返回给 Agent 的 context;需要资源内容时,仍调用现有的
skill工具。name参数增加资源路径语义:第一种形式加载
SKILL.md并列出资源,第二种形式读取指定资源。所有 Skill 都支持这种用法。对于 SiYuan 工作空间内且能通过现有
file工具访问的 Skill,激活结果还会提供工作空间相对路径,Agent 可以选择使用file.read、file.list、file.grep和file.find,完成分段读取、目录浏览和内容搜索。用户级 Skill 不提供该路径,继续使用skill.load(name/path)。此方案的优势在于简单,不引入任何额外的新工具,仅靠提示词引导,拓展已有行为的边界。
具体变更
skill工具返回<skill_resources>;工作空间路径通过现有file校验后,再返回<skill_location>效果示例与对比
SKILL.mdSKILL.md和资源清单skill.load(name/path),也可以选择file.read、file.list、file.grep或file.findskill.load(name/path)AGENT 可能的使用效果如下:
导入工作空间 Skill:
{ "action": "load", "name": "pdf-processing" }其中
skill_resources和skill_location均为新增。此格式参考 Agent Skills 客户端实现指南。此时只读取
SKILL.md。需要参考资料时,再读取对应资源:{ "action": "load", "name": "pdf-processing/references/spec.md" }skill_location和内部的指令仅仅作为附加产品,在 AGENT 可能希望做 chunk 读取而非无脑全量的时候,给他提供一些工具。其启发灵感来源于 PI 的设计,在 PI Coding Agent 中,harness 不提供 skill read 工具,而是直接暴露 SKILL 所在路径,让模型自己调用 read 或者 bash 工具根据需求读取。特别说明
本次变更中,
SKILL.md正文保留现有的非敏感变量渲染;resource 部分刻意保留原文,不进行变量渲染。考虑如下:
$NAME和${NAME}都是非常常见的模式)。$NAME和${NAME}排除在外、另立渲染机制”的做法。若开发者对本 PR 的选择有异议,可以提出辩驳,也可以按自己的意愿修改,或关闭 PR。
变更类型
验证
效果对比
变更前
变更后
检查清单
dev分支且不存在合并冲突