Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ jobs:
- name: Workflow checker tests
if: ${{ steps.setup.outputs.run-check-build != 'false' }}
run: node --test scripts/test/check-workflows.test.mjs
- name: Skill spec check — every SKILL.md, same rules as ans skill validate
if: ${{ steps.setup.outputs.run-check-build != 'false' }}
run: node scripts/check-skills.mjs
- name: Skill spec check tests
if: ${{ steps.setup.outputs.run-check-build != 'false' }}
run: node --test scripts/test/check-skills.test.mjs
- if: ${{ steps.setup.outputs.run-check-build != 'false' }}
run: pnpm -w turbo check
- name: "Test — all packages (node:test discovery, full truth)"
Expand Down
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ AnySearch is an agent CLI (`ans`) that works inside one domain only. It keeps re
- Push gate status: `pnpm hooks:status` exits 0 when the hook is in place and runs the same commands as the source; when it is missing, out of date, not executable, or someone else's, it exits non-zero and names which; outside a git repo it exits 2.
- `node scripts/preflight-test.mjs --dry-run` prints the plan; `--full` runs everything. Every test run points `HOME`/`USERPROFILE` at a throwaway temp dir and drops the repository pointers (`GIT_DIR` and the rest), so a test that forgets its own sandbox writes there instead of your `~/.ans`, and a test that makes its own repo cannot commit into your checkout; a green run deletes it (or says it could not), a red one keeps it and prints the path. What runs at each step is under "Gate rules" below.
- The gate's own tests, three groups: `node --test "scripts/test/preflight-*.test.mjs"` covers the gate's rules — which files a push carries, which packages that selects, what a red run prints, which home the child gets, which repository git reads inside a test, that a red self-test blocks, and that `hooks:install` / `hooks:status` put the right file in place and name what is wrong when they cannot. `node --test scripts/test/ci-changes.test.mjs` and `node --test scripts/test/check-workflows.test.mjs` cover the shared judgments: CI's change policy and workflow checker (#487). CI runs all three in `check-build`, and a full gate run runs each group as its own run. The gate names each group and, when it passes, how many tests ran; a red group blocks the push before the suite starts. An incremental push does not pay for any of it.
- `node scripts/check-skills.mjs` — every `SKILL.md` Git can see (tracked, plus new files that are not ignored), checked against the agentskills.io rules the product enforces: frontmatter is a mapping, `name` is 1–64 lowercase letters/digits with single hyphens (not a Windows device name) and equals its directory, `description` is 1–1024 characters and says when to use the skill, body stays under 500 lines. It calls the same `validateSkillFile` / `validateSkillDirectory` that `ans skill install` and `ans skill validate` use, so all three give the same verdict — except on `name` equals its directory, which install skips on purpose (a cloned repo's folder carries its own name) and validate and this script enforce. Exit 1 = a skill broke a rule or nothing was found; exit 2 = the check could not run. Pass a directory or a `SKILL.md` to check just that one; CI runs it in `check-build`.

### Gate rules (#367 — a commit, a push, a merge)

Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
## Unreleased — #387: skill 规范检查进 CI,规则和 `ans skill` 共用一份

一句话说清:**agentskills.io 那套规范以前靠人肉对表,现在 `node scripts/check-skills.mjs` 一条命令查全仓的 `SKILL.md`,`check-build` 里也跑它;规则没有第二份,`ans skill install` / `ans skill validate` 走的就是它导入的那段代码。**

### Added

- **`scripts/check-skills.mjs`**:默认用 `git ls-files` 找出 Git 看得见的所有 `SKILL.md` 逐个查(已跟踪的,加上还没被忽略的新文件;构建产物和 `node_modules` 里的副本不算),也可以直接指定目录或文件。每条结果都带文件、字段和期望,比如 `[FAIL] …/SKILL.md: SKILL.md description must be 1–1024 characters, got 0`,不是只说「不合法」。有红的退出码 1;文件读不了算「没查成」,退出码 2,不混进「这个 skill 不合格」。
- **一个 `SKILL.md` 都找不到也报红**:宁可退出码 1 也不假装查过了——仓库本来就该带着这份 skill。
- **`check-build` 多了两步**:跑这个检查,再跑它自己的测试(大写名字、清空 `description`、正文到 500 行,三种改坏都会红)。

### Changed

- **`validateSkillFile` 查的从「frontmatter + name」变成整套要查的东西**:frontmatter 是 YAML mapping、`name` 合不合规之外,还要 `description` 1–1024 字并说清什么时候用、正文少于 500 行。规范里标 Must 的那几条照旧,另外三条是本仓库自己加的:`description` 要点出什么时候用、正文 500 行、名字不能是 Windows 保留设备名;`license` / `compatibility` / `metadata` 这些可选字段不查。
- **新增 `validateSkillDirectory`**:在文件检查之外加上「`name` 必须等于所在目录名」,`ans skill validate` 和仓库检查都走它。安装仍然只查文件——clone 下来的仓库文件夹名不一定等于 skill 名,装进 `skills/synced/<name>` 之后这条规则自然成立。
- **装 skill 的门槛跟着变了**:`ans skill install` 以前收只写了 `name` 的 frontmatter,现在收不了。缺 `description`、正文到 500 行、名字不合规都会被挡下来,`description` 只是把「做什么」写清楚、没写「什么时候用」的也一样被挡(规范对这种写法只说「写得不好」,这里直接不收)。已经装好但不合规的,`ans skill validate` 会报红。要装的 skill 得先改好。
- **报错和通过的话都跟着改了**:`ans skill validate` 通过时打 `[OK] … SKILL.md name, description and body follow the spec`;`SKILL.md` 不存在时说「is missing」,不再说成「must be a regular file」;缺字段时说「has no name field / has no description」,不再把 YAML 空值(`name:`、`description:`)念成 `undefined` / `null` / `object`。

### Known limits

- **「说了什么时候用」只能认几个词**:`description` 里要有英文的 `when` / `whenever`、中文的 `什么时候` / `何时` / `时用` / `时使用` / `使用时`(繁体也认),或者日文的 `とき`。换个说法的(比如「审查代码时用」)、以及西班牙语这类没进词表的描述,照样会被挡;错误信息会把认的词列出来。反过来,带这些词但没真说清什么时候用的也照样过。这条挡的是漏写,不是写得不好。
- **正文行数不算前后空行**:frontmatter 后面那行空行、正文末尾的空行都不计入 500 行,数的是实际内容行。
- **只查代码里写死的那些规则**:规范的 `license`、`compatibility`、`metadata`、`allowed-tools` 和引用文件一律不管,所以通过只说明名字、描述、正文这三样没问题。

## Unreleased — #505: 宿主模板检查:坏形状、非整数 timeout、指错适配器都会红

一句话说清:**四份 `configs/*/hooks.json` 以前各测各的,没人横向比对;codebuddy 模板的命令和 `ans host connect` 写出来的已经不是同一条。现在一条测试读四份模板:timeout 必须是正整数、命令必须是本宿主自己的 bin、每条 hook 必须和 `hosts.ts` 的 `HOSTS` 候选逐字对上。生成物漂移改成和 `HEAD` 比,根目录 `pnpm test` 先跑 `gen:configs` 也洗不绿了。**
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ ans skill uninstall ans --project
`ans skill` only copies a directory inside a local Git checkout (one that contains a `SKILL.md`) into `skills/synced/`,
recording its source and commit. It is not a package manager and does not execute skill code. Locking, manifests, and cleanup live in `apps/cli/src/skill-store.ts`.

`install` and `validate` check the [Agent Skills spec](https://agentskills.io/specification) rules this repo enforces, plus a few house rules: the frontmatter is a YAML mapping, `name` is 1–64 lowercase letters/digits with single hyphens (not a Windows device name), `description` is 1–1024 characters and says when to use the skill, and the body stays under 500 lines. A source folder may carry any name (a cloned repo usually does); `ans skill validate` and `node scripts/check-skills.mjs` — which checks every `SKILL.md` in this repository — also require `name` to equal its directory.

**Installed does not mean active.** These commands never touch domain TOML files:
- **What `[skills].active` names**: skill keys declared in the domain TOML (shipped domains list runtime tags like `search`, `doctor`, `research`), not an auto-loader for `skills/synced/` directories.
- **What `[skills.toolRequires]` is**: a reserved optional skill-to-tool filter (`filterAgentTools` keeps `hooks.toolWhitelist ∩ (∪ toolRequires[active] ∪ {search})`). No shipped domain declares `toolRequires`; when omitted, `hooks.toolWhitelist` alone filters tools and `[skills].active` does not change runtime behavior.
Expand Down
6 changes: 6 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ ans skill uninstall ans --project
并记下来源和 commit。它不是包管理器,也不会执行 skill 里的代码。锁、清单、
残留清理这些细节看 `apps/cli/src/skill-store.ts`。

`install` 和 `validate` 查的是 [Agent Skills 规范](https://agentskills.io/specification) 里这个仓库认的几条,外加几条自己的规矩:
frontmatter 是 YAML mapping,`name` 是 1–64 位小写字母数字加单连字符(不能是 Windows 保留设备名),
`description` 1–1024 字且说清什么时候用,正文少于 500 行。
源目录叫什么名字都行(clone 下来的仓库一般不是 skill 名);`ans skill validate` 和
`node scripts/check-skills.mjs`(查本仓库所有 `SKILL.md`)另外要求 `name` 和所在目录同名。

**装了不等于打开。** 这些命令不会改 domain TOML:
- **`[skills].active` 里的名字是什么**:域 TOML 里声明的技能键名(出厂域写的是 `search`、`doctor`、`research` 这类运行时能力名),不是去 `skills/synced/` 自动加载目录的开关。
- **`[skills.toolRequires]` 现在干什么**:保留的可选「技能 → 所需工具」过滤表(`filterAgentTools` 按 `hooks.toolWhitelist ∩ (∪ toolRequires[active] ∪ {search})` 筛工具)。出厂域一个都没写它;没写 `toolRequires` 时,只靠 `hooks.toolWhitelist` 筛工具,`[skills].active` 写什么都不影响运行时。
Expand Down
12 changes: 9 additions & 3 deletions apps/cli/src/commands/skill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const HELP = `Usage: ans skill <command> [options]

Commands:
install <source> Copy a directory containing SKILL.md from a local Git checkout
validate [name] Validate installed SKILL.md frontmatter (all, or one skill)
validate [name] Check installed SKILL.md against the Agent Skills spec (all, or one skill)
list List skills recorded in installed.json
uninstall <name> Remove only the directory recorded in installed.json

Expand All @@ -26,7 +26,13 @@ Options:
--help, -h Show this help

The source's current Git HEAD is recorded; checkout a commit/tag before installing.
Frontmatter must be a YAML mapping with a safe lowercase name (1–64 characters).
Checked rules (agentskills.io/specification plus a few house rules): frontmatter is a YAML
mapping; name is 1–64 lowercase letters/digits with single hyphens and is not a Windows
device name; description is 1–1024 characters and says when to use the skill — checked by
keyword (when / whenever / 什么时候 / 何时 / 使用时 / 時 / とき …); the body stays under
500 lines. validate also requires name to equal the installed directory name;
install accepts any source folder name (a cloned repo usually has its own) and installs
under the name the frontmatter declares.
Managed skills live in ${MANAGED_SKILLS_REL_PATH}; sibling directories under skills/ are user-authored.
install copies the whole skill directory into ${MANAGED_SKILLS_REL_PATH}; the runtime never loads it (a host agent reads the files directly).
[skills].active is just a list of keys for [skills.toolRequires], unrelated to directories in ${MANAGED_SKILLS_REL_PATH}.
Expand Down Expand Up @@ -88,7 +94,7 @@ export async function runSkill(args: string[], opts: SkillCommandOptions = {}):
const results = validateInstalledSkills(scopeOpts, selected);
if (results.length === 0) out("No installed skills to validate.\n");
for (const result of results) {
out(result.ok ? `[OK] ${result.name}: SKILL.md frontmatter\n` : `[FAIL] ${result.name}: ${result.error}\n`);
out(result.ok ? `[OK] ${result.name}: SKILL.md name, description and body follow the spec\n` : `[FAIL] ${result.name}: ${result.error}\n`);
}
return results.every((result) => result.ok) ? 0 : 1;
}
Expand Down
Loading
Loading