feat(app): 移除内置agents并添加CORS支持和技能上传优化
移除了agents/registry.json中的所有内置agents配置,将agents数组清空。 为web应用添加了CORS中间件支持,允许指定的前端地址跨域访问。 重构了技能上传功能,增加了LLM重写机制,自动规范化上传的技能格式。 新增了工具名称提取逻辑,从技能正文中自动识别Required Tools段落。 更新了技能学习候选者和草稿的载荷结构,添加评估报告统计信息。 修改了意图路由技能的说明,改进任务状态管理逻辑。
This commit is contained in:
@ -84,6 +84,41 @@ def strip_frontmatter(content: str) -> str:
|
||||
return body
|
||||
|
||||
|
||||
def extract_required_tool_names(body: str) -> list[str]:
|
||||
"""从 canonical skill 正文的 `## Required Tools` 段落提取工具名。
|
||||
|
||||
这是 frontmatter `tools` 的容错补充,不从任意正文里猜工具。只读取明确
|
||||
命名的 Required Tools section,支持常见 bullet/code 格式。
|
||||
"""
|
||||
|
||||
if not body:
|
||||
return []
|
||||
|
||||
match = re.search(
|
||||
r"(?ims)^##\s+Required\s+Tools\s*$\n(?P<section>.*?)(?=^##\s+|\Z)",
|
||||
body,
|
||||
)
|
||||
if match is None:
|
||||
return []
|
||||
|
||||
names: list[str] = []
|
||||
for line in match.group("section").splitlines():
|
||||
stripped = line.strip()
|
||||
if not stripped or not stripped.startswith(("-", "*")):
|
||||
continue
|
||||
candidate = stripped[1:].strip()
|
||||
code_matches = re.findall(r"`([^`]+)`", candidate)
|
||||
raw_items = code_matches or re.split(r"[,,]", candidate)
|
||||
for raw_item in raw_items:
|
||||
name = raw_item.strip().strip("`\"' ")
|
||||
if not name:
|
||||
continue
|
||||
token = name.split()[0].strip("`\"' ::-")
|
||||
if re.fullmatch(r"[A-Za-z0-9_.:-]+", token) and token not in names:
|
||||
names.append(token)
|
||||
return names
|
||||
|
||||
|
||||
def parse_skill_metadata_blob(raw: str) -> dict[str, Any]:
|
||||
"""解析 metadata 字段里的 JSON 扩展配置。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user