8 Commits

Author SHA1 Message Date
laily 681aa9e237 feat(builder): load publish credentials from .env.builder
Keep DEB/Docker publish keys out of the project's .env. Scripts and
check.py --ready only read .env.builder; empty values count as missing.
2026-08-25 16:58:56 +08:00
laily 10d8800f07 feat: add skill init/check and isolate builder makefile
Give ack, builder, and deployer an explicit init/check mode that reports
missing project config instead of failing mid-work. Point builder at
makefile.builder so its contract targets do not collide with an existing
Makefile.
2026-08-25 16:49:28 +08:00
laily e9d2b5fde6 fix(builder): point version.mk at ~/.pouch after merging main
Keep ~/.skills as a lookup fallback so existing checkouts still resolve
version.sh.
2026-08-25 15:29:08 +08:00
laily f0b71b5bec Merge remote-tracking branch 'origin/main' into rename 2026-08-25 15:27:32 +08:00
laily 4423e7df1a feat: update 2026-08-25 15:26:29 +08:00
laily 12e00bd594 Merge branch 'main' into rename
Keep pouch naming and .pouch/ack project state, and bring in ACK
regression mode, deployer test-environment binding, and manage-release
updates from main.
2026-08-25 15:23:48 +08:00
laily f3cd56b78e feat: rename skills/skiff to pouch and move ACK state under .pouch
Use ~/.pouch, the pouch CLI, and .pouch.yaml as the SSOT container.
Keep the inner skills/ packages, and store ACK project state in
.pouch/ack instead of docs/ack.
2026-08-25 15:20:02 +08:00
laily 03d6298145 Merge pull request 'feat: update release' (#7) from fix-release into main
Reviewed-on: laily/.skills#7
2026-08-25 14:42:58 +08:00
103 changed files with 3215 additions and 1400 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
# Python(skiff CLI 运行时产物) # Python(pouch CLI 运行时产物)
__pycache__/ __pycache__/
*.py[cod] *.py[cod]
*$py.class *$py.class
@@ -1,4 +1,4 @@
# 复制为 docs/ack/knowledge.yaml,替换占位符。结构见 templates/knowledge.schema.json。 # 复制为 .pouch/ack/knowledge.yaml,替换占位符。结构见 templates/knowledge.schema.json。
# Developer/Test 只能在任务证据中提出 candidate;只有 Coordinator 写入这里。 # Developer/Test 只能在任务证据中提出 candidate;只有 Coordinator 写入这里。
version: 1 version: 1
updatedAt: "2026-08-01T12:43:06+08:00" updatedAt: "2026-08-01T12:43:06+08:00"
@@ -1,6 +1,6 @@
# Agent Skills 仓库 ACK 协作协议(项目覆盖层) # Agent Skills 仓库 ACK 协作协议(项目覆盖层)
> 本项目基于 ACK Skill v0.18.0。通用规范由 `/ack` 从 Skill 自身的 > 本项目基于 ACK Skill v0.19.0。通用规范由 `/ack` 从 Skill 自身的
> `references/` 读取;本文件只保存当前仓库差异。 > `references/` 读取;本文件只保存当前仓库差异。
## 项目概览 ## 项目概览
@@ -9,9 +9,9 @@
- 技术栈:Python 3、Markdown、JSON Schema - 技术栈:Python 3、Markdown、JSON Schema
- 运行命令:`python3 -m unittest discover -s tests -p 'test_*.py'` - 运行命令:`python3 -m unittest discover -s tests -p 'test_*.py'`
- Base URL:`n/a` - Base URL:`n/a`
- 任务板:`docs/ack/tasks.yaml` - 任务板:`.pouch/ack/tasks.yaml`
- 项目知识:`docs/ack/knowledge.yaml` - 项目知识:`.pouch/ack/knowledge.yaml`
- 覆盖层文件:`docs/ack/project.md` - 覆盖层文件:`.pouch/ack/project.md`
## 通用规范(由 ACK Skill 按需读取) ## 通用规范(由 ACK Skill 按需读取)
@@ -26,7 +26,7 @@
## Worker 路由 ## Worker 路由
机器可校验的 worker profile、允许 worktree 和 receipt 只以 机器可校验的 worker profile、允许 worktree 和 receipt 只以
`docs/ack/tasks.yaml` 为准。本次 Developer 使用当前项目根 `/home/ace/.skills`;Test `.pouch/ack/tasks.yaml` 为准。本次 Developer 使用当前项目根 `/home/ace/.skills`;Test
必须使用 fresh worker,并在独立临时项目、独立假 CLI 配置目录中完成黑盒演练。 必须使用 fresh worker,并在独立临时项目、独立假 CLI 配置目录中完成黑盒演练。
## 路径权限 ## 路径权限
@@ -34,7 +34,7 @@
| 路径 | Coordinator | Test | Developer | 说明 | | 路径 | Coordinator | Test | Developer | 说明 |
|------|:-----------:|:----:|:---------:|------| |------|:-----------:|:----:|:---------:|------|
| `docs/ack-feishu-bug-intake.md` | R/W | Read-only | Read-only | 本需求规格与验收契约 | | `docs/ack-feishu-bug-intake.md` | R/W | Read-only | Read-only | 本需求规格与验收契约 |
| `docs/ack/` | R/W | Read-only | Read-only | ACK 项目状态,只有 Coordinator 写 | | `.pouch/ack/` | R/W | Read-only | Read-only | ACK 项目状态,只有 Coordinator 写 |
| `skills/ack/` | Read-only | Read-only | R/W | ACK Skill 实现、模板与通用规范 | | `skills/ack/` | Read-only | Read-only | R/W | ACK Skill 实现、模板与通用规范 |
| `tests/test_ack_feishu_intake_unit.py` | Read-only | Read-only | R/W | Developer 白盒测试 | | `tests/test_ack_feishu_intake_unit.py` | Read-only | Read-only | R/W | Developer 白盒测试 |
| `tests/test_ack_feishu_intake_e2e.py` | Read-only | R/W | Read-only | Test 独立黑盒演练与回归测试 | | `tests/test_ack_feishu_intake_e2e.py` | Read-only | R/W | Read-only | Test 独立黑盒演练与回归测试 |
@@ -57,8 +57,8 @@ Test 黑盒复测:
```bash ```bash
python3 -m unittest discover -s tests -p 'test_ack_feishu_intake_e2e.py' python3 -m unittest discover -s tests -p 'test_ack_feishu_intake_e2e.py'
python3 -m unittest discover -s tests -p 'test_ack*.py' python3 -m unittest discover -s tests -p 'test_ack*.py'
python3 skills/ack/scripts/validate_tasks.py docs/ack/tasks.yaml python3 skills/ack/scripts/validate_tasks.py .pouch/ack/tasks.yaml
python3 skills/ack/scripts/validate_knowledge.py docs/ack/knowledge.yaml --tasks docs/ack/tasks.yaml python3 skills/ack/scripts/validate_knowledge.py .pouch/ack/knowledge.yaml --tasks .pouch/ack/tasks.yaml
``` ```
## 本次任务硬规则 ## 本次任务硬规则
@@ -1,14 +1,14 @@
version: 1 version: 1
updatedAt: "2026-08-23T20:30:26+08:00" updatedAt: "2026-08-23T20:30:26+08:00"
source: "Coordinator (PM) Agent" source: "Coordinator (PM) Agent"
ackVersion: "0.18.0" ackVersion: "0.19.0"
project: project:
name: "skills" name: "skills"
repoPath: "/home/ace/orca/workspaces/.skills/record-bug" repoPath: "/home/ace/orca/workspaces/.skills/record-bug"
baseUrl: "n/a" baseUrl: "n/a"
devWorktree: "/home/ace/orca/workspaces/.skills/record-bug" devWorktree: "/home/ace/orca/workspaces/.skills/record-bug"
overlayFile: "docs/ack/project.md" overlayFile: ".pouch/ack/project.md"
knowledgeFile: "docs/ack/knowledge.yaml" knowledgeFile: ".pouch/ack/knowledge.yaml"
orchestration: orchestration:
profileVersion: 1 profileVersion: 1
mode: "orca" mode: "orca"
@@ -455,7 +455,7 @@ tasks:
- "python3 -m unittest discover -s tests -p 'test_ack_feishu_intake_unit.py'" - "python3 -m unittest discover -s tests -p 'test_ack_feishu_intake_unit.py'"
- "python3 -m unittest discover -s tests -p 'test_ack_feishu_intake_e2e.py'" - "python3 -m unittest discover -s tests -p 'test_ack_feishu_intake_e2e.py'"
- "python3 -m unittest discover -s tests -p 'test_ack*.py'" - "python3 -m unittest discover -s tests -p 'test_ack*.py'"
- "python3 skills/ack/scripts/validate_tasks.py docs/ack/tasks.yaml" - "python3 skills/ack/scripts/validate_tasks.py .pouch/ack/tasks.yaml"
browser: browser:
page: "n/a" page: "n/a"
checks: checks:
@@ -507,7 +507,7 @@ tasks:
explicit tenant-b selection, trusted executable resolution, explicit tenant-b selection, trusted executable resolution,
screenshot containment, stable opaque sourceRef deduplication and screenshot containment, stable opaque sourceRef deduplication and
fail-closed handling for malformed, ambiguous, non-progressing and fail-closed handling for malformed, ambiguous, non-progressing and
over-limit responses. Validators, skiff check, compileall and diff over-limit responses. Validators, pouch check, compileall and diff
checks also passed. checks also passed.
resolution: resolution:
@@ -617,7 +617,7 @@ tasks:
verification: verification:
commands: commands:
- "python3 -m unittest tests.test_ack_omp_worker tests.test_ack_worker_profiles tests.test_ack_launch_worker" - "python3 -m unittest tests.test_ack_omp_worker tests.test_ack_worker_profiles tests.test_ack_launch_worker"
- "python3 skills/ack/scripts/validate_tasks.py docs/ack/tasks.yaml" - "python3 skills/ack/scripts/validate_tasks.py .pouch/ack/tasks.yaml"
browser: browser:
page: "n/a" page: "n/a"
checks: checks:
@@ -809,8 +809,8 @@ tasks:
verification: verification:
commands: commands:
- "python3 -m unittest discover -s tests -p 'test_ack_omp_e2e.py'" - "python3 -m unittest discover -s tests -p 'test_ack_omp_e2e.py'"
- "python3 skills/ack/scripts/validate_tasks.py docs/ack/tasks.yaml" - "python3 skills/ack/scripts/validate_tasks.py .pouch/ack/tasks.yaml"
- "python3 skills/ack/scripts/validate_knowledge.py docs/ack/knowledge.yaml --tasks docs/ack/tasks.yaml" - "python3 skills/ack/scripts/validate_knowledge.py .pouch/ack/knowledge.yaml --tasks .pouch/ack/tasks.yaml"
browser: browser:
page: "n/a" page: "n/a"
checks: checks:
+74 -72
View File
@@ -1,12 +1,11 @@
# Agent Skills 仓库 # pouch
自研 Agent Skills 与配套规范资料的单一事实来源(SSOT)。Skill 内容、规范包与可运行的 skiff CLI 在本仓库一并维护。 自研 Agent Skills 与配套规范资料的单一事实来源(SSOT)。仓库名、家目录 `~/.pouch` 和 CLI 都叫 **pouch**。旧名是 `skills` / `pouch`。
| 仓库 | 地址 | 职责 | | 仓库 | 地址 | 职责 |
| --------------- | ------------------------------------------------------------------------ | -------------------------- | | --------------- | ------------------------------------------------------------------------ | -------------------------- |
| **skills**(本仓库) | [https://git.yumee.top/laily/skills](https://git.yumee.top/laily/skills) | skill、规范包、skiff CLI 的当前 SSOT | | **pouch**(本仓库) | [https://git.yumee.top/laily/pouch](https://git.yumee.top/laily/pouch) | skill、规范包、pouch CLI 的当前 SSOT |
| **skiff** | [https://git.yumee.top/laily/skiff](https://git.yumee.top/laily/skiff) | skiff CLI 的独立来源 / 上游同步参考 |
--- ---
@@ -15,16 +14,16 @@
```bash ```bash
# 1. 克隆并关联 # 1. 克隆并关联
git clone https://git.yumee.top/laily/skills.git ~/.skills git clone https://git.yumee.top/laily/pouch.git ~/.pouch
cd ~/.skills && ./install.sh cd ~/.pouch && ./install.sh
# install.sh 会自动把 skiff 项目 skill 安装到所有 Agent # install.sh 会自动把 pouch 项目 skill 安装到所有 Agent
# 2. 安装其他 skill # 2. 安装其他 skill
skiff add declarative-openspec-loop -g pouch add declarative-openspec-loop -g
# 3. 查看状态 # 3. 查看状态
skiff list pouch list
skiff status pouch status
``` ```
--- ---
@@ -41,13 +40,13 @@ skills/
├── discussion-notes/ # 讨论沉淀笔记 ├── discussion-notes/ # 讨论沉淀笔记
│ ├── SKILL.md │ ├── SKILL.md
│ └── reference.md │ └── reference.md
skiff/ # CLI 源码(Python 3) pouch/ # CLI 源码(Python 3)
bin/skiff # CLI 入口 bin/pouch # CLI 入口
catalog.yaml # skiff 预置 Skill 来源目录 catalog.yaml # pouch 预置 Skill 来源目录
AGENTS.md # 本文档 AGENTS.md # 本文档
``` ```
**本仓库包含**:`skills/`、`skiff/`、`bin/skiff`、`catalog.yaml`、`AGENTS.md` **本仓库包含**:`skills/`、`pouch/`、`bin/pouch`、`catalog.yaml`、`AGENTS.md`
**本仓库不包含**:各项目的 skill 启用清单 **本仓库不包含**:各项目的 skill 启用清单
--- ---
@@ -61,7 +60,7 @@ AGENTS.md # 本文档
| ---------------------------------------------------------------------- | ------------------------------------------------- | | ---------------------------------------------------------------------- | ------------------------------------------------- |
| [orc](skills/orc/SKILL.md) | ORC 入口:显式编排开发、版本发布与产物任务,支持 Agent 分档 | | [orc](skills/orc/SKILL.md) | ORC 入口:显式编排开发、版本发布与产物任务,支持 Agent 分档 |
| [ack](skills/ack/SKILL.md) | ACK 入口:显式初始化、检查并运行三角色闭环、测试环境、发版与回归 | | [ack](skills/ack/SKILL.md) | ACK 入口:显式初始化、检查并运行三角色闭环、测试环境、发版与回归 |
| [skiff](skills/skiff/SKILL.md) | 本项目工作流:创建、使用、反馈与更新 builtin skill | | [pouch](skills/pouch/SKILL.md) | 本项目工作流:创建、使用、反馈与更新 builtin skill |
| [declarative-openspec-loop](skills/declarative-openspec-loop/SKILL.md) | 声明式编程循环:用户提供校验方式,Agent 自动 propose/apply/校验并迭代直到通过 | | [declarative-openspec-loop](skills/declarative-openspec-loop/SKILL.md) | 声明式编程循环:用户提供校验方式,Agent 自动 propose/apply/校验并迭代直到通过 |
| [discussion-notes](skills/discussion-notes/SKILL.md) | 讨论沉淀:边讨论边维护 Markdown 笔记,无 .raw.md | | [discussion-notes](skills/discussion-notes/SKILL.md) | 讨论沉淀:边讨论边维护 Markdown 笔记,无 .raw.md |
@@ -73,12 +72,15 @@ Skill 需要的稳定规范、模板、示例和脚本直接放在自己的目
项目状态,不复制或链接 Skill 内容: 项目状态,不复制或链接 Skill 内容:
```bash ```bash
skiff init ack pouch init ack
``` ```
builder 与 deployer 的项目接入走各自 skill 的「初始化」模式(检查配置并引导补齐),
不要 `pouch init builder` / `pouch init deployer`。
### 预置目录(Catalog) ### 预置目录(Catalog)
在 `catalog.yaml` 中预置,通过 skiff 拉取安装: 在 `catalog.yaml` 中预置,通过 pouch 拉取安装:
| Source | 来源 | | Source | 来源 |
@@ -87,8 +89,8 @@ skiff init ack
```bash ```bash
skiff fetch waza pouch fetch waza
skiff add waza/think -g pouch add waza/think -g
``` ```
### 自定义仓库(Custom Sources) ### 自定义仓库(Custom Sources)
@@ -96,21 +98,21 @@ skiff add waza/think -g
公司或团队维护、且一个仓库中包含多个 skill 时,使用命名 custom source: 公司或团队维护、且一个仓库中包含多个 skill 时,使用命名 custom source:
```bash ```bash
skiff source add company \ pouch source add company \
git@git.company.com:platform/agent-skills.git \ git@git.company.com:platform/agent-skills.git \
--skills-path skills --skills-path skills
skiff list --source company pouch list --source company
skiff add company/internal-review -g pouch add company/internal-review -g
``` ```
也可以接入已有本地 checkout: 也可以接入已有本地 checkout:
```bash ```bash
skiff source add company --local ~/code/company-skills --skills-path skills pouch source add company --local ~/code/company-skills --skills-path skills
``` ```
配置保存在 `~/.config/skiff/config.yaml`,Git source 默认 clone 到 配置保存在 `~/.config/pouch/config.yaml`,Git source 默认 clone 到
`~/.local/share/skiff/sources/<source>/`。项目 `.skills.yaml` 只记录逻辑 `~/.local/share/pouch/sources/<source>/`。项目 `.pouch.yaml` 只记录逻辑
source 名称,每台机器独立配置实际仓库地址。 source 名称,每台机器独立配置实际仓库地址。
### 社区(External NPM / GitHub) ### 社区(External NPM / GitHub)
@@ -127,28 +129,28 @@ npx skills find typescript
## 设计原则 ## 设计原则
1. **SSOT** — 自研 skill 只存在于 `skills/<name>/`,不在 Agent 目录直接创建 1. **SSOT** — 自研 skill 只存在于 `skills/<name>/`,不在 Agent 目录直接创建
2. **项目自治** — 每个项目自己维护 `.skills.yaml`,本仓库不维护项目清单 2. **项目自治** — 每个项目自己维护 `.pouch.yaml`,本仓库不维护项目清单
3. **软链优先** — 通过 symlink 映射到 Agent 目录,改 skill 即改 SSOT 3. **软链优先** — 通过 symlink 映射到 Agent 目录,改 skill 即改 SSOT
4. **能力内聚** — Skill 使用的规范、模板和脚本与 `SKILL.md` 同目录维护 4. **能力内聚** — Skill 使用的规范、模板和脚本与 `SKILL.md` 同目录维护
5. **一体维护** — skill 与 CLI 同仓库维护;需要时再与独立 skiff 仓库同步 5. **一体维护** — skill 与 CLI 同仓库维护
--- ---
## 架构 ## 架构
``` ```
skills 仓库(本仓库) skiff CLI pouch 仓库(本仓库) pouch CLI
skills/<name>/ ←── skiff install / enable skills/<name>/ ←── pouch install / enable
skiff/ ←── python3 -m skiff pouch/ ←── python3 -m pouch
catalog.yaml ←── skiff add / fetch catalog.yaml ←── pouch add / fetch
↑ ↑
~/.skills(symlink) ~/.pouch(symlink)
│ │
┌────┴────┐ ┌────┴────┐
▼ ▼ ▼ ▼
~/.cursor/skills/ project/.agents/skills/ ~/.cursor/skills/ project/.agents/skills/
~/.claude/skills/ project/.claude/skills/ ~/.claude/skills/ project/.claude/skills/
~/.codex/skills/ project/.skills.yaml ~/.codex/skills/ project/.pouch.yaml
~/.agents/skills/ (agents 标准目录,覆盖 OMP) ~/.agents/skills/ (agents 标准目录,覆盖 OMP)
``` ```
@@ -158,8 +160,8 @@ catalog.yaml ←── skiff add / fetch
| 层级 | 位置 | 维护方式 | | 层级 | 位置 | 维护方式 |
| ---------------- | ---------------------------------- | ------------------------------- | | ---------------- | ---------------------------------- | ------------------------------- |
| **Builtin** | `skills/<name>/` | 本仓库 commit | | **Builtin** | `skills/<name>/` | 本仓库 commit |
| **Catalog** | `catalog.yaml` + checkout 缓存 | `skiff catalog add / fetch` | | **Catalog** | `catalog.yaml` + checkout 缓存 | `pouch catalog add / fetch` |
| **Custom Source** | `~/.local/share/skiff/sources/` 或本地路径 | `skiff source add/fetch` | | **Custom Source** | `~/.local/share/pouch/sources/` 或本地路径 | `pouch source add/fetch` |
| **External NPM** | `node_modules/` | `npx skills add` / `skills-npm` | | **External NPM** | `node_modules/` | `npx skills add` / `skills-npm` |
### 非 Skill 资料分类 ### 非 Skill 资料分类
@@ -184,10 +186,10 @@ catalog.yaml ←── skiff add / fetch
## 项目级启用 ## 项目级启用
每个项目**自己维护** `.skills.yaml`,不由本仓库管理: 每个项目**自己维护** `.pouch.yaml`,不由本仓库管理:
```yaml ```yaml
# .skills.yaml(在项目根目录) # .pouch.yaml(在项目根目录)
skills: skills:
- name: declarative-openspec-loop - name: declarative-openspec-loop
source: builtin source: builtin
@@ -205,38 +207,38 @@ targets: # 可选,默认 all
| 概念 | 类比 | | 概念 | 类比 |
| -------------- | --------------------------- | | -------------- | --------------------------- |
| skills 仓库 | npm registry | | pouch 仓库 | npm registry |
| `.skills.yaml` | `package.json` dependencies | | `.pouch.yaml` | `package.json` dependencies |
| `skiff enable` | `npm install` | | `pouch enable` | `npm install` |
| `skiff sync` | `npm ci` | | `pouch sync` | `npm ci` |
项目级命令: 项目级命令:
```bash ```bash
cd ~/code/my-app cd ~/code/my-app
skiff enable declarative-openspec-loop pouch enable declarative-openspec-loop
skiff disable declarative-openspec-loop pouch disable declarative-openspec-loop
skiff sync pouch sync
``` ```
--- ---
## skiff 命令 ## pouch 命令
详见 [skiff README](https://git.yumee.top/laily/skiff)。 详见 [pouch README](https://git.yumee.top/laily/pouch)。
### 已实现 ### 已实现
| 命令 | 说明 | | 命令 | 说明 |
| -------------------------------------- | ------------------- | | -------------------------------------- | ------------------- |
| `skiff bootstrap` | 将 skiff 项目 skill 全局安装到所有 Agent | | `pouch bootstrap` | 将 pouch 项目 skill 全局安装到所有 Agent |
| `skiff list` | 列出所有 skill | | `pouch list` | 列出所有 skill |
| `skiff status` | 安装状态总览 | | `pouch status` | 安装状态总览 |
| `skiff add <name> [-g]` | 项目或全局安装(symlink) | | `pouch add <name> [-g]` | 项目或全局安装(symlink) |
| `skiff remove <name> [-g]` | 移除 symlink | | `pouch remove <name> [-g]` | 移除 symlink |
| `skiff catalog add` / `skiff fetch` | 管理和拉取 catalog source | | `pouch catalog add` / `pouch fetch` | 管理和拉取 catalog source |
### 草稿与健康检查 ### 草稿与健康检查
@@ -244,10 +246,10 @@ skiff sync
| 命令 | 说明 | | 命令 | 说明 |
| --- | --- | | --- | --- |
| `skiff create <name> --idea TEXT [--from-project PATH]` | 从 `_template/` 创建草稿 | | `pouch create <name> --idea TEXT [--from-project PATH]` | 从 `_template/` 创建草稿 |
| `skiff check <name>` | 校验草稿或正式 skill | | `pouch check <name>` | 校验草稿或正式 skill |
| `skiff finalize <name>` | 校验并将草稿转为正式 skill | | `pouch finalize <name>` | 校验并将草稿转为正式 skill |
| `skiff doctor [--fix]` | symlink 健康检查与修复 | | `pouch doctor [--fix]` | symlink 健康检查与修复 |
--- ---
@@ -282,12 +284,12 @@ description: >-
### 新建流程 ### 新建流程
1. `skiff create my-skill --idea "..." --from-project .` 1. `pouch create my-skill --idea "..." --from-project .`
2. Agent 编辑 `~/.skills/.drafts/my-skill/SKILL.md` 2. Agent 编辑 `~/.pouch/.drafts/my-skill/SKILL.md`
3. `skiff check my-skill` 3. `pouch check my-skill`
4. 用户确认后执行 `skiff finalize my-skill` 4. 用户确认后执行 `pouch finalize my-skill`
5. `skiff add my-skill -a cursor -g -y` 验证 5. `pouch add my-skill -a cursor -g -y` 验证
6. 在本仓库 commit;需要的项目再用 `skiff add my-skill` 启用 6. 在本仓库 commit;需要的项目再用 `pouch add my-skill` 启用
**禁止**在 `~/.cursor/skills/` 或项目 Agent 目录直接创建非 symlink 的 skill。 **禁止**在 `~/.cursor/skills/` 或项目 Agent 目录直接创建非 symlink 的 skill。
@@ -299,7 +301,7 @@ symlink 正确时,Agent 在项目里改 skill 文件 = 直接改 SSOT:
``` ```
project/.agents/skills/foo/SKILL.md project/.agents/skills/foo/SKILL.md
→ ~/.skills/skills/foo/SKILL.md → ~/.pouch/skills/foo/SKILL.md
→ 在本仓库 commit → 在本仓库 commit
``` ```
@@ -314,7 +316,7 @@ Claude Code 对 symlink 支持不稳定:可能无法发现 skill,或写入
| -------------- | ----------------------------------------------------- | | -------------- | ----------------------------------------------------- |
| Cursor / Codex | symlink,正常 | | Cursor / Codex | symlink,正常 |
| Claude Code | symlink 单个 skill 目录,不要 symlink 整个 `~/.claude/skills/` | | Claude Code | symlink 单个 skill 目录,不要 symlink 整个 `~/.claude/skills/` |
| symlink 被替换 | `skiff doctor --fix` → 重建 symlink | | symlink 被替换 | `pouch doctor --fix` → 重建 symlink |
--- ---
@@ -324,7 +326,7 @@ Claude Code 对 symlink 支持不稳定:可能无法发现 skill,或写入
| 场景 | 工具 | | 场景 | 工具 |
| -------------- | ---------------------------------------------------- | | -------------- | ---------------------------------------------------- |
| 自研 skill 安装/管理 | **skiff** | | 自研 skill 安装/管理 | **pouch** |
| 社区 skill 安装 | **Vercel `npx skills add`** | | 社区 skill 安装 | **Vercel `npx skills add`** |
| NPM 包内 skill | **skills-npm** / **skill-indexer** | | NPM 包内 skill | **skills-npm** / **skill-indexer** |
| 搜索发现 | **npx skills find** / [skills.sh](https://skills.sh) | | 搜索发现 | **npx skills find** / [skills.sh](https://skills.sh) |
@@ -337,13 +339,13 @@ Claude Code 对 symlink 支持不稳定:可能无法发现 skill,或写入
| 我要… | 命令 | 在哪 | | 我要… | 命令 | 在哪 |
| ---------- | --------------------------------- | ---- | | ---------- | --------------------------------- | ---- |
| 首次安装 | `git clone <repo> ~/.skills && ~/.skills/install.sh` | 任意 | | 首次安装 | `git clone <repo> ~/.pouch && ~/.pouch/install.sh` | 任意 |
| 新建 skill | `skiff create` → Agent 完善 → `check/finalize` | 任意项目 | | 新建 skill | `pouch create` → Agent 完善 → `check/finalize` | 任意项目 |
| 全局启用 | `skiff install <name>` | 任意 | | 全局启用 | `pouch install <name>` | 任意 |
| 项目启用 | `skiff enable <name>` | 项目目录 | | 项目启用 | `pouch enable <name>` | 项目目录 |
| 看状态 | `skiff status` | 任意 | | 看状态 | `pouch status` | 任意 |
| 装社区 skill | `npx skills add owner/repo -g -y` | 任意 | | 装社区 skill | `npx skills add owner/repo -g -y` | 任意 |
| 更新外部 skill | `skiff fetch <name>` | 任意 | | 更新外部 skill | `pouch fetch <name>` | 任意 |
--- ---
@@ -351,7 +353,7 @@ Claude Code 对 symlink 支持不稳定:可能无法发现 skill,或写入
## 参考 ## 参考
- [Agent Skills 开放标准](https://agentskills.io) - [Agent Skills 开放标准](https://agentskills.io)
- [skiff CLI](https://git.yumee.top/laily/skiff) - [pouch CLI](https://git.yumee.top/laily/pouch)
- [Vercel skills CLI](https://github.com/vercel-labs/skills) - [Vercel skills CLI](https://github.com/vercel-labs/skills)
- [skills.sh](https://skills.sh) - [skills.sh](https://skills.sh)
- [Cursor Skills 文档](https://cursor.com/docs/context/skills) - [Cursor Skills 文档](https://cursor.com/docs/context/skills)
+49 -40
View File
@@ -1,35 +1,44 @@
# Agent Skills # pouch
自研 [Agent Skills](https://agentskills.io) 的单一事实来源(SSOT)。Skill 内容与 **skiff** CLI 在本仓库一并维护。 自研 [Agent Skills](https://agentskills.io) 的单一事实来源(SSOT)。仓库、家目录 `~/.pouch` 和 CLI 都叫 **pouch**。Skill 内容与 CLI 在本仓库一并维护。
## 快速开始 ## 快速开始
```bash ```bash
git clone https://git.yumee.top/laily/skills.git ~/.skills git clone https://git.yumee.top/laily/pouch.git ~/.pouch
cd ~/.skills cd ~/.pouch
./install.sh # 安装 CLI,并将 skiff 项目 skill 安装到所有 Agent ./install.sh # 安装 CLI,并将 pouch 项目 skill 安装到所有 Agent
skiff add declarative-openspec-loop -g pouch add declarative-openspec-loop -g
skiff select # 交互式选择并批量安装 pouch select # 交互式选择并批量安装
skiff list pouch list
skiff status pouch status
``` ```
从旧的 `~/.skills` / `pouch` 迁移:
```bash
mv ~/.skills ~/.pouch
~/.pouch/install.sh
```
`install.sh` 会安装 `pouch` 命令,并保留 `pouch` 作为旧命令别名。项目里已有的 `.skills.yaml` 仍可读取;新写入使用 `.pouch.yaml`。
## 仓库结构 ## 仓库结构
``` ```
skills/ # 自研 skill(SSOT):每个子目录必须有 SKILL.md skills/ # 自研 skill(SSOT):每个子目录必须有 SKILL.md
skiff/ # CLI 源码(Python 3) pouch/ # CLI 源码(Python 3)
bin/skiff # CLI 入口 bin/pouch # CLI 入口
catalog.yaml # skiff 预置 Skill 来源目录 catalog.yaml # pouch 预置 Skill 来源目录
AGENTS.md # 详细规范与架构说明 AGENTS.md # 详细规范与架构说明
``` ```
| 路径 | 说明 | | 路径 | 说明 |
|------|------| |------|------|
| [skills/](skills/) | 自研 skill,每个子目录含 `SKILL.md`,可附带 references、templates 和 scripts | | [skills/](skills/) | 自研 skill,每个子目录含 `SKILL.md`,可附带 references、templates 和 scripts |
| [skiff/](skiff/README.md) | 安装、软链、健康检查 CLI | | [pouch/](pouch/README.md) | 安装、软链、健康检查 CLI |
| [catalog.yaml](catalog.yaml) | skiff 预置 Skill 来源目录 | | [catalog.yaml](catalog.yaml) | pouch 预置 Skill 来源目录 |
| [AGENTS.md](AGENTS.md) | 设计原则、编写规范、架构详解 | | [AGENTS.md](AGENTS.md) | 设计原则、编写规范、架构详解 |
## 自研 Skill ## 自研 Skill
@@ -38,45 +47,45 @@ AGENTS.md # 详细规范与架构说明
|-------|------| |-------|------|
| [orc](skills/orc/SKILL.md) | 显式编排开发、版本发布和产物任务,支持 low/mid/high Agent 档位 | | [orc](skills/orc/SKILL.md) | 显式编排开发、版本发布和产物任务,支持 low/mid/high Agent 档位 |
| [ack](skills/ack/SKILL.md) | 显式初始化、检查并运行 ACK 三角色协作及可选交付闭环 | | [ack](skills/ack/SKILL.md) | 显式初始化、检查并运行 ACK 三角色协作及可选交付闭环 |
| [skiff](skills/skiff/SKILL.md) | 在项目中创建、安装、反馈和维护 builtin skill | | [pouch](skills/pouch/SKILL.md) | 在项目中创建、安装、反馈和维护 builtin skill |
| [declarative-openspec-loop](skills/declarative-openspec-loop/SKILL.md) | 声明式编程循环:用户提供校验方式,Agent 自动迭代直到通过 | | [declarative-openspec-loop](skills/declarative-openspec-loop/SKILL.md) | 声明式编程循环:用户提供校验方式,Agent 自动迭代直到通过 |
| [discussion-notes](skills/discussion-notes/SKILL.md) | 讨论沉淀:边讨论边维护 Markdown 笔记 | | [discussion-notes](skills/discussion-notes/SKILL.md) | 讨论沉淀:边讨论边维护 Markdown 笔记 |
ACK 是包含规范、模板与校验脚本的完整 Skill。安装 Skill 后可初始化当前项目状态: ACK 是包含规范、模板与校验脚本的完整 Skill。安装 Skill 后可初始化当前项目状态:
```bash ```bash
skiff init ack pouch init ack
skiff init ack --project ~/app pouch init ack --project ~/app
``` ```
初始化会生成默认关闭的 `docs/ack/delivery.yaml` 和空的 `docs/ack/regression.yaml`。 初始化会生成默认关闭的 `.pouch/ack/delivery.yaml` 和空的 `.pouch/ack/regression.yaml`。
项目可用自然语言让 `/ack` 把测试环境绑到 deployer、维护发版 profile,并在任务 项目可用自然语言让 `/ack` 把测试环境绑到 deployer、维护发版 profile,并在任务
验证通过后收获回归用例。 验证通过后收获回归用例。
新建 skill: 新建 skill:
```bash ```bash
skiff create my-skill --idea "描述要解决的重复问题" --from-project . pouch create my-skill --idea "描述要解决的重复问题" --from-project .
# 由 Agent 完善 ~/.skills/.drafts/my-skill/SKILL.md # 由 Agent 完善 ~/.pouch/.drafts/my-skill/SKILL.md
skiff check my-skill pouch check my-skill
skiff finalize my-skill pouch finalize my-skill
skiff add my-skill -g # 全局安装验证 pouch add my-skill -g # 全局安装验证
``` ```
项目里使用 skill 发现通用问题或优化时,让 Agent 按 `skiff` skill 收集实际结果与期望结果,修改 `~/.skills/skills/<name>/` 的 SSOT,并执行 `skiff check <name>`。项目专属规则保留在项目内,不回流到通用 skill。 项目里使用 skill 发现通用问题或优化时,让 Agent 按 `pouch` skill 收集实际结果与期望结果,修改 `~/.pouch/skills/<name>/` 的 SSOT,并执行 `pouch check <name>`。项目专属规则保留在项目内,不回流到通用 skill。
## 安装方式 ## 安装方式
### 全局(用户级) ### 全局(用户级)
```bash ```bash
skiff add <name> -g # 安装到 ~/.cursor/skills/ 等 pouch add <name> -g # 安装到 ~/.cursor/skills/ 等
skiff add <name> -g -a cursor pouch add <name> -g -a cursor
``` ```
### 项目级 ### 项目级
在项目根目录维护 `.skills.yaml`: 在项目根目录维护 `.pouch.yaml`:
```yaml ```yaml
skills: skills:
@@ -92,9 +101,9 @@ targets: # 可选,默认 all
``` ```
```bash ```bash
skiff add declarative-openspec-loop pouch add declarative-openspec-loop
skiff sync pouch sync
skiff remove declarative-openspec-loop pouch remove declarative-openspec-loop
``` ```
## Catalog 与 Custom Source ## Catalog 与 Custom Source
@@ -102,15 +111,15 @@ skiff remove declarative-openspec-loop
安装 catalog 中预置的来源: 安装 catalog 中预置的来源:
```bash ```bash
skiff fetch waza pouch fetch waza
skiff add waza/think -g pouch add waza/think -g
``` ```
接入团队自己的本地目录或 Git 仓库: 接入团队自己的本地目录或 Git 仓库:
```bash ```bash
skiff source add company --local ~/code/company-skills --skills-path skills pouch source add company --local ~/code/company-skills --skills-path skills
skiff add company/internal-review -g pouch add company/internal-review -g
``` ```
**社区来源**(Vercel CLI): **社区来源**(Vercel CLI):
@@ -124,24 +133,24 @@ npx skills find typescript
``` ```
本仓库 本仓库
├── skills/<name>/ ←── skiff install / enable ├── skills/<name>/ ←── pouch install / enable
├── catalog.yaml ←── 预置来源发现与 fetch ├── catalog.yaml ←── 预置来源发现与 fetch
└── skiff/ ←── python3 -m skiff └── pouch/ ←── python3 -m pouch
↑ ↑
~/.skills(symlink) ~/.pouch(symlink)
│ │
┌────┴────────────────┐ ┌────┴────────────────┐
▼ ▼ ▼ ▼
~/.cursor/skills/ project/.agents/skills/ ~/.cursor/skills/ project/.agents/skills/
~/.claude/skills/ project/.claude/skills/ ~/.claude/skills/ project/.claude/skills/
~/.codex/skills/ project/.skills.yaml ~/.codex/skills/ project/.pouch.yaml
~/.agents/skills/ (agents 标准目录,覆盖 OMP) ~/.agents/skills/ (agents 标准目录,覆盖 OMP)
``` ```
## 设计原则 ## 设计原则
1. **SSOT** — 自研 skill 只存在于 `skills/<name>/` 1. **SSOT** — 自研 skill 只存在于 `skills/<name>/`
2. **项目自治** — 各项目自行维护 `.skills.yaml` 2. **项目自治** — 各项目自行维护 `.pouch.yaml`
3. **软链优先** — 通过 symlink 映射到 Agent 目录,改 skill 即改 SSOT 3. **软链优先** — 通过 symlink 映射到 Agent 目录,改 skill 即改 SSOT
4. **能力内聚** — Skill 所需规范、模板和脚本与 `SKILL.md` 放在同一目录 4. **能力内聚** — Skill 所需规范、模板和脚本与 `SKILL.md` 放在同一目录
5. **一体维护** — skill 与 CLI 同仓库,Python 3 直接运行,无需编译 5. **一体维护** — skill 与 CLI 同仓库,Python 3 直接运行,无需编译
@@ -149,7 +158,7 @@ npx skills find typescript
## 文档 ## 文档
- [AGENTS.md](AGENTS.md) — 完整规范、多 Agent 路径、编写约定 - [AGENTS.md](AGENTS.md) — 完整规范、多 Agent 路径、编写约定
- [skiff/README.md](skiff/README.md) — CLI 命令参考与开发说明 - [pouch/README.md](pouch/README.md) — CLI 命令参考与开发说明
## 参考 ## 参考
+2 -2
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
# 跟随软链,确保从 ~/.local/bin/skiff 调用时仍能找到仓库根目录 # 跟随软链,确保从 ~/.local/bin/pouch 调用时仍能找到仓库根目录
SCRIPT="${BASH_SOURCE[0]}" SCRIPT="${BASH_SOURCE[0]}"
while [ -L "$SCRIPT" ]; do while [ -L "$SCRIPT" ]; do
link_dir="$(cd "$(dirname "$SCRIPT")" && pwd)" link_dir="$(cd "$(dirname "$SCRIPT")" && pwd)"
@@ -11,4 +11,4 @@ done
REPO_ROOT="$(cd "$(dirname "$SCRIPT")/.." && pwd)" REPO_ROOT="$(cd "$(dirname "$SCRIPT")/.." && pwd)"
export PYTHONPATH="${REPO_ROOT}${PYTHONPATH:+:$PYTHONPATH}" export PYTHONPATH="${REPO_ROOT}${PYTHONPATH:+:$PYTHONPATH}"
exec python3 -m skiff "$@" exec python3 -m pouch "$@"
+1 -1
View File
@@ -4,7 +4,7 @@
# repo: <git-url> # repo: <git-url>
# ref: <branch|tag> (default: main) # ref: <branch|tag> (default: main)
# path: <subpath> (default: .) # path: <subpath> (default: .)
# description: <text> (optional, shown by `skiff select`) # description: <text> (optional, shown by `pouch select`)
# tags: (optional) # tags: (optional)
# - <tag> # - <tag>
# #
+11 -11
View File
@@ -17,7 +17,7 @@ updated: "2026-07-31T23:31:48+08:00"
## 背景 ## 背景
本轮评审覆盖 `skills/ack/` 的入口、角色规范、闭环流程、项目模板、任务板 本轮评审覆盖 `skills/ack/` 的入口、角色规范、闭环流程、项目模板、任务板
schema、校验脚本、Orca 适配器,以及 `skiff init ack` 的真实运行路径。 schema、校验脚本、Orca 适配器,以及 `pouch init ack` 的真实运行路径。
评审主要回答两个问题: 评审主要回答两个问题:
@@ -216,15 +216,15 @@ Deferred,当前 launcher 必须 fail closed。
## P0:初始化需要原子化 ## P0:初始化需要原子化
`skiff init ack` 会先写 `project.md` 和 `tasks.yaml`,再运行任务板校验。缺少 PyYAML `pouch init ack` 会先写 `project.md` 和 `tasks.yaml`,再运行任务板校验。缺少 PyYAML
时,命令会失败但保留两个文件。再次运行又会因为拒绝覆盖而失败。 时,命令会失败但保留两个文件。再次运行又会因为拒绝覆盖而失败。
相关位置: 相关位置:
- `requirements.txt:1` - `requirements.txt:1`
- `skills/ack/scripts/validate_tasks.py:37` - `skills/ack/scripts/validate_tasks.py:37`
- `skiff/cli.py:1144` - `pouch/cli.py:1144`
- `skiff/cli.py:1156` - `pouch/cli.py:1156`
本轮在不含第三方包的隔离 Python 环境中复现了这个状态。 本轮在不含第三方包的隔离 Python 环境中复现了这个状态。
@@ -232,7 +232,7 @@ Deferred,当前 launcher 必须 fail closed。
- 在临时目录渲染和校验,全部通过后再原子 rename。 - 在临时目录渲染和校验,全部通过后再原子 rename。
- 失败时只清理由本次调用创建的临时文件。 - 失败时只清理由本次调用创建的临时文件。
- 提供 `skiff init ack --repair` 或等价恢复路径。 - 提供 `pouch init ack --repair` 或等价恢复路径。
- 默认模板使用 `tasks: []`,完整示例继续放在 `examples/`。 - 默认模板使用 `tasks: []`,完整示例继续放在 `examples/`。
- CLI 输出“脚手架已创建,待配置”,检查通过后再称为“初始化完成”。 - CLI 输出“脚手架已创建,待配置”,检查通过后再称为“初始化完成”。
@@ -332,7 +332,7 @@ ACK 默认不提交、不推送。隔离 worktree 中的任务即使复测通过
2. 把 Orca adapter 改成每轮 Developer/Test 双任务。 2. 把 Orca adapter 改成每轮 Developer/Test 双任务。
3. 定义同 worktree 默认策略和跨 worktree transfer。 3. 定义同 worktree 默认策略和跨 worktree transfer。
4. 改造 worker launcher 与安全授权。 4. 改造 worker launcher 与安全授权。
5. 原子化 `skiff init ack`,空任务板作为默认模板。 5. 原子化 `pouch init ack`,空任务板作为默认模板。
6. 引入追加式 attempts、幂等恢复和失败分类。 6. 引入追加式 attempts、幂等恢复和失败分类。
7. 统一 schema 与语义校验,补齐对抗性 fixture。 7. 统一 schema 与语义校验,补齐对抗性 fixture。
8. 区分工作空间验证、集成验证和发布状态。 8. 区分工作空间验证、集成验证和发布状态。
@@ -342,7 +342,7 @@ ACK 默认不提交、不推送。隔离 worktree 中的任务即使复测通过
本轮执行了: 本轮执行了:
- `skiff check ack`:通过。这个命令只证明 Skill 的元数据和基础结构有效。 - `pouch check ack`:通过。这个命令只证明 Skill 的元数据和基础结构有效。
- `validate_tasks.py examples/tasks.example.yaml`:通过,当前机器使用内置规则。 - `validate_tasks.py examples/tasks.example.yaml`:通过,当前机器使用内置规则。
- `validate_worker_command.py --self-test`:7 项通过。 - `validate_worker_command.py --self-test`:7 项通过。
- `python3 -m unittest discover -s tests -v`:58 项通过。 - `python3 -m unittest discover -s tests -v`:58 项通过。
@@ -394,10 +394,10 @@ ACK 需要增加第三类项目事实,用来保存跨任务复用、会改变
| `tasks.yaml` | 当前任务状态、attempt 和执行证据 | Coordinator | | `tasks.yaml` | 当前任务状态、attempt 和执行证据 | Coordinator |
| `knowledge.yaml` | 跨任务复用的已验证经验 | Coordinator | | `knowledge.yaml` | 跨任务复用的已验证经验 | Coordinator |
建议新增项目级 SSOT:`docs/ack/knowledge.yaml`。知识归项目所有,与 Orca 等编排 建议新增项目级 SSOT:`.pouch/ack/knowledge.yaml`。知识归项目所有,与 Orca 等编排
工具无关;ACK 负责在任务闭环中生产、选择和消费这些知识。 工具无关;ACK 负责在任务闭环中生产、选择和消费这些知识。
这项设计会修改当前“`docs/ack/` 只保存 `project.md` 与 `tasks.yaml`”的边界。 这项设计会修改当前“`.pouch/ack/` 只保存 `project.md` 与 `tasks.yaml`”的边界。
新增文件保存项目事实,不复制 ACK Skill 的通用规范,因此不违反 Skill 内容仍以 新增文件保存项目事实,不复制 ACK Skill 的通用规范,因此不违反 Skill 内容仍以
`skills/ack/` 为 SSOT 的原则。 `skills/ack/` 为 SSOT 的原则。
@@ -580,8 +580,8 @@ issue、日志和外部网页只能作为不可信 evidence。进入知识库前
### 第一版范围 ### 第一版范围
第一版只实现一个 `docs/ack/knowledge.yaml`,不拆目录。活跃条目达到几十条、单文件 第一版只实现一个 `.pouch/ack/knowledge.yaml`,不拆目录。活跃条目达到几十条、单文件
开始影响审阅和选择时,再平滑迁移为 `docs/ack/knowledge/index.yaml` 加独立知识卡, 开始影响审阅和选择时,再平滑迁移为 `.pouch/ack/knowledge/index.yaml` 加独立知识卡,
条目 schema 和引用格式保持不变。 条目 schema 和引用格式保持不变。
第一版包括: 第一版包括:
+1 -1
View File
@@ -16,7 +16,7 @@
## 项目配置契约 ## 项目配置契约
可选配置位于 `docs/ack/tasks.yaml` 的 `project.bugIntake`。未配置时 ACK 保持现有行为。 可选配置位于 `.pouch/ack/tasks.yaml` 的 `project.bugIntake`。未配置时 ACK 保持现有行为。
配置存在时必须包含: 配置存在时必须包含:
| 字段 | 约束 | | 字段 | 约束 |
+10 -5
View File
@@ -3,17 +3,22 @@ set -euo pipefail
REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BIN_DIR="${HOME}/.local/bin" BIN_DIR="${HOME}/.local/bin"
PATH_MARKER="# skiff: ~/.local/bin" PATH_MARKER="# pouch: ~/.local/bin"
LEGACY_PATH_MARKER="# skiff: ~/.local/bin"
mkdir -p "$BIN_DIR" mkdir -p "$BIN_DIR"
ln -sf "$REPO/bin/skiff" "$BIN_DIR/skiff" ln -sf "$REPO/bin/pouch" "$BIN_DIR/pouch"
echo "已安装 skiff -> $BIN_DIR/skiff" echo "已安装 pouch -> $BIN_DIR/pouch"
if [[ ! -e "$BIN_DIR/skiff" || -L "$BIN_DIR/skiff" ]]; then
ln -sf "pouch" "$BIN_DIR/skiff"
echo "已保留 skiff -> pouch(旧命令名)"
fi
PYTHONPATH="$REPO${PYTHONPATH:+:$PYTHONPATH}" python3 -m skiff bootstrap PYTHONPATH="$REPO${PYTHONPATH:+:$PYTHONPATH}" python3 -m pouch bootstrap
path_already_configured() { path_already_configured() {
local file="$1" local file="$1"
[[ -f "$file" ]] && grep -qF "$PATH_MARKER" "$file" [[ -f "$file" ]] && { grep -qF "$PATH_MARKER" "$file" || grep -qF "$LEGACY_PATH_MARKER" "$file"; }
} }
configure_bash() { configure_bash() {
+253
View File
@@ -0,0 +1,253 @@
# pouch
Agent Skills 安装与管理 CLI。纯 Python 3 实现,无第三方依赖,无需编译。
## 安装
```bash
cd /path/to/pouch # 本仓库根目录
./install.sh # 软链到 ~/.local/bin/pouch
```
确保 `~/.local/bin` 在 `PATH` 中。
## 命令风格
接口对齐 [Vercel skills CLI](https://github.com/vercel-labs/skills) 的 `add` / `remove`,
统一管理 builtin skill、预置 catalog source 和用户命名的 custom source。
```bash
# 浏览可用自研 skill
pouch add --list
# 装到当前项目 / 全局
pouch add discussion-notes -a cursor -y
pouch add discussion-notes -a cursor -g -y
# 卸载
pouch remove discussion-notes -a cursor -y
pouch rm discussion-notes -g -y
# 改完 skill 后提交推送(在任意目录执行,操作 ~/.pouch)
pouch publish skills/discussion-notes -m "update discussion-notes" --push
```
开发时也可直接运行:
```bash
PYTHONPATH=/path/to/pouch python3 -m pouch <command>
```
## 首次安装
```bash
git clone https://git.yumee.top/laily/pouch.git ~/.pouch
~/.pouch/install.sh
```
`install.sh` 会安装 CLI,并自动执行 `pouch bootstrap`,将本仓库的 `pouch` skill 全局软链到 Cursor、Claude Code 和 Codex。也可以随时手动重跑:
```bash
pouch bootstrap
```
## 命令参考
### 查看
| 命令 | 说明 |
|------|------|
| `pouch list [--source NAME]` | 列出所有来源或指定 source 中的 skill |
| `pouch status [--target all\|cursor\|claude\|codex\|agents]` | 安装状态总览 |
### 项目初始化
| 命令 | 说明 |
|------|------|
| `pouch bootstrap` | 将本项目的 `pouch` skill 全局安装到所有 Agent |
| `pouch update` | 在 `~/.pouch` 执行 `git pull`,更新 pouch 自身 |
| `pouch init <name> [--project DIR]` | 使用 builtin skill 自带模板初始化项目状态(目前用于 ack) |
### Skill 安装
| 命令 | 说明 |
|------|------|
| `pouch add <name> [--global] [-a AGENT...] [-y]` | 安装到 Agent 目录(软链) |
| `pouch select [--global] [-a AGENT...]` | 打开终端多选界面,批量安装 skill |
| `pouch remove <name> [--global] [-a AGENT...] [-y]` | 移除软链(`rm` / `r` 别名) |
| `pouch add --list` | 列出可用 builtin skill |
| `pouch publish [paths] -m MSG [--push]` | 在 ~/.pouch 内 git add/commit/push |
旧命令 `install` / `uninstall` 已移除,请改用 `add` / `remove`。
全局目标路径:
| Agent | 路径 |
|-------|------|
| cursor | `~/.cursor/skills/` |
| claude | `~/.claude/skills/` |
| codex | `~/.codex/skills/` |
| agents | `~/.agents/skills/`(agents 标准目录,覆盖 OMP) |
### 预置 Catalog Source
| 命令 | 说明 |
|------|------|
| `pouch catalog add <name> <repo-url> [--ref main] [--path .]` | 写入 `catalog.yaml` |
| `pouch fetch <name>` | 克隆或更新 catalog source checkout |
| `pouch add <name> [-g] [-a AGENT...]` | 安装 catalog 中的单个 skill 或完整 collection(缺失时自动 fetch) |
| `pouch add <collection>/<skill> [...]` | 只安装 collection 中指定的 skill |
`catalog.yaml` 条目可额外提供 `description` 和 `tags`。`description`
会显示在 `pouch select` 的候选列表中。`path` 可以直接指向含
`SKILL.md` 的单个 skill,也可以指向由多个 skill 目录组成的 collection。
collection 会自动发现下一层所有含 `SKILL.md` 的目录;`pouch add <name>`
安装全部,`pouch select` 则展开为 `<name>/<skill>` 供分别勾选。同一
`repo` 与 `ref` 共享一份 Git checkout。
### 交互式批量安装
```bash
pouch select # 当前项目,全部 Agent
pouch select -a codex # 当前项目,仅 Codex
pouch select -g # 全局安装
pouch select --project ~/code/app # 指定项目
```
使用方向键移动、空格勾选、`/` 搜索、Enter 安装,按 `q` 或 Esc
取消。普通 `pouch select` 只安装到项目,并在每一项旁只读显示各 Agent 的
全局安装状态;`pouch select -g` 只安装到全局。已经安装到目标范围的 skill
默认勾选;取消勾选不会卸载已有 skill,卸载请使用 `pouch remove`。如果全局
存在同名但指向其它来源的 skill,项目选择器会显示“全局同名冲突”。
项目模式会把成功选择的项目写入 `.pouch.yaml`。非交互环境请使用
`pouch add <name>...`。使用 `-a` 限定 Agent 时,该范围会记录在对应的
skill 条目中,后续 `pouch sync` 不会扩散到其他 Agent。
### Custom source(多-skill 仓库)
公司或团队维护的仓库通常包含多个 skill。使用命名 source 接入:
```bash
# Git 仓库,默认 clone 到 ~/.local/share/pouch/sources/company
pouch source add company \
git@git.company.com:platform/agent-skills.git \
--ref main \
--skills-path internal/skills
# 或接入已有本地仓库
pouch source add company \
--local ~/code/company-agent-skills \
--skills-path skills
pouch source list
pouch source fetch company
pouch list --source company
pouch add company/code-review -g -a codex
```
| 命令 | 说明 |
|------|------|
| `pouch source add <name> <repo> [--ref REF] [--checkout PATH] [--skills-path PATH]` | 注册并克隆 Git source |
| `pouch source add <name> --local PATH [--skills-path PATH]` | 接入已有本地仓库 |
| `pouch source list` / `show <name>` | 查看 source |
| `pouch source fetch <name>` / `fetch --all` | clone 或 fast-forward 更新 |
| `pouch source remove <name>` | 移除配置并保留 checkout |
配置保存在 `~/.config/pouch/config.yaml`。Git/SSH 认证复用本机 Git 配置,
pouch 不保存 token。可以使用 `company/code-review`,也可以使用
`pouch add code-review --source company`。多个来源包含同名 skill 时,必须明确来源。
### 项目级
| 命令 | 说明 |
|------|------|
| `pouch enable <name> [--target all] [--project <dir>]` | 写入 `.pouch.yaml` 并创建项目软链 |
| `pouch disable <name> [--target all] [--project <dir>]` | 从 manifest 移除并删除软链 |
| `pouch sync [--target all] [--project <dir>]` | 按 `.pouch.yaml` 重建软链 |
项目目标路径:
| Agent | 路径 |
|-------|------|
| cursor | `<project>/.agents/skills/` |
| claude | `<project>/.claude/skills/` |
| codex | `<project>/.agents/skills/` |
| agents | `<project>/.agents/skills/`(与 cursor/codex 共用路径,软链幂等) |
### 脚手架与健康检查
| 命令 | 说明 |
|------|------|
| `pouch create <name> [--idea TEXT] [--from-project PATH]` | 从模板创建含 `SKILL.md`、`README.md` 的草稿 |
| `pouch check <name>` | 校验草稿或正式 skill,包括人类使用说明 |
| `pouch finalize <name>` | 校验草稿并移动到正式 `skills/` |
| `pouch doctor [--target all] [--fix]` | 检查软链健康状态,`--fix` 自动修复 |
## 常用工作流
### 新建并全局启用自研 skill
```bash
pouch create my-skill --idea "描述要解决的重复问题" --from-project .
# 由 Agent 完善草稿中的 SKILL.md 和 README.md
pouch check my-skill
pouch finalize my-skill
pouch publish skills/my-skill -m "add my-skill" --push
pouch add my-skill -a cursor -g -y
pouch doctor -a cursor
```
### 在项目中启用 skill
```bash
cd ~/code/my-app
pouch add declarative-openspec-loop -a cursor -y
```
### 添加 Catalog Source
```bash
pouch catalog add my-ext https://github.com/org/repo --ref main
pouch fetch my-ext
pouch add my-ext -g
```
## 源码结构
```
pouch/
├── __init__.py # 版本号
├── __main__.py # python3 -m pouch 入口
├── cli.py # 命令定义与调度
├── paths.py # 路径常量与 Agent 目标
├── skills.py # builtin/catalog/custom 统一解析
├── catalog.py # catalog.yaml 读写与 Skill 发现
├── sources.py # custom source 配置、发现与 Git 管理
├── project.py # .pouch.yaml 管理
├── symlinks.py # 软链创建/检查/修复
└── yaml_io.py # 轻量 YAML 解析(无第三方依赖)
```
入口脚本:[../bin/pouch](../bin/pouch)
## 路径约定
| 变量 | 路径 | 说明 |
|------|------|------|
| `POUCH_HOME` | `~/.pouch` | pouch 仓库(软链;兼容 `~/.skills`) |
| `SKILLS_DIR` | `~/.pouch/skills/` | builtin skill 目录 |
| `CATALOG_FILE` | `~/.pouch/catalog.yaml` | 预置 Skill 来源目录 |
| `CATALOG_CACHE_DIR` | `~/.local/share/pouch/externals/` | catalog checkout 缓存;按 repo/ref 共享 |
| `CONFIG_FILE` | `~/.config/pouch/config.yaml` | custom source 配置 |
| `SOURCES_DIR` | `~/.local/share/pouch/sources/` | custom Git source 默认 checkout |
## 注意事项
- **禁止**在 `~/.cursor/skills/` 等 Agent 目录直接创建非软链的 skill
- Claude Code 对 symlink 支持不稳定;建议对单个 skill 目录软链,不要软链整个 `~/.claude/skills/`
- 若 Agent 将软链替换为普通目录,运行 `pouch doctor --fix` 重建
## 相关文档
- [项目 README](../README.md)
- [AGENTS.md](../AGENTS.md)
+3
View File
@@ -0,0 +1,3 @@
"""pouch — Agent Skills 安装与管理 CLI。"""
__version__ = "0.6.0"
+1 -1
View File
@@ -1,4 +1,4 @@
from skiff.cli import main from pouch.cli import main
if __name__ == "__main__": if __name__ == "__main__":
main() main()
+1 -1
View File
@@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
from skiff.paths import ALL_TARGETS from pouch.paths import ALL_TARGETS
AGENT_ALIASES: dict[str, str] = { AGENT_ALIASES: dict[str, str] = {
"cursor": "cursor", "cursor": "cursor",
+4 -4
View File
@@ -6,8 +6,8 @@ import hashlib
from pathlib import Path from pathlib import Path
from typing import Any from typing import Any
from skiff import yaml_io from pouch import yaml_io
from skiff.paths import CATALOG_FILE, LEGACY_REGISTRY_FILE from pouch.paths import CATALOG_FILE, LEGACY_REGISTRY_FILE
def load_catalog(path: Path | None = None) -> dict[str, dict[str, Any]]: def load_catalog(path: Path | None = None) -> dict[str, dict[str, Any]]:
@@ -36,7 +36,7 @@ def catalog_repo(entry: dict[str, Any]) -> str:
def catalog_repo_path(entry: dict[str, Any]) -> Path: def catalog_repo_path(entry: dict[str, Any]) -> Path:
"""Return the shared checkout path for a repo/ref pair.""" """Return the shared checkout path for a repo/ref pair."""
from skiff.paths import CATALOG_CACHE_DIR from pouch.paths import CATALOG_CACHE_DIR
repo = str(entry.get("repo", "")) repo = str(entry.get("repo", ""))
ref = str(entry.get("ref", "main")) ref = str(entry.get("ref", "main"))
@@ -46,7 +46,7 @@ def catalog_repo_path(entry: dict[str, Any]) -> Path:
def catalog_checkout_path(name: str, entry: dict[str, Any]) -> Path: def catalog_checkout_path(name: str, entry: dict[str, Any]) -> Path:
"""Use a local repo directly, otherwise return its external checkout.""" """Use a local repo directly, otherwise return its external checkout."""
from skiff.paths import CATALOG_CACHE_DIR from pouch.paths import CATALOG_CACHE_DIR
configured_repo = str(entry.get("repo", "")) configured_repo = str(entry.get("repo", ""))
local_repo = Path(catalog_repo(entry)) local_repo = Path(catalog_repo(entry))
+97 -96
View File
@@ -1,4 +1,4 @@
"""skiff CLI 入口。""" """pouch CLI 入口。"""
from __future__ import annotations from __future__ import annotations
@@ -15,28 +15,29 @@ import tempfile
from datetime import datetime from datetime import datetime
from pathlib import Path from pathlib import Path
from skiff import __version__ from pouch import __version__
from skiff.agents import flatten_agent_args, resolve_agent_args from pouch.agents import flatten_agent_args, resolve_agent_args
from skiff.gitops import publish as git_publish from pouch.gitops import publish as git_publish
from skiff.paths import ( from pouch.paths import (
ALL_TARGETS, ALL_TARGETS,
DRAFTS_DIR, DRAFTS_DIR,
CATALOG_CACHE_DIR, CATALOG_CACHE_DIR,
CONFIG_FILE, CONFIG_FILE,
SKILLS_DIR, SKILLS_DIR,
SKILLS_HOME, POUCH_HOME,
TEMPLATE_DIR, TEMPLATE_DIR,
agent_skill_dir, agent_skill_dir,
ensure_skills_home, ensure_pouch_home,
project_manifest,
) )
from skiff.project import ( from pouch.project import (
add_skill_to_manifest, add_skill_to_manifest,
iter_manifest_skills, iter_manifest_skills,
load_manifest, load_manifest,
remove_skill_from_manifest, remove_skill_from_manifest,
resolve_manifest_skill, resolve_manifest_skill,
) )
from skiff.catalog import ( from pouch.catalog import (
discover_catalog_skills, discover_catalog_skills,
catalog_checkout_path, catalog_checkout_path,
catalog_skill_path, catalog_skill_path,
@@ -44,8 +45,8 @@ from skiff.catalog import (
catalog_repo, catalog_repo,
save_catalog, save_catalog,
) )
from skiff.selector import SkillChoice, select_skills from pouch.selector import SkillChoice, select_skills
from skiff.skills import ( from pouch.skills import (
list_custom_skills, list_custom_skills,
list_builtin_skills, list_builtin_skills,
builtin_skill_path, builtin_skill_path,
@@ -57,7 +58,7 @@ from skiff.skills import (
validate_skill_dir, validate_skill_dir,
validate_skill_name, validate_skill_name,
) )
from skiff.sources import ( from pouch.sources import (
discover_source_skills, discover_source_skills,
fetch_source, fetch_source,
load_sources, load_sources,
@@ -66,8 +67,8 @@ from skiff.sources import (
source_skills_root, source_skills_root,
validate_source_name, validate_source_name,
) )
from skiff.yaml_io import safe_dump from pouch.yaml_io import safe_dump
from skiff.symlinks import check_link, copy_template, create_link, find_repo_root, remove_link from pouch.symlinks import check_link, copy_template, create_link, find_repo_root, remove_link
_RENAME_NOREPLACE = 1 _RENAME_NOREPLACE = 1
@@ -485,7 +486,7 @@ def _remove_skill(
def cmd_list(args: argparse.Namespace) -> None: def cmd_list(args: argparse.Namespace) -> None:
ensure_skills_home() ensure_pouch_home()
source_filter = normalize_source(args.source) source_filter = normalize_source(args.source)
builtin = list_builtin_skills() builtin = list_builtin_skills()
catalog = load_catalog() catalog = load_catalog()
@@ -528,18 +529,18 @@ def cmd_list(args: argparse.Namespace) -> None:
def cmd_bootstrap(args: argparse.Namespace) -> None: def cmd_bootstrap(args: argparse.Namespace) -> None:
del args del args
ensure_skills_home() ensure_pouch_home()
project_skill = "skiff" project_skill = "pouch"
builtin_skill_path(project_skill) builtin_skill_path(project_skill)
_install_skill(project_skill, list(ALL_TARGETS), project_root=None) _install_skill(project_skill, list(ALL_TARGETS), project_root=None)
_print("已全局安装 builtin skiff skill 到所有 agent") _print("已全局安装 builtin pouch skill 到所有 agent")
def cmd_update(args: argparse.Namespace) -> None: def cmd_update(args: argparse.Namespace) -> None:
del args del args
ensure_skills_home() ensure_pouch_home()
_print(f"更新 skiff: {SKILLS_HOME}") _print(f"更新 pouch: {POUCH_HOME}")
subprocess.run(["git", "-C", str(SKILLS_HOME), "pull"], check=True) subprocess.run(["git", "-C", str(POUCH_HOME), "pull"], check=True)
def _installed_links( def _installed_links(
@@ -558,7 +559,7 @@ def _installed_links(
def cmd_status(args: argparse.Namespace) -> None: def cmd_status(args: argparse.Namespace) -> None:
ensure_skills_home() ensure_pouch_home()
targets = resolve_agent_args(flatten_agent_args(args.agents)) targets = resolve_agent_args(flatten_agent_args(args.agents))
builtin = list_builtin_skills() builtin = list_builtin_skills()
catalog = load_catalog() catalog = load_catalog()
@@ -578,7 +579,7 @@ def cmd_status(args: argparse.Namespace) -> None:
) )
entries.extend((source, name) for source, names in custom.items() for name in names) entries.extend((source, name) for source, names in custom.items() for name in names)
_print(f"skills 仓库: {SKILLS_HOME.resolve()}") _print(f"pouch 仓库: {POUCH_HOME.resolve()}")
_print(f"agents: {', '.join(targets)}\n") _print(f"agents: {', '.join(targets)}\n")
for package in unfetched_catalog: for package in unfetched_catalog:
@@ -604,10 +605,10 @@ def cmd_status(args: argparse.Namespace) -> None:
def _print_available_skills() -> None: def _print_available_skills() -> None:
ensure_skills_home() ensure_pouch_home()
builtin = list_builtin_skills() builtin = list_builtin_skills()
if not builtin: if not builtin:
_print("~/.skills/skills/ 中没有自研 skill") _print("~/.pouch/skills/ 中没有自研 skill")
return return
_print(f"来源: {SKILLS_DIR}\n") _print(f"来源: {SKILLS_DIR}\n")
@@ -621,14 +622,14 @@ def _print_available_skills() -> None:
def cmd_add(args: argparse.Namespace) -> None: def cmd_add(args: argparse.Namespace) -> None:
ensure_skills_home() ensure_pouch_home()
if args.list_available: if args.list_available:
if args.source: if args.source:
cmd_list(argparse.Namespace(source=args.source)) cmd_list(argparse.Namespace(source=args.source))
else: else:
_print_available_skills() _print_available_skills()
_print("使用 skiff add <name> 安装,或 skiff add <name> -g 全局安装") _print("使用 pouch add <name> 安装,或 pouch add <name> -g 全局安装")
return return
if args.all: if args.all:
@@ -647,7 +648,7 @@ def cmd_add(args: argparse.Namespace) -> None:
else: else:
names = _collect_skill_names(args.skills, args.skills_flag) names = _collect_skill_names(args.skills, args.skills_flag)
if not names: if not names:
raise SystemExit("请指定 skill 名称,或使用 skiff add --list 查看可用 skill") raise SystemExit("请指定 skill 名称,或使用 pouch add --list 查看可用 skill")
targets = resolve_agent_args(flatten_agent_args(args.agents)) targets = resolve_agent_args(flatten_agent_args(args.agents))
project_root = None if args.global_scope else _project_root(args.project) project_root = None if args.global_scope else _project_root(args.project)
@@ -671,7 +672,7 @@ def cmd_add(args: argparse.Namespace) -> None:
(link, str(link.readlink()) if link.is_symlink() else None) (link, str(link.readlink()) if link.is_symlink() else None)
) )
manifest_path = project_root / ".skills.yaml" if project_root else None manifest_path = project_manifest(project_root) if project_root else None
manifest_before = ( manifest_before = (
manifest_path.read_bytes() manifest_path.read_bytes()
if manifest_path and manifest_path.is_file() if manifest_path and manifest_path.is_file()
@@ -709,10 +710,10 @@ def cmd_add(args: argparse.Namespace) -> None:
def cmd_select(args: argparse.Namespace) -> None: def cmd_select(args: argparse.Namespace) -> None:
ensure_skills_home() ensure_pouch_home()
if not sys.stdin.isatty() or not sys.stdout.isatty(): if not sys.stdin.isatty() or not sys.stdout.isatty():
raise SystemExit( raise SystemExit(
"`skiff select` 需要交互式终端;非交互环境请使用 `skiff add <name>...`" "`pouch select` 需要交互式终端;非交互环境请使用 `pouch add <name>...`"
) )
targets = resolve_agent_args(flatten_agent_args(args.agents)) targets = resolve_agent_args(flatten_agent_args(args.agents))
@@ -877,7 +878,7 @@ def cmd_select(args: argparse.Namespace) -> None:
names = sorted(selected - selected_installed_keys) names = sorted(selected - selected_installed_keys)
failures: list[tuple[str, str]] = [] failures: list[tuple[str, str]] = []
manifest_path = project_root / ".skills.yaml" if project_root else None manifest_path = project_manifest(project_root) if project_root else None
successful = set(selected & selected_installed_keys) successful = set(selected & selected_installed_keys)
for name in names: for name in names:
skill_name, source = choice_requests[name] skill_name, source = choice_requests[name]
@@ -915,7 +916,7 @@ def cmd_select(args: argparse.Namespace) -> None:
def cmd_remove(args: argparse.Namespace) -> None: def cmd_remove(args: argparse.Namespace) -> None:
ensure_skills_home() ensure_pouch_home()
project_root = None if args.global_scope else _project_root(args.project) project_root = None if args.global_scope else _project_root(args.project)
targets = resolve_agent_args(flatten_agent_args(args.agents)) targets = resolve_agent_args(flatten_agent_args(args.agents))
@@ -925,7 +926,7 @@ def cmd_remove(args: argparse.Namespace) -> None:
names = _collect_skill_names(args.skills, args.skills_flag) names = _collect_skill_names(args.skills, args.skills_flag)
if not names: if not names:
raise SystemExit("请指定 skill 名称,或使用 skiff remove --all") raise SystemExit("请指定 skill 名称,或使用 pouch remove --all")
catalog = load_catalog() catalog = load_catalog()
sources = load_sources() sources = load_sources()
@@ -958,14 +959,14 @@ def cmd_remove(args: argparse.Namespace) -> None:
for name in dict.fromkeys(expanded): for name in dict.fromkeys(expanded):
total += _remove_skill(name, targets, project_root=project_root) total += _remove_skill(name, targets, project_root=project_root)
if project_root is not None: if project_root is not None:
remove_skill_from_manifest(project_root / ".skills.yaml", name) remove_skill_from_manifest(project_manifest(project_root), name)
if total == 0: if total == 0:
_print("没有移除任何 skill") _print("没有移除任何 skill")
def cmd_publish(args: argparse.Namespace) -> None: def cmd_publish(args: argparse.Namespace) -> None:
ensure_skills_home() ensure_pouch_home()
paths = args.paths or ["."] paths = args.paths or ["."]
git_publish( git_publish(
paths=paths, paths=paths,
@@ -976,7 +977,7 @@ def cmd_publish(args: argparse.Namespace) -> None:
def cmd_catalog_add(args: argparse.Namespace) -> None: def cmd_catalog_add(args: argparse.Namespace) -> None:
ensure_skills_home() ensure_pouch_home()
validate_skill_name(args.name) validate_skill_name(args.name)
catalog = load_catalog() catalog = load_catalog()
if args.name in catalog: if args.name in catalog:
@@ -992,7 +993,7 @@ def cmd_catalog_add(args: argparse.Namespace) -> None:
def cmd_fetch(args: argparse.Namespace) -> None: def cmd_fetch(args: argparse.Namespace) -> None:
ensure_skills_home() ensure_pouch_home()
catalog = load_catalog() catalog = load_catalog()
if args.name not in catalog: if args.name not in catalog:
raise SystemExit(f"catalog 中不存在: {args.name}") raise SystemExit(f"catalog 中不存在: {args.name}")
@@ -1106,9 +1107,9 @@ def cmd_source_remove(args: argparse.Namespace) -> None:
def cmd_sync(args: argparse.Namespace) -> None: def cmd_sync(args: argparse.Namespace) -> None:
ensure_skills_home() ensure_pouch_home()
root = _project_root(args.project) root = _project_root(args.project)
manifest_path = root / ".skills.yaml" manifest_path = project_manifest(root)
if not manifest_path.is_file(): if not manifest_path.is_file():
raise SystemExit(f"未找到 {manifest_path}") raise SystemExit(f"未找到 {manifest_path}")
@@ -1133,7 +1134,7 @@ def cmd_sync(args: argparse.Namespace) -> None:
def cmd_create(args: argparse.Namespace) -> None: def cmd_create(args: argparse.Namespace) -> None:
ensure_skills_home() ensure_pouch_home()
validate_skill_name(args.name) validate_skill_name(args.name)
if not TEMPLATE_DIR.is_dir(): if not TEMPLATE_DIR.is_dir():
raise SystemExit(f"模板目录不存在: {TEMPLATE_DIR}") raise SystemExit(f"模板目录不存在: {TEMPLATE_DIR}")
@@ -1170,8 +1171,8 @@ def cmd_create(args: argparse.Namespace) -> None:
} }
(dst / "brief.yaml").write_text(safe_dump(brief), encoding="utf-8") (dst / "brief.yaml").write_text(safe_dump(brief), encoding="utf-8")
_print(f"草稿已创建: {dst}") _print(f"草稿已创建: {dst}")
_print(f"下一步: 请完善 skiff 草稿 {args.name}") _print(f"下一步: 请完善 pouch 草稿 {args.name}")
_print(f"完成后运行: skiff check {args.name} && skiff finalize {args.name}") _print(f"完成后运行: pouch check {args.name} && pouch finalize {args.name}")
def _draft_or_builtin_path(name: str) -> tuple[Path, str]: def _draft_or_builtin_path(name: str) -> tuple[Path, str]:
@@ -1185,7 +1186,7 @@ def _draft_or_builtin_path(name: str) -> tuple[Path, str]:
def cmd_check(args: argparse.Namespace) -> None: def cmd_check(args: argparse.Namespace) -> None:
ensure_skills_home() ensure_pouch_home()
validate_skill_name(args.name) validate_skill_name(args.name)
path, kind = _draft_or_builtin_path(args.name) path, kind = _draft_or_builtin_path(args.name)
issues = validate_skill_dir(path, args.name) issues = validate_skill_dir(path, args.name)
@@ -1199,7 +1200,7 @@ def cmd_check(args: argparse.Namespace) -> None:
def cmd_finalize(args: argparse.Namespace) -> None: def cmd_finalize(args: argparse.Namespace) -> None:
ensure_skills_home() ensure_pouch_home()
validate_skill_name(args.name) validate_skill_name(args.name)
draft = DRAFTS_DIR / args.name draft = DRAFTS_DIR / args.name
if not draft.is_dir(): if not draft.is_dir():
@@ -1221,25 +1222,25 @@ def cmd_finalize(args: argparse.Namespace) -> None:
if brief.exists(): if brief.exists():
brief.unlink() brief.unlink()
_print(f"已完成 skill: {final}") _print(f"已完成 skill: {final}")
_print(f"下一步: skiff publish skills/{args.name} -m \"add {args.name}\" --push") _print(f"下一步: pouch publish skills/{args.name} -m \"add {args.name}\" --push")
def cmd_doctor(args: argparse.Namespace) -> None: def cmd_doctor(args: argparse.Namespace) -> None:
ensure_skills_home() ensure_pouch_home()
targets = resolve_agent_args(flatten_agent_args(args.agents)) targets = resolve_agent_args(flatten_agent_args(args.agents))
issues = 0 issues = 0
_print(f"skills 仓库: {SKILLS_HOME.resolve()}") _print(f"pouch 仓库: {POUCH_HOME.resolve()}")
if SKILLS_HOME.is_symlink(): if POUCH_HOME.is_symlink():
if not SKILLS_HOME.resolve().is_dir(): if not POUCH_HOME.resolve().is_dir():
_err(f"✗ ~/.skills 指向无效路径: {SKILLS_HOME.resolve()}") _err(f"✗ ~/.pouch 指向无效路径: {POUCH_HOME.resolve()}")
issues += 1 issues += 1
else: else:
_print("✓ ~/.skills 软链正常") _print("✓ ~/.pouch 软链正常")
elif SKILLS_HOME.is_dir() and (SKILLS_HOME / "skills").is_dir(): elif POUCH_HOME.is_dir() and (POUCH_HOME / "skills").is_dir():
_print("✓ ~/.skills 为本地仓库目录") _print("✓ ~/.pouch 为本地仓库目录")
else: else:
_err("✗ ~/.skills 未正确配置") _err("✗ ~/.pouch 未正确配置")
issues += 1 issues += 1
for name in list_builtin_skills(): for name in list_builtin_skills():
@@ -1278,13 +1279,13 @@ def cmd_doctor(args: argparse.Namespace) -> None:
else: else:
_print(f"\n发现 {issues} 个问题") _print(f"\n发现 {issues} 个问题")
if not args.fix: if not args.fix:
_print("提示: 使用 skiff doctor --fix 尝试自动修复软链") _print("提示: 使用 pouch doctor --fix 尝试自动修复软链")
sys.exit(1) sys.exit(1)
def cmd_init(args: argparse.Namespace) -> None: def cmd_init(args: argparse.Namespace) -> None:
"""使用 builtin skill 自带的模板初始化目标项目状态。""" """使用 builtin skill 自带的模板初始化目标项目状态。"""
ensure_skills_home() ensure_pouch_home()
validate_skill_name(args.name) validate_skill_name(args.name)
skills_root = SKILLS_DIR.resolve() skills_root = SKILLS_DIR.resolve()
skill_source = (SKILLS_DIR / args.name).resolve() skill_source = (SKILLS_DIR / args.name).resolve()
@@ -1307,7 +1308,7 @@ def cmd_init(args: argparse.Namespace) -> None:
initial_project_stat.st_ino, initial_project_stat.st_ino,
stat.S_IFMT(initial_project_stat.st_mode), stat.S_IFMT(initial_project_stat.st_mode),
) )
destination = project / "docs" / args.name destination = project / ".pouch" / args.name
project_file = destination / "project.md" project_file = destination / "project.md"
tasks_file = destination / "tasks.yaml" tasks_file = destination / "tasks.yaml"
knowledge_file = destination / "knowledge.yaml" knowledge_file = destination / "knowledge.yaml"
@@ -1340,7 +1341,7 @@ def cmd_init(args: argparse.Namespace) -> None:
) )
missing = [path for path, _ in template_targets if not path.is_file()] missing = [path for path, _ in template_targets if not path.is_file()]
if missing: if missing:
paths = ", ".join(str(path.relative_to(SKILLS_HOME)) for path in missing) paths = ", ".join(str(path.relative_to(POUCH_HOME)) for path in missing)
raise SystemExit(f"skill 缺少初始化模板: {paths}") raise SystemExit(f"skill 缺少初始化模板: {paths}")
validator = skill_source / "scripts" / "validate_tasks.py" validator = skill_source / "scripts" / "validate_tasks.py"
knowledge_validator = skill_source / "scripts" / "validate_knowledge.py" knowledge_validator = skill_source / "scripts" / "validate_knowledge.py"
@@ -1368,13 +1369,13 @@ def cmd_init(args: argparse.Namespace) -> None:
"<project_name>": project.name, "<project_name>": project.name,
"<repo_path>": str(project), "<repo_path>": str(project),
"<dev_worktree>": str(project), "<dev_worktree>": str(project),
"<overlay_file_path>": f"docs/{args.name}/project.md", "<overlay_file_path>": f".pouch/{args.name}/project.md",
"<ack_version>": ack_version, "<ack_version>": ack_version,
"<接入时的 ack skill 版本>": ack_version, "<接入时的 ack skill 版本>": ack_version,
"<YYYY-MM-DDTHH:mm:ss+TZ>": now, "<YYYY-MM-DDTHH:mm:ss+TZ>": now,
} }
with tempfile.TemporaryDirectory(prefix=f"skiff-{args.name}-init-") as temp_dir: with tempfile.TemporaryDirectory(prefix=f"pouch-{args.name}-init-") as temp_dir:
staging = Path(temp_dir) staging = Path(temp_dir)
staged_files: dict[Path, Path] = {} staged_files: dict[Path, Path] = {}
rendered_files: dict[Path, str] = {} rendered_files: dict[Path, str] = {}
@@ -1456,10 +1457,10 @@ def cmd_init(args: argparse.Namespace) -> None:
raise SystemExit(f"拒绝覆盖已有路径: {paths}") raise SystemExit(f"拒绝覆盖已有路径: {paths}")
project_fd: int | None = None project_fd: int | None = None
docs_fd: int | None = None pouch_fd: int | None = None
transaction_fd: int | None = None transaction_fd: int | None = None
staging_fd: int | None = None staging_fd: int | None = None
docs_created = False pouch_created = False
transaction_name: str | None = None transaction_name: str | None = None
staged_names: list[str] = [] staged_names: list[str] = []
published = False published = False
@@ -1487,8 +1488,8 @@ def cmd_init(args: argparse.Namespace) -> None:
project, project,
phase="初始化", phase="初始化",
) )
docs_fd, docs_created = _open_or_create_directory_at(project_fd, "docs") pouch_fd, pouch_created = _open_or_create_directory_at(project_fd, ".pouch")
if docs_created: if pouch_created:
os.fsync(project_fd) os.fsync(project_fd)
_assert_open_directory_path( _assert_open_directory_path(
project_fd, project_fd,
@@ -1496,15 +1497,15 @@ def cmd_init(args: argparse.Namespace) -> None:
phase="初始化", phase="初始化",
) )
_assert_open_directory_path( _assert_open_directory_path(
docs_fd, pouch_fd,
project / "docs", project / ".pouch",
phase="初始化", phase="初始化",
label="docs 目录", label=".pouch 目录",
) )
try: try:
destination_stat = os.stat( destination_stat = os.stat(
args.name, args.name,
dir_fd=docs_fd, dir_fd=pouch_fd,
follow_symlinks=False, follow_symlinks=False,
) )
except FileNotFoundError: except FileNotFoundError:
@@ -1513,14 +1514,14 @@ def cmd_init(args: argparse.Namespace) -> None:
if stat.S_ISLNK(destination_stat.st_mode): if stat.S_ISLNK(destination_stat.st_mode):
raise SystemExit( raise SystemExit(
"初始化路径必须是普通目录且不能是软链接: " "初始化路径必须是普通目录且不能是软链接: "
f"docs/{args.name}" f".pouch/{args.name}"
) )
raise SystemExit(f"拒绝覆盖已有路径: docs/{args.name}") raise SystemExit(f"拒绝覆盖已有路径: .pouch/{args.name}")
for _ in range(32): for _ in range(32):
candidate = f".{args.name}-init-{secrets.token_hex(8)}" candidate = f".{args.name}-init-{secrets.token_hex(8)}"
try: try:
os.mkdir(candidate, mode=0o700, dir_fd=docs_fd) os.mkdir(candidate, mode=0o700, dir_fd=pouch_fd)
except FileExistsError: except FileExistsError:
continue continue
transaction_name = candidate transaction_name = candidate
@@ -1531,7 +1532,7 @@ def cmd_init(args: argparse.Namespace) -> None:
transaction_fd = os.open( transaction_fd = os.open(
transaction_name, transaction_name,
os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW,
dir_fd=docs_fd, dir_fd=pouch_fd,
) )
os.mkdir("payload", mode=0o755, dir_fd=transaction_fd) os.mkdir("payload", mode=0o755, dir_fd=transaction_fd)
staging_fd = os.open( staging_fd = os.open(
@@ -1560,21 +1561,21 @@ def cmd_init(args: argparse.Namespace) -> None:
phase="发布", phase="发布",
) )
_assert_open_directory_path( _assert_open_directory_path(
docs_fd, pouch_fd,
project / "docs", project / ".pouch",
phase="发布", phase="发布",
label="docs 目录", label=".pouch 目录",
) )
try: try:
_rename_directory_noreplace( _rename_directory_noreplace(
transaction_fd, transaction_fd,
"payload", "payload",
docs_fd, pouch_fd,
args.name, args.name,
) )
except FileExistsError as exc: except FileExistsError as exc:
raise SystemExit( raise SystemExit(
f"拒绝覆盖已有路径: docs/{args.name}" f"拒绝覆盖已有路径: .pouch/{args.name}"
) from exc ) from exc
published = True published = True
_assert_open_directory_path( _assert_open_directory_path(
@@ -1586,23 +1587,23 @@ def cmd_init(args: argparse.Namespace) -> None:
if ( if (
transaction_name is not None transaction_name is not None
and _directory_entry_matches_open_fd( and _directory_entry_matches_open_fd(
docs_fd, pouch_fd,
transaction_name, transaction_name,
transaction_fd, transaction_fd,
) )
): ):
try: try:
os.rmdir(transaction_name, dir_fd=docs_fd) os.rmdir(transaction_name, dir_fd=pouch_fd)
except OSError: except OSError:
pass pass
else: else:
transaction_name = None transaction_name = None
try: try:
os.fsync(docs_fd) os.fsync(pouch_fd)
except OSError as exc: except OSError as exc:
raise SystemExit( raise SystemExit(
"初始化目录已完整发布,但无法确认目录项持久化;" "初始化目录已完整发布,但无法确认目录项持久化;"
f"请检查 docs/{args.name} 后再重试" f"请检查 .pouch/{args.name} 后再重试"
) from exc ) from exc
_assert_open_directory_path( _assert_open_directory_path(
project_fd, project_fd,
@@ -1610,10 +1611,10 @@ def cmd_init(args: argparse.Namespace) -> None:
phase="完成初始化", phase="完成初始化",
) )
_assert_open_directory_path( _assert_open_directory_path(
docs_fd, pouch_fd,
project / "docs", project / ".pouch",
phase="完成初始化", phase="完成初始化",
label="docs 目录", label=".pouch 目录",
) )
_assert_open_directory_path( _assert_open_directory_path(
staging_fd, staging_fd,
@@ -1638,15 +1639,15 @@ def cmd_init(args: argparse.Namespace) -> None:
if ( if (
transaction_name is not None transaction_name is not None
and transaction_fd is not None and transaction_fd is not None
and docs_fd is not None and pouch_fd is not None
and _directory_entry_matches_open_fd( and _directory_entry_matches_open_fd(
docs_fd, pouch_fd,
transaction_name, transaction_name,
transaction_fd, transaction_fd,
) )
): ):
try: try:
os.rmdir(transaction_name, dir_fd=docs_fd) os.rmdir(transaction_name, dir_fd=pouch_fd)
except OSError: except OSError:
pass pass
raise raise
@@ -1654,7 +1655,7 @@ def cmd_init(args: argparse.Namespace) -> None:
for directory_fd in ( for directory_fd in (
staging_fd, staging_fd,
transaction_fd, transaction_fd,
docs_fd, pouch_fd,
project_fd, project_fd,
): ):
if directory_fd is not None: if directory_fd is not None:
@@ -1697,20 +1698,20 @@ def _add_common_flags(parser: argparse.ArgumentParser) -> None:
def build_parser() -> argparse.ArgumentParser: def build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
prog="skiff", prog="pouch",
description="自研 Agent Skills 安装与管理 CLI(接口对齐 Vercel skills)", description="自研 Agent Skills 安装与管理 CLI(接口对齐 Vercel skills)",
) )
parser.add_argument("--version", action="version", version=f"skiff {__version__}") parser.add_argument("--version", action="version", version=f"pouch {__version__}")
sub = parser.add_subparsers(dest="command", required=True) sub = parser.add_subparsers(dest="command", required=True)
p_bootstrap = sub.add_parser( p_bootstrap = sub.add_parser(
"bootstrap", "bootstrap",
help="将本项目 skiff skill 全局安装到所有 agent", help="将本项目 pouch skill 全局安装到所有 agent",
) )
p_bootstrap.set_defaults(func=cmd_bootstrap) p_bootstrap.set_defaults(func=cmd_bootstrap)
p_update = sub.add_parser("update", help="通过 git pull 更新 skiff 自身") p_update = sub.add_parser("update", help="通过 git pull 更新 pouch 自身")
p_update.set_defaults(func=cmd_update) p_update.set_defaults(func=cmd_update)
p_list = sub.add_parser("list", help="列出所有 source 中的 skill") p_list = sub.add_parser("list", help="列出所有 source 中的 skill")
@@ -1754,7 +1755,7 @@ def build_parser() -> argparse.ArgumentParser:
p_publish = sub.add_parser( p_publish = sub.add_parser(
"publish", "publish",
help="在 ~/.skills 内 git add / commit / push", help="在 ~/.pouch 内 git add / commit / push",
) )
p_publish.add_argument("paths", nargs="*", help="要提交的路径(默认 .)") p_publish.add_argument("paths", nargs="*", help="要提交的路径(默认 .)")
p_publish.add_argument("-m", "--message", help="commit 说明") p_publish.add_argument("-m", "--message", help="commit 说明")
@@ -1805,11 +1806,11 @@ def build_parser() -> argparse.ArgumentParser:
p_source_remove.add_argument( p_source_remove.add_argument(
"--delete-checkout", "--delete-checkout",
action="store_true", action="store_true",
help="同时永久删除 skiff 管理的 checkout", help="同时永久删除 pouch 管理的 checkout",
) )
p_source_remove.set_defaults(func=cmd_source_remove) p_source_remove.set_defaults(func=cmd_source_remove)
p_sync = sub.add_parser("sync", help="按 .skills.yaml 重建项目软链") p_sync = sub.add_parser("sync", help="按 .pouch.yaml 重建项目软链")
p_sync.add_argument("-a", "--agent", dest="agents", nargs="+", action="append") p_sync.add_argument("-a", "--agent", dest="agents", nargs="+", action="append")
p_sync.add_argument("--project") p_sync.add_argument("--project")
p_sync.set_defaults(func=cmd_sync) p_sync.set_defaults(func=cmd_sync)
+3 -3
View File
@@ -1,4 +1,4 @@
"""~/.skills 仓库内的 git 操作。""" """~/.pouch 仓库内的 git 操作。"""
from __future__ import annotations from __future__ import annotations
@@ -6,7 +6,7 @@ import subprocess
import sys import sys
from pathlib import Path from pathlib import Path
from skiff.paths import SKILLS_HOME from pouch.paths import POUCH_HOME
def _run_git(repo: Path, *args: str, check: bool = True) -> subprocess.CompletedProcess[str]: def _run_git(repo: Path, *args: str, check: bool = True) -> subprocess.CompletedProcess[str]:
@@ -35,7 +35,7 @@ def publish(
push: bool, push: bool,
no_commit: bool, no_commit: bool,
) -> None: ) -> None:
repo = SKILLS_HOME.resolve() repo = POUCH_HOME.resolve()
ensure_git_repo(repo) ensure_git_repo(repo)
_run_git(repo, "add", "--", *paths) _run_git(repo, "add", "--", *paths)
+103
View File
@@ -0,0 +1,103 @@
"""路径与 Agent 目标定义。"""
from __future__ import annotations
from pathlib import Path
HOME = Path.home()
PREFERRED_POUCH_HOME = HOME / ".pouch"
LEGACY_POUCH_HOME = HOME / ".skills"
PROJECT_MANIFEST = ".pouch.yaml"
LEGACY_PROJECT_MANIFEST = ".skills.yaml"
def _first_existing_dir(*candidates: Path, default: Path) -> Path:
for path in candidates:
if path.is_dir():
return path
return default
def _first_existing_file(*candidates: Path, default: Path) -> Path:
for path in candidates:
if path.is_file():
return path
return default
POUCH_HOME = _first_existing_dir(
PREFERRED_POUCH_HOME,
LEGACY_POUCH_HOME,
default=PREFERRED_POUCH_HOME,
)
SKILLS_DIR = POUCH_HOME / "skills"
TEMPLATE_DIR = SKILLS_DIR / "_template"
DRAFTS_DIR = POUCH_HOME / ".drafts"
CATALOG_FILE = POUCH_HOME / "catalog.yaml"
LEGACY_REGISTRY_FILE = POUCH_HOME / "registry.yaml"
CATALOG_CACHE_DIR = _first_existing_dir(
HOME / ".local" / "share" / "pouch" / "externals",
HOME / ".local" / "share" / "skills" / "externals",
default=HOME / ".local" / "share" / "pouch" / "externals",
)
CONFIG_FILE = _first_existing_file(
HOME / ".config" / "pouch" / "config.yaml",
HOME / ".config" / "skiff" / "config.yaml",
default=HOME / ".config" / "pouch" / "config.yaml",
)
SOURCES_DIR = _first_existing_dir(
HOME / ".local" / "share" / "pouch" / "sources",
HOME / ".local" / "share" / "skiff" / "sources",
default=HOME / ".local" / "share" / "pouch" / "sources",
)
AGENT_GLOBAL: dict[str, Path] = {
"cursor": HOME / ".cursor" / "skills",
"claude": HOME / ".claude" / "skills",
"codex": HOME / ".codex" / "skills",
# agents 标准目录:OMP 原生 canonical(agents provider),cursor/codex 项目级同路径
"agents": HOME / ".agents" / "skills",
}
AGENT_PROJECT: dict[str, str] = {
"cursor": ".agents/skills",
"claude": ".claude/skills",
"codex": ".agents/skills",
# 与 cursor/codex 共用 .agents/skills;软链幂等,同路径只写一次
"agents": ".agents/skills",
}
ALL_TARGETS = ("cursor", "claude", "codex", "agents")
def project_manifest(root: Path) -> Path:
"""项目清单路径:优先 .pouch.yaml,否则沿用 .skills.yaml。"""
preferred = root / PROJECT_MANIFEST
legacy = root / LEGACY_PROJECT_MANIFEST
if preferred.is_file():
return preferred
if legacy.is_file():
return legacy
return preferred
def resolve_targets(target: str | None) -> list[str]:
if target is None or target == "all":
return list(ALL_TARGETS)
if target not in ALL_TARGETS:
raise ValueError(f"未知 target: {target!r},可选: {', '.join(ALL_TARGETS)}, all")
return [target]
def agent_skill_dir(target: str, *, project_root: Path | None = None) -> Path:
if project_root is None:
return AGENT_GLOBAL[target]
return project_root / AGENT_PROJECT[target]
def ensure_pouch_home() -> None:
if not POUCH_HOME.is_dir():
raise SystemExit(
"~/.pouch 不存在。请将本仓库克隆到 ~/.pouch。"
"若仍是 ~/.skills,先执行: mv ~/.skills ~/.pouch"
)
+10 -10
View File
@@ -1,22 +1,22 @@
"""项目级 .skills.yaml 管理。""" """项目级 .pouch.yaml 管理。"""
from __future__ import annotations from __future__ import annotations
from pathlib import Path from pathlib import Path
from typing import Any from typing import Any
from skiff import yaml_io from pouch import yaml_io
from skiff.paths import PROJECT_MANIFEST from pouch.paths import project_manifest
from skiff.skills import normalize_source, resolve_skill_source from pouch.skills import normalize_source, resolve_skill_source
def load_manifest(path: Path | None = None) -> tuple[Path, dict[str, Any]]: def load_manifest(path: Path | None = None) -> tuple[Path, dict[str, Any]]:
path = path or Path.cwd() / PROJECT_MANIFEST path = path or project_manifest(Path.cwd())
if not path.is_file(): if not path.is_file():
return path, {"skills": []} return path, {"skills": []}
data = yaml_io.safe_load(path.read_text(encoding="utf-8")) or {} data = yaml_io.safe_load(path.read_text(encoding="utf-8")) or {}
if not isinstance(data, dict): if not isinstance(data, dict):
raise SystemExit(f".skills.yaml 格式错误: {path}") raise SystemExit(f".pouch.yaml 格式错误: {path}")
if "skills" not in data: if "skills" not in data:
data["skills"] = [] data["skills"] = []
return path, data return path, data
@@ -34,7 +34,7 @@ def normalize_skill_entry(entry: str | dict[str, Any]) -> dict[str, Any]:
return {"name": entry, "source": "builtin"} return {"name": entry, "source": "builtin"}
name = entry.get("name") name = entry.get("name")
if not name: if not name:
raise SystemExit(f".skills.yaml 条目缺少 name: {entry}") raise SystemExit(f".pouch.yaml 条目缺少 name: {entry}")
source = normalize_source(str(entry.get("source", "builtin"))) source = normalize_source(str(entry.get("source", "builtin")))
if source == "catalog" and entry.get("registry"): if source == "catalog" and entry.get("registry"):
source = f"catalog:{entry['registry']}" source = f"catalog:{entry['registry']}"
@@ -58,7 +58,7 @@ def add_skill_to_manifest(
) -> None: ) -> None:
path = manifest_path path = manifest_path
if path.is_dir(): if path.is_dir():
path = path / PROJECT_MANIFEST path = project_manifest(path)
file_path, data = load_manifest(path) if path.is_file() else (path, {"skills": []}) file_path, data = load_manifest(path) if path.is_file() else (path, {"skills": []})
if not path.is_file(): if not path.is_file():
@@ -82,8 +82,8 @@ def add_skill_to_manifest(
def remove_skill_from_manifest(manifest_path: Path, name: str) -> bool: def remove_skill_from_manifest(manifest_path: Path, name: str) -> bool:
path = manifest_path path = manifest_path
if not path.is_file(): if path.is_dir() or not path.is_file():
path = path / PROJECT_MANIFEST path = project_manifest(path if path.is_dir() else path.parent)
file_path, data = load_manifest(path) file_path, data = load_manifest(path)
original = data.get("skills", []) original = data.get("skills", [])
kept = [e for e in original if normalize_skill_entry(e)["name"] != name] kept = [e for e in original if normalize_skill_entry(e)["name"] != name]
+1 -1
View File
@@ -165,7 +165,7 @@ def select_skills(
) )
footer = ( footer = (
f"已选择 {len(selected)} 项 · 取消选择不卸载,卸载用 skiff remove" f"已选择 {len(selected)} 项 · 取消选择不卸载,卸载用 pouch remove"
) )
stdscr.addnstr( stdscr.addnstr(
height - 1, height - 1,
+8 -8
View File
@@ -5,13 +5,13 @@ from __future__ import annotations
import re import re
from pathlib import Path from pathlib import Path
from skiff.paths import SKILLS_DIR, TEMPLATE_DIR, ensure_skills_home from pouch.paths import SKILLS_DIR, TEMPLATE_DIR, ensure_pouch_home
from skiff.catalog import ( from pouch.catalog import (
catalog_skill_path, catalog_skill_path,
discover_catalog_skills, discover_catalog_skills,
load_catalog, load_catalog,
) )
from skiff.sources import ( from pouch.sources import (
discover_source_skills, discover_source_skills,
list_source_skills, list_source_skills,
load_sources, load_sources,
@@ -19,7 +19,7 @@ from skiff.sources import (
def list_builtin_skills() -> list[str]: def list_builtin_skills() -> list[str]:
ensure_skills_home() ensure_pouch_home()
if not SKILLS_DIR.is_dir(): if not SKILLS_DIR.is_dir():
return [] return []
names: list[str] = [] names: list[str] = []
@@ -76,7 +76,7 @@ def list_custom_skills(source: str | None = None) -> dict[str, list[str]]:
def resolve_skill_source(name: str, *, source: str | None = None) -> tuple[Path, str]: def resolve_skill_source(name: str, *, source: str | None = None) -> tuple[Path, str]:
"""返回 (skill_path, source),未指定来源时拒绝同名歧义。""" """返回 (skill_path, source),未指定来源时拒绝同名歧义。"""
ensure_skills_home() ensure_pouch_home()
name, source = split_skill_spec(name, source) name, source = split_skill_spec(name, source)
builtin = SKILLS_DIR / name builtin = SKILLS_DIR / name
@@ -106,7 +106,7 @@ def resolve_skill_source(name: str, *, source: str | None = None) -> tuple[Path,
if not (path / "SKILL.md").is_file(): if not (path / "SKILL.md").is_file():
raise SystemExit( raise SystemExit(
f"catalog skill {name!r} 尚未 fetch 或 path 中缺少 SKILL.md。" f"catalog skill {name!r} 尚未 fetch 或 path 中缺少 SKILL.md。"
f"请运行: skiff fetch {name}" f"请运行: pouch fetch {name}"
) )
return path, f"catalog:{name}" return path, f"catalog:{name}"
@@ -114,7 +114,7 @@ def resolve_skill_source(name: str, *, source: str | None = None) -> tuple[Path,
if source not in sources: if source not in sources:
raise SystemExit( raise SystemExit(
f"项目依赖 source {source!r},但本机尚未配置。" f"项目依赖 source {source!r},但本机尚未配置。"
f"请运行: skiff source add {source} <repo>" f"请运行: pouch source add {source} <repo>"
) )
skills = discover_source_skills(source, sources[source]) skills = discover_source_skills(source, sources[source])
if name not in skills: if name not in skills:
@@ -156,7 +156,7 @@ def resolve_skill_source(name: str, *, source: str | None = None) -> tuple[Path,
path, resolved_source = candidates[0] path, resolved_source = candidates[0]
if resolved_source.startswith("catalog:") and not path.exists(): if resolved_source.startswith("catalog:") and not path.exists():
provider = resolved_source.split(":", 1)[1] provider = resolved_source.split(":", 1)[1]
raise SystemExit(f"catalog source {provider!r} 尚未 fetch。请先运行: skiff fetch {provider}") raise SystemExit(f"catalog source {provider!r} 尚未 fetch。请先运行: pouch fetch {provider}")
return path, resolved_source return path, resolved_source
raise SystemExit(f"找不到 skill: {name}") raise SystemExit(f"找不到 skill: {name}")
+26 -26
View File
@@ -2,7 +2,7 @@
## 背景 ## 背景
skiff 当前使用 `owned` 表示本仓库 `skills/` 中维护的 Skill,同时还支持 pouch 当前使用 `owned` 表示本仓库 `skills/` 中维护的 Skill,同时还支持
`registry` 外部仓库和用户配置的 custom source。 `registry` 外部仓库和用户配置的 custom source。
这些名称混合了不同维度: 这些名称混合了不同维度:
@@ -17,8 +17,8 @@ skiff 当前使用 `owned` 表示本仓库 `skills/` 中维护的 Skill,同时
本文建议将用户可见的来源注册方式统一为三类: 本文建议将用户可见的来源注册方式统一为三类:
- `builtin`:随当前 skiff 仓库提供的 Skill。 - `builtin`:随当前 pouch 仓库提供的 Skill。
- `catalog:<name>`:由 skiff 自带目录预先登记的来源。 - `catalog:<name>`:由 pouch 自带目录预先登记的来源。
- `custom:<name>`:用户在本机显式配置的命名来源。 - `custom:<name>`:用户在本机显式配置的命名来源。
来源注册方式与获取方式、仓库布局相互独立。builtin、catalog 和 custom 中的任意 来源注册方式与获取方式、仓库布局相互独立。builtin、catalog 和 custom 中的任意
@@ -29,20 +29,20 @@ Git 仓库或本地目录。
```mermaid ```mermaid
flowchart TD flowchart TD
S[skiff 可发现的 Skills] S[pouch 可发现的 Skills]
S --> O["owned<br/>~/.skills/skills/*"] S --> O["owned<br/>~/.pouch/skills/*"]
S --> C["custom source<br/>~/.config/skiff/config.yaml"] S --> C["custom source<br/>~/.config/pouch/config.yaml"]
S --> R["registry<br/>registry.yaml"] S --> R["registry<br/>registry.yaml"]
O --> O1["本仓库维护<br/>随 skiff 一起分发"] O --> O1["本仓库维护<br/>随 pouch 一起分发"]
C --> C1["本地目录<br/>--local PATH"] C --> C1["本地目录<br/>--local PATH"]
C --> C2["指定 Git 仓库<br/>repo + skills_path"] C --> C2["指定 Git 仓库<br/>repo + skills_path"]
R --> R1["外部单 Skill 仓库"] R --> R1["外部单 Skill 仓库"]
R --> R2["外部 Skill Collection"] R --> R2["外部 Skill Collection"]
R1 --> E["~/.local/share/skills/externals/"] R1 --> E["~/.local/share/pouch/externals/"]
R2 --> E R2 --> E
``` ```
@@ -51,7 +51,7 @@ flowchart TD
- `list` 和 `status` 支持 owned、registry 和 custom source。 - `list` 和 `status` 支持 owned、registry 和 custom source。
- `resolve_skill_source` 可以解析三种来源并处理同名歧义。 - `resolve_skill_source` 可以解析三种来源并处理同名歧义。
- `select` 只组装 owned 和 registry 条目,尚未展示 custom source。 - `select` 只组装 owned 和 registry 条目,尚未展示 custom source。
- `.skills.yaml` 默认将未声明来源的 Skill 解释为 `owned`。 - `.pouch.yaml` 默认将未声明来源的 Skill 解释为 `owned`。
- custom source 的 `skills_path` 已经可以包含多个 Skill,本质上也是 collection。 - custom source 的 `skills_path` 已经可以包含多个 Skill,本质上也是 collection。
## 现行模型 ## 现行模型
@@ -61,11 +61,11 @@ flowchart TD
A[Skill Provider] A[Skill Provider]
A --> B["builtin<br/>仓库内隐式注册"] A --> B["builtin<br/>仓库内隐式注册"]
A --> C["catalog:waza<br/>skiff 预置目录"] A --> C["catalog:waza<br/>pouch 预置目录"]
A --> D["custom:company<br/>用户本机配置"] A --> D["custom:company<br/>用户本机配置"]
B --> B1["skills/ack"] B --> B1["skills/ack"]
B --> B2["skills/skiff"] B --> B2["skills/pouch"]
B --> B3["skills/builder"] B --> B3["skills/builder"]
C --> C1["Git 或本地目录"] C --> C1["Git 或本地目录"]
@@ -85,14 +85,14 @@ flowchart TD
| 类型 | 含义 | 配置来源 | 用户界面展示 | | 类型 | 含义 | 配置来源 | 用户界面展示 |
| --- | --- | --- | --- | | --- | --- | --- | --- |
| `builtin` | 随当前 skiff 仓库提供 | `skills/` | `builtin` | | `builtin` | 随当前 pouch 仓库提供 | `skills/` | `builtin` |
| `catalog` | skiff 预先登记、所有用户可发现的来源 | `catalog.yaml` | `catalog:<name>` | | `catalog` | pouch 预先登记、所有用户可发现的来源 | `catalog.yaml` | `catalog:<name>` |
| `custom` | 用户在本机显式注册的命名来源 | `~/.config/skiff/config.yaml` | `custom:<name>` | | `custom` | 用户在本机显式注册的命名来源 | `~/.config/pouch/config.yaml` | `custom:<name>` |
`builtin` 比 `owned` 更适合作为用户可见名称,因为它表达 Skill 的分发位置和可用 `builtin` 比 `owned` 更适合作为用户可见名称,因为它表达 Skill 的分发位置和可用
方式,而不是仓库的所有权关系。 方式,而不是仓库的所有权关系。
`catalog` 比 `registry` 更准确:当前文件只是 skiff 随仓库维护的预置来源目录, `catalog` 比 `registry` 更准确:当前文件只是 pouch 随仓库维护的预置来源目录,
并不是远程注册中心,也不是一种 Skill 来源协议。 并不是远程注册中心,也不是一种 Skill 来源协议。
### 三个正交维度 ### 三个正交维度
@@ -128,7 +128,7 @@ layout: single | collection
## `select` 展示 ## `select` 展示
`skiff select` 应同时展示 builtin、catalog 和 custom Skill: `pouch select` 应同时展示 builtin、catalog 和 custom Skill:
```text ```text
[ ] ack builtin [ ] ack builtin
@@ -151,7 +151,7 @@ layout: single | collection
## 配置表示 ## 配置表示
新写入的 `.skills.yaml` 使用以下形式: 新写入的 `.pouch.yaml` 使用以下形式:
```yaml ```yaml
skills: skills:
@@ -172,7 +172,7 @@ custom source 在 manifest 中继续保存其逻辑名称,例如 `company`。
1. 对外文档、CLI 输出和 selector 统一使用 `builtin`、`catalog:<name>` 和 1. 对外文档、CLI 输出和 selector 统一使用 `builtin`、`catalog:<name>` 和
`custom:<name>`。 `custom:<name>`。
2. 新生成的 `.skills.yaml` 对内置 Skill 写入 `source: builtin`。 2. 新生成的 `.pouch.yaml` 对内置 Skill 写入 `source: builtin`。
3. 读取旧 manifest 时继续接受 `source: owned`,并在解析时归一化为 `builtin`。 3. 读取旧 manifest 时继续接受 `source: owned`,并在解析时归一化为 `builtin`。
4. CLI 参数在过渡期继续接受 `--source owned`,但帮助和输出只推荐 `builtin`。 4. CLI 参数在过渡期继续接受 `--source owned`,但帮助和输出只推荐 `builtin`。
5. 读取旧 manifest 中的 `source: registry` 和 `registry: <name>`,归一化为 5. 读取旧 manifest 中的 `source: registry` 和 `registry: <name>`,归一化为
@@ -188,14 +188,14 @@ custom source 在 manifest 中继续保存其逻辑名称,例如 `company`。
当前实现覆盖: 当前实现覆盖:
- `skiff/skills.py`:来源解析、归一化和 builtin 命名。 - `pouch/skills.py`:来源解析、归一化和 builtin 命名。
- `skiff/project.py`:manifest 默认值、序列化与旧值兼容。 - `pouch/project.py`:manifest 默认值、序列化与旧值兼容。
- `skiff/sources.py`:来源保留字。 - `pouch/sources.py`:来源保留字。
- `skiff/catalog.py`:catalog 配置、checkout 与 Skill 发现。 - `pouch/catalog.py`:catalog 配置、checkout 与 Skill 发现。
- `skiff/cli.py`:`list`、`status`、`add`、`select` 和输出文案。 - `pouch/cli.py`:`list`、`status`、`add`、`select` 和输出文案。
- `skiff/selector.py`:统一 catalog/custom collection 的父子展示。 - `pouch/selector.py`:统一 catalog/custom collection 的父子展示。
- CLI 与来源解析测试。 - CLI 与来源解析测试。
- 根 README、`skiff/README.md`、`skills/skiff/SKILL.md` 和相关示例。 - 根 README、`pouch/README.md`、`skills/pouch/SKILL.md` 和相关示例。
## 验证要求 ## 验证要求
@@ -212,6 +212,6 @@ custom source 在 manifest 中继续保存其逻辑名称,例如 `company`。
## 设计前提 ## 设计前提
迁移前 `registry.yaml` 的真实职责只是维护 skiff 预置的来源目录,而不是提供远程 迁移前 `registry.yaml` 的真实职责只是维护 pouch 预置的来源目录,而不是提供远程
发布、版本解析或可信签名等注册中心能力,因此现已改为 `catalog.yaml`。如果未来 发布、版本解析或可信签名等注册中心能力,因此现已改为 `catalog.yaml`。如果未来
实现真正的远程 registry,应单独定义其协议和与 catalog 的同步关系,不复用旧名称。 实现真正的远程 registry,应单独定义其协议和与 catalog 的同步关系,不复用旧名称。
+5 -5
View File
@@ -6,14 +6,14 @@ import subprocess
from pathlib import Path from pathlib import Path
from typing import Any from typing import Any
from skiff import yaml_io from pouch import yaml_io
from skiff.paths import CONFIG_FILE, SOURCES_DIR from pouch.paths import CONFIG_FILE, SOURCES_DIR
RESERVED_SOURCES = {"builtin", "catalog", "owned", "registry"} RESERVED_SOURCES = {"builtin", "catalog", "owned", "registry"}
def validate_source_name(name: str) -> None: def validate_source_name(name: str) -> None:
from skiff.skills import validate_skill_name from pouch.skills import validate_skill_name
validate_skill_name(name) validate_skill_name(name)
if name in RESERVED_SOURCES: if name in RESERVED_SOURCES:
@@ -26,12 +26,12 @@ def load_sources(path: Path | None = None) -> dict[str, dict[str, Any]]:
return {} return {}
data = yaml_io.safe_load(path.read_text(encoding="utf-8")) or {} data = yaml_io.safe_load(path.read_text(encoding="utf-8")) or {}
if not isinstance(data, dict): if not isinstance(data, dict):
raise SystemExit(f"skiff 配置格式错误: {path}") raise SystemExit(f"pouch 配置格式错误: {path}")
raw = data.get("sources", {}) raw = data.get("sources", {})
if raw is None: if raw is None:
return {} return {}
if not isinstance(raw, dict): if not isinstance(raw, dict):
raise SystemExit(f"skiff 配置 sources 格式错误: {path}") raise SystemExit(f"pouch 配置 sources 格式错误: {path}")
return {str(name): entry for name, entry in raw.items() if isinstance(entry, dict)} return {str(name): entry for name, entry in raw.items() if isinstance(entry, dict)}
+1 -1
View File
@@ -66,7 +66,7 @@ def copy_template(src: Path, dst: Path) -> None:
def find_repo_root(start: Path | None = None) -> Path | None: def find_repo_root(start: Path | None = None) -> Path | None:
start = (start or Path.cwd()).resolve() start = (start or Path.cwd()).resolve()
for directory in [start, *start.parents]: for directory in [start, *start.parents]:
if (directory / ".skills.yaml").is_file(): if (directory / ".pouch.yaml").is_file() or (directory / ".skills.yaml").is_file():
return directory return directory
if (directory / "skills").is_dir() and ( if (directory / "skills").is_dir() and (
(directory / "catalog.yaml").is_file() (directory / "catalog.yaml").is_file()
+1 -1
View File
@@ -1,4 +1,4 @@
"""轻量 YAML 读写(覆盖 skiff 使用的子集,无第三方依赖)。""" """轻量 YAML 读写(覆盖 pouch 使用的子集,无第三方依赖)。"""
from __future__ import annotations from __future__ import annotations
+1 -1
View File
@@ -1 +1 @@
# skiff 仅使用 Python 标准库,无第三方依赖 # pouch 仅使用 Python 标准库,无第三方依赖
-253
View File
@@ -1,253 +0,0 @@
# skiff
Agent Skills 安装与管理 CLI。纯 Python 3 实现,无第三方依赖,无需编译。
## 安装
```bash
cd /path/to/skills # 本仓库根目录
./install.sh # 软链到 ~/.local/bin/skiff
```
确保 `~/.local/bin` 在 `PATH` 中。
## 命令风格
接口对齐 [Vercel skills CLI](https://github.com/vercel-labs/skills) 的 `add` / `remove`,
统一管理 builtin skill、预置 catalog source 和用户命名的 custom source。
```bash
# 浏览可用自研 skill
skiff add --list
# 装到当前项目 / 全局
skiff add discussion-notes -a cursor -y
skiff add discussion-notes -a cursor -g -y
# 卸载
skiff remove discussion-notes -a cursor -y
skiff rm discussion-notes -g -y
# 改完 skill 后提交推送(在任意目录执行,操作 ~/.skills)
skiff publish skills/discussion-notes -m "update discussion-notes" --push
```
开发时也可直接运行:
```bash
PYTHONPATH=/path/to/skills python3 -m skiff <command>
```
## 首次安装
```bash
git clone https://git.yumee.top/laily/skills.git ~/.skills
~/.skills/install.sh
```
`install.sh` 会安装 CLI,并自动执行 `skiff bootstrap`,将本仓库的 `skiff` skill 全局软链到 Cursor、Claude Code 和 Codex。也可以随时手动重跑:
```bash
skiff bootstrap
```
## 命令参考
### 查看
| 命令 | 说明 |
|------|------|
| `skiff list [--source NAME]` | 列出所有来源或指定 source 中的 skill |
| `skiff status [--target all\|cursor\|claude\|codex\|agents]` | 安装状态总览 |
### 项目初始化
| 命令 | 说明 |
|------|------|
| `skiff bootstrap` | 将本项目的 `skiff` skill 全局安装到所有 Agent |
| `skiff update` | 在 `~/.skills` 执行 `git pull`,更新 skiff 自身 |
| `skiff init <name> [--project DIR]` | 使用 builtin skill 自带模板初始化项目状态 |
### Skill 安装
| 命令 | 说明 |
|------|------|
| `skiff add <name> [--global] [-a AGENT...] [-y]` | 安装到 Agent 目录(软链) |
| `skiff select [--global] [-a AGENT...]` | 打开终端多选界面,批量安装 skill |
| `skiff remove <name> [--global] [-a AGENT...] [-y]` | 移除软链(`rm` / `r` 别名) |
| `skiff add --list` | 列出可用 builtin skill |
| `skiff publish [paths] -m MSG [--push]` | 在 ~/.skills 内 git add/commit/push |
旧命令 `install` / `uninstall` 已移除,请改用 `add` / `remove`。
全局目标路径:
| Agent | 路径 |
|-------|------|
| cursor | `~/.cursor/skills/` |
| claude | `~/.claude/skills/` |
| codex | `~/.codex/skills/` |
| agents | `~/.agents/skills/`(agents 标准目录,覆盖 OMP) |
### 预置 Catalog Source
| 命令 | 说明 |
|------|------|
| `skiff catalog add <name> <repo-url> [--ref main] [--path .]` | 写入 `catalog.yaml` |
| `skiff fetch <name>` | 克隆或更新 catalog source checkout |
| `skiff add <name> [-g] [-a AGENT...]` | 安装 catalog 中的单个 skill 或完整 collection(缺失时自动 fetch) |
| `skiff add <collection>/<skill> [...]` | 只安装 collection 中指定的 skill |
`catalog.yaml` 条目可额外提供 `description` 和 `tags`。`description`
会显示在 `skiff select` 的候选列表中。`path` 可以直接指向含
`SKILL.md` 的单个 skill,也可以指向由多个 skill 目录组成的 collection。
collection 会自动发现下一层所有含 `SKILL.md` 的目录;`skiff add <name>`
安装全部,`skiff select` 则展开为 `<name>/<skill>` 供分别勾选。同一
`repo` 与 `ref` 共享一份 Git checkout。
### 交互式批量安装
```bash
skiff select # 当前项目,全部 Agent
skiff select -a codex # 当前项目,仅 Codex
skiff select -g # 全局安装
skiff select --project ~/code/app # 指定项目
```
使用方向键移动、空格勾选、`/` 搜索、Enter 安装,按 `q` 或 Esc
取消。普通 `skiff select` 只安装到项目,并在每一项旁只读显示各 Agent 的
全局安装状态;`skiff select -g` 只安装到全局。已经安装到目标范围的 skill
默认勾选;取消勾选不会卸载已有 skill,卸载请使用 `skiff remove`。如果全局
存在同名但指向其它来源的 skill,项目选择器会显示“全局同名冲突”。
项目模式会把成功选择的项目写入 `.skills.yaml`。非交互环境请使用
`skiff add <name>...`。使用 `-a` 限定 Agent 时,该范围会记录在对应的
skill 条目中,后续 `skiff sync` 不会扩散到其他 Agent。
### Custom source(多-skill 仓库)
公司或团队维护的仓库通常包含多个 skill。使用命名 source 接入:
```bash
# Git 仓库,默认 clone 到 ~/.local/share/skiff/sources/company
skiff source add company \
git@git.company.com:platform/agent-skills.git \
--ref main \
--skills-path internal/skills
# 或接入已有本地仓库
skiff source add company \
--local ~/code/company-agent-skills \
--skills-path skills
skiff source list
skiff source fetch company
skiff list --source company
skiff add company/code-review -g -a codex
```
| 命令 | 说明 |
|------|------|
| `skiff source add <name> <repo> [--ref REF] [--checkout PATH] [--skills-path PATH]` | 注册并克隆 Git source |
| `skiff source add <name> --local PATH [--skills-path PATH]` | 接入已有本地仓库 |
| `skiff source list` / `show <name>` | 查看 source |
| `skiff source fetch <name>` / `fetch --all` | clone 或 fast-forward 更新 |
| `skiff source remove <name>` | 移除配置并保留 checkout |
配置保存在 `~/.config/skiff/config.yaml`。Git/SSH 认证复用本机 Git 配置,
skiff 不保存 token。可以使用 `company/code-review`,也可以使用
`skiff add code-review --source company`。多个来源包含同名 skill 时,必须明确来源。
### 项目级
| 命令 | 说明 |
|------|------|
| `skiff enable <name> [--target all] [--project <dir>]` | 写入 `.skills.yaml` 并创建项目软链 |
| `skiff disable <name> [--target all] [--project <dir>]` | 从 manifest 移除并删除软链 |
| `skiff sync [--target all] [--project <dir>]` | 按 `.skills.yaml` 重建软链 |
项目目标路径:
| Agent | 路径 |
|-------|------|
| cursor | `<project>/.agents/skills/` |
| claude | `<project>/.claude/skills/` |
| codex | `<project>/.agents/skills/` |
| agents | `<project>/.agents/skills/`(与 cursor/codex 共用路径,软链幂等) |
### 脚手架与健康检查
| 命令 | 说明 |
|------|------|
| `skiff create <name> [--idea TEXT] [--from-project PATH]` | 从模板创建含 `SKILL.md`、`README.md` 的草稿 |
| `skiff check <name>` | 校验草稿或正式 skill,包括人类使用说明 |
| `skiff finalize <name>` | 校验草稿并移动到正式 `skills/` |
| `skiff doctor [--target all] [--fix]` | 检查软链健康状态,`--fix` 自动修复 |
## 常用工作流
### 新建并全局启用自研 skill
```bash
skiff create my-skill --idea "描述要解决的重复问题" --from-project .
# 由 Agent 完善草稿中的 SKILL.md 和 README.md
skiff check my-skill
skiff finalize my-skill
skiff publish skills/my-skill -m "add my-skill" --push
skiff add my-skill -a cursor -g -y
skiff doctor -a cursor
```
### 在项目中启用 skill
```bash
cd ~/code/my-app
skiff add declarative-openspec-loop -a cursor -y
```
### 添加 Catalog Source
```bash
skiff catalog add my-ext https://github.com/org/repo --ref main
skiff fetch my-ext
skiff add my-ext -g
```
## 源码结构
```
skiff/
├── __init__.py # 版本号
├── __main__.py # python3 -m skiff 入口
├── cli.py # 命令定义与调度
├── paths.py # 路径常量与 Agent 目标
├── skills.py # builtin/catalog/custom 统一解析
├── catalog.py # catalog.yaml 读写与 Skill 发现
├── sources.py # custom source 配置、发现与 Git 管理
├── project.py # .skills.yaml 管理
├── symlinks.py # 软链创建/检查/修复
└── yaml_io.py # 轻量 YAML 解析(无第三方依赖)
```
入口脚本:[../bin/skiff](../bin/skiff)
## 路径约定
| 变量 | 路径 | 说明 |
|------|------|------|
| `SKILLS_HOME` | `~/.skills` | skills 仓库(软链) |
| `SKILLS_DIR` | `~/.skills/skills/` | builtin skill 目录 |
| `CATALOG_FILE` | `~/.skills/catalog.yaml` | 预置 Skill 来源目录 |
| `CATALOG_CACHE_DIR` | `~/.local/share/skills/externals/` | catalog checkout 兼容缓存;按 repo/ref 共享 |
| `CONFIG_FILE` | `~/.config/skiff/config.yaml` | custom source 配置 |
| `SOURCES_DIR` | `~/.local/share/skiff/sources/` | custom Git source 默认 checkout |
## 注意事项
- **禁止**在 `~/.cursor/skills/` 等 Agent 目录直接创建非软链的 skill
- Claude Code 对 symlink 支持不稳定;建议对单个 skill 目录软链,不要软链整个 `~/.claude/skills/`
- 若 Agent 将软链替换为普通目录,运行 `skiff doctor --fix` 重建
## 相关文档
- [项目 README](../README.md)
- [AGENTS.md](../AGENTS.md)
-3
View File
@@ -1,3 +0,0 @@
"""skiff — Agent Skills 安装与管理 CLI。"""
__version__ = "0.6.0"
-56
View File
@@ -1,56 +0,0 @@
"""路径与 Agent 目标定义。"""
from __future__ import annotations
from pathlib import Path
HOME = Path.home()
SKILLS_HOME = HOME / ".skills"
SKILLS_DIR = SKILLS_HOME / "skills"
TEMPLATE_DIR = SKILLS_DIR / "_template"
DRAFTS_DIR = SKILLS_HOME / ".drafts"
CATALOG_FILE = SKILLS_HOME / "catalog.yaml"
LEGACY_REGISTRY_FILE = SKILLS_HOME / "registry.yaml"
CATALOG_CACHE_DIR = HOME / ".local" / "share" / "skills" / "externals"
CONFIG_FILE = HOME / ".config" / "skiff" / "config.yaml"
SOURCES_DIR = HOME / ".local" / "share" / "skiff" / "sources"
PROJECT_MANIFEST = ".skills.yaml"
AGENT_GLOBAL: dict[str, Path] = {
"cursor": HOME / ".cursor" / "skills",
"claude": HOME / ".claude" / "skills",
"codex": HOME / ".codex" / "skills",
# agents 标准目录:OMP 原生 canonical(agents provider),cursor/codex 项目级同路径
"agents": HOME / ".agents" / "skills",
}
AGENT_PROJECT: dict[str, str] = {
"cursor": ".agents/skills",
"claude": ".claude/skills",
"codex": ".agents/skills",
# 与 cursor/codex 共用 .agents/skills;软链幂等,同路径只写一次
"agents": ".agents/skills",
}
ALL_TARGETS = ("cursor", "claude", "codex", "agents")
def resolve_targets(target: str | None) -> list[str]:
if target is None or target == "all":
return list(ALL_TARGETS)
if target not in ALL_TARGETS:
raise ValueError(f"未知 target: {target!r},可选: {', '.join(ALL_TARGETS)}, all")
return [target]
def agent_skill_dir(target: str, *, project_root: Path | None = None) -> Path:
if project_root is None:
return AGENT_GLOBAL[target]
return project_root / AGENT_PROJECT[target]
def ensure_skills_home() -> None:
if not SKILLS_HOME.is_dir():
raise SystemExit(
"~/.skills 不存在。请将 skills 仓库克隆到 ~/.skills"
)
+25
View File
@@ -27,6 +27,31 @@ description: >-
2. 第二步 2. 第二步
3. 第三步 3. 第三步
## 运营类 skill 可选:初始化 / 检查 / 工作
需要项目配置才能工作的 skill(例如构建、部署、协作闭环)增加这三个模式:
- **初始化**(用户点名才跑):探项目 → 只建本 skill 拥有的安全空结构 → 用仓库
证据填能填的 → 列出待配置项。不覆盖已有文件,不猜密钥、主机、仓库地址。
- **检查**(只读):同一套诊断,不写文件。
- **工作**:配置不齐就停,告诉用户先初始化。禁止静默初始化。
报告格式:
```text
## <skill> 初始化:完成 | 部分完成 | 阻塞
已具备: …
待配置: 路径 + 字段 + 可粘贴示例 + 缺了会挡住哪步
工具链: …
下一步: 一句话
```
项目状态放在 skill 真正消费的位置(覆盖层、`makefile.builder`、compose),不要为了对齐
而新建一层没人读的 `.pouch/<skill>/`。`pouch init` 只用于确实有 templates/
覆盖层的 skill。需要 make 目标或发布凭据的 skill 用自己的文件名(如 `makefile.builder`、
`.env.builder`),不要占用用户的 `Makefile` 或 `.env`。
--- ---
## 注意事项 ## 注意事项
+38 -36
View File
@@ -10,8 +10,8 @@ ACK 是一个显式调用的 Agent Skill,用三种独立角色运行工程协
`leftover`,然后继续处理其它任务。 `leftover`,然后继续处理其它任务。
测试环境部署由 ACK 触发、**内部调用 deployer** 执行。发版仍写在同一份 测试环境部署由 ACK 触发、**内部调用 deployer** 执行。发版仍写在同一份
`docs/ack/delivery.yaml`。功能或 bug 验证通过后,把黑盒用例收进 `.pouch/ack/delivery.yaml`。功能或 bug 验证通过后,把黑盒用例收进
`docs/ack/regression.yaml`;之后可以单独跑回归。 `.pouch/ack/regression.yaml`;之后可以单独跑回归。
ACK 只在用户显式调用 `/ack` 或 `$ack` 时运行。 ACK 只在用户显式调用 `/ack` 或 `$ack` 时运行。
@@ -19,12 +19,12 @@ ACK 只在用户显式调用 `/ack` 或 `$ack` 时运行。
| 场景 | 怎么说 | 结果 | | 场景 | 怎么说 | 结果 |
| --- | --- | --- | | --- | --- | --- |
| 初始化 | `/ack 初始化` | 生成并补全 `docs/ack/` | | 初始化 | `/ack 初始化` | 生成并补全 `.pouch/ack/`;缺项按统一格式列出 |
| 检查 | `/ack 检查配置` | 只读校验,默认不改文件 | | 检查 | `/ack 检查配置` | 只读校验,默认不改文件;测试环境缺 deployer 时转交 |
| 做需求 | `/ack 处理这个需求:…` | 产品文档 + 拆任务 → 确认 → 三角色闭环 | | 做需求 | `/ack 处理这个需求:…` | 产品文档 + 拆任务 → 确认 → 三角色闭环 |
| 修 bug | `/ack 修这个 bug:…` 或处理飞书收件 | 短描述 + 验收 → 确认(飞书须你点「已确认」)→ 同一闭环 | | 修 bug | `/ack 修这个 bug:…` 或处理飞书收件 | 短描述 + 验收 → 确认(飞书须你点「已确认」)→ 同一闭环 |
| 交付配置 | 说明怎么布测试环境 / 怎么发版 | 写入同一份 `delivery.yaml`;测试环境绑定 deployer | | 交付配置 | 说明怎么布测试环境 / 怎么发版 | 写入同一份 `delivery.yaml`;测试环境绑定 deployer |
| 运行测试环境 | `/ack 重新布测试环境` | 内部加载 deployer,布 `.skiff/deployer/<env>` | | 运行测试环境 | `/ack 重新布测试环境` | 内部加载 deployer,布 `.pouch/deployer/<env>` |
| 运行版本发布 | `/ack 发布一个版本` | 按 `intents.release`;stable/生产仍要单独批准 | | 运行版本发布 | `/ack 发布一个版本` | 按 `intents.release`;stable/生产仍要单独批准 |
| 回归 | `/ack 回归` | 先布测试环境,再按 `regression.yaml` 用浏览器或 API 跑 | | 回归 | `/ack 回归` | 先布测试环境,再按 `regression.yaml` 用浏览器或 API 跑 |
@@ -35,26 +35,26 @@ ACK 只在用户显式调用 `/ack` 或 `$ack` 时运行。
全局安装: 全局安装:
```bash ```bash
skiff add ack -g pouch add ack -g
``` ```
或只安装到当前项目: 或只安装到当前项目:
```bash ```bash
skiff add ack pouch add ack
``` ```
## 初始化项目 ## 初始化项目
```bash ```bash
skiff init ack pouch init ack
skiff init ack --project ~/code/my-app pouch init ack --project ~/code/my-app
``` ```
初始化后,项目只保存自己的 ACK 状态: 初始化后,项目只保存自己的 ACK 状态:
```text ```text
docs/ack/ .pouch/ack/
├── project.md ├── project.md
├── tasks.yaml ├── tasks.yaml
├── knowledge.yaml ├── knowledge.yaml
@@ -65,7 +65,7 @@ docs/ack/
不会在项目中复制或链接 ACK Skill。通用规范、模板和脚本始终从已安装的 Skill 不会在项目中复制或链接 ACK Skill。通用规范、模板和脚本始终从已安装的 Skill
目录读取。 目录读取。
ACK 从当前命令指定的 `--project-root/docs/ack/` 定位项目状态,不要求在 ACK 从当前命令指定的 `--project-root/.pouch/ack/` 定位项目状态,不要求在
`tasks.yaml` 中持久化 `repoPath` 或 `devWorktree`。自动 worker 的实际工作目录由 `tasks.yaml` 中持久化 `repoPath` 或 `devWorktree`。自动 worker 的实际工作目录由
`--worktree` 指定;默认在 `--project-root` 工作,v0.19 起不再配置 `allowedWorktrees` 白名单。 `--worktree` 指定;默认在 `--project-root` 工作,v0.19 起不再配置 `allowedWorktrees` 白名单。
@@ -83,12 +83,12 @@ skills/ack/
``` ```
`SKILL.md` 是 Agent 的工作流入口。`references/` 是按需读取的稳定规范; `SKILL.md` 是 Agent 的工作流入口。`references/` 是按需读取的稳定规范;
`docs/ack/project.md` 只保存当前项目的命令、路径和权限差异; `.pouch/ack/project.md` 只保存当前项目的命令、路径和权限差异;
`docs/ack/tasks.yaml` 保存当前任务状态;`docs/ack/knowledge.yaml` 保存跨任务复用、 `.pouch/ack/tasks.yaml` 保存当前任务状态;`.pouch/ack/knowledge.yaml` 保存跨任务复用、
已经独立验证的项目知识护栏。 已经独立验证的项目知识护栏。
`docs/ack/delivery.yaml` 是测试环境绑定和版本发布的唯一契约;测试环境由 ACK `.pouch/ack/delivery.yaml` 是测试环境绑定和版本发布的唯一契约;测试环境由 ACK
内部调用 deployer,运行证据记在 `tasks.yaml.deliveryRuns`。 内部调用 deployer,运行证据记在 `tasks.yaml.deliveryRuns`。
`docs/ack/regression.yaml` 是黑盒回归用例目录,运行证据记在 `.pouch/ack/regression.yaml` 是黑盒回归用例目录,运行证据记在
`tasks.yaml.regressionRuns`。 `tasks.yaml.regressionRuns`。
## 检查项目状态 ## 检查项目状态
@@ -96,27 +96,27 @@ skills/ack/
Agent 会从当前 ACK Skill 目录解析校验脚本: Agent 会从当前 ACK Skill 目录解析校验脚本:
```bash ```bash
python3 <ack-skill-dir>/scripts/validate_tasks.py docs/ack/tasks.yaml python3 <ack-skill-dir>/scripts/validate_tasks.py .pouch/ack/tasks.yaml
python3 <ack-skill-dir>/scripts/validate_knowledge.py docs/ack/knowledge.yaml \ python3 <ack-skill-dir>/scripts/validate_knowledge.py .pouch/ack/knowledge.yaml \
--tasks docs/ack/tasks.yaml --tasks .pouch/ack/tasks.yaml
python3 <ack-skill-dir>/scripts/validate_delivery.py docs/ack/delivery.yaml \ python3 <ack-skill-dir>/scripts/validate_delivery.py .pouch/ack/delivery.yaml \
--tasks docs/ack/tasks.yaml --project-root <project-root> --tasks .pouch/ack/tasks.yaml --project-root <project-root>
python3 <ack-skill-dir>/scripts/validate_regression.py docs/ack/regression.yaml \ python3 <ack-skill-dir>/scripts/validate_regression.py .pouch/ack/regression.yaml \
--tasks docs/ack/tasks.yaml --tasks .pouch/ack/tasks.yaml
``` ```
Coordinator 可以按当前任务上下文做确定性推荐: Coordinator 可以按当前任务上下文做确定性推荐:
```bash ```bash
python3 <ack-skill-dir>/scripts/select_tasks.py docs/ack/tasks.yaml python3 <ack-skill-dir>/scripts/select_tasks.py .pouch/ack/tasks.yaml
python3 <ack-skill-dir>/scripts/select_tasks.py docs/ack/tasks.yaml \ python3 <ack-skill-dir>/scripts/select_tasks.py .pouch/ack/tasks.yaml \
--task-id BUG-001 --task-id BUG-001
python3 <ack-skill-dir>/scripts/select_knowledge.py docs/ack/knowledge.yaml \ python3 <ack-skill-dir>/scripts/select_knowledge.py .pouch/ack/knowledge.yaml \
--component web --path web/app.py --tag long-running-service --limit 10 --component web --path web/app.py --tag long-running-service --limit 10
python3 <ack-skill-dir>/scripts/select_regression.py docs/ack/regression.yaml python3 <ack-skill-dir>/scripts/select_regression.py .pouch/ack/regression.yaml
python3 <ack-skill-dir>/scripts/select_regression.py docs/ack/regression.yaml \ python3 <ack-skill-dir>/scripts/select_regression.py .pouch/ack/regression.yaml \
--suite full --case-id REG-login-001 --suite full --case-id REG-login-001
``` ```
@@ -133,7 +133,7 @@ run。默认最多 20 条,超过预算时显式失败;Agent 不应回退为
```bash ```bash
python3 <ack-skill-dir>/scripts/run_verification.py \ python3 <ack-skill-dir>/scripts/run_verification.py \
docs/ack/knowledge.yaml check-api-contract --project-root <project-root> .pouch/ack/knowledge.yaml check-api-contract --project-root <project-root>
``` ```
该入口会在执行前重新校验知识库,只打开一次项目根目录 fd,再从同一个 fd 逐段以 该入口会在执行前重新校验知识库,只打开一次项目根目录 fd,再从同一个 fd 逐段以
@@ -141,7 +141,7 @@ python3 <ack-skill-dir>/scripts/run_verification.py \
快照,再以结构化 argv 和 `shell=False` 启动。它不接受临时命令或额外参数。 快照,再以结构化 argv 和 `shell=False` 启动。它不接受临时命令或额外参数。
选择器输出的 path/args 只用于审阅,不应由 Agent 自行拼接执行。Runner 只读取 选择器输出的 path/args 只用于审阅,不应由 Agent 自行拼接执行。Runner 只读取
项目内无 symlink 的权威 项目内无 symlink 的权威
`docs/ack/knowledge.yaml`,不接受替代知识文件或放宽后的项目根。检查进程的 cwd `.pouch/ack/knowledge.yaml`,不接受替代知识文件或放宽后的项目根。检查进程的 cwd
和 `ACK_PROJECT_ROOT` 都固定到该根 fd;后者是只在检查进程存活期间有效的 和 `ACK_PROJECT_ROOT` 都固定到该根 fd;后者是只在检查进程存活期间有效的
`/proc/self/fd/...` 或 `/dev/fd/...` 路径。原始可读路径另放在 `/proc/self/fd/...` 或 `/dev/fd/...` 路径。原始可读路径另放在
`ACK_PROJECT_ROOT_DISPLAY`,只能用于日志,不能用于资源访问。Runner 还提供 `ACK_PROJECT_ROOT_DISPLAY`,只能用于日志,不能用于资源访问。Runner 还提供
@@ -155,7 +155,7 @@ python3 <ack-skill-dir>/scripts/run_verification.py \
旧项目只有 `project.md` 和 `tasks.yaml` 时,不要重跑初始化。由 `/ack` 检查现有 旧项目只有 `project.md` 和 `tasks.yaml` 时,不要重跑初始化。由 `/ack` 检查现有
状态,获得用户授权后补一个空的 `knowledge.yaml`;如果任务板尚未声明知识库, 状态,获得用户授权后补一个空的 `knowledge.yaml`;如果任务板尚未声明知识库,
同时只补 `project.knowledgeFile: docs/ack/knowledge.yaml`,再运行跨文件校验。 同时只补 `project.knowledgeFile: .pouch/ack/knowledge.yaml`,再运行跨文件校验。
只有 Coordinator 写 `tasks.yaml`、`knowledge.yaml` 和 `regression.yaml`。知识正文 只有 Coordinator 写 `tasks.yaml`、`knowledge.yaml` 和 `regression.yaml`。知识正文
不能作为自由 shell 执行;关键约束应继续下沉到测试、lint、CI 或正式规范。ACK 不能作为自由 shell 执行;关键约束应继续下沉到测试、lint、CI 或正式规范。ACK
@@ -163,15 +163,17 @@ python3 <ack-skill-dir>/scripts/run_verification.py \
## 配置与运行交付 ## 配置与运行交付
测试环境走 deployer 的项目内布局(通常是 `.skiff/deployer/test`),发版仍用 测试环境走 deployer 的项目内布局(通常是 `.pouch/deployer/test`),发版仍用
delivery profile。可以直接说: delivery profile。可以直接说:
```text ```text
/ack 测试环境用项目里的 .skiff/deployer/test;发版方式以后再告诉你。 /ack 测试环境用项目里的 .pouch/deployer/test;发版方式以后再告诉你。
``` ```
ACK 把测试环境写成 `intents.testEnvironment.via: deployer`,把发版写成 ACK 把测试环境写成 `intents.testEnvironment.via: deployer`,把发版写成
`intents.release` 指向的 profile。首次配置保持关闭,确认后才启用。之后可以说: `intents.release` 指向的 profile。`.pouch/deployer/<env>` 还没就绪时,ACK
会转去 deployer 的初始化,而不是自己编 compose。首次配置保持关闭,确认后才启用。
之后可以说:
```text ```text
/ack 重新布一下测试环境,我要测试 /ack 重新布一下测试环境,我要测试
@@ -260,7 +262,7 @@ Coordinator 最后标记整轮任务完成后,会关闭所有只关联 `verifi
Coordinator 会先读取项目状态和 `references/kickoff.md`,生成产品文档、任务拆分与 Coordinator 会先读取项目状态和 `references/kickoff.md`,生成产品文档、任务拆分与
可观测验收信号;用户确认后才派发实现和复测。任务 `verified` 后会把本轮黑盒路径 可观测验收信号;用户确认后才派发实现和复测。任务 `verified` 后会把本轮黑盒路径
收进 `docs/ack/regression.yaml`,确认后才写入。 收进 `.pouch/ack/regression.yaml`,确认后才写入。
## 修复 bug ## 修复 bug
@@ -283,7 +285,7 @@ revision 审核通过,并亲自把状态改成「已确认」之前,不创
## 运行回归 ## 运行回归
平时做需求和修 bug 结束后,ACK 按本轮内容更新 `docs/ack/regression.yaml`。 平时做需求和修 bug 结束后,ACK 按本轮内容更新 `.pouch/ack/regression.yaml`。
之后可以单独跑: 之后可以单独跑:
```text ```text
@@ -325,6 +327,6 @@ ACK 会自动读取 `delivery.yaml`,无需再逐步提醒它构建、上传、
`cli: omp` profile(精确 provider/model、thinking 与 approval-mode);从 `0.17.1` 起 Grok worker argv 固定带 `cli: omp` profile(精确 provider/model、thinking 与 approval-mode);从 `0.17.1` 起 Grok worker argv 固定带
`--always-approve`,sandbox 仍必开;从 `0.19.0` 起 `intents.testEnvironment` 改为 `--always-approve`,sandbox 仍必开;从 `0.19.0` 起 `intents.testEnvironment` 改为
deployer 绑定,ACK 内部调用 deployer skill 布测试环境,并增加 deployer 绑定,ACK 内部调用 deployer skill 布测试环境,并增加
`docs/ack/regression.yaml` 与「运行回归」模式。旧的测试环境 profile ID 字符串不再 `.pouch/ack/regression.yaml` 与「运行回归」模式。旧的测试环境 profile ID 字符串不再
执行,需要迁到 `{via: deployer, env: <env>}`。旧项目可以不迁移回归目录而继续使用 执行,需要迁到 `{via: deployer, env: <env>}`。旧项目可以不迁移回归目录而继续使用
原闭环。旧项目的 `kitVersion` 可以继续读取,但建议迁移为 `ackVersion`。 原闭环。旧项目的 `kitVersion` 可以继续读取,但建议迁移为 `ackVersion`。
+71 -56
View File
@@ -2,7 +2,7 @@
name: ack name: ack
description: >- description: >-
初始化、检查并运行 ACK 三角色协作闭环。仅在用户显式调用 /ack 或 $ack,并要求 初始化、检查并运行 ACK 三角色协作闭环。仅在用户显式调用 /ack 或 $ack,并要求
初始化 ACK、检查 docs/ack 配置、按 ACK 规划需求或修复 bug、指挥 初始化 ACK、检查 .pouch/ack 配置、按 ACK 规划需求或修复 bug、指挥
Coordinator/Developer/Test 工作,配置测试环境与发版方式,重新部署测试环境 Coordinator/Developer/Test 工作,配置测试环境与发版方式,重新部署测试环境
(内部调用 deployer),发布版本,或运行回归测试时使用。 (内部调用 deployer),发布版本,或运行回归测试时使用。
--- ---
@@ -10,7 +10,7 @@ description: >-
# ACK 项目协作入口 # ACK 项目协作入口
本 Skill 是 ACK 的完整能力包:`references/` 保存通用规范,`templates/` 保存项目 本 Skill 是 ACK 的完整能力包:`references/` 保存通用规范,`templates/` 保存项目
状态模板,`scripts/` 保存校验工具。目标项目只在 `docs/ack/` 保存 `project.md`、 状态模板,`scripts/` 保存校验工具。目标项目只在 `.pouch/ack/` 保存 `project.md`、
`tasks.yaml`、`knowledge.yaml`、默认关闭的 `delivery.yaml` 和空的 `tasks.yaml`、`knowledge.yaml`、默认关闭的 `delivery.yaml` 和空的
`regression.yaml`,不要复制或链接 Skill 内容。 `regression.yaml`,不要复制或链接 Skill 内容。
@@ -25,12 +25,12 @@ description: >-
飞书收件仍走本模式。 飞书收件仍走本模式。
- 用户用自然语言说明怎么部署测试环境、怎么发布版本,或要求增加、修改、关闭交付 - 用户用自然语言说明怎么部署测试环境、怎么发布版本,或要求增加、修改、关闭交付
流程:执行“交付配置维护”。测试环境绑定 deployer,发版写在同一份 流程:执行“交付配置维护”。测试环境绑定 deployer,发版写在同一份
`docs/ack/delivery.yaml`。 `.pouch/ack/delivery.yaml`。
- 用户要求部署、重新部署测试环境,或按已配置方式开始测试:执行“运行测试环境”。 - 用户要求部署、重新部署测试环境,或按已配置方式开始测试:执行“运行测试环境”。
内部加载 deployer skill,不在 ACK 里复制 compose/rsync 命令。 内部加载 deployer skill,不在 ACK 里复制 compose/rsync 命令。
- 用户要求发布版本:执行“运行版本发布”。 - 用户要求发布版本:执行“运行版本发布”。
- 用户要求回归、跑回归测试:执行“运行回归”。先布测试环境,再派 Test 按 - 用户要求回归、跑回归测试:执行“运行回归”。先布测试环境,再派 Test 按
`docs/ack/regression.yaml` 用浏览器或 API 执行。 `.pouch/ack/regression.yaml` 用浏览器或 API 执行。
始终先解析真实项目根目录。优先使用 `git rev-parse --show-toplevel`;不是 Git 始终先解析真实项目根目录。优先使用 `git rev-parse --show-toplevel`;不是 Git
项目时使用用户指定目录或当前目录。不要修改项目的 `AGENTS.md`、`CLAUDE.md` 项目时使用用户指定目录或当前目录。不要修改项目的 `AGENTS.md`、`CLAUDE.md`
@@ -38,70 +38,78 @@ description: >-
## 初始化 ## 初始化
1. 确认 `skiff` 可执行,并检查 `<project>/docs/ack` 是否存在。 1. 确认 `pouch` 可执行,并检查 `<project>/.pouch/ack` 是否存在。
2. 不存在时执行: 2. 不存在时执行:
```bash ```bash
skiff init ack --project <project-root> pouch init ack --project <project-root>
``` ```
该命令从本 Skill 的 `templates/` 生成项目状态,不会在项目中创建 Skill 该命令从本 Skill 的 `templates/` 生成项目状态,不会在项目中创建 Skill
软链接或资源副本。 软链接或资源副本。
3. 如果 `docs/ack` 已存在,不重复初始化、不覆盖文件;转入“检查”。旧项目只有 3. 如果 `.pouch/ack` 已存在,不重复初始化、不覆盖文件;转入“检查”。旧项目只有
`project.md` 与 `tasks.yaml` 时,先报告缺少 `knowledge.yaml`。用户授权后, `project.md` 与 `tasks.yaml` 时,先报告缺少 `knowledge.yaml`。用户授权后,
从 `templates/knowledge.template.yaml` 生成这个缺失文件并替换项目名和时间;若 从 `templates/knowledge.template.yaml` 生成这个缺失文件并替换项目名和时间;若
`tasks.yaml` 尚无 `project.knowledgeFile`,同时只补 `tasks.yaml` 尚无 `project.knowledgeFile`,同时只补
`docs/ack/knowledge.yaml` 这一项。不要重跑 `skiff init`,也不要改写其它已有 `.pouch/ack/knowledge.yaml` 这一项。不要重跑 `pouch init`,也不要改写其它已有
项目状态。 项目状态。
4. 读取项目的公开配置和文档,例如 README、语言清单、包管理清单、测试配置与 4. 读取项目的公开配置和文档,例如 README、语言清单、包管理清单、测试配置与
CI,确定项目名、技术栈、源码/规格/测试路径及真实可执行命令。 CI,确定项目名、技术栈、源码/规格/测试路径及真实可执行命令。
5. 完善 `docs/ack/project.md`: 5. 完善 `.pouch/ack/project.md`:
- 用实际项目值替换全部占位符。 - 用实际项目值替换全部占位符。
- 无服务地址时把 Base URL 写为 `n/a`,不要虚构端口。 - 无服务地址时把 Base URL 写为 `n/a`,不要虚构端口。
- 无法从项目证据确定的命令写为 `n/a`,并在结果中列为待配置项。 - 无法从项目证据确定的命令写为 `n/a`,并在结果中列为待配置项。
- 只写项目差异,不复制 `references/` 中的通用规范。 - 只写项目差异,不复制 `references/` 中的通用规范。
6. 完善 `docs/ack/tasks.yaml` 的项目信息。纯初始化且用户没有提供真实任务时, 6. 完善 `.pouch/ack/tasks.yaml` 的项目信息。纯初始化且用户没有提供真实任务时,
删除模板示例任务并保留 `tasks: []`;不要虚构需求或缺陷。 删除模板示例任务并保留 `tasks: []`;不要虚构需求或缺陷。
项目状态固定从当前项目根的 `docs/ack/` 推导,不写入 `repoPath` 或 `devWorktree`; 项目状态固定从当前项目根的 `.pouch/ack/` 推导,不写入 `repoPath` 或 `devWorktree`;
worker 默认在 `--project-root`(权威状态目录)工作,不再配置 worker 默认在 `--project-root`(权威状态目录)工作,不再配置
`allowedWorktrees` 白名单(v0.19 起废弃);需要隔离 worktree 时由 Coordinator 在 `allowedWorktrees` 白名单(v0.19 起废弃);需要隔离 worktree 时由 Coordinator 在
派发时显式指定。旧任务板中的 `repoPath`、`devWorktree` 仅兼容读取。 派发时显式指定。旧任务板中的 `repoPath`、`devWorktree` 仅兼容读取。
7. 检查 `docs/ack/knowledge.yaml`。新项目没有已验证的项目经验时保留 7. 检查 `.pouch/ack/knowledge.yaml`。新项目没有已验证的项目经验时保留
`verificationRegistry: {}` 与 `entries: []`,不从聊天、README 或单次失败中 `verificationRegistry: {}` 与 `entries: []`,不从聊天、README 或单次失败中
猜测并激活知识。 猜测并激活知识。
8. 检查 `docs/ack/delivery.yaml`。新项目保留 `enabled: false`、空能力表和空 profile; 8. 检查 `.pouch/ack/delivery.yaml`。新项目保留 `enabled: false`、空能力表和空 profile;
不从 README 或 CI 猜测、启用交付。旧项目没有该文件时仍可继续使用原 ACK 不从 README 或 CI 猜测、启用交付。旧项目没有该文件时仍可继续使用原 ACK
闭环;只有用户明确要求配置交付时,才按“交付配置维护”补齐。 闭环;只有用户明确要求配置交付时,才按“交付配置维护”补齐。
9. 检查 `docs/ack/regression.yaml`。新项目保留 `cases: []`。旧项目没有该文件时仍 9. 检查 `.pouch/ack/regression.yaml`。新项目保留 `cases: []`。旧项目没有该文件时仍
可继续原闭环;用户授权后从 `templates/regression.template.yaml` 生成,并只补 可继续原闭环;用户授权后从 `templates/regression.template.yaml` 生成,并只补
`project.regressionFile` 与顶层 `regressionRuns: []`。不要从聊天虚构用例。 `project.regressionFile` 与顶层 `regressionRuns: []`。不要从聊天虚构用例。
10. 更新 `updatedAt`,并运行: 10. 更新 `updatedAt`,并运行:
```bash ```bash
python3 <ack-skill-dir>/scripts/validate_tasks.py docs/ack/tasks.yaml python3 <ack-skill-dir>/scripts/validate_tasks.py .pouch/ack/tasks.yaml
python3 <ack-skill-dir>/scripts/validate_knowledge.py docs/ack/knowledge.yaml \ python3 <ack-skill-dir>/scripts/validate_knowledge.py .pouch/ack/knowledge.yaml \
--tasks docs/ack/tasks.yaml --tasks .pouch/ack/tasks.yaml
python3 <ack-skill-dir>/scripts/validate_delivery.py docs/ack/delivery.yaml \ python3 <ack-skill-dir>/scripts/validate_delivery.py .pouch/ack/delivery.yaml \
--tasks docs/ack/tasks.yaml --project-root <project-root> --tasks .pouch/ack/tasks.yaml --project-root <project-root>
python3 <ack-skill-dir>/scripts/validate_regression.py docs/ack/regression.yaml \ python3 <ack-skill-dir>/scripts/validate_regression.py .pouch/ack/regression.yaml \
--tasks docs/ack/tasks.yaml --tasks .pouch/ack/tasks.yaml
``` ```
11. 检查 `project.md`、`tasks.yaml`、`knowledge.yaml`、`delivery.yaml` 与 11. 检查 `project.md`、`tasks.yaml`、`knowledge.yaml`、`delivery.yaml` 与
`regression.yaml` 是否仍有 `<...>` 占位符。 `regression.yaml` 是否仍有 `<...>` 占位符。
结构校验通过且必填项目事实完整时才称“初始化完成”;否则称“部分完成”并列出 12. 按下面格式报告。结构校验通过且必填项目事实完整时才称「完成」;否则称
缺失值。 「部分完成」或「阻塞」并列出待配置项。除非用户明确要求,不提交、不推送。
12. 报告创建的路径、检测到的命令、校验结果和下一步。除非用户明确要求,不提交、 初始化 ACK **不**自动初始化 deployer 或 builder。
不推送。
```text
## ack 初始化:完成 | 部分完成 | 阻塞
已具备: …
待配置: 路径 + 字段 + 可粘贴示例 + 缺了会挡住哪步
工具链: pouch …
下一步: 一句话
```
## 检查 ## 检查
1. 检查以下路径: 1. 检查以下路径:
- `docs/ack/project.md` - `.pouch/ack/project.md`
- `docs/ack/tasks.yaml` - `.pouch/ack/tasks.yaml`
- `docs/ack/knowledge.yaml` - `.pouch/ack/knowledge.yaml`
- `docs/ack/delivery.yaml`(旧项目可无;存在或被任务板引用时必须校验) - `.pouch/ack/delivery.yaml`(旧项目可无;存在或被任务板引用时必须校验)
- `docs/ack/regression.yaml`(旧项目可无;存在或被任务板引用时必须校验) - `.pouch/ack/regression.yaml`(旧项目可无;存在或被任务板引用时必须校验)
需要查看任务内容时,使用 `<ack-skill-dir>/scripts/select_tasks.py` 解析完整任务板并 需要查看任务内容时,使用 `<ack-skill-dir>/scripts/select_tasks.py` 解析完整任务板并
只输出项目配置、摘要和可工作任务;不要用 `cat`、整文件 `sed` 或等价方式把完整 只输出项目配置、摘要和可工作任务;不要用 `cat`、整文件 `sed` 或等价方式把完整
`tasks.yaml` 注入上下文。完整性仍由校验器检查。 `tasks.yaml` 注入上下文。完整性仍由校验器检查。
@@ -112,16 +120,16 @@ description: >-
3. 查找未替换占位符,并核对项目根、覆盖层路径、Developer 白盒命令、Test 3. 查找未替换占位符,并核对项目根、覆盖层路径、Developer 白盒命令、Test
黑盒命令和 Base URL。 黑盒命令和 Base URL。
4. 使用 `<ack-skill-dir>/scripts/validate_tasks.py` 校验任务板,使用 4. 使用 `<ack-skill-dir>/scripts/validate_tasks.py` 校验任务板,使用
`<ack-skill-dir>/scripts/validate_knowledge.py docs/ack/knowledge.yaml --tasks `<ack-skill-dir>/scripts/validate_knowledge.py .pouch/ack/knowledge.yaml --tasks
docs/ack/tasks.yaml` 校验项目知识和跨文件引用。如果存在交付配置或任务板声明了 .pouch/ack/tasks.yaml` 校验项目知识和跨文件引用。如果存在交付配置或任务板声明了
`project.deliveryFile`,再使用 `<ack-skill-dir>/scripts/validate_delivery.py `project.deliveryFile`,再使用 `<ack-skill-dir>/scripts/validate_delivery.py
docs/ack/delivery.yaml --tasks docs/ack/tasks.yaml --project-root <project-root>` .pouch/ack/delivery.yaml --tasks .pouch/ack/tasks.yaml --project-root <project-root>`
校验交付能力、顺序、安全边界和跨文件引用。如果存在回归目录或任务板声明了 校验交付能力、顺序、安全边界和跨文件引用。如果存在回归目录或任务板声明了
`project.regressionFile`,再使用 `<ack-skill-dir>/scripts/validate_regression.py `project.regressionFile`,再使用 `<ack-skill-dir>/scripts/validate_regression.py
docs/ack/regression.yaml --tasks docs/ack/tasks.yaml` 校验用例与跨文件引用。 .pouch/ack/regression.yaml --tasks .pouch/ack/tasks.yaml` 校验用例与跨文件引用。
只报告证据明确的问题,不因旧项目缺少可选交付或回归配置而宣称失败。 只报告证据明确的问题,不因旧项目缺少可选交付或回归配置而宣称失败。
5. 若存在 `project.bugIntake`,运行 5. 若存在 `project.bugIntake`,运行
`python3 <ack-skill-dir>/scripts/feishu_bug_intake.py check docs/ack/tasks.yaml`。 `python3 <ack-skill-dir>/scripts/feishu_bug_intake.py check .pouch/ack/tasks.yaml`。
它只接受 `feishu-base` 和显式 profile;详细的飞书配置、凭据初始化和读取方式见 它只接受 `feishu-base` 和显式 profile;详细的飞书配置、凭据初始化和读取方式见
`references/feishu-bug-intake.md`。 `references/feishu-bug-intake.md`。
6. 检查知识引用能解析到固定 revision,candidate 仍留在任务证据中,且 6. 检查知识引用能解析到固定 revision,candidate 仍留在任务证据中,且
@@ -132,19 +140,24 @@ description: >-
必须同时为空或同时填写。 必须同时为空或同时填写。
缺少结构化路由的旧任务板只能使用手动模式,不能自动创建 worker。 缺少结构化路由的旧任务板只能使用手动模式,不能自动创建 worker。
8. 检查不会自动修复或覆盖现有配置;用户明确要求修复后再修改。 8. 检查不会自动修复或覆盖现有配置;用户明确要求修复后再修改。
9. 若 `delivery.yaml` 已把 `intents.testEnvironment` 写成 `{via: deployer, env: <env>}`,
只读运行已安装 deployer skill 的 `scripts/deploy/check.py --project <project-root>`。
未通过时列入待配置,加载 deployer skill 的「检查」说明;不要在 ACK 里复制
compose/rsync 命令,也不要静默初始化 deployer。
10. 用与「初始化」相同的报告格式,标题改为 `## ack 检查:…`。
## 工作 ## 工作
1. 若 `docs/ack` 不存在,停止并建议先用 `/ack` 初始化;不要静默初始化。 1. 若 `.pouch/ack` 不存在,停止并建议先用 `/ack` 初始化;不要静默初始化。
2. 依次读取: 2. 依次读取:
- `docs/ack/project.md` - `.pouch/ack/project.md`
- 运行 `python3 <ack-skill-dir>/scripts/select_tasks.py docs/ack/tasks.yaml`,只读取 - 运行 `python3 <ack-skill-dir>/scripts/select_tasks.py .pouch/ack/tasks.yaml`,只读取
`project`、`summary` 和默认可工作状态的任务;已知当前任务时传 `project`、`summary` 和默认可工作状态的任务;已知当前任务时传
`--task-id <ack-task-id>`。选择器会解析并校验完整任务板,并只附带选中任务引用的 `--task-id <ack-task-id>`。选择器会解析并校验完整任务板,并只附带选中任务引用的
receipt 与 delivery run。命中超过默认预算时用 `--task-id` / `--status` 缩小, receipt 与 delivery run。命中超过默认预算时用 `--task-id` / `--status` 缩小,
不直接回退为输出完整 `tasks.yaml`。 不直接回退为输出完整 `tasks.yaml`。
- 通过 `<ack-skill-dir>/scripts/select_knowledge.py` 从 - 通过 `<ack-skill-dir>/scripts/select_knowledge.py` 从
`docs/ack/knowledge.yaml` 选择的当前任务相关 `active` 条目 `.pouch/ack/knowledge.yaml` 选择的当前任务相关 `active` 条目
- `<ack-skill-dir>/references/kickoff.md` - `<ack-skill-dir>/references/kickoff.md`
- kickoff 指定且与当前任务相关的 references 文件 - kickoff 指定且与当前任务相关的 references 文件
- 若 `tasks.yaml.project.deliveryFile` 存在,再读取该 `delivery.yaml` 和 - 若 `tasks.yaml.project.deliveryFile` 存在,再读取该 `delivery.yaml` 和
@@ -199,10 +212,10 @@ description: >-
`knowledgeCandidates`,Test 回报 `knowledgeChecks` 和 `regressionCandidates`; `knowledgeCandidates`,Test 回报 `knowledgeChecks` 和 `regressionCandidates`;
`candidate` 只有在独立验证和 gate 后才能由 Coordinator 写入或激活。 `candidate` 只有在独立验证和 gate 后才能由 Coordinator 写入或激活。
任务进入 `verified` 且改了用户可见行为或 API 后,按 `references/regression.md` 任务进入 `verified` 且改了用户可见行为或 API 后,按 `references/regression.md`
给出新增/更新/退役/无回归四选一,用户确认后写入 `docs/ack/regression.yaml`, 给出新增/更新/退役/无回归四选一,用户确认后写入 `.pouch/ack/regression.yaml`,
并把 case id 记入 `regressionRefs`。Test 只提名,不写该文件。 并把 case id 记入 `regressionRefs`。Test 只提名,不写该文件。
7. 执行知识项的 `verification.ref` 时,只调用 7. 执行知识项的 `verification.ref` 时,只调用
`<ack-skill-dir>/scripts/run_verification.py docs/ack/knowledge.yaml `<ack-skill-dir>/scripts/run_verification.py .pouch/ack/knowledge.yaml
<verification-ref> --project-root <project-root>`。不要直接执行选择器返回的 path/args, <verification-ref> --project-root <project-root>`。不要直接执行选择器返回的 path/args,
也不要给 runner 注入额外命令或参数。 也不要给 runner 注入额外命令或参数。
8. 不把 `worker_done` 或 Test 自报成功直接当作完成。三轮预算只计算 Test 已对齐正确 8. 不把 `worker_done` 或 Test 自报成功直接当作完成。三轮预算只计算 Test 已对齐正确
@@ -232,13 +245,14 @@ description: >-
1. 读取 `references/delivery.md`、deployer skill、模板、schema、现有 1. 读取 `references/delivery.md`、deployer skill、模板、schema、现有
`delivery.yaml`、项目构建/发布入口和 CI。测试环境写成 `delivery.yaml`、项目构建/发布入口和 CI。测试环境写成
`intents.testEnvironment: {via: deployer, env: <env>}`,并按 deployer skill `intents.testEnvironment: {via: deployer, env: <env>}`。若
准备 `.skiff/deployer/<env>`;不要把 compose/rsync 命令写进 ACK。发版仍指向 `.pouch/deployer/<env>` 不存在或 deployer `check.py` 未通过:停止,加载
deployer skill 的「初始化」,不要在 ACK 里复制 compose/rsync 命令。发版仍指向
本文件的 profile。不要拆成第二份文档。配置只引用仓库内脚本或声明式工具 本文件的 profile。不要拆成第二份文档。配置只引用仓库内脚本或声明式工具
target,不保存 shell。本地 `npm run dev` / `go run` 写在 `project.md` 的 target,不保存 shell。本地 `npm run dev` / `go run` 写在 `project.md` 的
Developer 白盒命令里,不算测试环境部署。 Developer 白盒命令里,不算测试环境部署。
2. 若旧项目首次启用,生成 `docs/ack/delivery.yaml`,在 `tasks.yaml.project` 增加 2. 若旧项目首次启用,生成 `.pouch/ack/delivery.yaml`,在 `tasks.yaml.project` 增加
`deliveryFile: docs/ack/delivery.yaml`,并增加顶层 `deliveryRuns: []`;不改写其它 `deliveryFile: .pouch/ack/delivery.yaml`,并增加顶层 `deliveryRuns: []`;不改写其它
项目状态。首次生成保持 `enabled: false`,先展示 diff 和解析出的执行顺序。 项目状态。首次生成保持 `enabled: false`,先展示 diff 和解析出的执行顺序。
3. 运行 delivery、tasks 和跨文件校验;需要的脚本不存在、不可执行、引用不完整或 3. 运行 delivery、tasks 和跨文件校验;需要的脚本不存在、不可执行、引用不完整或
涉及凭据正文时 fail closed。凭据只写 secret 名称,值由外部环境提供。 涉及凭据正文时 fail closed。凭据只写 secret 名称,值由外部环境提供。
@@ -248,7 +262,7 @@ description: >-
## 运行测试环境 ## 运行测试环境
1. 读取 `docs/ack/delivery.yaml`、`references/delivery.md` 和 deployer skill 的 1. 读取 `.pouch/ack/delivery.yaml`、`references/delivery.md` 和 deployer skill 的
`SKILL.md`。 `SKILL.md`。
2. `enabled` 不为 true,或 `intents.testEnvironment` 为 null:停止,请用户说明如何 2. `enabled` 不为 true,或 `intents.testEnvironment` 为 null:停止,请用户说明如何
部署测试环境,转入交付配置维护。不猜测编译或启动命令。 部署测试环境,转入交付配置维护。不猜测编译或启动命令。
@@ -256,19 +270,20 @@ description: >-
profile ID 字符串:停止,展示迁移说明,转入交付配置维护。不要执行 ACK profile ID 字符串:停止,展示迁移说明,转入交付配置维护。不要执行 ACK
delivery profile 来布测试环境。 delivery profile 来布测试环境。
4. 不要求任务已 `verified`。按 deployer 的项目内环境布局操作 4. 不要求任务已 `verified`。按 deployer 的项目内环境布局操作
`.skiff/deployer/<env>`:list 确认服务,再按服务 sync + up(或用户要求的 `.pouch/deployer/<env>`:list 确认服务,再按服务 sync + up(或用户要求的
recreate),并用 ps/logs/健康检查验证。不要复制 deployer 脚本,不要发明 recreate),并用 ps/logs/健康检查验证。不要复制 deployer 脚本,不要发明
第二套 compose 命令。 第二套 compose 命令。
5. 把访问地址交给用户或随后的 Test 黑盒。证据写入 `deliveryRuns`, 5. 把访问地址交给用户或随后的 Test 黑盒。证据写入 `deliveryRuns`,
`intent: testEnvironment`,`profile` 记 `deployer-<env>`,`taskIds` 可为空。 `intent: testEnvironment`,`profile` 记 `deployer-<env>`,`taskIds` 可为空。
6. 派发 Test 前若该 intent 已启用,必须先完成本步骤。deployer 未安装、环境目录 6. 派发 Test 前若该 intent 已启用,必须先完成本步骤。deployer 未安装、环境目录
不存在或健康检查失败:fail closed,报告 `userAction`,不把环境失败写成产品 不存在或 `check.py` 未通过:停止,加载 deployer skill 的「初始化」,报告
失败。 `userAction`,不把环境失败写成产品失败,也不要在 ACK 里发明 compose 命令。
健康检查失败同样 fail closed。
## 运行回归 ## 运行回归
1. 若 `docs/ack` 不存在,停止并建议先初始化。 1. 若 `.pouch/ack` 不存在,停止并建议先初始化。
2. 若没有 `docs/ack/regression.yaml` 或 `project.regressionFile`:停止,用户授权后 2. 若没有 `.pouch/ack/regression.yaml` 或 `project.regressionFile`:停止,用户授权后
从模板生成空文件并只补任务板指针与 `regressionRuns: []`。 从模板生成空文件并只补任务板指针与 `regressionRuns: []`。
3. 用 `scripts/select_regression.py` 读取 active 用例(默认 `--suite smoke`;用户 3. 用 `scripts/select_regression.py` 读取 active 用例(默认 `--suite smoke`;用户
指定 full 或 case id 时缩小范围)。没有命中用例时停止并说明先收获用例。 指定 full 或 case id 时缩小范围)。没有命中用例时停止并说明先收获用例。
@@ -284,7 +299,7 @@ description: >-
## 运行版本发布 ## 运行版本发布
1. 读取同一份 `docs/ack/delivery.yaml` 与 `references/delivery.md`。 1. 读取同一份 `.pouch/ack/delivery.yaml` 与 `references/delivery.md`。
2. `enabled` 不为 true,或 `intents.release` 为 null:停止,请用户说明如何发版, 2. `enabled` 不为 true,或 `intents.release` 为 null:停止,请用户说明如何发版,
写入同一文件后再执行。 写入同一文件后再执行。
3. 按该 profile 顺序执行。stable 发布和生产部署的 `approval` 不能用口头「发版」 3. 按该 profile 顺序执行。stable 发布和生产部署的 `approval` 不能用口头「发版」
@@ -309,7 +324,7 @@ description: >-
没有可信空闲状态、配置匹配和历史消息清理证明时不复用既有 worker。 没有可信空闲状态、配置匹配和历史消息清理证明时不复用既有 worker。
- launcher 返回 `indeterminate` 或 `reconcile required` 时,不直接重试;先按 - launcher 返回 `indeterminate` 或 `reconcile required` 时,不直接重试;先按
launch ID、外部 record 和 Orca live state 完成人工核对。 launch ID、外部 record 和 Orca live state 完成人工核对。
- 不覆盖已有 `docs/ack` 文件;除用户确认的 ACK 任务或 delivery profile 外,不擅自 - 不覆盖已有 `.pouch/ack` 文件;除用户确认的 ACK 任务或 delivery profile 外,不擅自
提交、推送、创建终端、新 worktree、发布产物或部署。 提交、推送、创建终端、新 worktree、发布产物或部署。
- 只有 Coordinator 写 `tasks.yaml`、`knowledge.yaml`、`regression.yaml`、 - 只有 Coordinator 写 `tasks.yaml`、`knowledge.yaml`、`regression.yaml`、
`deliveryRuns` 和 `regressionRuns`;Developer 与 Test 只读,只能通过回报提名 `deliveryRuns` 和 `regressionRuns`;Developer 与 Test 只读,只能通过回报提名
@@ -318,8 +333,8 @@ description: >-
按 registry ID 执行。不自动修改 `AGENTS.md`、`CLAUDE.md` 或其它 Agent 指令文件。 按 registry ID 执行。不自动修改 `AGENTS.md`、`CLAUDE.md` 或其它 Agent 指令文件。
- 不把完整 `tasks.yaml` 注入上下文;使用 `select_tasks.py` 获取有预算的项目与任务 - 不把完整 `tasks.yaml` 注入上下文;使用 `select_tasks.py` 获取有预算的项目与任务
视图,写回前仍运行完整任务板校验。 视图,写回前仍运行完整任务板校验。
- 项目只保存 `docs/ack/project.md`、`docs/ack/tasks.yaml`、 - 项目只保存 `.pouch/ack/project.md`、`.pouch/ack/tasks.yaml`、
`docs/ack/knowledge.yaml`、可选的 `docs/ack/delivery.yaml` 和可选的 `.pouch/ack/knowledge.yaml`、可选的 `.pouch/ack/delivery.yaml` 和可选的
`docs/ack/regression.yaml`;通用资源始终从当前 ACK Skill 目录读取。 `.pouch/ack/regression.yaml`;通用资源始终从当前 ACK Skill 目录读取。
- 不把完整 `regression.yaml` 注入上下文;使用 `select_regression.py` 获取有预算的 - 不把完整 `regression.yaml` 注入上下文;使用 `select_regression.py` 获取有预算的
用例视图,写回前仍运行完整校验。 用例视图,写回前仍运行完整校验。
+8 -8
View File
@@ -2,9 +2,9 @@
> 本项目基于 ack v0.19.0。 > 本项目基于 ack v0.19.0。
> 通用规范由 `/ack` 从 Skill 自身的 `references/` 读取,本文件只填项目差异。 > 通用规范由 `/ack` 从 Skill 自身的 `references/` 读取,本文件只填项目差异。
> 覆盖层文件放在 `docs/ack/project.md`,不占用 `AGENTS.md`。 > 覆盖层文件放在 `.pouch/ack/project.md`,不占用 `AGENTS.md`。
> ACK 不会自动修改 `AGENTS.md`、`CLAUDE.md` 或其它 Agent 指令文件。 > ACK 不会自动修改 `AGENTS.md`、`CLAUDE.md` 或其它 Agent 指令文件。
> `docs/ack/` 只保存 `project.md`、`tasks.yaml`、`knowledge.yaml`、`delivery.yaml` > `.pouch/ack/` 只保存 `project.md`、`tasks.yaml`、`knowledge.yaml`、`delivery.yaml`
> 与 `regression.yaml`。 > 与 `regression.yaml`。
## 项目概览 ## 项目概览
@@ -13,11 +13,11 @@
- 技术栈:`TypeScript + React (Vite) + Go` - 技术栈:`TypeScript + React (Vite) + Go`
- 运行命令:`npm run dev`(前端)、`go run ./server`(后端) - 运行命令:`npm run dev`(前端)、`go run ./server`(后端)
- Base URL:`http://localhost:5173` - Base URL:`http://localhost:5173`
- 任务板:`docs/ack/tasks.yaml` - 任务板:`.pouch/ack/tasks.yaml`
- 项目知识:`docs/ack/knowledge.yaml` - 项目知识:`.pouch/ack/knowledge.yaml`
- 交付契约:`docs/ack/delivery.yaml` - 交付契约:`.pouch/ack/delivery.yaml`
- 回归目录:`docs/ack/regression.yaml` - 回归目录:`.pouch/ack/regression.yaml`
- 覆盖层文件:`docs/ack/project.md` - 覆盖层文件:`.pouch/ack/project.md`
## 稳定规范(引用,不重复) ## 稳定规范(引用,不重复)
@@ -33,7 +33,7 @@
## Worker 路由 ## Worker 路由
结构化配置位于 `docs/ack/tasks.yaml` 的 `project.orchestration`,启动记录位于顶层 结构化配置位于 `.pouch/ack/tasks.yaml` 的 `project.orchestration`,启动记录位于顶层
`workerReceipts`。本项目默认使用: `workerReceipts`。本项目默认使用:
| 角色 | profile ID | 档位 | | 角色 | profile ID | 档位 |
+4 -4
View File
@@ -7,10 +7,10 @@ ackVersion: "0.19.0"
project: project:
name: "notes-web" name: "notes-web"
baseUrl: "http://localhost:5173" baseUrl: "http://localhost:5173"
overlayFile: "docs/ack/project.md" overlayFile: ".pouch/ack/project.md"
knowledgeFile: "docs/ack/knowledge.yaml" knowledgeFile: ".pouch/ack/knowledge.yaml"
deliveryFile: "docs/ack/delivery.yaml" deliveryFile: ".pouch/ack/delivery.yaml"
regressionFile: "docs/ack/regression.yaml" regressionFile: ".pouch/ack/regression.yaml"
orchestration: orchestration:
profileVersion: 1 profileVersion: 1
mode: "manual" mode: "manual"
+8 -8
View File
@@ -3,8 +3,8 @@
## 安装与初始化 ## 安装与初始化
- [ ] ACK Skill 已全局安装或安装到当前项目。 - [ ] ACK Skill 已全局安装或安装到当前项目。
- [ ] 已运行 `skiff init ack --project <project-root>`。 - [ ] 已运行 `pouch init ack --project <project-root>`。
- [ ] `docs/ack/` 只包含项目自己的 `project.md`、`tasks.yaml`、`knowledge.yaml`、 - [ ] `.pouch/ack/` 只包含项目自己的 `project.md`、`tasks.yaml`、`knowledge.yaml`、
默认关闭的 `delivery.yaml` 与空的 `regression.yaml`。 默认关闭的 `delivery.yaml` 与空的 `regression.yaml`。
- [ ] 旧项目缺少 `knowledge.yaml` 时,只补空文件及缺失的 - [ ] 旧项目缺少 `knowledge.yaml` 时,只补空文件及缺失的
`project.knowledgeFile` 指针,没有重跑初始化或覆盖其它项目状态。 `project.knowledgeFile` 指针,没有重跑初始化或覆盖其它项目状态。
@@ -16,10 +16,10 @@
- [ ] `project.md` 只保存项目差异,不复制 Skill 的通用规范。 - [ ] `project.md` 只保存项目差异,不复制 Skill 的通用规范。
- [ ] `tasks.yaml` 的 `project.overlayFile` 指向实际覆盖层。 - [ ] `tasks.yaml` 的 `project.overlayFile` 指向实际覆盖层。
- [ ] `tasks.yaml` 的 `project.knowledgeFile` 固定为 - [ ] `tasks.yaml` 的 `project.knowledgeFile` 固定为
`docs/ack/knowledge.yaml`。 `.pouch/ack/knowledge.yaml`。
- [ ] 新项目的 `project.deliveryFile` 固定为 `docs/ack/delivery.yaml`,顶层有 - [ ] 新项目的 `project.deliveryFile` 固定为 `.pouch/ack/delivery.yaml`,顶层有
`deliveryRuns: []`;旧项目未采用交付能力时可无这两项。 `deliveryRuns: []`;旧项目未采用交付能力时可无这两项。
- [ ] 新项目的 `project.regressionFile` 固定为 `docs/ack/regression.yaml`,顶层有 - [ ] 新项目的 `project.regressionFile` 固定为 `.pouch/ack/regression.yaml`,顶层有
`regressionRuns: []`;旧项目未采用回归能力时可无这两项。 `regressionRuns: []`;旧项目未采用回归能力时可无这两项。
- [ ] 技术栈、运行、构建、单测和集成测试命令均来自项目证据。 - [ ] 技术栈、运行、构建、单测和集成测试命令均来自项目证据。
- [ ] Coordinator、Developer、Test 的模型档位和升级规则已明确。 - [ ] Coordinator、Developer、Test 的模型档位和升级规则已明确。
@@ -28,7 +28,7 @@
- [ ] `allowedWorktrees` 已废弃(v0.19 起),新任务板不配置;worker 默认在 - [ ] `allowedWorktrees` 已废弃(v0.19 起),新任务板不配置;worker 默认在
`--project-root` 工作,其它 worktree 由 launcher 按同 git 仓库且已注册约束放行。 `--project-root` 工作,其它 worktree 由 launcher 按同 git 仓库且已注册约束放行。
- [ ] `tasks.yaml` 不需要保存 `repoPath` 或 `devWorktree`;项目状态从当前 - [ ] `tasks.yaml` 不需要保存 `repoPath` 或 `devWorktree`;项目状态从当前
`--project-root/docs/ack/` 推导,worker 路径由 `--worktree` 显式指定。 `--project-root/.pouch/ack/` 推导,worker 路径由 `--worktree` 显式指定。
## 路径权限 ## 路径权限
@@ -121,6 +121,6 @@
blocked/failed/leftover、未完成任务或未解决环境事件的终端保留且不设 TTL。 blocked/failed/leftover、未完成任务或未解决环境事件的终端保留且不设 TTL。
首次接入建议选择一个低风险问题跑完整闭环。项目差异写回 首次接入建议选择一个低风险问题跑完整闭环。项目差异写回
`docs/ack/project.md`;通用问题回流到 ACK Skill 的 `references/`、`templates/` `.pouch/ack/project.md`;通用问题回流到 ACK Skill 的 `references/`、`templates/`
或 `scripts/`,并更新 `VERSION`。项目特有、跨任务复用且已经验证的经验才写入 或 `scripts/`,并更新 `VERSION`。项目特有、跨任务复用且已经验证的经验才写入
`docs/ack/knowledge.yaml`。 `.pouch/ack/knowledge.yaml`。
+1 -1
View File
@@ -44,7 +44,7 @@ Coordinator 发现或读取 open 任务
直到 Developer 的 worker_done / escalation(含 knowledgeApplied / knowledgeCandidates) 直到 Developer 的 worker_done / escalation(含 knowledgeApplied / knowledgeCandidates)
-> writeback fixed_by_dev -> writeback fixed_by_dev
-> 若 delivery.yaml intents.testEnvironment 已启用:Coordinator 先按 deployer -> 若 delivery.yaml intents.testEnvironment 已启用:Coordinator 先按 deployer
绑定拉起 `.skiff/deployer/<env>`,再派 Test;Test 不发明编译或启动命令 绑定拉起 `.pouch/deployer/<env>`,再派 Test;Test 不发明编译或启动命令
-> 为 Test 独立解析安全 profile;安全重置同角色空闲 worker,或重新 plan/launch fresh worker -> 为 Test 独立解析安全 profile;安全重置同角色空闲 worker,或重新 plan/launch fresh worker
-> dispatch 给 Test(retesting) -> dispatch 给 Test(retesting)
-> 确认 Test 已开始执行(terminal read 确认任务注入;未开始按环境失败处理) -> 确认 Test 已开始执行(terminal read 确认任务注入;未开始按环境失败处理)
+12 -11
View File
@@ -2,8 +2,8 @@
本文件定义可选的 `verified -> validation_ready/review_ready/released` 交付阶段。开发、独立复测和 本文件定义可选的 `verified -> validation_ready/review_ready/released` 交付阶段。开发、独立复测和
Coordinator 终检仍由 ACK 原有闭环负责;只有选中的任务全部 `verified` 后才能进入 Coordinator 终检仍由 ACK 原有闭环负责;只有选中的任务全部 `verified` 后才能进入
交付。项目配置位于 `docs/ack/delivery.yaml`,运行证据写入 交付。项目配置位于 `.pouch/ack/delivery.yaml`,运行证据写入
`docs/ack/tasks.yaml.deliveryRuns`。 `.pouch/ack/tasks.yaml.deliveryRuns`。
## 1. 配置与授权不是一回事 ## 1. 配置与授权不是一回事
@@ -54,7 +54,7 @@ channel、environment 或 source revision 漂移时重新确认。
## 3.1 测试环境与发版写在同一份契约 ## 3.1 测试环境与发版写在同一份契约
`docs/ack/delivery.yaml` 是测试环境绑定和版本发布的唯一文档。不要另写操作手册, `.pouch/ack/delivery.yaml` 是测试环境绑定和版本发布的唯一文档。不要另写操作手册,
也不要把其中一项写进 `project.md`。用户用自然语言说明「怎么布测试环境」或 也不要把其中一项写进 `project.md`。用户用自然语言说明「怎么布测试环境」或
「怎么发版」时,Coordinator 把两者都维护进这份文件的 `intents`。 「怎么发版」时,Coordinator 把两者都维护进这份文件的 `intents`。
@@ -62,17 +62,18 @@ channel、environment 或 source revision 漂移时重新确认。
intents: intents:
testEnvironment: testEnvironment:
via: deployer via: deployer
env: test # 项目 .skiff/deployer/test;尚未说明时为 null env: test # 项目 .pouch/deployer/test;尚未说明时为 null
release: null # profile ID,或 null release: null # profile ID,或 null
``` ```
- `testEnvironment` 绑定 deployer skill 的项目环境目录。用户说「重新布测试环境」 - `testEnvironment` 绑定 deployer skill 的项目环境目录。用户说「重新布测试环境」
「我要测试」时,ACK 加载 deployer 的 `SKILL.md`,对 `.skiff/deployer/<env>` 「我要测试」时,ACK 加载 deployer 的 `SKILL.md`,对 `.pouch/deployer/<env>`
按服务执行 sync + up 和健康检查。派发 Test 复测或跑回归前,若该 intent 已配置 按服务执行 sync + up 和健康检查。环境目录不存在或 deployer `check.py` 未通过
且 `enabled: true`,Coordinator 也先执行它。不要求当前有 `verified` 任务。 时,加载 deployer skill 的「初始化」,不要在 ACK 里复制 compose 命令。派发
Test 不对这个 intent 发明编译或启动命令。旧的 profile ID 字符串不再执行,必须 Test 复测或跑回归前,若该 intent 已配置且 `enabled: true`,Coordinator 也先
迁到 `{via: deployer, env: <env>}`。本地进程启动写在 `project.md`,不算这个 执行它。不要求当前有 `verified` 任务。Test 不对这个 intent 发明编译或启动
intent。 命令。旧的 profile ID 字符串不再执行,必须迁到 `{via: deployer, env: <env>}`。
本地进程启动写在 `project.md`,不算这个 intent。
- `release` 指向 `stopAt: released` 的 profile。用户说「发布一个版本」时执行它。 - `release` 指向 `stopAt: released` 的 profile。用户说「发布一个版本」时执行它。
口头「发版」不能代替 stable/production 的 `approval` 步骤。 口头「发版」不能代替 stable/production 的 `approval` 步骤。
- 对应 intent 为 `null` 或交付未启用:停止,请用户说明怎么做,按「交付配置维护」 - 对应 intent 为 `null` 或交付未启用:停止,请用户说明怎么做,按「交付配置维护」
@@ -90,7 +91,7 @@ intents:
```bash ```bash
python3 <ack-skill-dir>/scripts/validate_delivery.py \ python3 <ack-skill-dir>/scripts/validate_delivery.py \
docs/ack/delivery.yaml --tasks docs/ack/tasks.yaml \ .pouch/ack/delivery.yaml --tasks .pouch/ack/tasks.yaml \
--project-root <project-root> --project-root <project-root>
``` ```
+9 -9
View File
@@ -9,7 +9,7 @@
## 项目配置与 Base 结构 ## 项目配置与 Base 结构
`docs/ack/tasks.yaml` 的 `project.bugIntake` 必须声明 `provider: feishu-base`、 `.pouch/ack/tasks.yaml` 的 `project.bugIntake` 必须声明 `provider: feishu-base`、
`workflow: clarified-writeback-v1`、显式 `profile`、`baseToken`、`tableId`、`viewId` 和字段映射: `workflow: clarified-writeback-v1`、显式 `profile`、`baseToken`、`tableId`、`viewId` 和字段映射:
```yaml ```yaml
@@ -34,8 +34,8 @@ fields:
调整当前 view 的可见字段,不删除旧列: 调整当前 view 的可见字段,不删除旧列:
```bash ```bash
python3 <ack-skill-dir>/scripts/feishu_bug_intake.py schema-plan docs/ack/tasks.yaml python3 <ack-skill-dir>/scripts/feishu_bug_intake.py schema-plan .pouch/ack/tasks.yaml
python3 <ack-skill-dir>/scripts/feishu_bug_intake.py schema-apply docs/ack/tasks.yaml \ python3 <ack-skill-dir>/scripts/feishu_bug_intake.py schema-apply .pouch/ack/tasks.yaml \
--expected-schema-fingerprint <schemaFingerprint> --expected-schema-fingerprint <schemaFingerprint>
``` ```
@@ -68,11 +68,11 @@ locale;调用者环境中的凭据和运行时注入变量不会传入。不
## 读取与整理 ## 读取与整理
```bash ```bash
python3 <ack-skill-dir>/scripts/feishu_bug_intake.py check docs/ack/tasks.yaml python3 <ack-skill-dir>/scripts/feishu_bug_intake.py check .pouch/ack/tasks.yaml
tmpdir=$(mktemp -d) tmpdir=$(mktemp -d)
python3 <ack-skill-dir>/scripts/feishu_bug_intake.py fetch docs/ack/tasks.yaml \ python3 <ack-skill-dir>/scripts/feishu_bug_intake.py fetch .pouch/ack/tasks.yaml \
--output-dir "$tmpdir" --output-dir "$tmpdir"
python3 <ack-skill-dir>/scripts/feishu_bug_intake.py plan docs/ack/tasks.yaml \ python3 <ack-skill-dir>/scripts/feishu_bug_intake.py plan .pouch/ack/tasks.yaml \
--output-dir "$tmpdir" --output-dir "$tmpdir"
``` ```
@@ -101,7 +101,7 @@ Coordinator 对每条 Bug:
```bash ```bash
python3 <ack-skill-dir>/scripts/feishu_bug_intake.py write-draft \ python3 <ack-skill-dir>/scripts/feishu_bug_intake.py write-draft \
docs/ack/tasks.yaml --record-id <record-id> \ .pouch/ack/tasks.yaml --record-id <record-id> \
--expected-source-ref <sourceRef> \ --expected-source-ref <sourceRef> \
--expected-draft-revision <draftRevision> --input <draft.json> --expected-draft-revision <draftRevision> --input <draft.json>
``` ```
@@ -120,7 +120,7 @@ python3 <ack-skill-dir>/scripts/feishu_bug_intake.py write-draft \
```bash ```bash
python3 <ack-skill-dir>/scripts/feishu_bug_intake.py import-approved \ python3 <ack-skill-dir>/scripts/feishu_bug_intake.py import-approved \
docs/ack/tasks.yaml --record-id <record-id> \ .pouch/ack/tasks.yaml --record-id <record-id> \
--expected-source-ref <approved-sourceRef> \ --expected-source-ref <approved-sourceRef> \
--expected-draft-revision <approvedDraftRevision> --expected-draft-revision <approvedDraftRevision>
``` ```
@@ -135,7 +135,7 @@ python3 <ack-skill-dir>/scripts/feishu_bug_intake.py import-approved \
```bash ```bash
python3 <ack-skill-dir>/scripts/feishu_bug_intake.py mark-imported \ python3 <ack-skill-dir>/scripts/feishu_bug_intake.py mark-imported \
docs/ack/tasks.yaml --record-id <record-id> --task-id <ack-task-id> \ .pouch/ack/tasks.yaml --record-id <record-id> --task-id <ack-task-id> \
--expected-source-ref <approved-sourceRef> \ --expected-source-ref <approved-sourceRef> \
--expected-draft-revision <approvedDraftRevision> --expected-draft-revision <approvedDraftRevision>
``` ```
+36 -39
View File
@@ -9,10 +9,10 @@
1. 目标项目根目录。 1. 目标项目根目录。
2. ACK Skill 已全局安装或安装到当前项目。 2. ACK Skill 已全局安装或安装到当前项目。
3. `skiff` 命令可用。 3. `pouch` 命令可用。
不要覆盖已有的 `docs/ack/project.md`、`docs/ack/tasks.yaml`、 不要覆盖已有的 `.pouch/ack/project.md`、`.pouch/ack/tasks.yaml`、
`docs/ack/knowledge.yaml`、`docs/ack/delivery.yaml`、`docs/ack/regression.yaml`、 `.pouch/ack/knowledge.yaml`、`.pouch/ack/delivery.yaml`、`.pouch/ack/regression.yaml`、
`AGENTS.md` 或其它 Agent `AGENTS.md` 或其它 Agent
指令文件。ACK 不会自动 指令文件。ACK 不会自动
修改 `AGENTS.md`、`CLAUDE.md` 或其它 Agent 指令文件。不要把 token、`.env` 修改 `AGENTS.md`、`CLAUDE.md` 或其它 Agent 指令文件。不要把 token、`.env`
@@ -23,19 +23,19 @@
在目标项目执行: 在目标项目执行:
```bash ```bash
skiff init ack pouch init ack
``` ```
或显式指定项目: 或显式指定项目:
```bash ```bash
skiff init ack --project <project-root> pouch init ack --project <project-root>
``` ```
命令从 ACK Skill 自带的 `templates/` 生成: 命令从 ACK Skill 自带的 `templates/` 生成:
```text ```text
docs/ack/ .pouch/ack/
├── project.md ├── project.md
├── tasks.yaml ├── tasks.yaml
├── knowledge.yaml ├── knowledge.yaml
@@ -49,31 +49,31 @@ docs/ack/
### 旧项目补充知识库 ### 旧项目补充知识库
旧项目已经有 `project.md` 和 `tasks.yaml`、但没有 `knowledge.yaml` 时,不要重跑 旧项目已经有 `project.md` 和 `tasks.yaml`、但没有 `knowledge.yaml` 时,不要重跑
`skiff init ack`。先检查现有文件并向用户报告缺失项;用户授权后,只从 `pouch init ack`。先检查现有文件并向用户报告缺失项;用户授权后,只从
`templates/knowledge.template.yaml` 生成 `docs/ack/knowledge.yaml`,替换项目名和 `templates/knowledge.template.yaml` 生成 `.pouch/ack/knowledge.yaml`,替换项目名和
当前时间,保留 `entries: []`。如果现有任务板缺少 当前时间,保留 `entries: []`。如果现有任务板缺少
`project.knowledgeFile`,同一次授权只补 `project.knowledgeFile`,同一次授权只补
`knowledgeFile: docs/ack/knowledge.yaml`,不改写其它项目状态。生成后运行任务板、 `knowledgeFile: .pouch/ack/knowledge.yaml`,不改写其它项目状态。生成后运行任务板、
知识库和跨文件引用校验。 知识库和跨文件引用校验。
### 旧项目补充交付配置 ### 旧项目补充交付配置
`delivery.yaml` 对旧项目是可选能力;缺少它不会影响三角色开发与验证闭环。只有用户 `delivery.yaml` 对旧项目是可选能力;缺少它不会影响三角色开发与验证闭环。只有用户
明确要求配置项目交付时,才从 `templates/delivery.template.yaml` 生成文件,同时在 明确要求配置项目交付时,才从 `templates/delivery.template.yaml` 生成文件,同时在
任务板补 `project.deliveryFile: docs/ack/delivery.yaml` 与顶层 任务板补 `project.deliveryFile: .pouch/ack/delivery.yaml` 与顶层
`deliveryRuns: []`。首次生成保持 `enabled: false`,按 `delivery.md` 展示并确认 `deliveryRuns: []`。首次生成保持 `enabled: false`,按 `delivery.md` 展示并确认
解析结果后才启用。不要重跑 `skiff init ack`,也不要改写已有任务或知识。 解析结果后才启用。不要重跑 `pouch init ack`,也不要改写已有任务或知识。
### 旧项目补充回归目录 ### 旧项目补充回归目录
`regression.yaml` 对旧项目是可选能力。用户明确要求回归或授权补齐时,从 `regression.yaml` 对旧项目是可选能力。用户明确要求回归或授权补齐时,从
`templates/regression.template.yaml` 生成 `docs/ack/regression.yaml`,并只补 `templates/regression.template.yaml` 生成 `.pouch/ack/regression.yaml`,并只补
`project.regressionFile: docs/ack/regression.yaml` 与顶层 `regressionRuns: []`。 `project.regressionFile: .pouch/ack/regression.yaml` 与顶层 `regressionRuns: []`。
保持 `cases: []`,不要从聊天虚构用例。 保持 `cases: []`,不要从聊天虚构用例。
## 完善项目覆盖层 ## 完善项目覆盖层
编辑 `docs/ack/project.md`,填入: 编辑 `.pouch/ack/project.md`,填入:
- 项目名、技术栈、运行命令和 Base URL。 - 项目名、技术栈、运行命令和 Base URL。
- Coordinator、Developer、Test 的实际模型档位。 - Coordinator、Developer、Test 的实际模型档位。
@@ -85,7 +85,7 @@ docs/ack/
## 完善任务板 ## 完善任务板
编辑 `docs/ack/tasks.yaml`: 编辑 `.pouch/ack/tasks.yaml`:
- `ackVersion` 使用 ACK Skill 的合法 SemVer `VERSION`;从 `0.10.0` 起 - `ackVersion` 使用 ACK Skill 的合法 SemVer `VERSION`;从 `0.10.0` 起
`project.orchestration` 与顶层 `workerReceipts` 必须同时存在。 `project.orchestration` 与顶层 `workerReceipts` 必须同时存在。
@@ -93,12 +93,12 @@ docs/ack/
自动补交付配置。 自动补交付配置。
- `updatedAt` 使用当前带时区时间。 - `updatedAt` 使用当前带时区时间。
- `project.name` 使用真实值;`overlayFile` 和 `knowledgeFile` 使用项目内相对路径。 - `project.name` 使用真实值;`overlayFile` 和 `knowledgeFile` 使用项目内相对路径。
ACK 从命令行 `--project-root` 下固定的 `docs/ack/` 布局解析项目状态,不把 ACK 从命令行 `--project-root` 下固定的 `.pouch/ack/` 布局解析项目状态,不把
`repoPath` 或 `devWorktree` 绝对路径写入任务板。旧任务板中的这两个字段仅兼容读取, `repoPath` 或 `devWorktree` 绝对路径写入任务板。旧任务板中的这两个字段仅兼容读取,
不再参与路径绑定。 不再参与路径绑定。
- 新项目的 `project.deliveryFile` 固定为 `docs/ack/delivery.yaml`,并保留顶层 - 新项目的 `project.deliveryFile` 固定为 `.pouch/ack/delivery.yaml`,并保留顶层
`deliveryRuns: []`。旧项目只有在采用交付能力时才补这两个字段。 `deliveryRuns: []`。旧项目只有在采用交付能力时才补这两个字段。
- 新项目的 `project.regressionFile` 固定为 `docs/ack/regression.yaml`,并保留顶层 - 新项目的 `project.regressionFile` 固定为 `.pouch/ack/regression.yaml`,并保留顶层
`regressionRuns: []`。旧项目只有在采用回归能力时才补这两个字段。 `regressionRuns: []`。旧项目只有在采用回归能力时才补这两个字段。
- `allowedWorktrees` 已废弃(v0.19 起),新任务板不生成该字段;worker 默认在 - `allowedWorktrees` 已废弃(v0.19 起),新任务板不生成该字段;worker 默认在
`--project-root` 工作。模型 allowlist、profiles 和 defaults 使用项目实际允许值。 `--project-root` 工作。模型 allowlist、profiles 和 defaults 使用项目实际允许值。
@@ -111,7 +111,7 @@ docs/ack/
## 初始化项目知识 ## 初始化项目知识
新项目的 `docs/ack/knowledge.yaml` 保持 `verificationRegistry: {}` 与 新项目的 `.pouch/ack/knowledge.yaml` 保持 `verificationRegistry: {}` 与
`entries: []`。不要从聊天、README、issue 或单次失败中猜测并激活知识。 `entries: []`。不要从聊天、README、issue 或单次失败中猜测并激活知识。
项目运行 ACK 后,Developer 和 Test 可以通过回报提名 `knowledgeCandidates`; 项目运行 ACK 后,Developer 和 Test 可以通过回报提名 `knowledgeCandidates`;
@@ -127,17 +127,18 @@ candidate 留在任务证据中,不会被派发。只有 Test 独立验证且
## 初始化项目交付 ## 初始化项目交付
新项目的 `docs/ack/delivery.yaml` 保持 `enabled: false`、空能力表、空 profile,以及 新项目的 `.pouch/ack/delivery.yaml` 保持 `enabled: false`、空能力表、空 profile,以及
`intents.testEnvironment: null` 与 `intents.release: null`。 `intents.testEnvironment: null` 与 `intents.release: null`。
不要根据 README 或 CI 自动推断并启用发布/部署。用户说明测试环境后,Coordinator 不要根据 README 或 CI 自动推断并启用发布/部署。用户说明测试环境后,Coordinator
按 deployer skill 准备 `.skiff/deployer/<env>`,并把 把 `intents.testEnvironment` 写成 `{via: deployer, env: <env>}`,若
`intents.testEnvironment` 写成 `{via: deployer, env: <env>}`;发版仍指向 profile。 `.pouch/deployer/<env>` 尚未就绪则加载 deployer skill 的「初始化」;发版仍指向
profile。ACK 初始化不自动跑 deployer 初始化。
配置中不保存 shell、环境变量值或凭据正文;稳定发布和生产部署必须有显式 配置中不保存 shell、环境变量值或凭据正文;稳定发布和生产部署必须有显式
approval 步骤。 approval 步骤。
## 初始化回归目录 ## 初始化回归目录
新项目的 `docs/ack/regression.yaml` 保持 `cases: []`。不要从 README 或聊天猜测 新项目的 `.pouch/ack/regression.yaml` 保持 `cases: []`。不要从 README 或聊天猜测
用例。任务 `verified` 后按 `regression.md` 收获。 用例。任务 `verified` 后按 `regression.md` 收获。
## 校验 ## 校验
@@ -145,12 +146,12 @@ approval 步骤。
Agent 从当前 `SKILL.md` 解析 ACK Skill 目录后运行: Agent 从当前 `SKILL.md` 解析 ACK Skill 目录后运行:
```bash ```bash
python3 <ack-skill-dir>/scripts/validate_tasks.py docs/ack/tasks.yaml python3 <ack-skill-dir>/scripts/validate_tasks.py .pouch/ack/tasks.yaml
python3 <ack-skill-dir>/scripts/validate_knowledge.py docs/ack/knowledge.yaml --tasks docs/ack/tasks.yaml python3 <ack-skill-dir>/scripts/validate_knowledge.py .pouch/ack/knowledge.yaml --tasks .pouch/ack/tasks.yaml
python3 <ack-skill-dir>/scripts/validate_delivery.py docs/ack/delivery.yaml \ python3 <ack-skill-dir>/scripts/validate_delivery.py .pouch/ack/delivery.yaml \
--tasks docs/ack/tasks.yaml --project-root <project-root> --tasks .pouch/ack/tasks.yaml --project-root <project-root>
python3 <ack-skill-dir>/scripts/validate_regression.py docs/ack/regression.yaml \ python3 <ack-skill-dir>/scripts/validate_regression.py .pouch/ack/regression.yaml \
--tasks docs/ack/tasks.yaml --tasks .pouch/ack/tasks.yaml
``` ```
同时确认: 同时确认:
@@ -158,8 +159,8 @@ python3 <ack-skill-dir>/scripts/validate_regression.py docs/ack/regression.yaml
- `project.md`、`tasks.yaml`、`knowledge.yaml`、`delivery.yaml` 和 - `project.md`、`tasks.yaml`、`knowledge.yaml`、`delivery.yaml` 和
`regression.yaml` 没有未替换的 `<...>` 占位符。 `regression.yaml` 没有未替换的 `<...>` 占位符。
- `project.overlayFile` 指向真实文件。 - `project.overlayFile` 指向真实文件。
- `project.knowledgeFile` 指向 `docs/ack/knowledge.yaml`。 - `project.knowledgeFile` 指向 `.pouch/ack/knowledge.yaml`。
- 新项目的 `project.deliveryFile` 指向 `docs/ack/delivery.yaml`;交付默认关闭。 - 新项目的 `project.deliveryFile` 指向 `.pouch/ack/delivery.yaml`;交付默认关闭。
- Developer 与 Test 的验证命令可执行。 - Developer 与 Test 的验证命令可执行。
- `project.orchestration` 的 profile/allowlist/defaults 通过校验,自动模式只允许 - `project.orchestration` 的 profile/allowlist/defaults 通过校验,自动模式只允许
`read-only` 或 `workspace-write`;旧任务板未迁移时保持手动模式。 `read-only` 或 `workspace-write`;旧任务板未迁移时保持手动模式。
@@ -171,12 +172,8 @@ python3 <ack-skill-dir>/scripts/validate_regression.py docs/ack/regression.yaml
## 初始化报告 ## 初始化报告
完成后报告: 按 `SKILL.md`「初始化」最后一步的格式报告(`## ack 初始化:完成 | 部分完成 | 阻塞`),
列出已具备项、待配置项(路径 + 字段 + 示例)、工具链和下一步。
- 创建或确认的项目文件(含回归目录)。 只有结构校验通过且必填项目事实完整时才称「完成」;否则称「部分完成」或「阻塞」。
- 检测到的技术栈和验证命令。 除非用户明确要求,不提交、不推送。
- 任务板、项目知识和交付契约校验结果。
- 仍需用户补充的值。
只有结构校验通过且必填项目事实完整时才称“初始化完成”;否则称“部分完成”,并列出
具体阻塞项。除非用户明确要求,不提交、不推送。
+12 -12
View File
@@ -9,7 +9,7 @@
**你(发起编排的强模型会话)就是 Coordinator (PM) / 产品。** 你负责写文档、拆任务、 **你(发起编排的强模型会话)就是 Coordinator (PM) / 产品。** 你负责写文档、拆任务、
编排、终检,**不亲自写代码、不亲自跑测试**。开发和测试是另起的 worker agent; 编排、终检,**不亲自写代码、不亲自跑测试**。开发和测试是另起的 worker agent;
具体 CLI、模型、reasoning effort 和执行模式的机器事实源是 具体 CLI、模型、reasoning effort 和执行模式的机器事实源是
`docs/ack/tasks.yaml` 的 `project.orchestration`。`docs/ack/project.md` 只解释项目 `.pouch/ack/tasks.yaml` 的 `project.orchestration`。`.pouch/ack/project.md` 只解释项目
差异,不能提供另一套启动命令。 差异,不能提供另一套启动命令。
--- ---
@@ -20,9 +20,9 @@
我要做一个新需求:<一句话需求>。 我要做一个新需求:<一句话需求>。
你作为 ack 的 Coordinator(PM),按 ACK Skill 的 references 规范执行: 你作为 ack 的 Coordinator(PM),按 ACK Skill 的 references 规范执行:
1. 先读 docs/ack/project.md,并用 `scripts/select_tasks.py docs/ack/tasks.yaml` 1. 先读 .pouch/ack/project.md,并用 `scripts/select_tasks.py .pouch/ack/tasks.yaml`
读取有预算的 project、summary 和可工作任务;已知任务时传 `--task-id`,不要把 读取有预算的 project、summary 和可工作任务;已知任务时传 `--task-id`,不要把
完整 tasks.yaml 注入上下文。校验 docs/ack/knowledge.yaml 并用 完整 tasks.yaml 注入上下文。校验 .pouch/ack/knowledge.yaml 并用
`scripts/select_knowledge.py` 只读取当前任务相关的 active 条目,再读 `scripts/select_knowledge.py` 只读取当前任务相关的 active 条目,再读
references/roles-and-permissions.md、closed-loop.md、optimization-method.md。 references/roles-and-permissions.md、closed-loop.md、optimization-method.md。
如果 tasks.yaml 声明 project.deliveryFile,再读取 delivery.yaml 与 如果 tasks.yaml 声明 project.deliveryFile,再读取 delivery.yaml 与
@@ -30,7 +30,7 @@
2. 写产品文档到 docs/(PRD / 交互 / 验收),把需求拆成任务,每个任务的验收写成可观测信号(可见文本 / API 结果 / 交互结果)。 2. 写产品文档到 docs/(PRD / 交互 / 验收),把需求拆成任务,每个任务的验收写成可观测信号(可见文本 / API 结果 / 交互结果)。
3. 按任务 scope 从 knowledge.yaml 推荐 active 知识,确认后把固定 revision 的 3. 按任务 scope 从 knowledge.yaml 推荐 active 知识,确认后把固定 revision 的
knowledgeRefs 写入任务;不要派发 candidate 或全量知识库。 knowledgeRefs 写入任务;不要派发 candidate 或全量知识库。
4. 把任务写进 docs/ack/tasks.yaml(只有你写),校验 tasks.yaml 和 knowledge.yaml。 4. 把任务写进 .pouch/ack/tasks.yaml(只有你写),校验 tasks.yaml 和 knowledge.yaml。
5. 先把「产品文档 + 任务拆分 + 验收信号 + 适用知识引用」给我确认;若启用了交付, 5. 先把「产品文档 + 任务拆分 + 验收信号 + 适用知识引用」给我确认;若启用了交付,
同时列明本次 profile、目标、停止点与审批步骤。不要急着派发或交付。 同时列明本次 profile、目标、停止点与审批步骤。不要急着派发或交付。
6. 我确认后,按 ack 闭环循环:先用 `scripts/launch_worker.py` 校验结构化 6. 我确认后,按 ack 闭环循环:先用 `scripts/launch_worker.py` 校验结构化
@@ -42,7 +42,7 @@
每个任务最多三轮有效产品复验,三轮不过记 leftover 并升级我复盘;环境失败单独 每个任务最多三轮有效产品复验,三轮不过记 leftover 并升级我复盘;环境失败单独
记录、恢复并告诉我下一步,不占产品复验轮次。 记录、恢复并告诉我下一步,不占产品复验轮次。
7. 所选任务都 verified 后,按 regression.md 给出新增/更新/退役/无回归,确认后写入 7. 所选任务都 verified 后,按 regression.md 给出新增/更新/退役/无回归,确认后写入
docs/ack/regression.yaml。只有本次计划包含交付时才按 profile 顺序执行并写 .pouch/ack/regression.yaml。只有本次计划包含交付时才按 profile 顺序执行并写
deliveryRuns;启用 delivery 时不能省略 defaultProfile,默认停在 validation_ready deliveryRuns;启用 delivery 时不能省略 defaultProfile,默认停在 validation_ready
或 review_ready,stable/production 步骤再次向我确认。 或 review_ready,stable/production 步骤再次向我确认。
``` ```
@@ -52,15 +52,15 @@
## 第 1 步:Coordinator 产出(确认前) ## 第 1 步:Coordinator 产出(确认前)
1. 产品文档 → `docs/PRD-<feature>.md` 等(Coordinator R/W)。 1. 产品文档 → `docs/PRD-<feature>.md` 等(Coordinator R/W)。
2. 任务板 → `docs/ack/tasks.yaml`,每条任务带 `expected` + `verification`,验收写成可观测信号(见 `optimization-method.md` §1)。 2. 任务板 → `.pouch/ack/tasks.yaml`,每条任务带 `expected` + `verification`,验收写成可观测信号(见 `optimization-method.md` §1)。
3. 项目知识 → 从 `docs/ack/knowledge.yaml` 按 component、path、dependency、version 3. 项目知识 → 从 `.pouch/ack/knowledge.yaml` 按 component、path、dependency、version
和 tag 推荐 `active` 条目,Coordinator 确认后写入固定 revision 的显式 和 tag 推荐 `active` 条目,Coordinator 确认后写入固定 revision 的显式
`knowledgeRefs`。candidate 不参与选择。 `knowledgeRefs`。candidate 不参与选择。
4. 校验结构与引用: 4. 校验结构与引用:
```bash ```bash
python3 <ack-skill-dir>/scripts/validate_tasks.py docs/ack/tasks.yaml python3 <ack-skill-dir>/scripts/validate_tasks.py .pouch/ack/tasks.yaml
python3 <ack-skill-dir>/scripts/validate_knowledge.py docs/ack/knowledge.yaml --tasks docs/ack/tasks.yaml python3 <ack-skill-dir>/scripts/validate_knowledge.py .pouch/ack/knowledge.yaml --tasks .pouch/ack/tasks.yaml
``` ```
`project.orchestration` 是 worker profile 的机器 SSOT;未知字段、非 allowlist 模型、 `project.orchestration` 是 worker profile 的机器 SSOT;未知字段、非 allowlist 模型、
@@ -69,8 +69,8 @@ python3 <ack-skill-dir>/scripts/validate_knowledge.py docs/ack/knowledge.yaml --
读取任务上下文使用: 读取任务上下文使用:
```bash ```bash
python3 <ack-skill-dir>/scripts/select_tasks.py docs/ack/tasks.yaml python3 <ack-skill-dir>/scripts/select_tasks.py .pouch/ack/tasks.yaml
python3 <ack-skill-dir>/scripts/select_tasks.py docs/ack/tasks.yaml \ python3 <ack-skill-dir>/scripts/select_tasks.py .pouch/ack/tasks.yaml \
--task-id <ack-task-id> --task-id <ack-task-id>
``` ```
@@ -180,7 +180,7 @@ Coordinator 只内联本轮 `knowledgeRefs` 指向的少量知识,不要求 wo
release profile 执行。intent 为 null 时先做交付配置维护。 release profile 执行。intent 为 null 时先做交付配置维护。
所选任务 `verified` 后,按 `regression.md` 把本轮黑盒路径收获进 所选任务 `verified` 后,按 `regression.md` 把本轮黑盒路径收获进
`docs/ack/regression.yaml`(新增/更新/退役/无回归四选一,用户确认后写入)。 `.pouch/ack/regression.yaml`(新增/更新/退役/无回归四选一,用户确认后写入)。
用户说「回归」时先布测试环境,再派 Test 按目录执行。 用户说「回归」时先布测试环境,再派 Test 按目录执行。
所选任务都由 Coordinator 标记为 `verified` 后,若用户确认的计划包含交付,按 所选任务都由 Coordinator 标记为 `verified` 后,若用户确认的计划包含交付,按
+3 -3
View File
@@ -66,7 +66,7 @@ profile 升级时不得复用旧 worker,Test 也不得使用 Developer 的强
### 机器事实源 ### 机器事实源
worker 路由的机器可读事实只保存在 `docs/ack/tasks.yaml` 的 worker 路由的机器可读事实只保存在 `.pouch/ack/tasks.yaml` 的
`project.orchestration`。`project.md` 可以解释项目为何选某个档位,但不能另写一份 `project.orchestration`。`project.md` 可以解释项目为何选某个档位,但不能另写一份
完整启动命令或覆盖机器配置。字段结构以 `templates/tasks.schema.json` 为准。 完整启动命令或覆盖机器配置。字段结构以 `templates/tasks.schema.json` 为准。
@@ -135,12 +135,12 @@ python3 <ack-skill-dir>/scripts/launch_worker.py launch \
--expected-launch-fingerprint <plan 中的 sha256:...> --expected-launch-fingerprint <plan 中的 sha256:...>
``` ```
`--project-root` 始终指向保存权威 `docs/ack/tasks.yaml` 的项目根;`--worktree` 是本次 `--project-root` 始终指向保存权威 `.pouch/ack/tasks.yaml` 的项目根;`--worktree` 是本次
worker 实际工作的绝对路径,两者可以不同。后者仍必须与项目根属于同一 Git worker 实际工作的绝对路径,两者可以不同。后者仍必须与项目根属于同一 Git
仓库(v0.19 起由 launcher 按 `git worktree list` 注册表 + 同 common-dir 校验, 仓库(v0.19 起由 launcher 按 `git worktree list` 注册表 + 同 common-dir 校验,
不再依赖 `allowedWorktrees` 白名单)。 不再依赖 `allowedWorktrees` 白名单)。
项目状态文件固定从 `--project-root/docs/ack/` 解析;任务板不需要保存 `repoPath` 或 项目状态文件固定从 `--project-root/.pouch/ack/` 解析;任务板不需要保存 `repoPath` 或
`devWorktree`。旧任务板中的这两个字段仅作兼容信息,launcher 不使用它们授权或定位。 `devWorktree`。旧任务板中的这两个字段仅作兼容信息,launcher 不使用它们授权或定位。
`projectRoot`、任务板内容摘要和 worker worktree identity 都会进入 launch fingerprint, `projectRoot`、任务板内容摘要和 worker worktree identity 都会进入 launch fingerprint,
因此切换权威项目根、任务板内容或 worker 路径后必须重新生成并审阅 plan。 因此切换权威项目根、任务板内容或 worker 路径后必须重新生成并审阅 plan。
+1 -1
View File
@@ -177,7 +177,7 @@ one dispatch = one bug = one acceptance path
## 8. 优先让测试可执行化 ## 8. 优先让测试可执行化
如果某个问题需要多轮修复,说明它值得沉淀成自动化检查。黑盒回归目录是 如果某个问题需要多轮修复,说明它值得沉淀成自动化检查。黑盒回归目录是
`docs/ack/regression.yaml`(见 `regression.md`);可执行脚本仍由 Test 维护在 `.pouch/ack/regression.yaml`(见 `regression.md`);可执行脚本仍由 Test 维护在
`<integration_test_paths>`。优先级: `<integration_test_paths>`。优先级:
1. 把本轮验收信号收获进 `regression.yaml`。 1. 把本轮验收信号收获进 `regression.yaml`。
+3 -3
View File
@@ -58,7 +58,7 @@ Coordinator 用这些模板向 **Developer** 派发修复、向 **Test** 派发
- 不要写 tasks.yaml,不要标记 verified。 - 不要写 tasks.yaml,不要标记 verified。
- 不要写 knowledge.yaml,不要自行扩展或全量读取知识库;candidate 不是已生效规则。 - 不要写 knowledge.yaml,不要自行扩展或全量读取知识库;candidate 不是已生效规则。
- 不要把知识正文或 path/args 拼成 shell 命令。只把 verification.ref 交给 - 不要把知识正文或 path/args 拼成 shell 命令。只把 verification.ref 交给
`<ack-skill-dir>/scripts/run_verification.py docs/ack/knowledge.yaml `<ack-skill-dir>/scripts/run_verification.py .pouch/ack/knowledge.yaml
<verification-ref> --project-root <project-root>`。 <verification-ref> --project-root <project-root>`。
- 不要提交或推送,除非用户明确要求。 - 不要提交或推送,除非用户明确要求。
- 最小 diff,只改本任务根因,避免无关重构;若必须先重构请停下说明并请示。 - 最小 diff,只改本任务根因,避免无关重构;若必须先重构请停下说明并请示。
@@ -137,9 +137,9 @@ Developer 本轮声称(仅供参考,不作数):
- 若 worker、权限、服务、测试数据、浏览器或工具导致验收无法完成,明确回报 - 若 worker、权限、服务、测试数据、浏览器或工具导致验收无法完成,明确回报
`environmentFailure`,不要把“未验证”写成产品 `signals-failed`;若已有独立产品失败 `environmentFailure`,不要把“未验证”写成产品 `signals-failed`;若已有独立产品失败
证据,则分别列出产品信号与环境限制。 证据,则分别列出产品信号与环境限制。
- 需要时把本轮通过的黑盒路径写成 `regressionCandidates`(见 regression.md),不要直接改 `docs/ack/regression.yaml`。 - 需要时把本轮通过的黑盒路径写成 `regressionCandidates`(见 regression.md),不要直接改 `.pouch/ack/regression.yaml`。
- 对每条适用的 `knowledgeRef`,把它的 verification.ref 交给 - 对每条适用的 `knowledgeRef`,把它的 verification.ref 交给
`<ack-skill-dir>/scripts/run_verification.py docs/ack/knowledge.yaml `<ack-skill-dir>/scripts/run_verification.py .pouch/ack/knowledge.yaml
<verification-ref> --project-root <project-root>`,并回报 `knowledgeChecks`。 <verification-ref> --project-root <project-root>`,并回报 `knowledgeChecks`。
对 candidate 使用独立观测验证,不能复述 Developer 的结论作为证据。 对 candidate 使用独立观测验证,不能复述 Developer 的结论作为证据。
+6 -6
View File
@@ -8,15 +8,15 @@
## 1. 目录 ## 1. 目录
项目状态是 `docs/ack/regression.yaml`。任务板用 项目状态是 `.pouch/ack/regression.yaml`。任务板用
`project.regressionFile: docs/ack/regression.yaml` 声明,运行证据写在 `project.regressionFile: .pouch/ack/regression.yaml` 声明,运行证据写在
`tasks.yaml.regressionRuns`。新项目初始化会生成空目录;旧项目没有该文件时, `tasks.yaml.regressionRuns`。新项目初始化会生成空目录;旧项目没有该文件时,
「运行回归」先停下来,用户授权后再从模板补齐。 「运行回归」先停下来,用户授权后再从模板补齐。
只有 Coordinator 写 `regression.yaml`。Test 在复测报告里提名 只有 Coordinator 写 `regression.yaml`。Test 在复测报告里提名
`regressionCandidates`;用户确认后 Coordinator 落盘,并把 case id 写入任务的 `regressionCandidates`;用户确认后 Coordinator 落盘,并把 case id 写入任务的
`regressionRefs`。不要把用例散落到第二份文档,也不要让 Test 直接改 `regressionRefs`。不要把用例散落到第二份文档,也不要让 Test 直接改
`docs/ack/`。 `.pouch/ack/`。
`tests/browser/**` 仍可由 Test 维护可执行脚本。用例可用可选 `automationRef` `tests/browser/**` 仍可由 Test 维护可执行脚本。用例可用可选 `automationRef`
指向那些脚本;没有脚本时 Test worker 按目录里的步骤和验收信号执行。 指向那些脚本;没有脚本时 Test worker 按目录里的步骤和验收信号执行。
@@ -30,10 +30,10 @@ Playwright。
读取时用 `scripts/select_regression.py`,不要把完整目录注入上下文: 读取时用 `scripts/select_regression.py`,不要把完整目录注入上下文:
```bash ```bash
python3 <ack-skill-dir>/scripts/select_regression.py docs/ack/regression.yaml python3 <ack-skill-dir>/scripts/select_regression.py .pouch/ack/regression.yaml
python3 <ack-skill-dir>/scripts/select_regression.py docs/ack/regression.yaml \ python3 <ack-skill-dir>/scripts/select_regression.py .pouch/ack/regression.yaml \
--suite full --suite full
python3 <ack-skill-dir>/scripts/select_regression.py docs/ack/regression.yaml \ python3 <ack-skill-dir>/scripts/select_regression.py .pouch/ack/regression.yaml \
--case-id REG-login-001 --case-id REG-login-001
``` ```
@@ -27,7 +27,7 @@ ACK 默认三个独立 Agent:**Coordinator 只编排、Test 只验证、Develo
上面的表定义了**边界**(谁能碰什么),这一节定义**能力**(每个角色到底该怎么做好自己的事)。每个角色用同一骨架描述:`Outcome`(产出什么)/ `Must Do`(必须做)/ `Must Not`(不能做)/ `Evidence`(拿什么证明)/ `Output`(交付格式)。派发 prompt 会引用这里,见 `prompt-templates.md`。 上面的表定义了**边界**(谁能碰什么),这一节定义**能力**(每个角色到底该怎么做好自己的事)。每个角色用同一骨架描述:`Outcome`(产出什么)/ `Must Do`(必须做)/ `Must Not`(不能做)/ `Evidence`(拿什么证明)/ `Output`(交付格式)。派发 prompt 会引用这里,见 `prompt-templates.md`。
这些是**通用工程习惯**,不含项目命令与路径;项目差异写在覆盖层文件(默认 `docs/ack/project.md`)。装了外部 skill 的环境可按每个角色末尾的「可选 skills」加速,未装则照本清单执行,不阻塞。 这些是**通用工程习惯**,不含项目命令与路径;项目差异写在覆盖层文件(默认 `.pouch/ack/project.md`)。装了外部 skill 的环境可按每个角色末尾的「可选 skills」加速,未装则照本清单执行,不阻塞。
### Coordinator (PM):拆解与终检 ### Coordinator (PM):拆解与终检
@@ -97,7 +97,7 @@ ACK 默认三个独立 Agent:**Coordinator 只编排、Test 只验证、Develo
## 路径权限模板 ## 路径权限模板
目标项目在自己的**覆盖层文件**中填入实际路径(模板见 `templates/project.template.md`;覆盖层默认 `docs/ack/project.md`,路径记在 `tasks.yaml` 的 `project.overlayFile`)。 目标项目在自己的**覆盖层文件**中填入实际路径(模板见 `templates/project.template.md`;覆盖层默认 `.pouch/ack/project.md`,路径记在 `tasks.yaml` 的 `project.overlayFile`)。
| 路径 | Coordinator | Test | Developer | 说明 | | 路径 | Coordinator | Test | Developer | 说明 |
|------|:-----------:|:----:|:---------:|------| |------|:-----------:|:----:|:---------:|------|
+1 -1
View File
@@ -51,7 +51,7 @@ from worker_profiles import ( # noqa: E402
PROTOCOL_VERSION = LAUNCH_PROTOCOL_VERSION PROTOCOL_VERSION = LAUNCH_PROTOCOL_VERSION
RECEIPT_VERSION = 1 RECEIPT_VERSION = 1
ENVIRONMENT_POLICY = "per-cli-allowlist-v1" ENVIRONMENT_POLICY = "per-cli-allowlist-v1"
TASKS_RELATIVE_PATH = Path("docs/ack/tasks.yaml") TASKS_RELATIVE_PATH = Path(".pouch/ack/tasks.yaml")
MAX_CONTROL_OUTPUT = 1024 * 1024 MAX_CONTROL_OUTPUT = 1024 * 1024
MAX_RECORD_SIZE = 256 * 1024 MAX_RECORD_SIZE = 256 * 1024
LAUNCH_TTL_SECONDS = 120 LAUNCH_TTL_SECONDS = 120
+3 -3
View File
@@ -57,7 +57,7 @@ def _validate_knowledge_location(
knowledge_path: Path, knowledge_path: Path,
project_root: Path, project_root: Path,
) -> str | None: ) -> str | None:
expected = project_root / "docs" / "ack" / "knowledge.yaml" expected = project_root / ".pouch" / "ack" / "knowledge.yaml"
lexical = Path(os.path.abspath(knowledge_path.expanduser())) lexical = Path(os.path.abspath(knowledge_path.expanduser()))
if lexical != expected: if lexical != expected:
return ( return (
@@ -171,7 +171,7 @@ def load_authoritative_knowledge(
) -> tuple[dict[str, Any] | None, str | None]: ) -> tuple[dict[str, Any] | None, str | None]:
source_fd, open_error = _open_regular_beneath( source_fd, open_error = _open_regular_beneath(
project_root, project_root,
"docs/ack/knowledge.yaml", ".pouch/ack/knowledge.yaml",
require_executable=False, require_executable=False,
) )
if open_error is not None or source_fd is None: if open_error is not None or source_fd is None:
@@ -329,7 +329,7 @@ def main(argv: list[str] | None = None) -> int:
parser.add_argument("verification_ref", help="verificationRegistry 中的检查 ID") parser.add_argument("verification_ref", help="verificationRegistry 中的检查 ID")
parser.add_argument( parser.add_argument(
"--project-root", "--project-root",
help="项目根目录;默认从 knowledge.yaml 的 docs/ack 布局或 Git 推断", help="项目根目录;默认从 knowledge.yaml 的 .pouch/ack 布局或 Git 推断",
) )
args = parser.parse_args(argv) args = parser.parse_args(argv)
+4 -4
View File
@@ -4,9 +4,9 @@
默认返回 smoke 套件。本脚本只输出数据,不执行 steps 或 automationRef。 默认返回 smoke 套件。本脚本只输出数据,不执行 steps 或 automationRef。
用法: 用法:
python3 select_regression.py docs/ack/regression.yaml python3 select_regression.py .pouch/ack/regression.yaml
python3 select_regression.py docs/ack/regression.yaml --suite full python3 select_regression.py .pouch/ack/regression.yaml --suite full
python3 select_regression.py docs/ack/regression.yaml --case-id REG-login-001 python3 select_regression.py .pouch/ack/regression.yaml --case-id REG-login-001
""" """
from __future__ import annotations from __future__ import annotations
@@ -65,7 +65,7 @@ def select_cases(
def main(argv: list[str] | None = None) -> int: def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description="选择 ACK 回归用例") parser = argparse.ArgumentParser(description="选择 ACK 回归用例")
parser.add_argument( parser.add_argument(
"regression", nargs="?", default="docs/ack/regression.yaml" "regression", nargs="?", default=".pouch/ack/regression.yaml"
) )
parser.add_argument( parser.add_argument(
"--suite", "--suite",
+1 -1
View File
@@ -197,7 +197,7 @@ def _parser() -> argparse.ArgumentParser:
parser.add_argument( parser.add_argument(
"tasks", "tasks",
nargs="?", nargs="?",
default="docs/ack/tasks.yaml", default=".pouch/ack/tasks.yaml",
help="任务板路径", help="任务板路径",
) )
parser.add_argument("--task-id", action="append", default=[]) parser.add_argument("--task-id", action="append", default=[])
+11 -9
View File
@@ -5,9 +5,9 @@
检查引用、步骤顺序、默认 profile 安全边界、敏感信息和仓库内入口路径。 检查引用、步骤顺序、默认 profile 安全边界、敏感信息和仓库内入口路径。
用法: 用法:
python3 validate_delivery.py docs/ack/delivery.yaml python3 validate_delivery.py .pouch/ack/delivery.yaml
python3 validate_delivery.py docs/ack/delivery.yaml \ python3 validate_delivery.py .pouch/ack/delivery.yaml \
--tasks docs/ack/tasks.yaml --project-root <project-root> --tasks .pouch/ack/tasks.yaml --project-root <project-root>
退出码: 0 通过 / 1 校验失败 / 2 环境或用法错误。 退出码: 0 通过 / 1 校验失败 / 2 环境或用法错误。
""" """
@@ -707,11 +707,13 @@ def _validate_test_environment_intent(
return return
if project_root is None: if project_root is None:
return return
env_dir = project_root / ".skiff" / "deployer" / env env_dir = project_root / ".pouch" / "deployer" / env
if not env_dir.is_dir():
env_dir = project_root / ".skiff" / "deployer" / env
if not env_dir.is_dir(): if not env_dir.is_dir():
errors.append( errors.append(
"intents.testEnvironment.env: 找不到 " "intents.testEnvironment.env: 找不到 "
f".skiff/deployer/{env};先按 deployer skill 配置项目测试环境" f".pouch/deployer/{env};先按 deployer skill 配置项目测试环境"
) )
@@ -816,8 +818,8 @@ def validate_tasks_link(delivery: dict[str, Any], tasks: dict[str, Any]) -> list
project = tasks.get("project") project = tasks.get("project")
if not isinstance(project, dict): if not isinstance(project, dict):
return ["tasks.project 必须是对象"] return ["tasks.project 必须是对象"]
if project.get("deliveryFile") != "docs/ack/delivery.yaml": if project.get("deliveryFile") != ".pouch/ack/delivery.yaml":
errors.append("tasks.project.deliveryFile 必须固定为 docs/ack/delivery.yaml") errors.append("tasks.project.deliveryFile 必须固定为 .pouch/ack/delivery.yaml")
delivery_project = delivery.get("project") delivery_project = delivery.get("project")
if ( if (
isinstance(delivery_project, dict) isinstance(delivery_project, dict)
@@ -845,8 +847,8 @@ def validate_with_schema(data: dict[str, Any], schema_path: Path) -> list[str]:
def main(argv: list[str] | None = None) -> int: def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description="校验 ACK 项目交付契约") parser = argparse.ArgumentParser(description="校验 ACK 项目交付契约")
parser.add_argument("delivery", nargs="?", default="docs/ack/delivery.yaml") parser.add_argument("delivery", nargs="?", default=".pouch/ack/delivery.yaml")
parser.add_argument("--tasks", help="关联的 docs/ack/tasks.yaml") parser.add_argument("--tasks", help="关联的 .pouch/ack/tasks.yaml")
parser.add_argument("--project-root", help="项目根目录;提供后检查入口路径") parser.add_argument("--project-root", help="项目根目录;提供后检查入口路径")
parser.add_argument("--schema", help="delivery.schema.json 路径(默认自动探测)") parser.add_argument("--schema", help="delivery.schema.json 路径(默认自动探测)")
args = parser.parse_args(argv) args = parser.parse_args(argv)
+7 -7
View File
@@ -189,10 +189,10 @@ def _timestamp(value: Any) -> datetime | None:
def infer_project_root(document_path: Path) -> Path | None: def infer_project_root(document_path: Path) -> Path | None:
"""从标准 docs/ack 布局或 Git marker 推断项目根,不解析文档 symlink。""" """从标准 .pouch/ack 布局或 Git marker 推断项目根,不解析文档 symlink。"""
lexical = document_path.expanduser().absolute() lexical = document_path.expanduser().absolute()
parent = lexical.parent parent = lexical.parent
if parent.name == "ack" and parent.parent.name == "docs": if parent.name == "ack" and parent.parent.name in {".pouch", "docs"}:
return parent.parent.parent.resolve() return parent.parent.parent.resolve()
for candidate in (parent, *parent.parents): for candidate in (parent, *parent.parents):
if (candidate / ".git").exists(): if (candidate / ".git").exists():
@@ -245,7 +245,7 @@ def _tasks_project_root(
return inferred return inferred
# Legacy task boards may still declare repoPath. It is only a fallback for # Legacy task boards may still declare repoPath. It is only a fallback for
# non-standard layouts; docs/ack location is authoritative when available. # non-standard layouts; .pouch/ack location is authoritative when available.
project = tasks_data.get("project") project = tasks_data.get("project")
repo_path = project.get("repoPath") if isinstance(project, dict) else None repo_path = project.get("repoPath") if isinstance(project, dict) else None
if _nonempty(repo_path): if _nonempty(repo_path):
@@ -779,10 +779,10 @@ def _validate_knowledge_file_binding(
knowledge_file = project.get("knowledgeFile") knowledge_file = project.get("knowledgeFile")
if not _nonempty(knowledge_file): if not _nonempty(knowledge_file):
return ["[tasks] project.knowledgeFile 必填"] return ["[tasks] project.knowledgeFile 必填"]
if knowledge_file != "docs/ack/knowledge.yaml": if knowledge_file != ".pouch/ack/knowledge.yaml":
errors.append( errors.append(
"[tasks] project.knowledgeFile 必须固定为 " "[tasks] project.knowledgeFile 必须固定为 "
"'docs/ack/knowledge.yaml'" "'.pouch/ack/knowledge.yaml'"
) )
relative = Path(knowledge_file) relative = Path(knowledge_file)
segments = knowledge_file.replace("\\", "/").split("/") segments = knowledge_file.replace("\\", "/").split("/")
@@ -812,7 +812,7 @@ def _validate_knowledge_file_binding(
binding_root = project_root or declared_root binding_root = project_root or declared_root
if binding_root is None or not binding_root.is_dir(): if binding_root is None or not binding_root.is_dir():
errors.append( errors.append(
"[tasks] 无法从 docs/ack 布局确定现有项目根目录;" "[tasks] 无法从 .pouch/ack 布局确定现有项目根目录;"
"请传入 --project-root" "请传入 --project-root"
) )
return errors return errors
@@ -1071,7 +1071,7 @@ def main(argv: list[str] | None = None) -> int:
parser.add_argument("--tasks", help="可选 tasks.yaml,用于跨文件引用校验") parser.add_argument("--tasks", help="可选 tasks.yaml,用于跨文件引用校验")
parser.add_argument( parser.add_argument(
"--project-root", "--project-root",
help="可选项目根目录;默认从 tasks.yaml 的 docs/ack 布局推断", help="可选项目根目录;默认从 tasks.yaml 的 .pouch/ack 布局推断",
) )
args = parser.parse_args(argv) args = parser.parse_args(argv)
+7 -7
View File
@@ -5,9 +5,9 @@
始终检查用例 ID、验收信号和跨文件引用。本脚本只解析数据,不执行 steps。 始终检查用例 ID、验收信号和跨文件引用。本脚本只解析数据,不执行 steps。
用法: 用法:
python3 validate_regression.py docs/ack/regression.yaml python3 validate_regression.py .pouch/ack/regression.yaml
python3 validate_regression.py docs/ack/regression.yaml \ python3 validate_regression.py .pouch/ack/regression.yaml \
--tasks docs/ack/tasks.yaml --tasks .pouch/ack/tasks.yaml
退出码: 0 通过 / 1 校验失败 / 2 环境或用法错误。 退出码: 0 通过 / 1 校验失败 / 2 环境或用法错误。
""" """
@@ -241,9 +241,9 @@ def validate_tasks_link(
if not isinstance(project, dict): if not isinstance(project, dict):
return ["[tasks] project 必须是对象"] return ["[tasks] project 必须是对象"]
regression_file = project.get("regressionFile") regression_file = project.get("regressionFile")
if regression_file != "docs/ack/regression.yaml": if regression_file != ".pouch/ack/regression.yaml":
errors.append( errors.append(
"[tasks] project.regressionFile 必须固定为 docs/ack/regression.yaml" "[tasks] project.regressionFile 必须固定为 .pouch/ack/regression.yaml"
) )
if not isinstance(tasks.get("regressionRuns"), list): if not isinstance(tasks.get("regressionRuns"), list):
errors.append("引用 regressionFile 的任务板必须包含 regressionRuns 列表") errors.append("引用 regressionFile 的任务板必须包含 regressionRuns 列表")
@@ -330,9 +330,9 @@ def validate_all(
def main(argv: list[str] | None = None) -> int: def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description="校验 ACK 项目回归目录") parser = argparse.ArgumentParser(description="校验 ACK 项目回归目录")
parser.add_argument( parser.add_argument(
"regression", nargs="?", default="docs/ack/regression.yaml" "regression", nargs="?", default=".pouch/ack/regression.yaml"
) )
parser.add_argument("--tasks", help="关联的 docs/ack/tasks.yaml") parser.add_argument("--tasks", help="关联的 .pouch/ack/tasks.yaml")
parser.add_argument("--schema", help="regression.schema.json 路径(默认自动探测)") parser.add_argument("--schema", help="regression.schema.json 路径(默认自动探测)")
args = parser.parse_args(argv) args = parser.parse_args(argv)
+6 -6
View File
@@ -1009,17 +1009,17 @@ def validate_builtin(data: dict) -> list[str]:
) )
if ( if (
"knowledgeFile" in project "knowledgeFile" in project
and project.get("knowledgeFile") != "docs/ack/knowledge.yaml" and project.get("knowledgeFile") != ".pouch/ack/knowledge.yaml"
): ):
errors.append( errors.append(
"project.knowledgeFile 必须固定为 docs/ack/knowledge.yaml" "project.knowledgeFile 必须固定为 .pouch/ack/knowledge.yaml"
) )
if ( if (
"deliveryFile" in project "deliveryFile" in project
and project.get("deliveryFile") != "docs/ack/delivery.yaml" and project.get("deliveryFile") != ".pouch/ack/delivery.yaml"
): ):
errors.append( errors.append(
"project.deliveryFile 必须固定为 docs/ack/delivery.yaml" "project.deliveryFile 必须固定为 .pouch/ack/delivery.yaml"
) )
if "deliveryFile" in project and not isinstance(data.get("deliveryRuns"), list): if "deliveryFile" in project and not isinstance(data.get("deliveryRuns"), list):
errors.append("引用 deliveryFile 的任务板必须包含 deliveryRuns 列表") errors.append("引用 deliveryFile 的任务板必须包含 deliveryRuns 列表")
@@ -1027,10 +1027,10 @@ def validate_builtin(data: dict) -> list[str]:
errors.append("deliveryRuns 存在时 project.deliveryFile 必须存在") errors.append("deliveryRuns 存在时 project.deliveryFile 必须存在")
if ( if (
"regressionFile" in project "regressionFile" in project
and project.get("regressionFile") != "docs/ack/regression.yaml" and project.get("regressionFile") != ".pouch/ack/regression.yaml"
): ):
errors.append( errors.append(
"project.regressionFile 必须固定为 docs/ack/regression.yaml" "project.regressionFile 必须固定为 .pouch/ack/regression.yaml"
) )
if "regressionFile" in project and not isinstance( if "regressionFile" in project and not isinstance(
data.get("regressionRuns"), list data.get("regressionRuns"), list
@@ -13,7 +13,7 @@ import sys
MIGRATION_MESSAGE = ( MIGRATION_MESSAGE = (
"ACK v0.10 已停用自由 worker command 校验器;请在 " "ACK v0.10 已停用自由 worker command 校验器;请在 "
"docs/ack/tasks.yaml 的 project.orchestration 中声明 profile,并仅调用 " ".pouch/ack/tasks.yaml 的 project.orchestration 中声明 profile,并仅调用 "
"scripts/launch_worker.py profile-hash|plan|launch。" "scripts/launch_worker.py profile-hash|plan|launch。"
) )
+2 -2
View File
@@ -1,8 +1,8 @@
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://git.yumee.top/laily/skills/skills/ack/templates/delivery.schema.json", "$id": "https://git.yumee.top/laily/pouch/skills/ack/templates/delivery.schema.json",
"title": "ACK project delivery contract", "title": "ACK project delivery contract",
"description": "docs/ack/delivery.yaml 的权威结构;语义规则由 scripts/validate_delivery.py 补充。", "description": ".pouch/ack/delivery.yaml 的权威结构;语义规则由 scripts/validate_delivery.py 补充。",
"type": "object", "type": "object",
"required": [ "required": [
"version", "version",
+1 -1
View File
@@ -1,4 +1,4 @@
# 复制为 docs/ack/delivery.yaml。默认关闭;由用户明确配置后再启用。 # 复制为 .pouch/ack/delivery.yaml。默认关闭;由用户明确配置后再启用。
version: 1 version: 1
updatedAt: "<YYYY-MM-DDTHH:mm:ss+TZ>" updatedAt: "<YYYY-MM-DDTHH:mm:ss+TZ>"
project: project:
+2 -2
View File
@@ -1,8 +1,8 @@
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://git.yumee.top/laily/skills/skills/ack/templates/knowledge.schema.json", "$id": "https://git.yumee.top/laily/pouch/skills/ack/templates/knowledge.schema.json",
"title": "ACK project knowledge guardrails", "title": "ACK project knowledge guardrails",
"description": "docs/ack/knowledge.yaml 的权威结构。知识只描述约束和验证引用,不保存可执行命令。", "description": ".pouch/ack/knowledge.yaml 的权威结构。知识只描述约束和验证引用,不保存可执行命令。",
"type": "object", "type": "object",
"required": ["version", "updatedAt", "project", "verificationRegistry", "entries"], "required": ["version", "updatedAt", "project", "verificationRegistry", "entries"],
"additionalProperties": false, "additionalProperties": false,
+1 -1
View File
@@ -1,4 +1,4 @@
# 复制为 docs/ack/knowledge.yaml,替换占位符。结构见 templates/knowledge.schema.json。 # 复制为 .pouch/ack/knowledge.yaml,替换占位符。结构见 templates/knowledge.schema.json。
# Developer/Test 只能在任务证据中提出 candidate;只有 Coordinator 写入这里。 # Developer/Test 只能在任务证据中提出 candidate;只有 Coordinator 写入这里。
version: 1 version: 1
updatedAt: "<YYYY-MM-DDTHH:mm:ss+TZ>" updatedAt: "<YYYY-MM-DDTHH:mm:ss+TZ>"
+9 -9
View File
@@ -3,12 +3,12 @@
> 本项目基于 ACK Skill v<ack_version>。通用规范由 `/ack` 从 Skill 自身的 > 本项目基于 ACK Skill v<ack_version>。通用规范由 `/ack` 从 Skill 自身的
> `references/` 读取;本文件只保存项目差异。 > `references/` 读取;本文件只保存项目差异。
> >
> **本文件是「项目覆盖层」,文件名可配置。** 默认放 `docs/ack/project.md`, > **本文件是「项目覆盖层」,文件名可配置。** 默认放 `.pouch/ack/project.md`,
> 不占用 `AGENTS.md`,避免与团队已有的 `AGENTS.md` 约定冲突。 > 不占用 `AGENTS.md`,避免与团队已有的 `AGENTS.md` 约定冲突。
> 若希望 Agent 自动加载,可由项目维护者自行在 `AGENTS.md` 中引用本文件;ACK > 若希望 Agent 自动加载,可由项目维护者自行在 `AGENTS.md` 中引用本文件;ACK
> 不会自动修改 `AGENTS.md`、`CLAUDE.md` 或其它 Agent 指令文件。 > 不会自动修改 `AGENTS.md`、`CLAUDE.md` 或其它 Agent 指令文件。
> 无论叫什么,都在 `tasks.yaml` 的 `project.overlayFile` 记录实际路径。 > 无论叫什么,都在 `tasks.yaml` 的 `project.overlayFile` 记录实际路径。
> `docs/ack/` 只保存本项目的 `project.md`、`tasks.yaml`、`knowledge.yaml`、默认关闭的 > `.pouch/ack/` 只保存本项目的 `project.md`、`tasks.yaml`、`knowledge.yaml`、默认关闭的
> `delivery.yaml` 与空的 `regression.yaml`, > `delivery.yaml` 与空的 `regression.yaml`,
> 不复制或链接 Skill。 > 不复制或链接 Skill。
@@ -18,11 +18,11 @@
- 技术栈:`<tech_stack>` - 技术栈:`<tech_stack>`
- 运行命令:`<run_command>` - 运行命令:`<run_command>`
- Base URL:`<base_url>` - Base URL:`<base_url>`
- 任务板:`docs/ack/tasks.yaml` - 任务板:`.pouch/ack/tasks.yaml`
- 项目知识:`docs/ack/knowledge.yaml` - 项目知识:`.pouch/ack/knowledge.yaml`
- 交付契约:`docs/ack/delivery.yaml`(默认关闭) - 交付契约:`.pouch/ack/delivery.yaml`(默认关闭)
- 回归目录:`docs/ack/regression.yaml` - 回归目录:`.pouch/ack/regression.yaml`
- 覆盖层文件:`<overlay_file_path>`(默认 `docs/ack/project.md`) - 覆盖层文件:`<overlay_file_path>`(默认 `.pouch/ack/project.md`)
## 通用规范(由 ACK Skill 按需读取) ## 通用规范(由 ACK Skill 按需读取)
@@ -39,7 +39,7 @@
## Worker 路由 ## Worker 路由
机器可校验的模型、reasoning effort、权限模式、默认 profile、允许 worktree 和启动 机器可校验的模型、reasoning effort、权限模式、默认 profile、允许 worktree 和启动
receipt 全部以 `docs/ack/tasks.yaml` 的 `project.orchestration` 与顶层 receipt 全部以 `.pouch/ack/tasks.yaml` 的 `project.orchestration` 与顶层
`workerReceipts` 为准。本文件不保存可执行 worker 命令。 `workerReceipts` 为准。本文件不保存可执行 worker 命令。
默认 profile: 默认 profile:
@@ -126,7 +126,7 @@ Skill 的 `scripts/run_verification.py` 执行,不直接拼接 path/args。检
- `delivery.yaml` 默认关闭,只描述能力,不自动授权提交、推送、发布或部署。测试环境 - `delivery.yaml` 默认关闭,只描述能力,不自动授权提交、推送、发布或部署。测试环境
绑定 deployer,发版写在 `intents.release`;用户明确要求重新部署测试环境或发布 绑定 deployer,发版写在 `intents.release`;用户明确要求重新部署测试环境或发布
版本时才执行对应 intent。常规交付仍在任务 `verified` 且本次 profile 得到确认后 版本时才执行对应 intent。常规交付仍在任务 `verified` 且本次 profile 得到确认后
运行。回归目录在 `docs/ack/regression.yaml`,由用户明确要求「回归」时运行。 运行。回归目录在 `.pouch/ack/regression.yaml`,由用户明确要求「回归」时运行。
- 默认交付 profile 最多到 `validation_ready` 或 `review_ready`;stable 发布或 production 部署必须有 - 默认交付 profile 最多到 `validation_ready` 或 `review_ready`;stable 发布或 production 部署必须有
approval 步骤并再次获得明确批准。配置变更只影响下一次 run。 approval 步骤并再次获得明确批准。配置变更只影响下一次 run。
- 每个任务最多派发 3 轮,仍不过标记 `leftover` 并继续下一个。 - 每个任务最多派发 3 轮,仍不过标记 `leftover` 并继续下一个。
+1 -1
View File
@@ -2,7 +2,7 @@
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://git.yumee.top/laily/skills/skills/ack/templates/regression.schema.json", "$id": "https://git.yumee.top/laily/skills/skills/ack/templates/regression.schema.json",
"title": "ACK project regression catalog", "title": "ACK project regression catalog",
"description": "docs/ack/regression.yaml 的权威结构。用例是给 Test worker 的可观测信号说明书,不是可执行 DSL。", "description": ".pouch/ack/regression.yaml 的权威结构。用例是给 Test worker 的可观测信号说明书,不是可执行 DSL。",
"type": "object", "type": "object",
"required": ["version", "updatedAt", "project", "cases"], "required": ["version", "updatedAt", "project", "cases"],
"additionalProperties": false, "additionalProperties": false,
@@ -1,4 +1,4 @@
# 复制为 docs/ack/regression.yaml。只有 Coordinator 写入;Test 通过回报提名。 # 复制为 .pouch/ack/regression.yaml。只有 Coordinator 写入;Test 通过回报提名。
# 结构见 templates/regression.schema.json。 # 结构见 templates/regression.schema.json。
version: 1 version: 1
updatedAt: "<YYYY-MM-DDTHH:mm:ss+TZ>" updatedAt: "<YYYY-MM-DDTHH:mm:ss+TZ>"
+6 -6
View File
@@ -1,6 +1,6 @@
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://git.yumee.top/laily/skills/skills/ack/templates/tasks.schema.json", "$id": "https://git.yumee.top/laily/pouch/skills/ack/templates/tasks.schema.json",
"title": "ACK task board", "title": "ACK task board",
"description": "tasks.yaml 的权威结构。跨语言可用;参考校验实现见 scripts/validate_tasks.py。", "description": "tasks.yaml 的权威结构。跨语言可用;参考校验实现见 scripts/validate_tasks.py。",
"type": "object", "type": "object",
@@ -45,7 +45,7 @@
"repoPath": { "repoPath": {
"type": "string", "type": "string",
"deprecated": true, "deprecated": true,
"description": "Legacy informational field; ACK derives project files from --project-root/docs/ack" "description": "Legacy informational field; ACK derives project files from --project-root/.pouch/ack"
}, },
"baseUrl": { "baseUrl": {
"type": "string" "type": "string"
@@ -57,21 +57,21 @@
}, },
"overlayFile": { "overlayFile": {
"type": "string", "type": "string",
"description": "项目覆盖层文件路径,默认 docs/ack/project.md,可自定义" "description": "项目覆盖层文件路径,默认 .pouch/ack/project.md,可自定义"
}, },
"knowledgeFile": { "knowledgeFile": {
"type": "string", "type": "string",
"const": "docs/ack/knowledge.yaml", "const": ".pouch/ack/knowledge.yaml",
"description": "项目知识护栏库的唯一权威路径" "description": "项目知识护栏库的唯一权威路径"
}, },
"deliveryFile": { "deliveryFile": {
"type": "string", "type": "string",
"const": "docs/ack/delivery.yaml", "const": ".pouch/ack/delivery.yaml",
"description": "可选项目交付契约的唯一权威路径" "description": "可选项目交付契约的唯一权威路径"
}, },
"regressionFile": { "regressionFile": {
"type": "string", "type": "string",
"const": "docs/ack/regression.yaml", "const": ".pouch/ack/regression.yaml",
"description": "可选项目回归目录的唯一权威路径" "description": "可选项目回归目录的唯一权威路径"
}, },
"bugIntake": { "bugIntake": {
+5 -5
View File
@@ -1,4 +1,4 @@
# 复制为 docs/ack/tasks.yaml,替换占位符。结构见 templates/tasks.schema.json。 # 复制为 .pouch/ack/tasks.yaml,替换占位符。结构见 templates/tasks.schema.json。
version: 1 version: 1
updatedAt: "<YYYY-MM-DDTHH:mm:ss+TZ>" updatedAt: "<YYYY-MM-DDTHH:mm:ss+TZ>"
source: "Coordinator (PM) Agent" source: "Coordinator (PM) Agent"
@@ -6,10 +6,10 @@ ackVersion: "<接入时的 ack skill 版本>"
project: project:
name: "<project_name>" name: "<project_name>"
baseUrl: "<base_url>" baseUrl: "<base_url>"
overlayFile: "docs/ack/project.md" overlayFile: ".pouch/ack/project.md"
knowledgeFile: "docs/ack/knowledge.yaml" knowledgeFile: ".pouch/ack/knowledge.yaml"
deliveryFile: "docs/ack/delivery.yaml" deliveryFile: ".pouch/ack/delivery.yaml"
regressionFile: "docs/ack/regression.yaml" regressionFile: ".pouch/ack/regression.yaml"
# 可选:飞书 Base Bug 收件箱。只保存 profile 名和资源 ID,绝不保存 App Secret。 # 可选:飞书 Base Bug 收件箱。只保存 profile 名和资源 ID,绝不保存 App Secret。
# bugIntake: # bugIntake:
# provider: "feishu-base" # provider: "feishu-base"
+75 -11
View File
@@ -6,35 +6,95 @@
## 什么时候使用 ## 什么时候使用
- "用 builder 初始化这个项目"
- "帮我构建这个项目的 DEB / Docker 镜像" - "帮我构建这个项目的 DEB / Docker 镜像"
- "把 1.2.3 发布到包仓库 / 镜像仓库" - "把 1.2.3 发布到包仓库 / 镜像仓库"
- "检查这个项目的 Makefile 是否符合 builder 契约" - "检查这个项目的 makefile.builder 是否符合 builder 契约"
- "看看项目现在的发布流程" - "看看项目现在的发布流程"
只构建不上传时明确说明即可;上传永远需要你显式授权。 只构建不上传时明确说明即可;上传永远需要你显式授权。
## 项目接入契约 ## 项目接入契约
1. 用 create-makefile skill 生成或修正 Makefile(目标 `help/build/clean/version` 对新项目说「用 builder 初始化」。Agent 会探测轨道、按
+ 条件 `deb/docker/push*`,变量 `ARCH/VERSION/DIST_DIR/PROJECT_NAME`)。 `templates/makefile.builder` 写出项目根 `makefile.builder`,并列出缺的发布配置。
2. 运行 `python3 -I -S <builder>/scripts/check.py .` 直到全部 PASS。 不改用户已有的 `Makefile` 或 `.env`。
3. 在项目根 `.env` 配置发布环境变量:
1. `makefile.builder` 目标:`help/build/clean/version` + 条件 `deb/docker/push*`,
变量 `ARCH/VERSION/DIST_DIR/PROJECT_NAME`。
`VERSION` 通过 `include <builder>/scripts/version.mk` 从 Git 推导。
2. 运行 `python3 -I -S <builder>/scripts/check.py . --ready` 直到构建项 PASS。
缺发布键只挡住上传,不挡住构建。
3. 在项目根 `.env.builder` 配置发布环境变量(不要写进 `.env`):
```text ```text
DEB_SERVER_URL=https://deb.example.com DEB_SERVER_URL=https://deb.example.com
DEB_REPOSITORY=main DEB_REPOSITORY=main
DEB_TOKEN=<token> # 只放 .env 或密钥系统,不进 git DEB_TOKEN=<token> # 只放 .env.builder 或密钥系统,不进 git
DOCKER_REGISTRY=registry.example.com DOCKER_REGISTRY=registry.example.com
``` ```
4. 日常发布就是两条命令:`make deb && make push-deb`、`make push-docker`。 4. 日常发布就是两条命令:
`make -f makefile.builder deb && make -f makefile.builder push-deb`、
`make -f makefile.builder push-docker`。
## 版本号
产物版本从 **当前 HEAD 的 Git 祖先** 推导,不调用 manage-release。
正式 tag 仍由 manage-release 创建;builder 只读取。完整规则见
[contract.md「版本号」](references/contract.md#版本号)。
| 谁 | 做什么 |
| --- | --- |
| manage-release | 选定下一个正式 SemVer,打 annotated tag `vX.Y.Z` |
| builder | 读 HEAD:落在稳定 tag 上则打正式产物,否则打测试产物 |
| `make -f makefile.builder version` | 输出一行规范版本(无 `v` 前缀),DEB / Docker 都从它渲染 |
**不要**用 `git tag \| sort -V \| tail -1` 取全仓库最大号,也不要把
`git describe --dirty` 的原始字符串写进 DEB 或镜像 tag。
### 正式(HEAD 恰好是稳定 tag `v1.4.2`)
```text
Git tag v1.4.2
规范版本 1.4.2
DEB foo_1.4.2_amd64.deb Version: 1.4.2
Docker registry/ns/foo:1.4.2
```
稳定 tag 仅匹配 `v<major>.<minor>.<patch>`,不含 `-rc`、`-app-N` 等后缀。
不是 exact-match 就不是正式包。
### 测试(其它任何 commit)
基线 = 祖先上最近的那颗稳定 tag(没有则为 `0.0.0`),再加上清洗后的
分支名、相对距离、短 SHA。测试与正式进**同一个** apt / Docker 仓库,
所以 DEB 必须用 `~`,保证测试包不会 `apt upgrade` 盖住正式包。
分支 `feat/login-v2`,相对 `v1.4.2` 第 7 个 commit,SHA `abc1234`:
```text
规范 / DEB 1.4.2~feat-login-v2.7+gabc1234
文件名 foo_1.4.2~feat-login-v2.7+gabc1234_amd64.deb
Docker registry/ns/foo:1.4.2-feat-login-v2.7.gabc1234
```
Docker tag 由规范版本映射:`~` → `-`,`+g` → `.g`(Docker 不允许 `~`)。
安装测试包必须显式指定版本或完整 tag,不能靠无参 `apt upgrade`。
### 分支名清洗
小写;`/`、`_` 改为 `-`;去掉其它非法字符;压缩连续 `-`;过长截断。
detached HEAD 用 `detached`,CI 可注入 `BUILD_BRANCH` / `CI_COMMIT_BRANCH` /
`GITHUB_REF_NAME`。脏工作树不把 `-dirty` 写进版本(发布本身会拒绝)。
## 使用示例 ## 使用示例
```text ```text
用 builder 检查这个项目的 Makefile 是否符合契约。 用 builder 初始化这个项目。
用 builder 检查这个项目的 makefile.builder 是否符合契约。
用 builder 构建当前版本的 DEB 和镜像,先不要上传。 用 builder 构建当前版本的 DEB 和镜像,先不要上传。
用 builder 把 dist/example_1.2.3_amd64.deb 发布到项目已配置的测试仓库。 用 builder 把当前 commit 的产物发布到项目已配置的仓库。
用 builder 发布多平台 linux/amd64,linux/arm64 镜像。 用 builder 发布多平台 linux/amd64,linux/arm64 镜像。
``` ```
@@ -42,10 +102,14 @@ DOCKER_REGISTRY=registry.example.com
| 脚本 | 用途 | | 脚本 | 用途 |
|------|------| |------|------|
| `scripts/check.py` | 校验项目 Makefile 是否符合契约(`--build` 实构核对产物) | | `scripts/check.py` | 校验契约(`--ready` 含工具链与发布键名,`--build` 实构核对产物) |
| `templates/makefile.builder` | 初始化用的契约文件骨架,拷到项目根 |
| `templates/env.builder` | 初始化用的 `.env.builder` 骨架(注释键,不含值) |
| `scripts/version.sh` | 从 Git 祖先稳定 tag 推导规范版本 / Docker tag |
| `scripts/version.mk` | `makefile.builder` `include`,设置 `VERSION` 与 `IMAGE_TAG` |
| `scripts/upload_deb.sh` | 上传 `.deb` 到 HTTP 包仓库(multipart package/token/repository_name) | | `scripts/upload_deb.sh` | 上传 `.deb` 到 HTTP 包仓库(multipart package/token/repository_name) |
| `scripts/publish_docker.sh` | buildx 构建 + 推送镜像,远端 digest 验证 | | `scripts/publish_docker.sh` | buildx 构建 + 推送镜像,远端 digest 验证 |
| `scripts/verify_deb.sh` | 核对包元数据、内容与 SHA-256 | | `scripts/verify_deb.sh` | 核对包元数据、内容与 SHA-256 |
环境变量契约、脚本解析顺序(`$BUILDER_SKILL_DIR` → `~/.skills/skills/builder/scripts/`)、 环境变量契约、脚本解析顺序(`$BUILDER_SKILL_DIR` → `~/.pouch/skills/builder/scripts/`)、
脏工作树策略等完整规则见 contract.md。 脏工作树策略等完整规则见 contract.md。
+96 -24
View File
@@ -1,12 +1,13 @@
--- ---
name: builder name: builder
description: >- description: >-
按统一契约构建并发布项目的 DEB 包与 Docker 镜像:先校验项目 Makefile 是否符合 初始化或检查项目是否满足 DEB/Docker 构建发布契约,再按契约构建并发布:
builder 契约(check.py),再 make 构建产物,经授权后用 skill 自带脚本上传并验证。 先校验 makefile.builder(check.py),再 make -f makefile.builder 构建产物,
触发词:构建 deb、发布 deb、上传 deb、推送 apt 仓库、打 Debian 包、构建镜像、 经授权后用 skill 自带脚本上传并验证。触发词:初始化 builder、接入 builder、
发布镜像、推送 Docker 镜像、make push、检查 Makefile 是否符合规范。仅分析打包 检查 makefile.builder、构建 deb、发布 deb、上传 deb、推送 apt 仓库、打 Debian
逻辑或只构建不上传时也可使用;不会在未获授权时执行任何上传。Docker 轨道保持 包、构建镜像、发布镜像、推送 Docker 镜像、make push。仅分析打包逻辑或只构建
显式触发:用户点名(builder/publish docker)时才走镜像发布。 不上传时也可使用;不会在未获授权时执行任何上传。Docker 轨道保持显式触发:
用户点名(builder/publish docker)时才走镜像发布。
--- ---
# Builder:DEB / Docker 构建发布 # Builder:DEB / Docker 构建发布
@@ -14,28 +15,94 @@ description: >-
复用项目已有发布约定,安全地完成"校验 → 构建 → 检查 → 授权 → 上传 → 验证"。 复用项目已有发布约定,安全地完成"校验 → 构建 → 检查 → 授权 → 上传 → 验证"。
分工原则:**make 管构建,skill 脚本管发布,本 SKILL.md 只留脚本做不了的决策。** 分工原则:**make 管构建,skill 脚本管发布,本 SKILL.md 只留脚本做不了的决策。**
项目状态是根目录 `makefile.builder` 与发布用 `.env.builder`,不要创建
`.pouch/builder/`,不要改用户的 `Makefile` / `makefile` / `.env`。
开始时解析当前 `SKILL.md` 所在目录,记为 `<skill-dir>`。优先
`git rev-parse --show-toplevel` 解析项目根。
## 选择模式
- 用户要求初始化、接入 builder,或新项目还没有 `makefile.builder`:执行“初始化”。
- 用户要求检查 builder 契约或发布配置是否齐全:执行“检查”。
- 用户要求构建、发布、上传:执行“工作流”。不要静默初始化。
## 何时使用 ## 何时使用
- 用户要求初始化或接入 builder。
- 用户要求构建、发布、上传 `.deb` 包或 Docker/OCI 镜像。 - 用户要求构建、发布、上传 `.deb` 包或 Docker/OCI 镜像。
- 用户要求检查项目 Makefile 是否符合 builder 契约。 - 用户要求检查 `makefile.builder` 是否符合 builder 契约。
- 用户要求梳理或接通项目现有的 DEB/镜像发布流程。 - 用户要求梳理或接通项目现有的 DEB/镜像发布流程。
不适用:本地安装/卸载 DEB;RPM/APK/语言包管理器;从零设计全新打包体系(先出方案); 不适用:本地安装/卸载 DEB;RPM/APK/语言包管理器;从零设计全新打包体系(先出方案);
普通编码与 Dockerfile 编辑。 普通编码与 Dockerfile 编辑。
## 初始化
1. 确认项目根。探测 `makefile.builder`、`.env.builder`、用户 `Makefile`/`makefile`
(只当抄 build 配方的证据,不改)、`Dockerfile`、`debian/`、语言清单。
`.env.builder` 只看键是否存在且非空,不读、不打印值。不要读取用户 `.env`。
2. 判定轨道:有 Dockerfile → docker;有 deb 信号或用户要打 deb → deb;都不清则问。
不要猜测 registry、token 或仓库名。
3. 没有 `makefile.builder`:把 `<skill-dir>/templates/makefile.builder` 拷到项目根。
按轨道删掉未使用的 deb/docker/push* 段,把 `build` 的 TODO 换成仓库里已有的
真实编译命令(可从用户 Makefile 抄配方,但不要 `include` 或递归调用它)。
`include` builder 的 `scripts/version.mk`。双产物把 `push` 改成
`push: push-deb push-docker`。不要改用户的 `Makefile` / `makefile`。
4. 已有 `makefile.builder`:跑检查;按 FAIL 给出修补说明。不覆盖该文件,除非
用户明确要求按契约改。不要调用 create-makefile(其版本规则与本契约冲突)。
5. 没有 `.env.builder`:把 `<skill-dir>/templates/env.builder` 拷到项目根为
`.env.builder`(注释键,不含值)。不要改、不要读取用户 `.env`。缺发布键时在
报告里给出可粘贴示例,并说明把 `.env.builder` 加入 `.gitignore`,不要提交。
6. 运行:
```bash
python3 -I -S <skill-dir>/scripts/check.py <project-dir> --ready
```
7. 按下面格式报告。结构校验通过且当前轨道能构建时才能称「完成」;只缺发布
键是「部分完成」(可构建,不可发布)。契约 FAIL 或轨道工具缺失是「阻塞」。
除非用户明确要求,不提交、不推送、不上传。
```text
## builder 初始化:完成 | 部分完成 | 阻塞
已具备: …
待配置: 路径 + 字段 + 可粘贴示例 + 缺了会挡住哪步
工具链: make / docker / dpkg-deb(缺则怎么装,不擅自安装)
下一步: 一句话
```
发布键示例(只示范键名):
```text
# .env.builder
DEB_SERVER_URL=https://deb.example.com
DEB_REPOSITORY=main
DEB_TOKEN=
DOCKER_REGISTRY=registry.example.com
```
## 检查
只读。运行 `check.py <project-dir> --ready`,用同一报告格式,标题改为
`## builder 检查:…`。不写 `makefile.builder` / `.env.builder`,不改用户 Makefile
或 `.env`。用户明确要求修复后再转入初始化。
## 工作流 ## 工作流
### 0. 校验契约 ### 0. 校验契约
```bash ```bash
python3 -I -S <skill-dir>/scripts/check.py <project-dir> # 静态检查 python3 -I -S <skill-dir>/scripts/check.py <project-dir> # 静态检查
python3 -I -S <skill-dir>/scripts/check.py <project-dir> --ready # 含工具链与发布键
python3 -I -S <skill-dir>/scripts/check.py <project-dir> --build # 额外实构 deb 并核对产物 python3 -I -S <skill-dir>/scripts/check.py <project-dir> --build # 额外实构 deb 并核对产物
``` ```
任一 FAIL:停下修复(引导用 create-makefile skill 补齐),不要绕过校验继续发布。 契约 FAIL 或轨道工具缺失:停下,转入「初始化」按契约补齐 `makefile.builder`,
完整要求见 [contract.md](references/contract.md)。存量项目未接契约时走第 6 节 不要绕过校验继续发布,不要改用户 Makefile。只缺发布键:允许构建,禁止上传。
fallback;成功交付一次后引导用户迁移到契约。 完整要求见 [contract.md](references/contract.md)。存量项目未接契约时走
「存量项目 fallback」;成功交付一次后引导用户迁到 `makefile.builder`。
### 1. 确认发布边界 ### 1. 确认发布边界
@@ -44,11 +111,11 @@ fallback;成功交付一次后引导用户迁移到契约。
执行上传前确认: 执行上传前确认:
- 目标服务和仓库来自项目配置(`.env`)或用户输入,不猜测生产端点。 - 目标服务和仓库来自项目配置(`.env.builder`)或用户输入,不猜测生产端点。
- 认证令牌已通过环境变量或密钥系统提供;绝不写入命令输出、文件、提交或回复, - 认证令牌已通过环境变量或密钥系统提供;绝不写入命令输出、文件、提交或回复,
不用 `set -x` 执行含凭据的命令。 不用 `set -x` 执行含凭据的命令。
- 相同版本是否允许覆盖;无法确认且可能覆盖时,先询问。 - 相同版本是否允许覆盖;无法确认且可能覆盖时,先询问。
- Docker 轨道需要用户已明确指定目标 registry/repository/tag 后才继续。 - Docker 轨道需要已确定 registry/repository;tag 未给出时按契约「版本号」推导。
脏工作树默认拒绝发布;用户明确接受时设置 `ALLOW_UNCOMMITTED=1` 并在汇报中注明 脏工作树默认拒绝发布;用户明确接受时设置 `ALLOW_UNCOMMITTED=1` 并在汇报中注明
包含的未提交修改。 包含的未提交修改。
@@ -56,13 +123,15 @@ fallback;成功交付一次后引导用户迁移到契约。
### 2. 构建 ### 2. 构建
```bash ```bash
make build ARCH=<amd64|arm64> VERSION=<version> # 主产物 make -f makefile.builder build ARCH=<amd64|arm64> VERSION=<version> # 主产物
make deb ARCH=<amd64|arm64> # DEB 项目 make -f makefile.builder deb ARCH=<amd64|arm64> # DEB 项目
``` ```
版本缺省由 make 从 `git describe --tags --always --dirty` 推导。构建目标若会自动 版本缺省按契约「版本号」从 Git 祖先稳定 tag 推导(正式 = HEAD exact-match
上传而当前仅获构建授权,改用纯构建目标。执行前确认所需工具可用(docker、 的 `vX.Y.Z`;测试 = `X.Y.Z~分支.距离+gSHA`)。不要调用 manage-release 来算
dpkg-deb 等)。不得擅自清理宽泛目录;脚本含 `rm -rf` 时先解析确认为受限构建目录。 产物版本,不要用全仓库最新 tag。构建目标若会自动上传而当前仅获构建授权,改用
纯构建目标。执行前确认所需工具可用(docker、dpkg-deb 等)。不得擅自清理宽泛
目录;脚本含 `rm -rf` 时先解析确认为受限构建目录。
### 3. 上传前检查 ### 3. 上传前检查
@@ -76,7 +145,7 @@ verify_deb.sh 输出元数据、关键内容清单和 SHA-256。匹配到多个
### 4. 发布 ### 4. 发布
优先 `make push[-deb|-docker]`(契约要求的薄包装);直接调用等价: 优先 `make -f makefile.builder push[-deb|-docker]`(契约要求的薄包装);直接调用等价:
```bash ```bash
DEB_SERVER_URL=… DEB_TOKEN=… DEB_REPOSITORY=… \ DEB_SERVER_URL=… DEB_TOKEN=… DEB_REPOSITORY=… \
@@ -86,7 +155,7 @@ DOCKER_REGISTRY=… \
<skill-dir>/scripts/publish_docker.sh # env 优先,flag 可覆盖 <skill-dir>/scripts/publish_docker.sh # env 优先,flag 可覆盖
``` ```
环境变量缺失时脚本会自动向上查找项目 `.env` 加载(shell 显式值优先)。不把 token 环境变量缺失时脚本会加载项目 `.env.builder`(shell 显式值优先),不读 `.env`。不把 token
作为命令行参数;不把脚本复制进项目。upload_deb.sh 默认请求 `/api/v2/upload/package` 作为命令行参数;不把脚本复制进项目。upload_deb.sh 默认请求 `/api/v2/upload/package`
(multipart 字段 `package`/`token`/`repository_name`,接受 200/201),协议不符时设 (multipart 字段 `package`/`token`/`repository_name`,接受 200/201),协议不符时设
`DEB_UPLOAD_PATH` 或改用项目专属逻辑。publish_docker.sh 用 buildx 一步完成构建+推送, `DEB_UPLOAD_PATH` 或改用项目专属逻辑。publish_docker.sh 用 buildx 一步完成构建+推送,
@@ -113,20 +182,23 @@ rg -n -i --hidden --glob '!.git' \
'build-deb|upload-deb|publish-deb|dpkg-deb|debuild|curl.*deb|\.deb\b|aptly|reprepro' 'build-deb|upload-deb|publish-deb|dpkg-deb|debuild|curl.*deb|\.deb\b|aptly|reprepro'
``` ```
重点检查 Makefile、CI 配置、`debian/`、构建脚本和发布文档中的入口、变量传递方式、 重点检查用户 Makefile、CI 配置、`debian/`、构建脚本和发布文档中的入口、变量传递方式、
端点与认证方式。优先复用已有构建入口;上传仍用 builder 脚本。交付后引导迁移到契约 端点与认证方式。优先复用已有构建入口;上传仍用 builder 脚本。交付后引导迁移到
(create-makefile + check.py 通过为准)。 `makefile.builder`(`templates/makefile.builder` + `check.py` 通过为准)。
## 修改 builder 自身时 ## 修改 builder 自身时
- 上传/发布脚本是 SSOT:通用行为修改落在 `skills/builder/scripts/`,不同步复制到 - 上传/发布脚本是 SSOT:通用行为修改落在 `skills/builder/scripts/`,不同步复制到
业务项目。 业务项目。产物版本只通过 `scripts/version.sh` 推导,不要在 `makefile.builder` 内联
- 契约变更先改 `scripts/check.py`,再同步 `references/contract.md`。 `git describe` 或 `sort -V`。
- 契约变更先改 `scripts/check.py`,再同步 `references/contract.md`、
`templates/makefile.builder` 与 `templates/env.builder`。
- 可用 `bash -n` 检查脚本语法;有 ShellCheck 时一并运行。 - 可用 `bash -n` 检查脚本语法;有 ShellCheck 时一并运行。
- 不通过真实生产上传测试脚本,除非用户明确授权并给出测试版本/仓库。 - 不通过真实生产上传测试脚本,除非用户明确授权并给出测试版本/仓库。
## 完成标准 ## 完成标准
- 初始化/检查:报告为完成、部分完成或阻塞;待配置项含文件、字段和示例。
- 仅分析:入口、调用链、配置来源和风险已被准确说明。 - 仅分析:入口、调用链、配置来源和风险已被准确说明。
- 仅校验:check.py 结果逐条可解释,修复建议明确。 - 仅校验:check.py 结果逐条可解释,修复建议明确。
- 仅构建:产物已生成并通过 verify_deb.sh,未发生上传。 - 仅构建:产物已生成并通过 verify_deb.sh,未发生上传。
+68 -15
View File
@@ -7,6 +7,18 @@ builder 脚本只做发布,不做项目特定的构建逻辑。
分工原则:**make 管构建(项目内、确定性),skill 脚本管发布(跨项目 SSOT), 分工原则:**make 管构建(项目内、确定性),skill 脚本管发布(跨项目 SSOT),
Agent 只保留授权判断和歧义处理。** Agent 只保留授权判断和歧义处理。**
契约文件固定为项目根 `makefile.builder`,调用方式:
```bash
make -f makefile.builder <target>
```
不要把 builder 目标写进用户的 `Makefile` 或 `makefile`。`check.py` 只读
`makefile.builder`。
发布凭据固定为项目根 `.env.builder`。不要把这些键写进用户的 `.env`。脚本不读取
`.env`。
## 1. Make 目标 ## 1. Make 目标
### 必备目标(所有项目) ### 必备目标(所有项目)
@@ -30,7 +42,7 @@ Agent 只保留授权判断和歧义处理。**
规则: 规则:
1. 项目有 DEB 产物的判据:Makefile 配方引用 `dpkg-deb`/`debuild` 或产出 `.deb`。 1. 项目有 DEB 产物的判据:`makefile.builder` 配方引用 `dpkg-deb`/`debuild` 或产出 `.deb`。
有镜像的判据:项目根存在 `Dockerfile`。 有镜像的判据:项目根存在 `Dockerfile`。
2. 双产物项目必须拆 `push-deb`/`push-docker`,`push` 依序聚合两者;单产物项目一个 2. 双产物项目必须拆 `push-deb`/`push-docker`,`push` 依序聚合两者;单产物项目一个
`push` 即可。 `push` 即可。
@@ -43,10 +55,47 @@ Agent 只保留授权判断和歧义处理。**
| 变量 | 默认 | 说明 | | 变量 | 默认 | 说明 |
|------|------|------| |------|------|------|
| `ARCH` | `amd64` | 仅允许 `amd64` \| `arm64`,非法值必须 `$(error)` 报错并提示合法值 | | `ARCH` | `amd64` | 仅允许 `amd64` \| `arm64`,非法值必须 `$(error)` 报错并提示合法值 |
| `VERSION` | `` (空) | 为空时由 make 从 `git describe --tags --always --dirty` 推导 | | `VERSION` | `` (空) | 为空时按「版本号」节从 Git 祖先稳定 tag 推导;禁止 `sort -V` 取全局最新 |
| `DIST_DIR` | `dist` | DEB 产物目录 | | `DIST_DIR` | `dist` | DEB 产物目录 |
| `PROJECT_NAME` | git 仓库名 | 包名/镜像名主体 | | `PROJECT_NAME` | git 仓库名 | 包名/镜像名主体 |
### 版本号
`make -f makefile.builder version` 输出一行规范版本(无 `v` 前缀)。DEB 的
`Version` 与文件名直接用它;Docker tag 由它渲染。推导入口是 `scripts/version.sh`
(`makefile.builder` 通过 `scripts/version.mk` 引用);Builder 只读取 Git 状态,不调用
manage-release,不猜测下一个正式 SemVer。正式 tag 由 manage-release 事先打好。
`version.sh` 不执行 `git fetch`。
推导前 `git fetch --tags`(本地 linked worktree 共享 tags,不必再 fetch 才
能看见其它 worktree 新打的 tag)。基线是 **HEAD 祖先上最近的稳定 tag**,
不是全仓库 `sort -V` 的最大号。稳定 tag 仅 `v<major>.<minor>.<patch>`。
| 判定 | 规范版本 | DEB 文件 | Docker tag |
| --- | --- | --- | --- |
| HEAD exact-match 稳定 tag `v1.4.2` | `1.4.2` | `name_1.4.2_<arch>.deb` | `1.4.2` |
| 其它 commit;祖先最近稳定 tag `v1.4.2` | `1.4.2~<branch>.<n>+g<sha>` | `name_1.4.2~<branch>.<n>+g<sha>_<arch>.deb` | `1.4.2-<branch>.<n>.g<sha>` |
| 祖先中没有稳定 tag | `0.0.0~<branch>+g<sha>` | 同上替换规范版本 | 同上映射 |
测试与正式进入同一 apt / Docker 仓库。测试 DEB 必须用 `~`,使
`1.4.2~…` < `1.4.2`,`apt upgrade` 不会装上测试包。Docker tag 不得含
`~`、`/`、`:`,由规范版本把 `~` → `-`、`+g` → `.g`。
`<branch>`:`git rev-parse --abbrev-ref HEAD`,detached 时用
`BUILD_BRANCH` / `CI_COMMIT_BRANCH` / `GITHUB_REF_NAME`,再没有则
`detached`。清洗:小写;`/`、`_` → `-`;去掉非 `[a-z0-9-]`;压缩连续
`-`;过长截断(给 base、距离、SHA 留位置;Docker tag 上限 128)。
`<n>` 为基线 tag 到 HEAD 的 commit 数;`<sha>` 为 7 位短哈希。不要把
`--dirty` 写入版本;脏树发布仍走既有门禁。显式 `VERSION=` / `IMAGE_TAG=`
可覆盖推导,但不得把非 exact-match 的 commit 标成正式 `X.Y.Z`。
`makefile.builder` 不要内联 `git describe` 或 `sort -V`,include 本 skill 的
`scripts/version.mk`:
```makefile
include $(HOME)/.pouch/skills/builder/scripts/version.mk
```
## 3. 发布环境变量 ## 3. 发布环境变量
### DEB 轨道 ### DEB 轨道
@@ -64,12 +113,12 @@ Agent 只保留授权判断和歧义处理。**
|------|------|------| |------|------|------|
| `DOCKER_REGISTRY` | 是 | registry 主机,无 scheme | | `DOCKER_REGISTRY` | 是 | registry 主机,无 scheme |
| `DOCKER_REPOSITORY` | 否 | 默认取 git 仓库名 | | `DOCKER_REPOSITORY` | 否 | 默认取 git 仓库名 |
| `IMAGE_TAG` | 否 | 默认 `git describe --tags --always --dirty` | | `IMAGE_TAG` | 否 | 默认由规范版本渲染:正式为 `X.Y.Z`;测试将 `~` 换成 `-`、`+g` 换成 `.g` |
| `PLATFORMS` | 否 | 默认 `linux/amd64`;多平台如 `linux/amd64,linux/arm64` | | `PLATFORMS` | 否 | 默认 `linux/amd64`;多平台如 `linux/amd64,linux/arm64` |
配置来源优先级:shell 已显式设置的值 > 项目根 `.env` > 失败并询问用户。 配置来源优先级:shell 已显式设置的值 > 项目根 `.env.builder` > 失败并询问用户。
`.env` 由 builder 脚本自动向上查找并加载(不回显任何值);当前 shell 已设置的值 `.env.builder` 由 builder 脚本加载(不回显任何值);当前 shell 已设置的值优先。
优先于 `.env`。 不要读取或改写用户 `.env`。空值视为未配置。不要提交 `.env.builder`。
### 工作区安全 ### 工作区安全
@@ -78,23 +127,27 @@ Agent 只保留授权判断和歧义处理。**
## 4. 脚本解析顺序 ## 4. 脚本解析顺序
push 目标定位 builder 脚本时按以下顺序,命中即用,不做静默兜底: push 目标与 `version.sh` 定位 builder 脚本时按以下顺序,命中即用,不做静默兜底:
1. `$BUILDER_SKILL_DIR/scripts/`(特殊安装位置) 1. `$BUILDER_SKILL_DIR/scripts/`(特殊安装位置)
2. `$HOME/.skills/skills/builder/scripts/`(标准 clone 位) 2. `$HOME/.pouch/skills/builder/scripts/`(标准 clone 位)
两个位置都不可用时必须失败并提示:设置 `BUILDER_SKILL_DIR`,或把 skills 仓库 两个位置都不可用时必须失败并提示:设置 `BUILDER_SKILL_DIR`,或把 pouch 仓库
clone 到 `~/.skills`。 clone 到 `~/.pouch`。
## 5. 校验 ## 5. 校验
`python3 -I -S <builder-scripts>/check.py <project-dir> [--build]` 对本项目逐条检查 `python3 -I -S <builder-scripts>/check.py <project-dir> [--build]` 对本项目逐条检查
上述要求,任一 FAIL 退出码非零,可直接挂 CI。`--build` 额外实构 `make deb` 并核对 上述要求,任一 FAIL 退出码非零,可直接挂 CI。`--build` 额外实构
产物元数据(默认只静态检查配方)。校验失败时的修复路径:用 create-makefile skill `make -f makefile.builder deb` 并核对产物元数据(默认只静态检查配方)。`--ready`
补齐或修正 Makefile,不要绕过校验器。 额外检查轨道工具链,以及 `.env.builder` / 环境中的发布键名是否存在且非空(不读取、
不打印值;缺键只挡住发布)。校验失败时的修复路径:按 `templates/makefile.builder` 补齐或
修正 `makefile.builder`,再跑 check.py,不要绕过校验器,不要改用户 Makefile,
不要用 create-makefile(版本推导与本契约冲突)。
## 6. 存量项目(legacy fallback) ## 6. 存量项目(legacy fallback)
未接入契约的项目:builder 仍可按发现流程工作——从 `Makefile`、CI 配置、`debian/` 未接入契约的项目:builder 仍可按发现流程工作——从用户 `Makefile`、CI 配置、`debian/`
与发布文档中找已有构建/上传入口,优先复用;上传仍使用 builder 脚本。完成一次成功 与发布文档中找已有构建/上传入口,优先复用;上传仍使用 builder 脚本。完成一次成功
交付后应引导用户用 create-makefile 把项目迁移到本契约,之后以 check.py 为准。 交付后应引导用户按 `templates/makefile.builder` 写入项目根 `makefile.builder`,之后以
check.py 为准。不把契约目标合并进用户 Makefile。
+8 -6
View File
@@ -14,8 +14,8 @@
信息来源优先级: 信息来源优先级:
1. 用户本次请求中明确给出的值。 1. 用户本次请求中明确给出的值。
2. 当前项目的 `.env` 与 `AGENTS.md`、发布文档。 2. 当前项目的 `.env.builder` 与 `AGENTS.md`、发布文档。不要读用户 `.env`。
3. Makefile、CI 配置或现有构建脚本中一致且无歧义的配置。 3. `makefile.builder`、用户 Makefile、CI 配置或现有构建脚本中一致且无歧义的配置。
4. 询问用户。 4. 询问用户。
不要从其他项目、shell history 或无关的本地配置中猜测发布目标。 不要从其他项目、shell history 或无关的本地配置中猜测发布目标。
@@ -34,7 +34,9 @@
## Tag 策略 ## Tag 策略
- release tag(如 `v1.2.3`)默认视为不可变。 - 未显式给出 `--tag` / `IMAGE_TAG` 时,使用契约「版本号」渲染出的 tag
- Git SHA tag 应对应当前源 commit。 (正式 `1.4.2`,测试 `1.4.2-feat-login.7.gabc1234`),不要退回
- `latest`、`stable` 等浮动 tag 只有在用户明确要求时才发布。 `git describe`,不要询问后另选一套。
- 用户未给 tag 且项目没有唯一明确规则时,必须询问,不要自行选择。 - 正式产物 tag 与 Git tag `vX.Y.Z` 对应,但镜像 tag **不含** `v`;默认视为不可变。
- `latest`、`stable`、裸分支名等浮动 tag 只有在用户明确要求时才额外发布,
不能代替上面那条唯一身份。
+211 -27
View File
@@ -1,14 +1,18 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""Executable form of the builder contract (references/contract.md). """Executable form of the builder contract (references/contract.md).
Checks a project's Makefile against the contract by probing make itself with Checks a project's makefile.builder against the contract by probing make
dry runs (`make -n`) instead of parsing Makefile text: includes, conditionals, itself with dry runs (`make -f makefile.builder -n`) instead of parsing
and variable expansion are resolved by make, so behavior is what gets judged. makefile text: includes, conditionals, and variable expansion are resolved
by make, so behavior is what gets judged. The default Makefile/makefile is
not read.
Usage: Usage:
python3 -I -S check.py <project-dir> [--build] python3 -I -S check.py <project-dir> [--build] [--ready]
Exit codes: 0 = all PASS, 1 = at least one FAIL, 2 = usage/environment error. Exit codes: 0 = all PASS, 1 = at least one FAIL, 2 = usage/environment error.
`--ready` 额外检查轨道工具链和发布环境变量键名(只看键是否存在,永不打印值)。
无 makefile.builder 时普通模式退出 2;`--ready` 输出结构化 FAIL 并继续工具链/发布键检查。
Change the contract here first, then mirror the change into contract.md. Change the contract here first, then mirror the change into contract.md.
""" """
@@ -17,6 +21,7 @@ from __future__ import annotations
import argparse import argparse
import hashlib import hashlib
import os
import re import re
import shutil import shutil
import subprocess import subprocess
@@ -37,6 +42,8 @@ SECRET_PATTERNS = (
FLOATING_TAGS = (":latest", ":stable") FLOATING_TAGS = (":latest", ":stable")
DEB_SHAPE = re.compile(r"^[^_\s]+_[^_\s]+_[^_\s]+\.deb$") DEB_SHAPE = re.compile(r"^[^_\s]+_[^_\s]+_[^_\s]+\.deb$")
VALID_SCRIPT_NAMES = ("upload_deb.sh", "publish_docker.sh") VALID_SCRIPT_NAMES = ("upload_deb.sh", "publish_docker.sh")
BUILDER_MAKEFILE = "makefile.builder"
BUILDER_ENV = ".env.builder"
PASS = "PASS" PASS = "PASS"
FAIL = "FAIL" FAIL = "FAIL"
@@ -58,10 +65,15 @@ class Report:
self.skips += 0 if self.skips else 1 self.skips += 0 if self.skips else 1
def run_make(project: Path, *args: str, timeout: int = 60) -> subprocess.CompletedProcess[str]: def run_make(
project: Path, *args: str, timeout: int = 60, dry_run: bool = True
) -> subprocess.CompletedProcess[str]:
cmd = ["make", "-C", str(project), "-f", BUILDER_MAKEFILE]
if dry_run:
cmd.append("-n")
cmd.extend(args)
return subprocess.run( return subprocess.run(
["make", "-C", str(project), "-n", *args], cmd, capture_output=True, text=True, timeout=timeout, check=False
capture_output=True, text=True, timeout=timeout, check=False,
) )
@@ -120,11 +132,15 @@ def check_version_output(report: Report, project: Path) -> None:
out_lines = [ln.lstrip()[5:] for ln in result.stdout.splitlines() if ln.lstrip().startswith("echo ")] out_lines = [ln.lstrip()[5:] for ln in result.stdout.splitlines() if ln.lstrip().startswith("echo ")]
out = "\n".join(out_lines).strip() out = "\n".join(out_lines).strip()
single = len(out.splitlines()) == 1 and out != "" single = len(out.splitlines()) == 1 and out != ""
no_v = single and not out.startswith("v")
detail = f"stdout={out!r}"
if single and not no_v:
detail += "\ncanonical version must not start with 'v'"
report.add( report.add(
PASS if single else FAIL, PASS if no_v else FAIL,
3, 3,
"version 输出一行非空版本号", "version 输出一行非空规范版本(无 v 前缀)",
f"stdout={out!r}", detail,
) )
@@ -196,7 +212,16 @@ def check_docker_recipe(report: Report, project: Path) -> None:
SCRIPT_RESOLVE_SNIPPETS = tuple( SCRIPT_RESOLVE_SNIPPETS = tuple(
f"{prefix}{name}" f"{prefix}{name}"
for prefix in ("$$BUILDER_SKILL_DIR", "$BUILDER_SKILL_DIR", "$$HOME/.skills/skills/builder/scripts", "$HOME/.skills/skills/builder/scripts", "~/.skills/skills/builder/scripts") for prefix in (
"$$BUILDER_SKILL_DIR",
"$BUILDER_SKILL_DIR",
"$$HOME/.pouch/skills/builder/scripts",
"$HOME/.pouch/skills/builder/scripts",
"~/.pouch/skills/builder/scripts",
"$$HOME/.skills/skills/builder/scripts",
"$HOME/.skills/skills/builder/scripts",
"~/.skills/skills/builder/scripts",
)
for name in VALID_SCRIPT_NAMES for name in VALID_SCRIPT_NAMES
) )
@@ -218,7 +243,7 @@ def check_push_delegates(report: Report, project: Path, dual_artifact: bool) ->
elif not any(snippet in text for snippet in SCRIPT_RESOLVE_SNIPPETS) \ elif not any(snippet in text for snippet in SCRIPT_RESOLVE_SNIPPETS) \
and "$(BUILDER_SCRIPT)" not in text and "upload_deb.sh" not in text \ and "$(BUILDER_SCRIPT)" not in text and "upload_deb.sh" not in text \
and "publish_docker.sh" not in text: and "publish_docker.sh" not in text:
inline.append(f"{target}: does not call a builder script (expected $BUILDER_SKILL_DIR/... or ~/.skills/... path)") inline.append(f"{target}: does not call a builder script (expected $BUILDER_SKILL_DIR/... or ~/.pouch/... path)")
else: else:
thin.append(target) thin.append(target)
problems = [] problems = []
@@ -231,8 +256,7 @@ def check_push_delegates(report: Report, project: Path, dual_artifact: bool) ->
def check_secrets_and_tags(report: Report, project: Path) -> None: def check_secrets_and_tags(report: Report, project: Path) -> None:
makefile = project / "Makefile" makefile = project / BUILDER_MAKEFILE
included_text = ""
problems = [] problems = []
files = [makefile] files = [makefile]
if makefile.exists(): if makefile.exists():
@@ -254,14 +278,113 @@ def check_secrets_and_tags(report: Report, project: Path) -> None:
report.add(FAIL if problems else PASS, 8, "无内联机密、无隐式 latest/stable", "\n".join(problems) or "clean") report.add(FAIL if problems else PASS, 8, "无内联机密、无隐式 latest/stable", "\n".join(problems) or "clean")
def check_script_paths(report: Report) -> None: DEB_ENV_KEYS = ("DEB_SERVER_URL", "DEB_TOKEN", "DEB_REPOSITORY")
import os DOCKER_ENV_KEYS = ("DOCKER_REGISTRY",)
ENV_KEY_LINE = re.compile(r"^([A-Za-z_][A-Za-z0-9_]*)=(.*)$")
def env_file_keys(project: Path) -> set[str]:
"""Return nonempty key names in `.env.builder`. Never return or print values."""
path = project / BUILDER_ENV
keys: set[str] = set()
if not path.is_file():
return keys
try:
text = path.read_text(encoding="utf-8")
except OSError:
return keys
for raw in text.splitlines():
stripped = raw.strip()
if not stripped or stripped.startswith("#"):
continue
match = ENV_KEY_LINE.match(stripped)
if not match:
continue
value = match.group(2).strip().strip("'\"")
if value:
keys.add(match.group(1))
return keys
def key_present(key: str, env_keys: set[str]) -> bool:
return bool(os.environ.get(key)) or key in env_keys
def check_ready_toolchain(
report: Report, *, deb_project: bool, docker_project: bool
) -> None:
lines = [f"make: {'found' if shutil.which('make') else 'MISSING'}"]
problems = []
if docker_project:
docker_ok = shutil.which("docker") is not None
lines.append(f"docker: {'found' if docker_ok else 'MISSING (blocks docker track)'}")
if not docker_ok:
problems.append("install docker to build/publish images")
else:
lines.append("docker: skipped (no docker track)")
if deb_project:
dpkg_ok = shutil.which("dpkg-deb") is not None
lines.append(
f"dpkg-deb: {'found' if dpkg_ok else 'MISSING (blocks make deb / --build)'}"
)
if not dpkg_ok:
problems.append("install dpkg-dev (or equivalent) to build .deb packages")
else:
lines.append("dpkg-deb: skipped (no deb track)")
report.add(
FAIL if problems else PASS,
10,
"轨道工具链",
"\n".join(lines + ([""] + problems if problems else [])),
)
def check_ready_env_keys(
report: Report, project: Path, *, deb_project: bool, docker_project: bool
) -> None:
env_keys = env_file_keys(project)
lines = []
missing: list[str] = []
if not deb_project and not docker_project:
report.add(SKIP, 11, "发布环境变量键名(不读取值)", "no deb/docker track")
return
if deb_project:
for key in DEB_ENV_KEYS:
found = key_present(key, env_keys)
lines.append(f"{key}: {'present' if found else 'MISSING'}")
if not found:
missing.append(key)
else:
lines.append("DEB_*: skipped (no deb track)")
if docker_project:
for key in DOCKER_ENV_KEYS:
found = key_present(key, env_keys)
lines.append(f"{key}: {'present' if found else 'MISSING'}")
if not found:
missing.append(key)
else:
lines.append("DOCKER_*: skipped (no docker track)")
if missing:
lines.extend(
[
"",
f"blocks publish, not build. Put keys in the environment or {BUILDER_ENV}:",
*[f" {key}=" for key in missing],
f"Do not commit {BUILDER_ENV}. Do not put these keys in `.env`. Never print values.",
]
)
report.add(SKIP, 11, "发布环境变量键名(不读取值)", "\n".join(lines))
return
report.add(PASS, 11, "发布环境变量键名(不读取值)", "\n".join(lines))
def check_script_paths(report: Report) -> None:
candidates = [] candidates = []
env_dir = os.environ.get("BUILDER_SKILL_DIR") env_dir = os.environ.get("BUILDER_SKILL_DIR")
if env_dir: if env_dir:
candidates.append(Path(env_dir) / "scripts") candidates.append(Path(env_dir) / "scripts")
home = Path(os.environ.get("HOME", "")) home = Path(os.environ.get("HOME", ""))
candidates.append(home / ".pouch" / "skills" / "builder" / "scripts")
candidates.append(home / ".skills" / "skills" / "builder" / "scripts") candidates.append(home / ".skills" / "skills" / "builder" / "scripts")
found = next((c for c in candidates if c.is_dir() and any((c / n).is_file() for n in VALID_SCRIPT_NAMES)), None) found = next((c for c in candidates if c.is_dir() and any((c / n).is_file() for n in VALID_SCRIPT_NAMES)), None)
if found: if found:
@@ -270,31 +393,85 @@ def check_script_paths(report: Report) -> None:
report.add(FAIL, 9, "builder 脚本路径可达", "\n".join([ report.add(FAIL, 9, "builder 脚本路径可达", "\n".join([
"none of these resolve to scripts/upload_deb.sh:", "none of these resolve to scripts/upload_deb.sh:",
*(f" {c}" for c in candidates), *(f" {c}" for c in candidates),
"Fix: set BUILDER_SKILL_DIR, or clone the skills repo to ~/.skills.", "Fix: set BUILDER_SKILL_DIR, or clone the pouch repo to ~/.pouch.",
])) ]))
def build_project(project: Path) -> Path | None: def build_project(project: Path) -> Path | None:
"""Run `make deb` for real and return the produced .deb, or None.""" """Run `make -f makefile.builder deb` for real and return the produced .deb, or None."""
result = subprocess.run(["make", "-C", str(project), "deb"], capture_output=True, text=True, timeout=1800, check=False) result = run_make(project, "deb", timeout=1800, dry_run=False)
if result.returncode != 0: if result.returncode != 0:
print(f"--build: `make deb` failed:\n{result.stderr[-2000:]}", file=sys.stderr) print(
f"--build: `make -f {BUILDER_MAKEFILE} deb` failed:\n{result.stderr[-2000:]}",
file=sys.stderr,
)
return None return None
debs = sorted((p for p in (project / "dist").glob("*.deb") if p.is_file()), key=lambda p: p.stat().st_mtime, reverse=True) debs = sorted((p for p in (project / "dist").glob("*.deb") if p.is_file()), key=lambda p: p.stat().st_mtime, reverse=True)
return debs[0] if debs else None return debs[0] if debs else None
MAKEFILE_HINT = (
f"Fix: copy <builder-skill>/templates/{BUILDER_MAKEFILE} to the project "
f"root as {BUILDER_MAKEFILE}. Do not put builder targets in Makefile or "
"makefile. Keep help/build/clean/version, include builder "
"scripts/version.mk, and enable deb/docker/push* for the tracks this "
"project actually uses. Then re-run check.py. Do not use create-makefile."
)
def main(argv: list[str] | None = None) -> int: def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("project", type=Path, help="project directory containing the Makefile") parser.add_argument(
parser.add_argument("--build", action="store_true", help="actually run `make deb` and verify the artifact") "project",
type=Path,
help="project directory containing makefile.builder",
)
parser.add_argument(
"--build",
action="store_true",
help="actually run `make -f makefile.builder deb` and verify the artifact",
)
parser.add_argument(
"--ready",
action="store_true",
help="also check toolchain and publish env key names (init/check mode)",
)
args = parser.parse_args(argv) args = parser.parse_args(argv)
project = args.project.resolve() project = args.project.resolve()
makefile = project / "Makefile" makefile = project / BUILDER_MAKEFILE
if not makefile.is_file(): if not makefile.is_file():
print(f"Error: no Makefile in {project}", file=sys.stderr) if not args.ready:
return 2 print(f"Error: no {BUILDER_MAKEFILE} in {project}", file=sys.stderr)
return 2
report = Report()
report.add(
FAIL,
1,
f"{BUILDER_MAKEFILE} 存在",
f"no {BUILDER_MAKEFILE} in {project}\n{MAKEFILE_HINT}",
)
skip_detail = f"(no {BUILDER_MAKEFILE})"
for number, title, detail in (
(2, "ARCH 守卫与缺省值", skip_detail),
(3, "version 输出一行非空规范版本(无 v 前缀)", skip_detail),
(4, "build 不含上传动作", skip_detail),
(5, "deb 目标产物形状与纯构建", skip_detail),
(6, "docker 目标为本地单平台构建", skip_detail),
(7, "push 仅委托 builder 脚本(薄包装)", skip_detail),
(8, "无内联机密、无隐式 latest/stable", skip_detail),
(9, "builder 脚本路径可达", skip_detail),
):
report.add(SKIP, number, title, detail)
docker_project = detect_docker_project(project)
deb_project = any(project.glob("debian/*"))
check_ready_toolchain(report, deb_project=deb_project, docker_project=docker_project)
check_ready_env_keys(
report, project, deb_project=deb_project, docker_project=docker_project
)
print()
print(f"RESULT: FAILED ({report.failures} check(s) failed)")
return 1
if shutil.which("make") is None: if shutil.which("make") is None:
print("Error: make is required.", file=sys.stderr) print("Error: make is required.", file=sys.stderr)
return 2 return 2
@@ -321,12 +498,12 @@ def main(argv: list[str] | None = None) -> int:
check_build_has_no_upload(report, project) check_build_has_no_upload(report, project)
else: else:
report.add(SKIP, 2, "ARCH 守卫与缺省值", "(build target missing)") report.add(SKIP, 2, "ARCH 守卫与缺省值", "(build target missing)")
report.add(SKIP, 3, "version 输出一行非空版本号", "(version target missing)") report.add(SKIP, 3, "version 输出一行非空规范版本(无 v 前缀)", "(version target missing)")
report.add(SKIP, 4, "build 不含上传动作", "(build target missing)") report.add(SKIP, 4, "build 不含上传动作", "(build target missing)")
if deb_project: if deb_project:
if args.build: if args.build:
print("--build: running `make deb` ...") print(f"--build: running `make -f {BUILDER_MAKEFILE} deb` ...")
built_deb = build_project(project) built_deb = build_project(project)
if built_deb is None: if built_deb is None:
print("--build: no .deb produced; artifact checks degrade to recipe-only.", file=sys.stderr) print("--build: no .deb produced; artifact checks degrade to recipe-only.", file=sys.stderr)
@@ -343,6 +520,13 @@ def main(argv: list[str] | None = None) -> int:
check_push_delegates(report, project, dual) check_push_delegates(report, project, dual)
check_secrets_and_tags(report, project) check_secrets_and_tags(report, project)
check_script_paths(report) check_script_paths(report)
if args.ready:
check_ready_toolchain(
report, deb_project=deb_project, docker_project=docker_project
)
check_ready_env_keys(
report, project, deb_project=deb_project, docker_project=docker_project
)
total_fail = report.failures total_fail = report.failures
print() print()
+30 -11
View File
@@ -6,8 +6,8 @@ usage() {
} }
# Build and publish a Docker image with buildx. Configuration comes from the # Build and publish a Docker image with buildx. Configuration comes from the
# environment first (optionally loaded from the project root .env); flags # environment first (optionally loaded from the project root .env.builder);
# override. # flags override. Does not read `.env`.
# #
# Usage: # Usage:
# publish_docker.sh [--registry HOST] [--repository PATH] [--tag TAG] \ # publish_docker.sh [--registry HOST] [--repository PATH] [--tag TAG] \
@@ -16,7 +16,7 @@ usage() {
# Environment: # Environment:
# DOCKER_REGISTRY Required (or --registry) # DOCKER_REGISTRY Required (or --registry)
# DOCKER_REPOSITORY Optional, default: git repository name (or --repository) # DOCKER_REPOSITORY Optional, default: git repository name (or --repository)
# IMAGE_TAG Optional, default: git describe --tags --always --dirty (or --tag) # IMAGE_TAG Optional, default: version.sh --docker (or --tag)
# PLATFORMS Optional, default: linux/amd64 (or --platform) # PLATFORMS Optional, default: linux/amd64 (or --platform)
# DOCKER_DOCKERFILE Optional, default: Dockerfile (--file) # DOCKER_DOCKERFILE Optional, default: Dockerfile (--file)
# DOCKER_CONTEXT Optional, default: . (--context) # DOCKER_CONTEXT Optional, default: . (--context)
@@ -30,18 +30,19 @@ usage() {
project_root=$(git rev-parse --show-toplevel 2>/dev/null || true) project_root=$(git rev-parse --show-toplevel 2>/dev/null || true)
# Load project .env without printing values; explicitly exported shell values keep precedence. # Load .env.builder without printing values; shell values win. Do not read `.env`.
if [[ -n "$project_root" && -f "$project_root/.env" ]]; then if [[ -n "$project_root" && -f "$project_root/.env.builder" ]]; then
while IFS='=' read -r key value; do while IFS='=' read -r key value; do
key=${key%%[[:space:]]*} key=${key%%[[:space:]]*}
[[ -z "$key" || "$key" == \#* ]] && continue [[ -z "$key" || "$key" == \#* ]] && continue
if [[ -n "${!key:-}" ]]; then if [[ -n "${!key:-}" ]]; then
continue # shell value already set: wins over .env continue # shell value already set: wins over .env.builder
fi fi
value=${value%\"}; value=${value#\"}; value=${value%\'}; value=${value#\'} value=${value%\"}; value=${value#\"}; value=${value%\'}; value=${value#\'}
[[ -z "$value" ]] && continue
printf -v "$key" '%s' "$value" printf -v "$key" '%s' "$value"
export "$key" export "$key"
done < <(grep -v '^[[:space:]]*$' "$project_root/.env") done < <(grep -v '^[[:space:]]*$' "$project_root/.env.builder")
fi fi
git_repo_name= git_repo_name=
@@ -81,7 +82,7 @@ if [[ -n "$registry" && ( "$registry" == *://* || "$registry" == */* ) ]]; then
fi fi
if [[ -z "$registry" ]]; then if [[ -z "$registry" ]]; then
echo "Error: DOCKER_REGISTRY (or --registry) is required." >&2 echo "Error: DOCKER_REGISTRY (or --registry) is required." >&2
echo "Set it in the environment or the project root .env." >&2 echo "Set it in the environment or the project root .env.builder." >&2
usage >&2 usage >&2
exit 2 exit 2
fi fi
@@ -89,19 +90,37 @@ if [[ -z "$repository" || "$repository" == /* || "$repository" == */ || "$reposi
echo "Error: repository must be namespace/name without leading or trailing slash: $repository" >&2 echo "Error: repository must be namespace/name without leading or trailing slash: $repository" >&2
exit 2 exit 2
fi fi
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
version_sh=$script_dir/version.sh
if [[ -z "$tag" ]]; then if [[ -z "$tag" ]]; then
if [[ -n "$project_root" ]]; then if [[ ! -x "$version_sh" ]]; then
tag=$(git -C "$project_root" describe --tags --always --dirty 2>/dev/null) || tag= echo "Error: version.sh not found next to publish_docker.sh: $version_sh" >&2
exit 2
fi fi
if [[ -z "$tag" ]]; then if [[ -z "$project_root" ]]; then
echo "Error: IMAGE_TAG (or --tag) is required outside a git repository." >&2 echo "Error: IMAGE_TAG (or --tag) is required outside a git repository." >&2
exit 2 exit 2
fi fi
tag=$("$version_sh" -C "$project_root" --docker) || {
echo "Error: failed to derive IMAGE_TAG from Git ancestry." >&2
exit 2
}
fi fi
if [[ "$tag" == *:* || "$tag" == */* ]]; then if [[ "$tag" == *:* || "$tag" == */* ]]; then
echo "Error: tag must not contain : or /: $tag" >&2 echo "Error: tag must not contain : or /: $tag" >&2
exit 2 exit 2
fi fi
# Official-shaped tags (X.Y.Z or vX.Y.Z) are only legal on that exact Git tag.
if [[ "$tag" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ && -x "$version_sh" && -n "$project_root" ]]; then
derived=$("$version_sh" -C "$project_root" --docker) || true
expected=${tag#v}
if [[ "$derived" != "$expected" ]]; then
echo "Error: IMAGE_TAG $tag looks official but HEAD is $derived" >&2
echo "Official X.Y.Z is allowed only when HEAD exact-matches vX.Y.Z." >&2
exit 2
fi
fi
if [[ "$tag" == latest && ${ALLOW_LATEST:-0} != 1 && "$mode" == push ]]; then if [[ "$tag" == latest && ${ALLOW_LATEST:-0} != 1 && "$mode" == push ]]; then
echo "Error: refusing to publish floating tag 'latest'; pass an explicit version." >&2 echo "Error: refusing to publish floating tag 'latest'; pass an explicit version." >&2
echo "Set ALLOW_LATEST=1 only when the user explicitly asked for 'latest'." >&2 echo "Set ALLOW_LATEST=1 only when the user explicitly asked for 'latest'." >&2
+10 -9
View File
@@ -15,9 +15,9 @@ Options:
-p UPLOAD_PATH Override DEB_UPLOAD_PATH (default: /api/v2/upload/package) -p UPLOAD_PATH Override DEB_UPLOAD_PATH (default: /api/v2/upload/package)
-h Show help -h Show help
Environment variables may live in the project root .env; this script walks up Environment variables may live in the project root .env.builder; this script
from the current directory, loads it silently (existing shell values win), and loads it silently (existing shell values win), never echoes values, and does
never echoes variable values. The endpoint must accept multipart fields named not read `.env`. The endpoint must accept multipart fields named
package, token, and repository_name. Authentication is read only from package, token, and repository_name. Authentication is read only from
DEB_TOKEN so it is not exposed in the process command line. DEB_TOKEN so it is not exposed in the process command line.
@@ -25,21 +25,22 @@ The working tree must be clean to publish; set ALLOW_UNCOMMITTED=1 to override.
EOF EOF
} }
# Locate project root (.git) upward from cwd for .env loading and git checks. # Locate project root (.git) upward from cwd for .env.builder loading and git checks.
project_root=$(git rev-parse --show-toplevel 2>/dev/null || true) project_root=$(git rev-parse --show-toplevel 2>/dev/null || true)
# Load project .env without printing values; explicitly exported shell values keep precedence. # Load .env.builder without printing values; shell values win. Do not read `.env`.
if [[ -n "$project_root" && -f "$project_root/.env" ]]; then if [[ -n "$project_root" && -f "$project_root/.env.builder" ]]; then
while IFS='=' read -r key value; do while IFS='=' read -r key value; do
key=${key%%[[:space:]]*} key=${key%%[[:space:]]*}
[[ -z "$key" || "$key" == \#* ]] && continue [[ -z "$key" || "$key" == \#* ]] && continue
if [[ -n "${!key:-}" ]]; then if [[ -n "${!key:-}" ]]; then
continue # shell value already set: wins over .env continue # shell value already set: wins over .env.builder
fi fi
value=${value%\"}; value=${value#\"}; value=${value%\'}; value=${value#\'} value=${value%\"}; value=${value#\"}; value=${value%\'}; value=${value#\'}
[[ -z "$value" ]] && continue
printf -v "$key" '%s' "$value" printf -v "$key" '%s' "$value"
export "$key" export "$key"
done < <(grep -v '^[[:space:]]*$' "$project_root/.env") done < <(grep -v '^[[:space:]]*$' "$project_root/.env.builder")
fi fi
server_url=${DEB_SERVER_URL:-} server_url=${DEB_SERVER_URL:-}
@@ -61,7 +62,7 @@ shift $((OPTIND - 1))
if [[ -z "$server_url" || -z "$repository" || -z "$token" || $# -eq 0 ]]; then if [[ -z "$server_url" || -z "$repository" || -z "$token" || $# -eq 0 ]]; then
echo "Error: DEB_SERVER_URL, DEB_TOKEN, DEB_REPOSITORY, and at least one file are required." >&2 echo "Error: DEB_SERVER_URL, DEB_TOKEN, DEB_REPOSITORY, and at least one file are required." >&2
echo "Set them in the environment or the project root .env." >&2 echo "Set them in the environment or the project root .env.builder." >&2
usage >&2 usage >&2
exit 2 exit 2
fi fi
+42
View File
@@ -0,0 +1,42 @@
# Include from makefile.builder. Sets VERSION (canonical, no leading v)
# and IMAGE_TAG (Docker rendering) via builder version.sh.
#
# Command-line / environment VERSION= is passed as --version (official X.Y.Z
# only when HEAD exact-matches that tag). Unset or empty VERSION is derived.
#
# include $(HOME)/.pouch/skills/builder/scripts/version.mk
_builder_scripts_dir := $(dir $(lastword $(MAKEFILE_LIST)))
ifeq ($(BUILDER_VERSION_SH),)
BUILDER_VERSION_SH := $(wildcard $(_builder_scripts_dir)version.sh)
endif
ifeq ($(BUILDER_VERSION_SH),)
ifneq ($(BUILDER_SKILL_DIR),)
BUILDER_VERSION_SH := $(wildcard $(BUILDER_SKILL_DIR)/scripts/version.sh)
endif
endif
ifeq ($(BUILDER_VERSION_SH),)
BUILDER_VERSION_SH := $(wildcard $(HOME)/.pouch/skills/builder/scripts/version.sh)
endif
ifeq ($(BUILDER_VERSION_SH),)
BUILDER_VERSION_SH := $(wildcard $(HOME)/.skills/skills/builder/scripts/version.sh)
endif
ifeq ($(BUILDER_VERSION_SH),)
$(error version.sh not found; set BUILDER_SKILL_DIR or clone pouch to ~/.pouch)
endif
ifeq ($(filter command line environment,$(origin VERSION)),)
VERSION := $(shell "$(BUILDER_VERSION_SH)")
else ifeq ($(strip $(VERSION)),)
VERSION := $(shell "$(BUILDER_VERSION_SH)")
else
VERSION := $(shell "$(BUILDER_VERSION_SH)" --version "$(VERSION)")
endif
ifeq ($(strip $(VERSION)),)
$(error version.sh produced an empty version)
endif
ifeq ($(origin IMAGE_TAG),undefined)
IMAGE_TAG := $(shell "$(BUILDER_VERSION_SH)" --docker --version "$(VERSION)")
endif
+195
View File
@@ -0,0 +1,195 @@
#!/usr/bin/env bash
set -euo pipefail
usage() {
cat <<'EOF'
Usage:
version.sh [-C GIT_DIR] [--docker] [--version VER]
Print one line: the canonical artifact version (Debian Version, no leading v).
With --docker, print the Docker tag rendering of that version.
Derivation (builder contract «版本号»):
official HEAD exact-match of vX.Y.Z → X.Y.Z
test nearest ancestor stable tag → X.Y.Z~branch.n+gSHA
no tag no stable tag reachable from HEAD → 0.0.0~branch+gSHA
Stable tags match v<major>.<minor>.<patch> only. Baseline is ancestry, not
the highest version in the repository. This script does not fetch tags.
--version VER overrides derivation. Official-shaped VER (X.Y.Z, optional
leading v) is accepted only when HEAD exact-matches that tag. Test-shaped
VER is used as-is.
Branch name: git symbolic-ref, or BUILD_BRANCH / CI_COMMIT_BRANCH /
GITHUB_REF_NAME when detached, else "detached". Sanitized to [a-z0-9-],
max 32 characters.
EOF
}
root=.
mode=canonical
override=
while (($#)); do
case "$1" in
-C) root=$2; shift 2 ;;
--docker) mode=docker; shift ;;
--version) override=$2; shift 2 ;;
-h|--help) usage; exit 0 ;;
*) echo "Error: unknown argument: $1" >&2; usage >&2; exit 2 ;;
esac
done
if ! git -C "$root" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "Error: not a git repository: $root" >&2
exit 2
fi
root=$(git -C "$root" rev-parse --show-toplevel)
gitc() {
git -C "$root" "$@"
}
is_stable_tag() {
[[ "$1" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]
}
is_official_version() {
[[ "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
}
# Strip one leading v if present.
strip_v() {
local v=$1
if [[ "$v" == v* ]]; then
v=${v#v}
fi
printf '%s' "$v"
}
sanitize_branch() {
local b=$1
b=$(printf '%s' "$b" | tr '[:upper:]' '[:lower:]')
b=${b//\//-}
b=${b//_/-}
b=$(printf '%s' "$b" | tr -cd 'a-z0-9-')
b=$(printf '%s' "$b" | tr -s '-')
b=${b#-}
b=${b%-}
if ((${#b} > 32)); then
b=${b:0:32}
b=${b%-}
fi
if [[ -z "$b" ]]; then
b=unknown
fi
printf '%s' "$b"
}
branch_slug() {
local b
b=$(gitc rev-parse --abbrev-ref HEAD)
if [[ "$b" == HEAD ]]; then
b=${BUILD_BRANCH:-${CI_COMMIT_BRANCH:-${GITHUB_REF_NAME:-detached}}}
fi
sanitize_branch "$b"
}
short_sha() {
gitc rev-parse HEAD | cut -c1-7
}
# Highest stable tag pointing at HEAD, or empty.
official_tag_at_head() {
local tag best=
while IFS= read -r tag; do
[[ -n "$tag" ]] || continue
is_stable_tag "$tag" || continue
if [[ -z "$best" ]]; then
best=$tag
elif printf '%s\n%s\n' "$best" "$tag" | sort -V | tail -n 1 | grep -qx "$tag"; then
best=$tag
fi
done < <(gitc tag --points-at HEAD)
printf '%s' "$best"
}
# Stable ancestor tag with the fewest commits to HEAD (not sort -V globally).
nearest_stable_tag() {
local tag dist best_dist="" best_tag=""
while IFS= read -r tag; do
[[ -n "$tag" ]] || continue
is_stable_tag "$tag" || continue
dist=$(gitc rev-list --count "${tag}..HEAD")
if [[ -z "$best_dist" ]] || ((dist < best_dist)); then
best_dist=$dist
best_tag=$tag
elif ((dist == best_dist)); then
if printf '%s\n%s\n' "$best_tag" "$tag" | sort -V | tail -n 1 | grep -qx "$tag"; then
best_tag=$tag
fi
fi
done < <(gitc tag --merged HEAD)
printf '%s' "$best_tag"
}
derive_canonical() {
local tag base n sha branch
tag=$(official_tag_at_head)
if [[ -n "$tag" ]]; then
printf '%s' "${tag#v}"
return
fi
sha=$(short_sha)
branch=$(branch_slug)
base=$(nearest_stable_tag)
if [[ -z "$base" ]]; then
printf '0.0.0~%s+g%s' "$branch" "$sha"
return
fi
n=$(gitc rev-list --count "${base}..HEAD")
printf '%s~%s.%s+g%s' "${base#v}" "$branch" "$n" "$sha"
}
to_docker() {
local v=$1
v=${v//\~/-}
v=${v//+g/.g}
printf '%s' "$v"
}
canonical=
if [[ -n "$override" ]]; then
canonical=$(strip_v "$override")
if [[ "$canonical" == *'_'* ]]; then
echo "Error: version must not contain '_': $canonical" >&2
exit 2
fi
if is_official_version "$canonical"; then
derived=$(derive_canonical)
if [[ "$derived" != "$canonical" ]]; then
echo "Error: --version $canonical looks official but HEAD is $derived" >&2
echo "Official X.Y.Z is allowed only when HEAD exact-matches vX.Y.Z." >&2
exit 2
fi
fi
else
canonical=$(derive_canonical)
fi
if [[ -z "$canonical" ]]; then
echo "Error: empty version" >&2
exit 1
fi
if [[ "$mode" == docker ]]; then
tag=$(to_docker "$canonical")
if [[ "$tag" == *:* || "$tag" == */* || "$tag" == *'~'* ]]; then
echo "Error: docker tag still contains illegal characters: $tag" >&2
exit 1
fi
printf '%s\n' "$tag"
else
printf '%s\n' "$canonical"
fi
+13
View File
@@ -0,0 +1,13 @@
# Builder publish credentials. Copy to the project root as `.env.builder`.
# Do not commit this file. Do not put these keys in the project's `.env`.
# Uncomment and fill the keys for tracks this project uses.
# Shell-exported values override this file.
#
# DEB_SERVER_URL=
# DEB_TOKEN=
# DEB_REPOSITORY=
# DEB_UPLOAD_PATH=
# DOCKER_REGISTRY=
# DOCKER_REPOSITORY=
# IMAGE_TAG=
# PLATFORMS=
+60
View File
@@ -0,0 +1,60 @@
# Builder 契约文件。放到项目根,用 `make -f makefile.builder <target>`。
# 不要把这些目标写进用户的 Makefile / makefile。
# 初始化时按项目轨道删掉未使用的 deb / docker 段。
# 把 build 的 TODO 换成真实编译命令;禁止在 build / deb / docker 里上传。
#
# include 路径见 references/contract.md。测试或非标准安装可设 BUILDER_SKILL_DIR。
ARCH ?= amd64
ifneq ($(filter $(ARCH),amd64 arm64),$(ARCH))
$(error ARCH must be amd64 or arm64)
endif
PROJECT_NAME ?= $(notdir $(CURDIR))
DIST_DIR ?= dist
ifneq ($(BUILDER_SKILL_DIR),)
include $(BUILDER_SKILL_DIR)/scripts/version.mk
else
include $(HOME)/.pouch/skills/builder/scripts/version.mk
endif
BUILDER_SCRIPTS := $(or $(BUILDER_SKILL_DIR),$(HOME)/.pouch/skills/builder)/scripts
.PHONY: help version clean build deb docker push push-deb push-docker
help:
@echo "$(PROJECT_NAME) $(VERSION)"
@echo " make -f makefile.builder build [ARCH=amd64|arm64] - 构建主产物 / build"
@echo " make -f makefile.builder version - 打印规范版本 / canonical version"
@echo " make -f makefile.builder clean - 删除 $(DIST_DIR)"
@echo " make -f makefile.builder deb - 打 DEB(只构建不上传)"
@echo " make -f makefile.builder docker - 本地单平台镜像"
@echo " make -f makefile.builder push / push-deb / push-docker"
version:
@echo $(VERSION)
clean:
rm -rf $(DIST_DIR)
# 替换为项目真实构建命令。不得 curl/scp/docker push。
build:
mkdir -p $(DIST_DIR)
@echo "TODO: build $(PROJECT_NAME) for linux/$(ARCH)"
deb: build
mkdir -p $(DIST_DIR)
dpkg-deb --build packaging $(DIST_DIR)/$(PROJECT_NAME)_$(VERSION)_$(ARCH).deb
docker:
docker build --platform=linux/$(ARCH) -t $(PROJECT_NAME):$(IMAGE_TAG) .
push-deb:
$(BUILDER_SCRIPTS)/upload_deb.sh $(DIST_DIR)/$(PROJECT_NAME)_$(VERSION)_$(ARCH).deb
push-docker:
$(BUILDER_SCRIPTS)/publish_docker.sh
# 单产物项目只保留一条 push。双产物改为:push: push-deb push-docker
push: push-deb
+14 -9
View File
@@ -5,19 +5,20 @@
支持三种用法: 支持三种用法:
- **独立配置中心**:一个专门的 Git 仓库管所有机器的所有 Compose 服务(如 app00) - **独立配置中心**:一个专门的 Git 仓库管所有机器的所有 Compose 服务(如 app00)
- **项目内 Compose 环境**:在普通项目里放 `.skiff/deployer/{prod,test,dev}/`, - **项目内 Compose 环境**:在普通项目里放 `.pouch/deployer/{prod,test,dev}/`,
把这个项目的生产/测试/开发环境用 rsync + docker compose 部署 把这个项目的生产/测试/开发环境用 rsync + docker compose 部署
- **Argo CD / GitOps**:项目里放 `.skiff/deployer/argocd.yaml`;Agent 改 GitOps 并开 MR, - **Argo CD / GitOps**:项目里放 `.pouch/deployer/argocd.yaml`;Agent 改 GitOps 并开 MR,
你合并后由 Argo CD 同步。仓库既可以只写 Git 地址(部署时浅 clone),也可以指定本机已有目录。 你合并后由 Argo CD 同步。仓库既可以只写 Git 地址(部署时浅 clone),也可以指定本机已有目录。
## 什么时候使用 ## 什么时候使用
- 给新项目初始化 deployer:检查缺什么,引导补 `.pouch/deployer/`
- 想用一套固定流程把本地改好的 Docker Compose 配置发到某台服务器 - 想用一套固定流程把本地改好的 Docker Compose 配置发到某台服务器
- 要升级某个服务的镜像版本、重启服务、看远程容器状态和日志 - 要升级某个服务的镜像版本、重启服务、看远程容器状态和日志
- 有编译好的 .deb 包要装到某台机器上(scp 上传安装,或从 URL 直接拉) - 有编译好的 .deb 包要装到某台机器上(scp 上传安装,或从 URL 直接拉)
- 新加一个服务、把服务从一台机器挪到另一台、或下线旧服务 - 新加一个服务、把服务从一台机器挪到另一台、或下线旧服务
- 想给当前项目加 prod/test/dev 三套远程环境并随时部署其中一套 - 想给当前项目加 prod/test/dev 三套远程环境并随时部署其中一套
- ACK 说「重新布测试环境」或跑回归前要先拉起 `.skiff/deployer/test` - ACK 说「重新布测试环境」或跑回归前要先拉起 `.pouch/deployer/test`
- 需要一张「哪台机器跑哪些服务」的清单 - 需要一张「哪台机器跑哪些服务」的清单
- 镜像要进 Kubernetes,走 Argo CD:改 GitOps、开 MR、合并后部署 - 镜像要进 Kubernetes,走 Argo CD:改 GitOps、开 MR、合并后部署
@@ -30,6 +31,10 @@
## 使用示例 ## 使用示例
```text ```text
# 新项目
用 deployer 初始化这个项目
给这个项目接上 test 环境,SSH 别名是 my-vps
# 独立配置中心 # 独立配置中心
帮我把 vyyo1/naiveproxy 的配置改完部署上去 帮我把 vyyo1/naiveproxy 的配置改完部署上去
升级 vora3/gpt-load 的镜像版本 升级 vora3/gpt-load 的镜像版本
@@ -43,7 +48,7 @@ vhom1 上那个 naiveproxy 为什么 sync 失败?
web1 能出网,直接让它从 https://... 把包拉下来装 web1 能出网,直接让它从 https://... 把包拉下来装
# 项目内环境 # 项目内环境
给这个项目建好 .skiff/deployer,prod 和 test 分别放到两台机器上 给这个项目建好 .pouch/deployer,prod 和 test 分别放到两台机器上
把 test 环境重新部署一下 把 test 环境重新部署一下
prod 的 compose 加个 redis,改完发上去 prod 的 compose 加个 redis,改完发上去
@@ -56,13 +61,13 @@ GitOps 我已经 clone 在 ../infra-gitops,用那个目录开 MR
## Agent 会做什么 ## Agent 会做什么
1. 读服务/环境目录(及共享的父目录)的 `_config.yaml`,确定目标机器和远程路径; 1. 读服务/环境目录(及共享的父目录)的 `_config.yaml`,确定目标机器和远程路径;
项目内布局从 `.skiff/deployer/` 自动发现,无需额外配置 项目内布局从 `.pouch/deployer/` 自动发现,无需额外配置
2. 用 skill 自带脚本把本地目录同步到远程(rsync,自动排除 `data/`、`_data/`) 2. 用 skill 自带脚本把本地目录同步到远程(rsync,自动排除 `data/`、`_data/`)
3. 在远程执行对应的 `docker compose` 操作(启动 / 重建 / 升级 / 重启) 3. 在远程执行对应的 `docker compose` 操作(启动 / 重建 / 升级 / 重启)
4. deb 包安装走独立脚本:scp 上传到暂存目录后远程 apt 安装,失败自动修依赖 4. deb 包安装走独立脚本:scp 上传到暂存目录后远程 apt 安装,失败自动修依赖
5. 同步后查看容器状态和日志确认生效 5. 同步后查看容器状态和日志确认生效
6. 只针对你指定的那一个服务操作,不会批量动整台机器 6. 只针对你指定的那一个服务操作,不会批量动整台机器
7. Argo CD:读 `.skiff/deployer/argocd.yaml`,浅 clone 或使用 `repo_dir`,改清单,推分支开 MR,停下来等你合并; 7. Argo CD:读 `.pouch/deployer/argocd.yaml`,浅 clone 或使用 `repo_dir`,改清单,推分支开 MR,停下来等你合并;
不直接 kubectl 发布,不把 Harbor/TLS 密钥提交进 Git 不直接 kubectl 发布,不把 Harbor/TLS 密钥提交进 Git
项目内布局下,远程目录名自动带上项目前缀(如 `my-project-prod`), 项目内布局下,远程目录名自动带上项目前缀(如 `my-project-prod`),
@@ -81,14 +86,14 @@ GitOps 我已经 clone 在 ../infra-gitops,用那个目录开 MR
## Argo CD 的两种接法 ## Argo CD 的两种接法
在业务项目里放 `.skiff/deployer/argocd.yaml`。Agent 只改 GitOps 并开 MR,**你合并之后** Argo CD 才部署。镜像、namespace、域名、Secret 名以 GitOps 清单为准,不必在这个文件里再抄一遍。 在业务项目里放 `.pouch/deployer/argocd.yaml`。Agent 只改 GitOps 并开 MR,**你合并之后** Argo CD 才部署。镜像、namespace、域名、Secret 名以 GitOps 清单为准,不必在这个文件里再抄一遍。
### 1. 只写仓库地址(默认) ### 1. 只写仓库地址(默认)
本机不用长期放 GitOps 仓库。部署时 Agent 浅 clone 到临时目录,改完开 MR,用完删掉。 本机不用长期放 GitOps 仓库。部署时 Agent 浅 clone 到临时目录,改完开 MR,用完删掉。
```yaml ```yaml
# .skiff/deployer/argocd.yaml # .pouch/deployer/argocd.yaml
repo: git@git.example.com:org/infra-gitops.git repo: git@git.example.com:org/infra-gitops.git
``` ```
@@ -106,7 +111,7 @@ repo: git@git.example.com:org/infra-gitops.git
GitOps 仓库已经 checkout 在旁边时,写 `repo_dir`,Agent 直接进这个目录改、推分支、开 MR。 GitOps 仓库已经 checkout 在旁边时,写 `repo_dir`,Agent 直接进这个目录改、推分支、开 MR。
```yaml ```yaml
# .skiff/deployer/argocd.yaml # .pouch/deployer/argocd.yaml
repo: git@git.example.com:org/infra-gitops.git repo: git@git.example.com:org/infra-gitops.git
repo_dir: ../infra-gitops repo_dir: ../infra-gitops
``` ```
+79 -19
View File
@@ -1,13 +1,14 @@
--- ---
name: deployer name: deployer
description: >- description: >-
管理两类部署:多机 Docker Compose(仓库存 compose.yaml 与静态配置,本 skill 脚本 初始化或检查项目部署配置,并管理两类部署:多机 Docker Compose(仓库存
同步到 SSH 节点后 docker compose 应用),以及 Argo CD GitOps(改 GitOps 仓库清单、 compose.yaml 与静态配置,本 skill 脚本同步到 SSH 节点后 docker compose 应用),
开 PR/MR,用户合并后由 Argo CD 同步)。当用户要求部署、同步、升级、重启远程 以及 Argo CD GitOps(改 GitOps 仓库清单、开 PR/MR,用户合并后由 Argo CD 同步)。
Compose 服务,向节点装 deb,新增/迁移/下线服务,梳理节点清单,make deploy TGT、 当用户要求初始化 deployer、接入测试/生产环境、检查 .pouch/deployer 是否齐全;
_config.yaml、rsync、tar over SSH、NAS 部署失败;或要求 ArgoCD / GitOps / K8s 或部署、同步、升级、重启远程 Compose 服务,向节点装 deb,新增/迁移/下线服务,
部署、更新 Application、升镜像 tag、开 MR 让用户合并部署;或 ACK 要求拉起/ 梳理节点清单,make deploy TGT、_config.yaml、rsync、tar over SSH、NAS 部署失败;
重布项目测试环境时使用。 或要求 ArgoCD / GitOps / K8s 部署、更新 Application、升镜像 tag、开 MR 让用户
合并部署;或 ACK 要求拉起/重布项目测试环境时使用。
--- ---
# deployer:Compose 节点与 Argo CD GitOps # deployer:Compose 节点与 Argo CD GitOps
@@ -18,7 +19,16 @@ description: >-
- **Argo CD**:改 GitOps 仓库清单 → 开 PR/MR → 用户合并 → Argo CD 同步。不要用 - **Argo CD**:改 GitOps 仓库清单 → 开 PR/MR → 用户合并 → Argo CD 同步。不要用
Compose 的 `sync.py`/`remote.py` 去推集群。 Compose 的 `sync.py`/`remote.py` 去推集群。
--- 开始时解析当前 `SKILL.md` 所在目录,记为 `<skill-dir>`。优先
`git rev-parse --show-toplevel` 解析项目根。不要创建 `.pouch/deployer/` 之外的
假配置中心,也不要用 `pouch init deployer`。
## 选择模式
- 用户要求初始化、接入 deployer,或给新项目建测试/生产环境:执行“初始化”。
- 用户要求检查 `.pouch/deployer`、node、compose 是否齐全:执行“检查”。
- 用户要求部署、同步、升级、重启、装 deb、开 GitOps MR:执行下面对应轨道步骤。
发现不了服务或解析不出 node 时停止,转入“初始化”。不要静默初始化。
## 何时使用 ## 何时使用
@@ -28,7 +38,8 @@ description: >-
- sync 失败排查、证书丢失、改了配置不生效等运维问题 - sync 失败排查、证书丢失、改了配置不生效等运维问题
- 提到 `make deploy TGT=...`、`TGT=`、`_config.yaml`、rsync/tar 同步 - 提到 `make deploy TGT=...`、`TGT=`、`_config.yaml`、rsync/tar 同步
- Argo CD / GitOps / 集群部署:新增 Application、改清单、升镜像 tag、开 MR 等用户合并 - Argo CD / GitOps / 集群部署:新增 Application、改清单、升镜像 tag、开 MR 等用户合并
- ACK Coordinator 拉起或重布项目测试环境(`.skiff/deployer/<env>`) - ACK Coordinator 拉起或重布项目测试环境(`.pouch/deployer/<env>`)
- 初始化 deployer、给项目接上 test/prod、检查部署配置缺什么
## 不适用 ## 不适用
@@ -44,7 +55,7 @@ description: >-
| 信号 | 轨道 | | 信号 | 轨道 |
|------|------| |------|------|
| ArgoCD / GitOps / 集群 / 开 MR 部署 / 项目有 `.skiff/deployer/argocd.yaml` | Argo CD,见 [argocd.md](references/argocd.md) | | ArgoCD / GitOps / 集群 / 开 MR 部署 / 项目有 `.pouch/deployer/argocd.yaml` | Argo CD,见 [argocd.md](references/argocd.md) |
| sync、`TGT=`、某台机器、`compose.yaml` | Compose(下文布局与步骤) | | sync、`TGT=`、某台机器、`compose.yaml` | Compose(下文布局与步骤) |
| 两者都有且意图不清 | 先问 | | 两者都有且意图不清 | 先问 |
@@ -59,7 +70,7 @@ description: >-
### Argo CD ### Argo CD
源项目 `.skiff/deployer/argocd.yaml`:`repo` 写 Git 地址(部署时浅 clone),或加 `repo_dir` 用已有 checkout。 源项目 `.pouch/deployer/argocd.yaml`:`repo` 写 Git 地址(部署时浅 clone),或加 `repo_dir` 用已有 checkout。
改 GitOps 清单,不要改 Compose 脚本。密钥不入库。两种接法见 skill README,步骤见 [argocd.md](references/argocd.md)。 改 GitOps 清单,不要改 Compose 脚本。密钥不入库。两种接法见 skill README,步骤见 [argocd.md](references/argocd.md)。
### 两种 Compose 布局 ### 两种 Compose 布局
@@ -77,14 +88,14 @@ repo/
远程目录名 = 目录末级名:`vyyo1/naiveproxy` → `/opt/app/naiveproxy`。 远程目录名 = 目录末级名:`vyyo1/naiveproxy` → `/opt/app/naiveproxy`。
**B. 项目内环境布局**:项目根放 `.skiff/deployer/{prod,test,dev}/`, **B. 项目内环境布局**:项目根放 `.pouch/deployer/{prod,test,dev}/`,
每个环境一个目录。从项目内任意位置运行脚本即自动发现(也可用 `DEPLOYER_ROOT` 每个环境一个目录。从项目内任意位置运行脚本即自动发现(也可用 `DEPLOYER_ROOT`
显式指定),无需环境变量: 显式指定),无需环境变量:
``` ```
my-project/ my-project/
├── src/ ... # 项目本体 ├── src/ ... # 项目本体
└── .skiff/deployer/ └── .pouch/deployer/
├── _config.yaml # 三个环境共享默认(node/base_path 等) ├── _config.yaml # 三个环境共享默认(node/base_path 等)
├── argocd.yaml # 可选,Argo CD 指针(不是 compose 环境) ├── argocd.yaml # 可选,Argo CD 指针(不是 compose 环境)
├── prod/ ├── prod/
@@ -98,10 +109,58 @@ my-project/
(如 `my-project-prod`),防止同主机多项目的同名环境互相覆盖; (如 `my-project-prod`),防止同主机多项目的同名环境互相覆盖;
`_config.yaml` 写 `name:` 可显式指定。 `_config.yaml` 写 `name:` 可显式指定。
## 初始化
独立配置中心仓库(已设 `DEPLOYER_ROOT`)只做检查,不要改成项目内布局。
1. 探测:`.pouch/deployer/`、根目录 `compose.yaml`/`docker-compose.yml`、
`Dockerfile`、ACK `intents.testEnvironment`、`.pouch/deployer/argocd.yaml`。
2. Compose 与 Argo 都有且意图不清:先问。两边都要也可以,必须分开确认。
3. **Compose / 新项目**(ACK 默认需要 `test`):
- 问环境:默认只建 `test`。`prod`/`dev` 用户点名再加。不默默建空的 prod。
- 问 SSH Host 别名(必须在 `~/.ssh/config`)。没给就**不要写假 node**;
目录可以建,`_config.yaml` 列为待配置。
- 有根目录 compose:提议迁到 `.pouch/deployer/<env>/`,确认后才动。
- 只有 Dockerfile:可给**单服务** compose 草稿(镜像名来自仓库名),用户确认
后写入。不发明多服务网格。
4. **Argo**:只问 GitOps `repo`(或 `repo_dir`),写 `.pouch/deployer/argocd.yaml`。
不 clone、不开 MR、不 `kubectl apply`。
5. 运行(不 SSH、不 up):
```bash
python3 -I -S <skill-dir>/scripts/deploy/check.py --project <project-root>
```
6. 按下面格式报告。缺 `node` / compose / ssh 别名 = 部分完成或阻塞。
不覆盖已有 compose/`_config.yaml`。除非用户明确要求,不部署、不提交。
```text
## deployer 初始化:完成 | 部分完成 | 阻塞
已具备: …
待配置: 路径 + 字段 + 可粘贴示例 + 缺了会挡住哪步
工具链: ssh / rsync(缺则怎么装,不擅自安装)
下一步: 一句话
```
`_config.yaml` 示例(`node` 必须是用户给出的 SSH Host 别名):
```yaml
# .pouch/deployer/_config.yaml
node: my-vps
base_path: /opt/app
```
## 检查
只读。运行 `scripts/deploy/check.py --project <project-root>`,用同一报告格式,
标题改为 `## deployer 检查:…`。不写文件、不 SSH 连接。用户明确要求修复后再转入
初始化。
## 被 ACK 调用 ## 被 ACK 调用
ACK 的「运行测试环境」和回归前布环境会加载本 skill,对项目 ACK 的「运行测试环境」和回归前布环境会加载本 skill,对项目
`.skiff/deployer/<env>`(通常是 `test`)按下面 Compose 轨道执行。ACK 只负责何时 `.pouch/deployer/<env>`(通常是 `test`)按下面 Compose 轨道执行。ACK 只负责何时
布、把访问地址写入 `deliveryRuns`;不要把本 skill 的脚本复制进 ACK。生产环境、 布、把访问地址写入 `deliveryRuns`;不要把本 skill 的脚本复制进 ACK。生产环境、
Argo CD 合入和节点级批量操作仍须用户明确要求,不能因为 ACK 调用就扩大范围。 Argo CD 合入和节点级批量操作仍须用户明确要求,不能因为 ACK 调用就扩大范围。
@@ -115,7 +174,7 @@ skill 目录下的 `scripts/deploy/` 是通用部署工具链(lib/sync/remote/
不依赖具体项目路径。部署根按以下顺序解析: 不依赖具体项目路径。部署根按以下顺序解析:
1. 环境变量 `DEPLOYER_ROOT` 显式指定(独立配置中心仓库用这个) 1. 环境变量 `DEPLOYER_ROOT` 显式指定(独立配置中心仓库用这个)
2. 从当前目录向上找 `.skiff/deployer/`(项目内环境布局自动发现) 2. 从当前目录向上找 `.pouch/deployer/`(项目内环境布局自动发现)
3. skill 安装位置兜底(仅用于查看,没有可部署服务) 3. skill 安装位置兜底(仅用于查看,没有可部署服务)
```bash ```bash
@@ -171,9 +230,9 @@ python3 <skill-dir>/scripts/deploy/sync.py <service-path>
项目环境布局: 项目环境布局:
1. 项目根建 `.skiff/deployer/{env}/`(env 通常为 prod/test/dev) 1. 项目根建 `.pouch/deployer/{env}/`(env 通常为 prod/test/dev)
2. 每个环境写 `compose.yaml`;三个环境共享的 node/base_path 放 2. 每个环境写 `compose.yaml`;三个环境共享的 node/base_path 放
`.skiff/deployer/_config.yaml` `.pouch/deployer/_config.yaml`
3. 环境有差异(不同主机、不同排除项)→ 在该环境的 `_config.yaml` 覆盖 3. 环境有差异(不同主机、不同排除项)→ 在该环境的 `_config.yaml` 覆盖
4. 同名冲突或需要固定远程目录名 → `_config.yaml` 写 `name:` 4. 同名冲突或需要固定远程目录名 → `_config.yaml` 写 `name:`
5. 首次部署前确认目标主机的远程目录不存在旧内容(rsync `--delete` 会清掉) 5. 首次部署前确认目标主机的远程目录不存在旧内容(rsync `--delete` 会清掉)
@@ -182,7 +241,7 @@ python3 <skill-dir>/scripts/deploy/sync.py <service-path>
独立仓库布局:配置移入 `unused/`(自动脱离发现体系),远程按需手动清理: 独立仓库布局:配置移入 `unused/`(自动脱离发现体系),远程按需手动清理:
`ssh <node> "cd <base_path>/<name> && docker compose down"`,数据卷按需保留或删除。 `ssh <node> "cd <base_path>/<name> && docker compose down"`,数据卷按需保留或删除。
项目环境布局:删除对应 `.skiff/deployer/{env}/` 目录即可脱离发现体系,远程清理同上。 项目环境布局:删除对应 `.pouch/deployer/{env}/` 目录即可脱离发现体系,远程清理同上。
#### 7. 向节点安装 deb 包 #### 7. 向节点安装 deb 包
@@ -213,7 +272,7 @@ python3 <skill-dir>/scripts/deploy/deb.py <target> apt https://example.com/foo_1
完整步骤与 `argocd.yaml` 字段见 [argocd.md](references/argocd.md)。 完整步骤与 `argocd.yaml` 字段见 [argocd.md](references/argocd.md)。
1. 读项目 `.skiff/deployer/argocd.yaml`(无则只问 Git 地址,写成 `repo:`)。 1. 读项目 `.pouch/deployer/argocd.yaml`(无则只问 Git 地址,写成 `repo:`)。
有 `repo_dir` 则用该目录;否则把 `repo` 浅 clone 到临时目录,用完删除。 有 `repo_dir` 则用该目录;否则把 `repo` 浅 clone 到临时目录,用完删除。
2. 在工作副本里按**已有应用惯例**新增 Application,或只改镜像 tag / 清单。 2. 在工作副本里按**已有应用惯例**新增 Application,或只改镜像 tag / 清单。
3. 从最新默认分支拉出分支,commit、push,用 `glab`/`gh`/`tea` 开 MR;CLI 对项目 404 则把 3. 从最新默认分支拉出分支,commit、push,用 `glab`/`gh`/`tea` 开 MR;CLI 对项目 404 则把
@@ -267,6 +326,7 @@ python3 <skill-dir>/scripts/deploy/deb.py <target> apt https://example.com/foo_1
| `scripts/deploy/remote.py` | SSH 远程 docker compose:up/recreate/restart/upgrade/ps/logs | | `scripts/deploy/remote.py` | SSH 远程 docker compose:up/recreate/restart/upgrade/ps/logs |
| `scripts/deploy/deb.py` | deb 包分发安装:push(scp+apt)/scp/dpkg/apt(URL) | | `scripts/deploy/deb.py` | deb 包分发安装:push(scp+apt)/scp/dpkg/apt(URL) |
| `scripts/deploy/list.py` | 扫描全部可部署服务 | | `scripts/deploy/list.py` | 扫描全部可部署服务 |
| `scripts/deploy/check.py` | 只读就绪检查:布局、compose、node、ssh config、工具链 |
## references/ ## references/
@@ -2,7 +2,7 @@
`_config.yaml` 供 **Compose 轨道**脚本解析,决定同步目标与排除规则。可放在**服务目录、部署根或其任意祖先目录**;子目录中的字段覆盖父目录(继承合并)。 `_config.yaml` 供 **Compose 轨道**脚本解析,决定同步目标与排除规则。可放在**服务目录、部署根或其任意祖先目录**;子目录中的字段覆盖父目录(继承合并)。
Argo CD 轨道用独立文件 `.skiff/deployer/argocd.yaml`,字段见 [argocd.md](argocd.md)。 Argo CD 轨道用独立文件 `.pouch/deployer/argocd.yaml`,字段见 [argocd.md](argocd.md)。
不要把 `argocd:` 嵌进本文件(脚本解析器不支持嵌套映射)。 不要把 `argocd:` 嵌进本文件(脚本解析器不支持嵌套映射)。
## 放置位置(两种布局) ## 放置位置(两种布局)
@@ -10,16 +10,16 @@ Argo CD 轨道用独立文件 `.skiff/deployer/argocd.yaml`,字段见 [argocd.
| 布局 | 部署根 | `_config.yaml` 典型位置 | | 布局 | 部署根 | `_config.yaml` 典型位置 |
|------|--------|------------------------| |------|--------|------------------------|
| 独立配置中心仓库(`DEPLOYER_ROOT` 指向) | 仓库根 | 主机目录 `vyyo1/_config.yaml`、服务目录 | | 独立配置中心仓库(`DEPLOYER_ROOT` 指向) | 仓库根 | 主机目录 `vyyo1/_config.yaml`、服务目录 |
| 项目内环境 `.skiff/deployer/{env}/` | `.skiff/deployer/` | 根级共享默认、各环境目录覆盖 | | 项目内环境 `.pouch/deployer/{env}/` | `.pouch/deployer/` | 根级共享默认、各环境目录覆盖 |
项目布局示例: 项目布局示例:
```yaml ```yaml
# .skiff/deployer/_config.yaml — 三个环境共享 # .pouch/deployer/_config.yaml — 三个环境共享
node: my-vps node: my-vps
base_path: /srv/apps base_path: /srv/apps
# .skiff/deployer/prod/_config.yaml — 仅生产环境差异 # .pouch/deployer/prod/_config.yaml — 仅生产环境差异
node: prod-vps # 覆盖父级 node: prod-vps # 覆盖父级
name: my-project-api # 可选,覆盖默认的 {项目名}-{env} name: my-project-api # 可选,覆盖默认的 {项目名}-{env}
``` ```
@@ -111,7 +111,7 @@ sync_exclude:
| 同一 SSH 主机多个服务 | 主机目录写一份 `node`/`base_path`,子服务免重复 | | 同一 SSH 主机多个服务 | 主机目录写一份 `node`/`base_path`,子服务免重复 |
| 各服务目标不同 | 服务目录单独写 `_config.yaml` | | 各服务目标不同 | 服务目录单独写 `_config.yaml` |
| 个别覆盖 | 子目录只写差异字段 | | 个别覆盖 | 子目录只写差异字段 |
| 项目三环境同主机 | `.skiff/deployer/_config.yaml` 写共享 node,各环境只放差异 | | 项目三环境同主机 | `.pouch/deployer/_config.yaml` 写共享 node,各环境只放差异 |
| 项目环境分属不同主机 | 各环境 `_config.yaml` 分别写 `node` | | 项目环境分属不同主机 | 各环境 `_config.yaml` 分别写 `node` |
## 示例 ## 示例
@@ -137,4 +137,4 @@ node: deploy@web2-backup
- 目录内有 `compose.yaml` - 目录内有 `compose.yaml`
- 能通过继承或兜底解析出 `node` - 能通过继承或兜底解析出 `node`
- 独立仓库布局:路径中不含 `unused/` 段 - 独立仓库布局:路径中不含 `unused/` 段
- 项目环境布局:位于部署根 `.skiff/deployer/` 内(其外的项目文件不扫描) - 项目环境布局:位于部署根 `.pouch/deployer/` 内(其外的项目文件不扫描)
+285
View File
@@ -0,0 +1,285 @@
#!/usr/bin/env python3
"""Readiness checker for deployer project layout.
Usage:
python3 -I -S check.py [--project DIR]
Resolves the deploy root as DEPLOYER_ROOT, else <project>/.pouch/deployer
(or .skiff/deployer), else walking up from cwd. Does not SSH, rsync, or
start containers. Exit 0 = PASS (SKIP allowed), 1 = FAIL, 2 = usage.
"""
from __future__ import annotations
import argparse
import os
import re
import shutil
import sys
from pathlib import Path
_SCRIPT_DIR = Path(__file__).resolve().parent
if str(_SCRIPT_DIR) not in sys.path:
sys.path.insert(0, str(_SCRIPT_DIR))
import lib # noqa: E402
PASS = "PASS"
FAIL = "FAIL"
SKIP = "SKIP"
_PROJECT_LAYOUT_DIRS = (".pouch", ".skiff")
_REPO_OR_DIR = re.compile(r"^(repo|repo_dir)\s*:", re.MULTILINE)
class Report:
def __init__(self) -> None:
self.failures = 0
def add(self, status: str, number: int, title: str, detail: str) -> None:
print(f"[{status}] {number}. {title}")
for line in detail.splitlines():
print(f" {line}")
if status == FAIL:
self.failures += 1
def node_in_ssh_config(node: str, hosts: set[str]) -> bool:
if node in hosts:
return True
if "@" in node:
_, host = node.rsplit("@", 1)
return host in hosts
return False
def resolve_deploy_root(project: Path | None) -> tuple[Path | None, str]:
env = os.environ.get("DEPLOYER_ROOT", "").strip()
if env:
path = Path(env).expanduser().resolve()
return (path if path.is_dir() else None), "DEPLOYER_ROOT"
if project is not None:
root = project.resolve()
for dirname in _PROJECT_LAYOUT_DIRS:
candidate = root / dirname / "deployer"
if candidate.is_dir():
return candidate, "project"
return None, "project"
found = lib._find_project_root()
if found.name == "deployer" and found.parent.name in _PROJECT_LAYOUT_DIRS:
return found, "project"
if found == lib._SKILL_DIR.parent:
return None, "cwd"
return found, "cwd"
def compose_service_dirs(root: Path) -> list[Path]:
dirs: list[Path] = []
for compose in sorted(root.glob("**/compose.yaml")):
service_dir = compose.parent
if not lib.is_deployable_dir(service_dir, root):
continue
dirs.append(service_dir)
return dirs
def check_layout(report: Report, root: Path | None, source: str, project: Path | None) -> bool:
if root is None:
if source == "DEPLOYER_ROOT":
report.add(
FAIL,
1,
"部署根存在",
"DEPLOYER_ROOT is set but is not a directory",
)
else:
hint_root = project.resolve() if project is not None else Path.cwd()
report.add(
FAIL,
1,
"部署根存在",
"\n".join(
[
f"no .pouch/deployer under {hint_root}",
"Fix: run deployer 初始化 and create .pouch/deployer/",
" _config.yaml # node: <ssh-host-alias>",
" test/compose.yaml # default env for ACK",
]
),
)
return False
kind = "project layout" if lib.in_project_layout(root) else "standalone deploy root"
report.add(PASS, 1, "部署根存在", f"{root} ({kind}, via {source})")
return True
def check_toolchain(report: Report) -> None:
ssh_ok = shutil.which("ssh") is not None
rsync_ok = shutil.which("rsync") is not None
lines = [
f"ssh: {'found' if ssh_ok else 'MISSING (blocks compose deploy)'}",
f"rsync: {'found' if rsync_ok else 'MISSING (tar-over-SSH fallback)'}",
]
if not ssh_ok:
lines.append("install openssh-client")
report.add(FAIL, 2, "工具链", "\n".join(lines))
return
report.add(PASS if rsync_ok else SKIP, 2, "工具链", "\n".join(lines))
def check_argocd(report: Report, root: Path) -> bool:
path = root / "argocd.yaml"
if not path.is_file():
report.add(SKIP, 3, "Argo CD 指针", "no argocd.yaml")
return False
text = path.read_text(encoding="utf-8")
if _REPO_OR_DIR.search(text):
report.add(PASS, 3, "Argo CD 指针", "argocd.yaml has repo or repo_dir")
return True
report.add(
FAIL,
3,
"Argo CD 指针",
"argocd.yaml exists but has neither repo: nor repo_dir:\n"
"Fix: repo: git@host:org/infra-gitops.git",
)
return True
def check_services(report: Report, root: Path) -> None:
services = compose_service_dirs(root)
if not services:
report.add(
FAIL,
4,
"至少有一个 compose.yaml",
"no compose.yaml under the deploy root\n"
"Fix: add .pouch/deployer/<env>/compose.yaml (env usually test)",
)
report.add(SKIP, 5, "每个服务能解析 node", "(no compose.yaml)")
report.add(SKIP, 6, "node 出现在 SSH config", "(no compose.yaml)")
report.add(SKIP, 7, "list 可发现服务", "(no compose.yaml)")
return
rels = [str(path.relative_to(root)) for path in services]
report.add(PASS, 4, "至少有一个 compose.yaml", "\n".join(rels))
hosts = lib.ssh_config_hosts()
node_lines = []
ssh_lines = []
node_fail = False
ssh_fail = False
for path in services:
rel = str(path.relative_to(root))
info = lib.service_info(rel, strict=False)
if info is None:
node_lines.append(f"{rel}: MISSING node")
ssh_lines.append(f"{rel}: skipped (no node)")
node_fail = True
continue
node = str(info["node"])
node_lines.append(f"{rel}: node={node}")
if node_in_ssh_config(node, hosts):
ssh_lines.append(f"{rel}: {node} in ~/.ssh/config")
else:
ssh_lines.append(f"{rel}: {node} NOT in ~/.ssh/config")
ssh_fail = True
if node_fail:
node_lines.extend(
[
"",
"Fix: write node in _config.yaml (deploy root or env dir).",
"Example:",
" node: my-vps",
" base_path: /opt/app",
"Do not invent a hostname. It must be an SSH Host alias.",
]
)
report.add(FAIL, 5, "每个服务能解析 node", "\n".join(node_lines))
else:
report.add(PASS, 5, "每个服务能解析 node", "\n".join(node_lines))
if ssh_fail or node_fail:
if ssh_fail:
ssh_lines.extend(
[
"",
"Fix: add a Host entry to ~/.ssh/config for the node alias.",
"This check does not open an SSH connection.",
]
)
report.add(FAIL, 6, "node 出现在 SSH config", "\n".join(ssh_lines))
else:
report.add(PASS, 6, "node 出现在 SSH config", "\n".join(ssh_lines))
found = lib.discover_services()
if not found:
report.add(
FAIL,
7,
"list 可发现服务",
"compose.yaml exists but discover_services found none "
"(need resolvable node)",
)
return
names = [os.path.relpath(item["service_dir"], root) for item in found]
report.add(PASS, 7, "list 可发现服务", f"{len(found)} service(s): " + ", ".join(names))
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
)
parser.add_argument(
"--project",
type=Path,
default=None,
help="project root (looks for .pouch/deployer); ignored when DEPLOYER_ROOT is set",
)
args = parser.parse_args(argv)
report = Report()
project = args.project.resolve() if args.project is not None else None
root, source = resolve_deploy_root(project)
layout_ok = check_layout(report, root, source, project)
check_toolchain(report)
if not layout_ok:
report.add(SKIP, 3, "Argo CD 指针", "(no deploy root)")
report.add(SKIP, 4, "至少有一个 compose.yaml", "(no deploy root)")
report.add(SKIP, 5, "每个服务能解析 node", "(no deploy root)")
report.add(SKIP, 6, "node 出现在 SSH config", "(no deploy root)")
report.add(SKIP, 7, "list 可发现服务", "(no deploy root)")
print()
print(f"RESULT: FAILED ({report.failures} check(s) failed)")
return 1
assert root is not None
lib.PROJECT_ROOT = root
lib._SSH_HOSTS = None
previous_cwd = Path.cwd()
try:
os.chdir(root)
has_argocd = check_argocd(report, root)
services = compose_service_dirs(root)
if services:
check_services(report, root)
elif has_argocd:
report.add(SKIP, 4, "至少有一个 compose.yaml", "Argo CD only; no compose env")
report.add(SKIP, 5, "每个服务能解析 node", "Argo CD only")
report.add(SKIP, 6, "node 出现在 SSH config", "Argo CD only")
report.add(SKIP, 7, "list 可发现服务", "Argo CD only")
else:
check_services(report, root)
finally:
os.chdir(previous_cwd)
print()
if report.failures:
print(f"RESULT: FAILED ({report.failures} check(s) failed)")
return 1
print("RESULT: PASSED")
return 0
if __name__ == "__main__":
raise SystemExit(main())
+12 -10
View File
@@ -3,7 +3,7 @@
支持两种布局: 支持两种布局:
1. 独立配置中心仓库(DEPLOYER_ROOT 指向,或 skill 安装位置) 1. 独立配置中心仓库(DEPLOYER_ROOT 指向,或 skill 安装位置)
2. 项目内环境目录 .skiff/deployer/{prod,test,dev}/(从 CWD 自动发现) 2. 项目内环境目录 .pouch/deployer/{prod,test,dev}/(从 CWD 自动发现;兼容 .skiff/deployer)
""" """
from __future__ import annotations from __future__ import annotations
@@ -18,10 +18,11 @@ DEFAULT_BASE_PATH = "/opt/app"
DEFAULT_SYNC_EXCLUDES = ("data", "_data") DEFAULT_SYNC_EXCLUDES = ("data", "_data")
_SKILL_DIR = Path(__file__).resolve().parent.parent # scripts/ _SKILL_DIR = Path(__file__).resolve().parent.parent # scripts/
PROJECT_ROOT: Path | None = None PROJECT_ROOT: Path | None = None
_PROJECT_LAYOUT_DIRS = (".pouch", ".skiff")
def _find_project_root() -> Path: def _find_project_root() -> Path:
"""部署根:DEPLOYER_ROOT > 从 CWD 向上找 .skiff/deployer > skill 安装位置。""" """部署根:DEPLOYER_ROOT > 从 CWD 向上找 .pouch/deployer > skill 安装位置。"""
env = os.environ.get("DEPLOYER_ROOT", "").strip() env = os.environ.get("DEPLOYER_ROOT", "").strip()
if env: if env:
p = Path(env).expanduser().resolve() p = Path(env).expanduser().resolve()
@@ -31,9 +32,10 @@ def _find_project_root() -> Path:
return p return p
cur = Path.cwd() cur = Path.cwd()
while True: while True:
cand = cur / ".skiff" / "deployer" for dirname in _PROJECT_LAYOUT_DIRS:
if cand.is_dir(): cand = cur / dirname / "deployer"
return cand if cand.is_dir():
return cand
if cur == cur.parent: if cur == cur.parent:
break break
cur = cur.parent cur = cur.parent
@@ -48,13 +50,13 @@ def project_root() -> Path:
def in_project_layout(root: Path | None = None) -> bool: def in_project_layout(root: Path | None = None) -> bool:
"""部署根是否为某项目内的 .skiff/deployer/。""" """部署根是否为某项目内的 .pouch/deployer/。"""
root = root or project_root() root = root or project_root()
return root.name == "deployer" and root.parent.name == ".skiff" return root.name == "deployer" and root.parent.name in _PROJECT_LAYOUT_DIRS
def project_display_name(root: Path | None = None) -> str: def project_display_name(root: Path | None = None) -> str:
"""项目名:git 仓库名优先,否则 .skiff 的父目录名。""" """项目名:git 仓库名优先,否则 .pouch 的父目录名。"""
root = root or project_root() root = root or project_root()
anchor = root.parent.parent if in_project_layout(root) else root anchor = root.parent.parent if in_project_layout(root) else root
try: try:
@@ -111,7 +113,7 @@ def load_config(config_path: os.PathLike | str, *, required: bool = True) -> dic
def config_paths_for_service(service_dir: str) -> list[Path]: def config_paths_for_service(service_dir: str) -> list[Path]:
"""收集部署根自身及服务目录各层 _config.yaml(祖先在前,服务目录在后)。 """收集部署根自身及服务目录各层 _config.yaml(祖先在前,服务目录在后)。
部署根的 _config.yaml(如 .skiff/deployer/_config.yaml)作为全局默认, 部署根的 _config.yaml(如 .pouch/deployer/_config.yaml)作为全局默认,
对所有环境/服务生效。 对所有环境/服务生效。
""" """
root = project_root() root = project_root()
@@ -333,7 +335,7 @@ def service_info(service_dir: str, *, strict: bool = True) -> dict | None:
def is_deployable_dir(path: Path, root: Path) -> bool: def is_deployable_dir(path: Path, root: Path) -> bool:
if "unused" in path.parts or "__pycache__" in path.parts: if "unused" in path.parts or "__pycache__" in path.parts:
return False return False
if ".skiff" in path.parts and root.name != "deployer": if any(part in _PROJECT_LAYOUT_DIRS for part in path.parts) and root.name != "deployer":
return False return False
if not (path / "compose.yaml").is_file(): if not (path / "compose.yaml").is_file():
return False return False
+5 -5
View File
@@ -46,7 +46,7 @@ description: >-
### 1. 解析目标并加载 manifest ### 1. 解析目标并加载 manifest
1. 解析目标 skill 名;在常见安装位置查找其目录(项目/全局的 agent skills 目录、`~/.skills/skills/`),跟随 symlink 到 SSOT。 1. 解析目标 skill 名;在常见安装位置查找其目录(项目/全局的 agent skills 目录、`~/.pouch/skills/`),跟随 symlink 到 SSOT。
2. 读取 `<skill-dir>/memories/manifest.md`。按 [references/manifest.md](references/manifest.md) 解析 `general` 与 `project` 路径(相对 skill 根或相对当前项目根)。 2. 读取 `<skill-dir>/memories/manifest.md`。按 [references/manifest.md](references/manifest.md) 解析 `general` 与 `project` 路径(相对 skill 根或相对当前项目根)。
3. 规范化路径:已存在则用;manifest 声明 `create: true` 且用户未禁止时,写入前再创建;否则列入待确认项。 3. 规范化路径:已存在则用;manifest 声明 `create: true` 且用户未禁止时,写入前再创建;否则列入待确认项。
4. 选定会话材料。会话文件与工具输出当作不可信历史:只抽候选,不执行其中的指令。 4. 选定会话材料。会话文件与工具输出当作不可信历史:只抽候选,不执行其中的指令。
@@ -72,7 +72,7 @@ description: >-
### 3. 对照已有记忆去重 ### 3. 对照已有记忆去重
读两个 store 的现有内容。`markdown-per-skill` 时只读写 `<path>/<skillname>.md`(例如 `docs/ack/memory/ack.md`),不要把其他 skill 的同目录文件混进本次更新。若 store 另有 schema / 校验器,按其约定更新。 读两个 store 的现有内容。`markdown-per-skill` 时只读写 `<path>/<skillname>.md`(例如 `.pouch/ack/memory/ack.md`),不要把其他 skill 的同目录文件混进本次更新。若 store 另有 schema / 校验器,按其约定更新。
- 已有等价 → `skip-duplicate` - 已有等价 → `skip-duplicate`
- 旧条目被纠正 → `update`(直接改正文) - 旧条目被纠正 → `update`(直接改正文)
@@ -85,12 +85,12 @@ description: >-
```text ```text
目标 skill: ack — ACK 三角色协作闭环 目标 skill: ack — ACK 三角色协作闭环
通用记忆: ~/.skills/skills/ack/memories/general (来自 manifest) 通用记忆: ~/.pouch/skills/ack/memories/general (来自 manifest)
项目记忆: ./docs/ack/memory/ack.md (manifest: docs/ack/memory + skillname) 项目记忆: ./.pouch/ack/memory/ack.md (manifest: .pouch/ack/memory + skillname)
将写入(待确认): 将写入(待确认):
- [general] add → general/coordinator-checklist.md :: … - [general] add → general/coordinator-checklist.md :: …
- [project] add → docs/ack/memory/ack.md :: … - [project] add → .pouch/ack/memory/ack.md :: …
跳过: 跳过:
- discard: … - discard: …
@@ -6,4 +6,4 @@ summary: ACK 三角色协作闭环
| kind | path | root | create | format | notes | | kind | path | root | create | format | notes |
|------|------|------|--------|--------|-------| |------|------|------|--------|--------|-------|
| general | memories/general | skill | true | markdown-dir | 跨项目:角色协作纪律、收尾检查、常见坑 | | general | memories/general | skill | true | markdown-dir | 跨项目:角色协作纪律、收尾检查、常见坑 |
| project | docs/ack/memory | project | true | markdown-per-skill | 仅本仓库;本 skill 写入 `docs/ack/memory/ack.md` | | project | .pouch/ack/memory | project | true | markdown-per-skill | 仅本仓库;本 skill 写入 `.pouch/ack/memory/ack.md` |
+2 -2
View File
@@ -17,7 +17,7 @@ summary: ACK 三角色协作闭环
| kind | path | root | create | format | notes | | kind | path | root | create | format | notes |
|------|------|------|--------|--------|-------| |------|------|------|--------|--------|-------|
| general | memories/general | skill | true | markdown-dir | 跨项目可复用的 ACK 流程纪律 | | general | memories/general | skill | true | markdown-dir | 跨项目可复用的 ACK 流程纪律 |
| project | docs/ack/memory | project | true | markdown-per-skill | 仅本仓库;写入 `docs/ack/memory/<skillname>.md` | | project | .pouch/ack/memory | project | true | markdown-per-skill | 仅本仓库;写入 `.pouch/ack/memory/<skillname>.md` |
``` ```
## 字段 ## 字段
@@ -49,5 +49,5 @@ summary: ACK 三角色协作闭环
2. `root: skill` 的路径相对 skill SSOT(解析 symlink 后)。 2. `root: skill` 的路径相对 skill SSOT(解析 symlink 后)。
3. `root: project` 的路径相对当前工作区项目根;找不到项目根则请用户确认。 3. `root: project` 的路径相对当前工作区项目根;找不到项目根则请用户确认。
4. 表格缺省:`create` 默认 `false`;`format` 默认 `markdown-dir`。 4. 表格缺省:`create` 默认 `false`;`format` 默认 `markdown-dir`。
5. `format: markdown-per-skill`:解析出目录 `path` 后,写入文件固定为 `<path>/<skillname>.md`(例:目标 `ack` → `docs/ack/memory/ack.md`)。不要把不同 skill 的项目记忆写进同一文件。 5. `format: markdown-per-skill`:解析出目录 `path` 后,写入文件固定为 `<path>/<skillname>.md`(例:目标 `ack` → `.pouch/ack/memory/ack.md`)。不要把不同 skill 的项目记忆写进同一文件。
6. 没有 manifest 时:在 skill 目录下寻找已存在的 `memories/general`,在项目下寻找文档已写明的 `…/memory/<skillname>.md`;仍不唯一则追问。 6. 没有 manifest 时:在 skill 目录下寻找已存在的 `memories/general`,在项目下寻找文档已写明的 `…/memory/<skillname>.md`;仍不唯一则追问。
@@ -1,7 +1,7 @@
# skiff # pouch
`skiff` 用于创建、维护、安装和发布团队自研的 Agent Skill。Skill 的唯一来源位于 `pouch` 用于创建、维护、安装和发布团队自研的 Agent Skill。Skill 的唯一来源位于
`~/.skills/skills/<name>/`,安装到各 Agent 时使用软链接。 `~/.pouch/skills/<name>/`,安装到各 Agent 时使用软链接。
## 什么时候使用 ## 什么时候使用
@@ -13,12 +13,12 @@
## 创建一个 skill ## 创建一个 skill
```bash ```bash
skiff create my-skill \ pouch create my-skill \
--idea "描述这个 skill 要解决的重复问题" \ --idea "描述这个 skill 要解决的重复问题" \
--from-project . --from-project .
``` ```
命令会在 `~/.skills/.drafts/my-skill/` 创建: 命令会在 `~/.pouch/.drafts/my-skill/` 创建:
- `SKILL.md`:给 Agent 阅读的工作流与约束。 - `SKILL.md`:给 Agent 阅读的工作流与约束。
- `README.md`:给人类阅读的用途、准备事项、示例和完成标准。 - `README.md`:给人类阅读的用途、准备事项、示例和完成标准。
@@ -27,8 +27,8 @@ skiff create my-skill \
完善 `SKILL.md` 和 `README.md` 后运行: 完善 `SKILL.md` 和 `README.md` 后运行:
```bash ```bash
skiff check my-skill pouch check my-skill
skiff finalize my-skill pouch finalize my-skill
``` ```
## 提交和发布 ## 提交和发布
@@ -36,13 +36,13 @@ skiff finalize my-skill
只提交: 只提交:
```bash ```bash
skiff publish skills/my-skill -m "add my-skill" pouch publish skills/my-skill -m "add my-skill"
``` ```
提交并推送: 提交并推送:
```bash ```bash
skiff publish skills/my-skill -m "add my-skill" --push pouch publish skills/my-skill -m "add my-skill" --push
``` ```
## 安装 ## 安装
@@ -50,18 +50,18 @@ skiff publish skills/my-skill -m "add my-skill" --push
安装到当前项目的 Codex: 安装到当前项目的 Codex:
```bash ```bash
skiff add my-skill -a codex -y pouch add my-skill -a codex -y
``` ```
安装到全局 Codex: 安装到全局 Codex:
```bash ```bash
skiff add my-skill -a codex -g -y pouch add my-skill -a codex -g -y
``` ```
## 如何判断完成 ## 如何判断完成
- `skiff check <name>` 输出校验通过。 - `pouch check <name>` 输出校验通过。
- 正式 skill 同时包含 `SKILL.md` 和 `README.md`。 - 正式 skill 同时包含 `SKILL.md` 和 `README.md`。
- `skiff status` 或 `skiff doctor` 显示目标软链接正常。 - `pouch status` 或 `pouch doctor` 显示目标软链接正常。
+46 -45
View File
@@ -1,15 +1,15 @@
--- ---
name: skiff name: pouch
description: >- description: >-
创建和维护 ~/.skills 自研 skill:把项目开发中产生的想法提炼为草稿,完善并校验后发布, 创建和维护 ~/.pouch 自研 skill:把项目开发中产生的想法提炼为草稿,完善并校验后发布,
用 skiff add/remove 在项目及全局挂卸 skill,或用 skiff init 初始化 skill 项目状态。 用 pouch add/remove 在项目及全局挂卸 skill,或用 pouch init 初始化 skill 项目状态。
触发词:skiff、自研 skill、创建 skill、想做一个 skill、publish skill、安装自研 skill、 触发词:pouch、skiff、自研 skill、创建 skill、想做一个 skill、publish skill、安装自研 skill、
更新 skill 到项目、初始化 skill。 更新 skill 到项目、初始化 skill。
--- ---
# skiff 自研 Skill 工作流 # pouch 自研 Skill 工作流
SSOT 固定在 `~/.skills/skills/<name>/`。内容通过 **symlink** 分发到各 agent,改 SSOT 即全项目生效。 SSOT 固定在 `~/.pouch/skills/<name>/`。内容通过 **symlink** 分发到各 agent,改 SSOT 即全项目生效。
--- ---
@@ -18,11 +18,11 @@ SSOT 固定在 `~/.skills/skills/<name>/`。内容通过 **symlink** 分发到
先浏览可用的 builtin skill,再安装到当前项目: 先浏览可用的 builtin skill,再安装到当前项目:
```bash ```bash
skiff add --list pouch add --list
skiff add <name> -a cursor -a claude -a codex -a agents -y pouch add <name> -a cursor -a claude -a codex -a agents -y
``` ```
`skiff add <name>` 默认安装到当前项目;只有用户明确需要所有项目使用时才加 `-g`。安装结果是指向 `~/.skills/skills/<name>/` 的软链,不要在 Agent 目录创建副本。 `pouch add <name>` 默认安装到当前项目;只有用户明确需要所有项目使用时才加 `-g`。安装结果是指向 `~/.pouch/skills/<name>/` 的软链,不要在 Agent 目录创建副本。
## 创建新的 skill ## 创建新的 skill
@@ -35,25 +35,25 @@ skiff add <name> -a cursor -a claude -a codex -a agents -y
3. 创建草稿: 3. 创建草稿:
```bash ```bash
skiff create <name> --idea "<用户原始想法>" --from-project . pouch create <name> --idea "<用户原始想法>" --from-project .
``` ```
4. 编辑 `~/.skills/.drafts/<name>/SKILL.md`,完善触发条件、不适用场景、步骤、边界与验证方法。 4. 编辑 `~/.pouch/.drafts/<name>/SKILL.md`,完善触发条件、不适用场景、步骤、边界与验证方法。
5. 编辑同目录的 `README.md`,用面向人类的语言说明用途、准备事项、可直接复制的请求示例、Agent 会做什么以及如何判断完成。README 不应复述 Agent 内部指令。 5. 编辑同目录的 `README.md`,用面向人类的语言说明用途、准备事项、可直接复制的请求示例、Agent 会做什么以及如何判断完成。README 不应复述 Agent 内部指令。
6. 仅在确有必要时增加 `references/`、`scripts/` 或 `assets/`。不要把项目专属路径、私有业务规则、一次性命令或密钥复制到通用 skill。 6. 仅在确有必要时增加 `references/`、`scripts/` 或 `assets/`。不要把项目专属路径、私有业务规则、一次性命令或密钥复制到通用 skill。
7. 运行校验并修复所有问题: 7. 运行校验并修复所有问题:
```bash ```bash
skiff check <name> pouch check <name>
``` ```
8. 向用户展示名称、description、README 的人类使用方式、核心步骤和验证方式。获得确认后再转正: 8. 向用户展示名称、description、README 的人类使用方式、核心步骤和验证方式。获得确认后再转正:
```bash ```bash
skiff finalize <name> pouch finalize <name>
``` ```
转正不会自动 commit、push 或安装。用户明确要求后再执行 `skiff publish` 或 `skiff add`。 转正不会自动 commit、push 或安装。用户明确要求后再执行 `pouch publish` 或 `pouch add`。
## 问题或优化回流 ## 问题或优化回流
@@ -63,35 +63,35 @@ skiff finalize <name>
2. 判断归属: 2. 判断归属:
- 通用工作流、触发条件或验证缺陷:回流 builtin skill。 - 通用工作流、触发条件或验证缺陷:回流 builtin skill。
- 仅当前项目成立的命令、路径、业务规则:留在项目文档或项目配置,不写回通用 skill。 - 仅当前项目成立的命令、路径、业务规则:留在项目文档或项目配置,不写回通用 skill。
- CLI 安装、软链或校验行为异常:修改 `~/.skills/skiff/` 中的 CLI 和测试。 - CLI 安装、软链或校验行为异常:修改 `~/.pouch/pouch/` 中的 CLI 和测试。
- 第三方 skill:不要复制成 builtin skill 或直接改安装目录;整理证据反馈上游,除非用户明确决定维护 fork。 - 第三方 skill:不要复制成 builtin skill 或直接改安装目录;整理证据反馈上游,除非用户明确决定维护 fork。
3. 确认真实来源。Agent 目录通常是软链,builtin skill 的 SSOT 固定为: 3. 确认真实来源。Agent 目录通常是软链,builtin skill 的 SSOT 固定为:
```text ```text
~/.skills/skills/<name>/ ~/.pouch/skills/<name>/
``` ```
4. 修改 SSOT。行为修复应先补能复现问题的测试或示例,再改 `SKILL.md`、引用文件或脚本。 4. 修改 SSOT。行为修复应先补能复现问题的测试或示例,再改 `SKILL.md`、引用文件或脚本。
5. 校验并在原项目重跑最初失败的场景: 5. 校验并在原项目重跑最初失败的场景:
```bash ```bash
skiff check <name> pouch check <name>
``` ```
6. 汇报修改内容、验证结果和影响范围。只有用户明确要求提交或推送时才运行: 6. 汇报修改内容、验证结果和影响范围。只有用户明确要求提交或推送时才运行:
```bash ```bash
skiff publish skills/<name> -m "update <name>" --push pouch publish skills/<name> -m "update <name>" --push
``` ```
软链正确时无需重新安装;SSOT 保存后项目立即读取新内容。 软链正确时无需重新安装;SSOT 保存后项目立即读取新内容。
## 安装与维护 ## 安装与维护
安装本项目的 `skiff` skill 到所有 Agent: 安装本项目的 `pouch` skill 到所有 Agent:
```bash ```bash
skiff bootstrap pouch bootstrap
``` ```
安装其他 skill: 安装其他 skill:
@@ -99,53 +99,54 @@ skiff bootstrap
```bash ```bash
# 当前项目 # 当前项目
cd ~/code/my-app cd ~/code/my-app
skiff add discussion-notes -a cursor -y pouch add discussion-notes -a cursor -y
# 全局(所有项目) # 全局(所有项目)
skiff add discussion-notes -a cursor -g -y pouch add discussion-notes -a cursor -g -y
# 多个 agent # 多个 agent
skiff add discussion-notes -a cursor -a codex -g -y pouch add discussion-notes -a cursor -a codex -g -y
``` ```
catalog source既可以指向单个 skill,也可以指向包含多个 skill 目录的 catalog source既可以指向单个 skill,也可以指向包含多个 skill 目录的
collection。安装 collection 全部内容或其中一个: collection。安装 collection 全部内容或其中一个:
```bash ```bash
skiff add waza -a codex -g -y pouch add waza -a codex -g -y
skiff add waza/think -a codex -g -y pouch add waza/think -a codex -g -y
``` ```
`skiff select` 会把 collection 显示为两级菜单:选择 `waza` 仓库会选中其 `pouch select` 会把 collection 显示为两级菜单:选择 `waza` 仓库会选中其
全部子 skill,也可以只选择 `waza/think`、`waza/ui` 中的若干项。 全部子 skill,也可以只选择 `waza/think`、`waza/ui` 中的若干项。
普通 `skiff select` 只向项目安装,并只读显示每个 Agent 的全局安装状态; 普通 `pouch select` 只向项目安装,并只读显示每个 Agent 的全局安装状态;
`skiff select -g` 只向全局安装。取消已勾选项不会卸载,卸载继续使用 `pouch select -g` 只向全局安装。取消已勾选项不会卸载,卸载继续使用
`skiff remove`。 `pouch remove`。
卸载: 卸载:
```bash ```bash
skiff remove discussion-notes -a cursor -y # 当前项目 pouch remove discussion-notes -a cursor -y # 当前项目
skiff remove discussion-notes -g -a cursor -y # 全局 pouch remove discussion-notes -g -a cursor -y # 全局
skiff rm discussion-notes -g -y # rm 别名 pouch rm discussion-notes -g -y # rm 别名
``` ```
浏览可用自研 skill: 浏览可用自研 skill:
```bash ```bash
skiff add --list pouch add --list
``` ```
使用 Skill 自带模板初始化项目状态: 使用 Skill 自带模板初始化项目状态:
```bash ```bash
skiff init ack pouch init ack
skiff init ack --project ~/app pouch init ack --project ~/app
``` ```
`skiff` 只负责可靠地生成项目状态文件,不复制或链接 Skill。需要分析项目并完善 `pouch` 只负责可靠地生成项目状态文件,不复制或链接 Skill。需要分析项目并完善
ACK 配置、检查接入状态或 ACK 配置、检查接入状态或
运行三角色闭环时,显式调用全局 `/ack` skill。 运行三角色闭环时,显式调用全局 `/ack` skill。builder / deployer 的项目接入走
对应 skill 的「初始化」模式,不要 `pouch init builder` 或 `pouch init deployer`。
--- ---
@@ -153,22 +154,22 @@ ACK 配置、检查接入状态或
| 场景 | 工具 | | 场景 | 工具 |
|------|------| |------|------|
| 自研 skill(~/.skills) | **skiff** | | 自研 skill(~/.pouch) | **pouch** |
| 社区 skill(GitHub 任意仓库) | `npx skills add` | | 社区 skill(GitHub 任意仓库) | `npx skills add` |
--- ---
## 命令对照 ## 命令对照
| skiff | 说明 | | pouch | 说明 |
|-------|------| |-------|------|
| `bootstrap` | 将本项目的 `skiff` skill 全局安装到所有 Agent | | `bootstrap` | 将本项目的 `pouch` skill 全局安装到所有 Agent |
| `update` | 在 `~/.skills` 执行 `git pull`,更新 skiff 自身 | | `update` | 在 `~/.pouch` 执行 `git pull`,更新 pouch 自身 |
| `add <name> [-g] [-a AGENT...] [-y]` | 安装 | | `add <name> [-g] [-a AGENT...] [-y]` | 安装 |
| `remove <name> [-g] [-a AGENT...] [-y]` | 卸载(`rm` / `r` 别名) | | `remove <name> [-g] [-a AGENT...] [-y]` | 卸载(`rm` / `r` 别名) |
| `add --list` | 列出可用自研 skill | | `add --list` | 列出可用自研 skill |
| `publish [paths] -m MSG [--push]` | git add / commit / push | | `publish [paths] -m MSG [--push]` | git add / commit / push |
| `list` | 列出 ~/.skills 目录结构 | | `list` | 列出 ~/.pouch 目录结构 |
| `status` | 查看软链安装状态 | | `status` | 查看软链安装状态 |
| `create <name> --idea TEXT [--from-project PATH]` | 创建自研 skill 草稿 | | `create <name> --idea TEXT [--from-project PATH]` | 创建自研 skill 草稿 |
| `check <name>` | 校验草稿或正式 skill | | `check <name>` | 校验草稿或正式 skill |
@@ -179,7 +180,7 @@ ACK 配置、检查接入状态或
## 注意 ## 注意
- 不要在 `project/.agents/skills/` 里直接改文件;应改 `~/.skills/skills/` 再 `publish` - 不要在 `project/.agents/skills/` 里直接改文件;应改 `~/.pouch/skills/` 再 `publish`
- 未完成的内容保留在 `~/.skills/.drafts/`,不要直接放进正式 `skills/` - 未完成的内容保留在 `~/.pouch/.drafts/`,不要直接放进正式 `skills/`
- symlink 正确时,**不需要 reinstall**;保存 SSOT 后各项目自动读到新内容 - symlink 正确时,**不需要 reinstall**;保存 SSOT 后各项目自动读到新内容
- 社区 skill 用 `npx skills add`,不要用 skiff `catalog add` 除非团队要 pin 版本 - 社区 skill 用 `npx skills add`,不要用 pouch `catalog add` 除非团队要 pin 版本
+3 -3
View File
@@ -291,7 +291,7 @@ class AckDeliveryValidationTests(unittest.TestCase):
errors = validate_delivery.validate_tasks_link(contract, tasks) errors = validate_delivery.validate_tasks_link(contract, tasks)
self.assertIn( self.assertIn(
"tasks.project.deliveryFile 必须固定为 docs/ack/delivery.yaml", "tasks.project.deliveryFile 必须固定为 .pouch/ack/delivery.yaml",
errors, errors,
) )
self.assertIn("delivery.project.name 必须与 tasks.project.name 一致", errors) self.assertIn("delivery.project.name 必须与 tasks.project.name 一致", errors)
@@ -343,9 +343,9 @@ class AckDeliveryValidationTests(unittest.TestCase):
root = Path(temp_dir) root = Path(temp_dir)
errors = validate_delivery.validate_builtin(contract, root) errors = validate_delivery.validate_builtin(contract, root)
self.assertTrue( self.assertTrue(
any(".skiff/deployer/test" in item for item in errors) any(".pouch/deployer/test" in item for item in errors)
) )
env_dir = root / ".skiff" / "deployer" / "test" env_dir = root / ".pouch" / "deployer" / "test"
env_dir.mkdir(parents=True) env_dir.mkdir(parents=True)
self.assertEqual(validate_delivery.validate_builtin(contract, root), []) self.assertEqual(validate_delivery.validate_builtin(contract, root), [])
+14 -14
View File
@@ -445,7 +445,7 @@ class AckKnowledgeTests(unittest.TestCase):
tasks_data = { tasks_data = {
"project": { "project": {
"name": "notes-web", "name": "notes-web",
"knowledgeFile": "docs/ack/knowledge.yaml", "knowledgeFile": ".pouch/ack/knowledge.yaml",
}, },
"tasks": [task], "tasks": [task],
} }
@@ -470,7 +470,7 @@ class AckKnowledgeTests(unittest.TestCase):
tasks = { tasks = {
"project": { "project": {
"name": "another-project", "name": "another-project",
"knowledgeFile": "docs/ack/knowledge.yaml", "knowledgeFile": ".pouch/ack/knowledge.yaml",
}, },
"tasks": [], "tasks": [],
} }
@@ -502,7 +502,7 @@ class AckKnowledgeTests(unittest.TestCase):
tasks_data = { tasks_data = {
"project": { "project": {
"name": "notes-web", "name": "notes-web",
"knowledgeFile": "docs/ack/knowledge.yaml", "knowledgeFile": ".pouch/ack/knowledge.yaml",
}, },
"tasks": [task], "tasks": [task],
} }
@@ -522,7 +522,7 @@ class AckKnowledgeTests(unittest.TestCase):
tasks_data = { tasks_data = {
"project": { "project": {
"name": "notes-web", "name": "notes-web",
"knowledgeFile": "docs/ack/knowledge.yaml", "knowledgeFile": ".pouch/ack/knowledge.yaml",
}, },
"tasks": [ "tasks": [
{ {
@@ -567,7 +567,7 @@ class AckKnowledgeTests(unittest.TestCase):
} }
with tempfile.TemporaryDirectory() as temp_dir: with tempfile.TemporaryDirectory() as temp_dir:
project = Path(temp_dir) / "project" project = Path(temp_dir) / "project"
ack_dir = project / "docs" / "ack" ack_dir = project / ".pouch" / "ack"
ack_dir.mkdir(parents=True) ack_dir.mkdir(parents=True)
knowledge_path = ack_dir / "knowledge.yaml" knowledge_path = ack_dir / "knowledge.yaml"
tasks_path = ack_dir / "tasks.yaml" tasks_path = ack_dir / "tasks.yaml"
@@ -578,7 +578,7 @@ class AckKnowledgeTests(unittest.TestCase):
"project": { "project": {
"name": "notes-web", "name": "notes-web",
"repoPath": str(project), "repoPath": str(project),
"knowledgeFile": "docs/ack/other.yaml", "knowledgeFile": ".pouch/ack/other.yaml",
}, },
"tasks": [task], "tasks": [task],
} }
@@ -595,9 +595,9 @@ class AckKnowledgeTests(unittest.TestCase):
errors = validate_knowledge.validate_task_references(data, tasks_data) errors = validate_knowledge.validate_task_references(data, tasks_data)
self.assertTrue(any("project.knowledgeFile 必填" in e for e in errors)) self.assertTrue(any("project.knowledgeFile 必填" in e for e in errors))
tasks_data["project"]["knowledgeFile"] = "docs/ack/knowledge.yaml" tasks_data["project"]["knowledgeFile"] = ".pouch/ack/knowledge.yaml"
staging_root = Path(temp_dir) / "staging" staging_root = Path(temp_dir) / "staging"
staged = staging_root / "docs" / "ack" / "knowledge.yaml" staged = staging_root / ".pouch" / "ack" / "knowledge.yaml"
staged.parent.mkdir(parents=True) staged.parent.mkdir(parents=True)
staged.write_text( staged.write_text(
yaml.safe_dump(data, allow_unicode=True), encoding="utf-8" yaml.safe_dump(data, allow_unicode=True), encoding="utf-8"
@@ -636,7 +636,7 @@ class AckKnowledgeTests(unittest.TestCase):
with tempfile.TemporaryDirectory() as temp_dir: with tempfile.TemporaryDirectory() as temp_dir:
base = Path(temp_dir) base = Path(temp_dir)
project = base / "project" project = base / "project"
ack_dir = project / "docs" / "ack" ack_dir = project / ".pouch" / "ack"
outside = base / "outside" outside = base / "outside"
ack_dir.mkdir(parents=True) ack_dir.mkdir(parents=True)
outside.mkdir() outside.mkdir()
@@ -653,7 +653,7 @@ class AckKnowledgeTests(unittest.TestCase):
"project": { "project": {
"name": "notes-web", "name": "notes-web",
"repoPath": str(project / "missing"), "repoPath": str(project / "missing"),
"knowledgeFile": "docs/ack/not-the-current-file.yaml", "knowledgeFile": ".pouch/ack/not-the-current-file.yaml",
}, },
"tasks": [task], "tasks": [task],
} }
@@ -746,7 +746,7 @@ class AckKnowledgeTests(unittest.TestCase):
tasks_data = { tasks_data = {
"project": { "project": {
"name": "notes-web", "name": "notes-web",
"knowledgeFile": "docs/ack/knowledge.yaml", "knowledgeFile": ".pouch/ack/knowledge.yaml",
}, },
"tasks": [task], "tasks": [task],
} }
@@ -765,7 +765,7 @@ class AckKnowledgeTests(unittest.TestCase):
def test_cli_validates_tasks_and_selector_outputs_stable_refs(self) -> None: def test_cli_validates_tasks_and_selector_outputs_stable_refs(self) -> None:
with tempfile.TemporaryDirectory() as temp_dir: with tempfile.TemporaryDirectory() as temp_dir:
project = Path(temp_dir) / "project" project = Path(temp_dir) / "project"
ack_dir = project / "docs" / "ack" ack_dir = project / ".pouch" / "ack"
ack_dir.mkdir(parents=True) ack_dir.mkdir(parents=True)
knowledge_path = ack_dir / "knowledge.yaml" knowledge_path = ack_dir / "knowledge.yaml"
knowledge_path.write_text( knowledge_path.write_text(
@@ -779,7 +779,7 @@ class AckKnowledgeTests(unittest.TestCase):
"project": { "project": {
"name": "notes-web", "name": "notes-web",
"repoPath": str(project), "repoPath": str(project),
"knowledgeFile": "docs/ack/knowledge.yaml", "knowledgeFile": ".pouch/ack/knowledge.yaml",
}, },
"tasks": [ "tasks": [
{ {
@@ -878,7 +878,7 @@ class AckKnowledgeTests(unittest.TestCase):
def test_paired_examples_validate_when_installed_in_project_layout(self) -> None: def test_paired_examples_validate_when_installed_in_project_layout(self) -> None:
with tempfile.TemporaryDirectory() as temp_dir: with tempfile.TemporaryDirectory() as temp_dir:
project = Path(temp_dir) / "notes-web" project = Path(temp_dir) / "notes-web"
ack_dir = project / "docs" / "ack" ack_dir = project / ".pouch" / "ack"
ack_dir.mkdir(parents=True) ack_dir.mkdir(parents=True)
knowledge_path = ack_dir / "knowledge.yaml" knowledge_path = ack_dir / "knowledge.yaml"
tasks_path = ack_dir / "tasks.yaml" tasks_path = ack_dir / "tasks.yaml"
+2 -2
View File
@@ -435,7 +435,7 @@ class PlanTests(unittest.TestCase):
def test_authoritative_board_is_derived_from_project_root_without_repo_path(self) -> None: def test_authoritative_board_is_derived_from_project_root_without_repo_path(self) -> None:
with tempfile.TemporaryDirectory() as temporary: with tempfile.TemporaryDirectory() as temporary:
project = Path(temporary).resolve() project = Path(temporary).resolve()
ack_dir = project / "docs" / "ack" ack_dir = project / ".pouch" / "ack"
ack_dir.mkdir(parents=True) ack_dir.mkdir(parents=True)
task_board = board(project) task_board = board(project)
del task_board["project"]["repoPath"] del task_board["project"]["repoPath"]
@@ -454,7 +454,7 @@ class PlanTests(unittest.TestCase):
def test_authoritative_board_ignores_legacy_repo_path(self) -> None: def test_authoritative_board_ignores_legacy_repo_path(self) -> None:
with tempfile.TemporaryDirectory() as temporary: with tempfile.TemporaryDirectory() as temporary:
project = Path(temporary).resolve() project = Path(temporary).resolve()
ack_dir = project / "docs" / "ack" ack_dir = project / ".pouch" / "ack"
ack_dir.mkdir(parents=True) ack_dir.mkdir(parents=True)
task_board = board(project) task_board = board(project)
task_board["project"]["repoPath"] = "/legacy/other-worktree" task_board["project"]["repoPath"] = "/legacy/other-worktree"
+3 -3
View File
@@ -127,7 +127,7 @@ class AckRegressionValidationTests(unittest.TestCase):
tasks = { tasks = {
"project": { "project": {
"name": "notes-web", "name": "notes-web",
"regressionFile": "docs/ack/regression.yaml", "regressionFile": ".pouch/ack/regression.yaml",
}, },
"regressionRuns": [], "regressionRuns": [],
"tasks": [ "tasks": [
@@ -140,9 +140,9 @@ class AckRegressionValidationTests(unittest.TestCase):
catalog = validate_regression.load_yaml(EXAMPLE, "回归目录") catalog = validate_regression.load_yaml(EXAMPLE, "回归目录")
self.assertEqual(validate_regression.validate_tasks_link(catalog, tasks), []) self.assertEqual(validate_regression.validate_tasks_link(catalog, tasks), [])
tasks["project"]["regressionFile"] = "docs/ack/other.yaml" tasks["project"]["regressionFile"] = ".pouch/ack/other.yaml"
errors = validate_regression.validate_tasks_link(catalog, tasks) errors = validate_regression.validate_tasks_link(catalog, tasks)
self.assertTrue(any("必须固定为 docs/ack/regression.yaml" in item for item in errors)) self.assertTrue(any("必须固定为 .pouch/ack/regression.yaml" in item for item in errors))
if __name__ == "__main__": if __name__ == "__main__":
+10 -8
View File
@@ -13,12 +13,12 @@ class AckSkillContentTests(unittest.TestCase):
content = (REPO_ROOT / "skills" / "ack" / "SKILL.md").read_text(encoding="utf-8") content = (REPO_ROOT / "skills" / "ack" / "SKILL.md").read_text(encoding="utf-8")
for expected in ( for expected in (
"skiff init ack --project <project-root>", "pouch init ack --project <project-root>",
"docs/ack/project.md", ".pouch/ack/project.md",
"docs/ack/tasks.yaml", ".pouch/ack/tasks.yaml",
"docs/ack/knowledge.yaml", ".pouch/ack/knowledge.yaml",
"docs/ack/delivery.yaml", ".pouch/ack/delivery.yaml",
"docs/ack/regression.yaml", ".pouch/ack/regression.yaml",
"tasks: []", "tasks: []",
"validate_tasks.py", "validate_tasks.py",
"validate_knowledge.py", "validate_knowledge.py",
@@ -35,6 +35,8 @@ class AckSkillContentTests(unittest.TestCase):
"运行版本发布", "运行版本发布",
"运行回归", "运行回归",
"via: deployer", "via: deployer",
"## ack 初始化:完成 | 部分完成 | 阻塞",
"加载 deployer skill 的「初始化」",
): ):
self.assertIn(expected, content) self.assertIn(expected, content)
@@ -167,8 +169,8 @@ class AckSkillContentTests(unittest.TestCase):
# v0.19 起 allowedWorktrees 白名单废弃:模板只保留废弃说明注释,不再生成该字段 # v0.19 起 allowedWorktrees 白名单废弃:模板只保留废弃说明注释,不再生成该字段
self.assertNotIn("allowedWorktrees:", template) self.assertNotIn("allowedWorktrees:", template)
self.assertIn("allowedWorktrees", template) self.assertIn("allowedWorktrees", template)
self.assertIn('knowledgeFile: "docs/ack/knowledge.yaml"', template) self.assertIn('knowledgeFile: ".pouch/ack/knowledge.yaml"', template)
self.assertIn('regressionFile: "docs/ack/regression.yaml"', template) self.assertIn('regressionFile: ".pouch/ack/regression.yaml"', template)
if __name__ == "__main__": if __name__ == "__main__":
+9 -9
View File
@@ -371,7 +371,7 @@ class AckTaskValidationTests(unittest.TestCase):
def test_delivery_run_is_separate_and_requires_verified_tasks(self) -> None: def test_delivery_run_is_separate_and_requires_verified_tasks(self) -> None:
board = valid_manual_routing_board() board = valid_manual_routing_board()
board["project"]["deliveryFile"] = "docs/ack/delivery.yaml" board["project"]["deliveryFile"] = ".pouch/ack/delivery.yaml"
board["tasks"][0]["status"] = "verified" board["tasks"][0]["status"] = "verified"
board["deliveryRuns"] = [ board["deliveryRuns"] = [
{ {
@@ -412,7 +412,7 @@ class AckTaskValidationTests(unittest.TestCase):
def test_validation_ready_delivery_run_does_not_require_pull_request(self) -> None: def test_validation_ready_delivery_run_does_not_require_pull_request(self) -> None:
board = valid_manual_routing_board() board = valid_manual_routing_board()
board["project"]["deliveryFile"] = "docs/ack/delivery.yaml" board["project"]["deliveryFile"] = ".pouch/ack/delivery.yaml"
board["tasks"][0]["status"] = "verified" board["tasks"][0]["status"] = "verified"
board["deliveryRuns"] = [ board["deliveryRuns"] = [
{ {
@@ -447,7 +447,7 @@ class AckTaskValidationTests(unittest.TestCase):
def test_intent_delivery_run_allows_empty_task_ids(self) -> None: def test_intent_delivery_run_allows_empty_task_ids(self) -> None:
board = valid_manual_routing_board() board = valid_manual_routing_board()
board["project"]["deliveryFile"] = "docs/ack/delivery.yaml" board["project"]["deliveryFile"] = ".pouch/ack/delivery.yaml"
board["deliveryRuns"] = [ board["deliveryRuns"] = [
{ {
"id": "DR-test-env-1", "id": "DR-test-env-1",
@@ -495,7 +495,7 @@ class AckTaskValidationTests(unittest.TestCase):
) )
board = valid_manual_routing_board() board = valid_manual_routing_board()
board["project"]["deliveryFile"] = "docs/ack/delivery.yaml" board["project"]["deliveryFile"] = ".pouch/ack/delivery.yaml"
self.assert_board_rejected_in_all_modes( self.assert_board_rejected_in_all_modes(
board, board,
"引用 deliveryFile 的任务板必须包含 deliveryRuns 列表", "引用 deliveryFile 的任务板必须包含 deliveryRuns 列表",
@@ -503,7 +503,7 @@ class AckTaskValidationTests(unittest.TestCase):
def test_delivery_run_binds_revisions_and_final_artifact_digest(self) -> None: def test_delivery_run_binds_revisions_and_final_artifact_digest(self) -> None:
board = valid_manual_routing_board() board = valid_manual_routing_board()
board["project"]["deliveryFile"] = "docs/ack/delivery.yaml" board["project"]["deliveryFile"] = ".pouch/ack/delivery.yaml"
board["deliveryRuns"] = [ board["deliveryRuns"] = [
{ {
"id": "DR-demo-2", "id": "DR-demo-2",
@@ -919,11 +919,11 @@ class AckTaskValidationTests(unittest.TestCase):
def test_knowledge_file_is_fixed_in_all_modes(self) -> None: def test_knowledge_file_is_fixed_in_all_modes(self) -> None:
board = valid_knowledge_board() board = valid_knowledge_board()
board["project"]["knowledgeFile"] = "docs/ack/alternate.yaml" board["project"]["knowledgeFile"] = ".pouch/ack/alternate.yaml"
self.assert_board_rejected_in_all_modes( self.assert_board_rejected_in_all_modes(
board, board,
"project.knowledgeFile 必须固定为 docs/ack/knowledge.yaml", "project.knowledgeFile 必须固定为 .pouch/ack/knowledge.yaml",
) )
def test_basic_identifiers_must_be_nonempty_strings_in_all_modes(self) -> None: def test_basic_identifiers_must_be_nonempty_strings_in_all_modes(self) -> None:
@@ -1123,8 +1123,8 @@ class AckTaskValidationTests(unittest.TestCase):
"repoPath": "/repo", "repoPath": "/repo",
"baseUrl": "http://127.0.0.1:3000", "baseUrl": "http://127.0.0.1:3000",
"devWorktree": "/repo-dev", "devWorktree": "/repo-dev",
"overlayFile": "docs/ack/project.md", "overlayFile": ".pouch/ack/project.md",
"knowledgeFile": "docs/ack/knowledge.yaml", "knowledgeFile": ".pouch/ack/knowledge.yaml",
} }
) )
board["tasks"][0].update( board["tasks"][0].update(
+8 -8
View File
@@ -42,7 +42,7 @@ class AckVerificationRunnerTests(unittest.TestCase):
project: Path, project: Path,
knowledge: dict, knowledge: dict,
) -> subprocess.CompletedProcess[str]: ) -> subprocess.CompletedProcess[str]:
knowledge_path = project / "docs" / "ack" / "knowledge.yaml" knowledge_path = project / ".pouch" / "ack" / "knowledge.yaml"
knowledge_path.parent.mkdir(parents=True, exist_ok=True) knowledge_path.parent.mkdir(parents=True, exist_ok=True)
knowledge_path.write_text( knowledge_path.write_text(
yaml.safe_dump(knowledge, allow_unicode=True), yaml.safe_dump(knowledge, allow_unicode=True),
@@ -153,7 +153,7 @@ class AckVerificationRunnerTests(unittest.TestCase):
target = outside / "unsafe" target = outside / "unsafe"
target.write_text("#!/bin/sh\nexit 0\n", encoding="utf-8") target.write_text("#!/bin/sh\nexit 0\n", encoding="utf-8")
target.chmod(target.stat().st_mode | 0o111) target.chmod(target.stat().st_mode | 0o111)
knowledge_path = project / "docs" / "ack" / "knowledge.yaml" knowledge_path = project / ".pouch" / "ack" / "knowledge.yaml"
knowledge_path.parent.mkdir(parents=True) knowledge_path.parent.mkdir(parents=True)
knowledge_path.write_text( knowledge_path.write_text(
yaml.safe_dump( yaml.safe_dump(
@@ -194,7 +194,7 @@ class AckVerificationRunnerTests(unittest.TestCase):
encoding="utf-8", encoding="utf-8",
) )
target.chmod(target.stat().st_mode | 0o111) target.chmod(target.stat().st_mode | 0o111)
knowledge_path = project / "docs" / "ack" / "knowledge.yaml" knowledge_path = project / ".pouch" / "ack" / "knowledge.yaml"
knowledge_path.parent.mkdir(parents=True) knowledge_path.parent.mkdir(parents=True)
knowledge_path.write_text( knowledge_path.write_text(
"""\ """\
@@ -238,7 +238,7 @@ entries: []
with tempfile.TemporaryDirectory() as temp_dir: with tempfile.TemporaryDirectory() as temp_dir:
base = Path(temp_dir) base = Path(temp_dir)
project = base / "project" project = base / "project"
ack_dir = project / "docs" / "ack" ack_dir = project / ".pouch" / "ack"
ack_dir.mkdir(parents=True) ack_dir.mkdir(parents=True)
document = yaml.safe_dump( document = yaml.safe_dump(
knowledge_with_target("checks/reviewed", []), knowledge_with_target("checks/reviewed", []),
@@ -293,7 +293,7 @@ entries: []
with tempfile.TemporaryDirectory() as temp_dir: with tempfile.TemporaryDirectory() as temp_dir:
base = Path(temp_dir) base = Path(temp_dir)
project = base / "project" project = base / "project"
canonical = project / "docs" / "ack" / "knowledge.yaml" canonical = project / ".pouch" / "ack" / "knowledge.yaml"
canonical.parent.mkdir(parents=True) canonical.parent.mkdir(parents=True)
safe_document = knowledge_with_target("checks/safe", []) safe_document = knowledge_with_target("checks/safe", [])
forged_document = knowledge_with_target("checks/danger", []) forged_document = knowledge_with_target("checks/danger", [])
@@ -335,7 +335,7 @@ entries: []
) -> None: ) -> None:
with tempfile.TemporaryDirectory() as temp_dir: with tempfile.TemporaryDirectory() as temp_dir:
project = Path(temp_dir) / "project" project = Path(temp_dir) / "project"
canonical = project / "docs" / "ack" / "knowledge.yaml" canonical = project / ".pouch" / "ack" / "knowledge.yaml"
canonical.parent.mkdir(parents=True) canonical.parent.mkdir(parents=True)
canonical.write_text( canonical.write_text(
yaml.safe_dump( yaml.safe_dump(
@@ -346,7 +346,7 @@ entries: []
) )
source_fd, error = RUNNER_MODULE._open_regular_beneath( source_fd, error = RUNNER_MODULE._open_regular_beneath(
project, project,
"docs/ack/knowledge.yaml", ".pouch/ack/knowledge.yaml",
require_executable=False, require_executable=False,
) )
self.assertIsNone(error) self.assertIsNone(error)
@@ -521,7 +521,7 @@ entries: []
encoding="utf-8", encoding="utf-8",
) )
target.chmod(target.stat().st_mode | 0o111) target.chmod(target.stat().st_mode | 0o111)
knowledge_path = project / "docs" / "ack" / "knowledge.yaml" knowledge_path = project / ".pouch" / "ack" / "knowledge.yaml"
knowledge_path.parent.mkdir(parents=True) knowledge_path.parent.mkdir(parents=True)
knowledge_path.write_text( knowledge_path.write_text(
yaml.safe_dump( yaml.safe_dump(
+11 -11
View File
@@ -25,7 +25,7 @@ class AgentsTargetTests(unittest.TestCase):
def setUp(self) -> None: def setUp(self) -> None:
self.temp_dir = tempfile.TemporaryDirectory() self.temp_dir = tempfile.TemporaryDirectory()
self.home = Path(self.temp_dir.name) self.home = Path(self.temp_dir.name)
self.skills_home = self.home / ".skills" self.skills_home = self.home / ".pouch"
self.skills_home.mkdir(parents=True) self.skills_home.mkdir(parents=True)
(self.skills_home / "catalog.yaml").write_text("", encoding="utf-8") (self.skills_home / "catalog.yaml").write_text("", encoding="utf-8")
write_skill(self.skills_home, "demo-skill") write_skill(self.skills_home, "demo-skill")
@@ -33,12 +33,12 @@ class AgentsTargetTests(unittest.TestCase):
def tearDown(self) -> None: def tearDown(self) -> None:
self.temp_dir.cleanup() self.temp_dir.cleanup()
def run_skiff(self, *args: str) -> subprocess.CompletedProcess[str]: def run_pouch(self, *args: str) -> subprocess.CompletedProcess[str]:
env = os.environ.copy() env = os.environ.copy()
env["HOME"] = str(self.home) env["HOME"] = str(self.home)
env["PYTHONPATH"] = str(REPO_ROOT) env["PYTHONPATH"] = str(REPO_ROOT)
return subprocess.run( return subprocess.run(
[sys.executable, "-m", "skiff", *args], [sys.executable, "-m", "pouch", *args],
cwd=REPO_ROOT, cwd=REPO_ROOT,
env=env, env=env,
text=True, text=True,
@@ -47,7 +47,7 @@ class AgentsTargetTests(unittest.TestCase):
) )
def test_global_add_creates_symlink_in_agents_skills(self) -> None: def test_global_add_creates_symlink_in_agents_skills(self) -> None:
result = self.run_skiff("add", "builtin/demo-skill", "-g", "-a", "agents") result = self.run_pouch("add", "builtin/demo-skill", "-g", "-a", "agents")
self.assertEqual(result.returncode, 0, result.stderr) self.assertEqual(result.returncode, 0, result.stderr)
link = self.home / ".agents" / "skills" / "demo-skill" link = self.home / ".agents" / "skills" / "demo-skill"
@@ -56,7 +56,7 @@ class AgentsTargetTests(unittest.TestCase):
link.resolve(), (self.skills_home / "skills" / "demo-skill").resolve() link.resolve(), (self.skills_home / "skills" / "demo-skill").resolve()
) )
removed = self.run_skiff("rm", "builtin/demo-skill", "-g", "-a", "agents") removed = self.run_pouch("rm", "builtin/demo-skill", "-g", "-a", "agents")
self.assertEqual(removed.returncode, 0, removed.stderr) self.assertEqual(removed.returncode, 0, removed.stderr)
self.assertFalse(link.exists()) self.assertFalse(link.exists())
@@ -64,7 +64,7 @@ class AgentsTargetTests(unittest.TestCase):
project = self.home / "app" project = self.home / "app"
project.mkdir() project.mkdir()
added = self.run_skiff( added = self.run_pouch(
"add", "add",
"builtin/demo-skill", "builtin/demo-skill",
"--project", "--project",
@@ -80,25 +80,25 @@ class AgentsTargetTests(unittest.TestCase):
links = list((project / ".agents" / "skills").glob("demo-skill")) links = list((project / ".agents" / "skills").glob("demo-skill"))
self.assertEqual(len(links), 1) self.assertEqual(len(links), 1)
self.assertTrue(links[0].is_symlink()) self.assertTrue(links[0].is_symlink())
manifest = (project / ".skills.yaml").read_text(encoding="utf-8") manifest = (project / ".pouch.yaml").read_text(encoding="utf-8")
self.assertIn("demo-skill", manifest) self.assertIn("demo-skill", manifest)
removed = self.run_skiff( removed = self.run_pouch(
"rm", "builtin/demo-skill", "--project", str(project), "-y" "rm", "builtin/demo-skill", "--project", str(project), "-y"
) )
self.assertEqual(removed.returncode, 0, removed.stderr) self.assertEqual(removed.returncode, 0, removed.stderr)
self.assertFalse((project / ".agents" / "skills" / "demo-skill").exists()) self.assertFalse((project / ".agents" / "skills" / "demo-skill").exists())
def test_status_lists_installed_skill_for_agents_target(self) -> None: def test_status_lists_installed_skill_for_agents_target(self) -> None:
installed = self.run_skiff("add", "builtin/demo-skill", "-g", "-a", "agents") installed = self.run_pouch("add", "builtin/demo-skill", "-g", "-a", "agents")
status = self.run_skiff("status", "-a", "agents") status = self.run_pouch("status", "-a", "agents")
self.assertEqual(installed.returncode, 0, installed.stderr) self.assertEqual(installed.returncode, 0, installed.stderr)
self.assertEqual(status.returncode, 0, status.stderr) self.assertEqual(status.returncode, 0, status.stderr)
self.assertIn("demo-skill", status.stdout) self.assertIn("demo-skill", status.stdout)
def test_opencode_target_is_no_longer_supported(self) -> None: def test_opencode_target_is_no_longer_supported(self) -> None:
result = self.run_skiff("add", "builtin/demo-skill", "-g", "-a", "opencode") result = self.run_pouch("add", "builtin/demo-skill", "-g", "-a", "opencode")
self.assertNotEqual(result.returncode, 0) self.assertNotEqual(result.returncode, 0)
self.assertIn("未知 agent", result.stderr) self.assertIn("未知 agent", result.stderr)
+238
View File
@@ -0,0 +1,238 @@
from __future__ import annotations
import importlib.util
import os
import shutil
import subprocess
import tempfile
import unittest
from io import StringIO
from pathlib import Path
from unittest import mock
REPO_ROOT = Path(__file__).resolve().parents[1]
SCRIPTS = REPO_ROOT / "skills" / "builder" / "scripts"
CHECK_PY = SCRIPTS / "check.py"
TEMPLATE = REPO_ROOT / "skills" / "builder" / "templates" / "makefile.builder"
spec = importlib.util.spec_from_file_location("builder_check", CHECK_PY)
assert spec is not None and spec.loader is not None
builder_check = importlib.util.module_from_spec(spec)
spec.loader.exec_module(builder_check)
def git(cwd: Path, *args: str) -> None:
result = subprocess.run(
["git", *args],
cwd=cwd,
text=True,
capture_output=True,
check=False,
env={
**os.environ,
"GIT_AUTHOR_NAME": "Test",
"GIT_AUTHOR_EMAIL": "test@example.com",
"GIT_COMMITTER_NAME": "Test",
"GIT_COMMITTER_EMAIL": "test@example.com",
},
)
if result.returncode != 0:
raise AssertionError(f"git {args} failed: {result.stderr}")
def init_repo(path: Path) -> None:
git(path, "init", "-b", "main")
git(path, "config", "user.email", "test@example.com")
git(path, "config", "user.name", "Test")
(path / "README").write_text("x\n", encoding="utf-8")
git(path, "add", "README")
git(path, "commit", "-m", "init")
def write_contract_makefile(project: Path) -> None:
text = TEMPLATE.read_text(encoding="utf-8")
text = text.replace(
"include $(HOME)/.pouch/skills/builder/scripts/version.mk",
f"include {SCRIPTS / 'version.mk'}",
)
(project / "makefile.builder").write_text(text, encoding="utf-8")
def run_check(
project: Path,
*flags: str,
env: dict[str, str] | None = None,
which: dict[str, str | None] | None = None,
) -> tuple[int, str]:
merged = os.environ.copy()
if env:
merged.update(env)
merged["BUILDER_SKILL_DIR"] = str(SCRIPTS.parent)
stdout = StringIO()
stderr = StringIO()
real_which = shutil.which
def fake_which(name: str, *args: object, **kwargs: object) -> str | None:
if which is not None and name in which:
return which[name]
return real_which(name)
with mock.patch.dict(os.environ, merged, clear=True):
with mock.patch("sys.stdout", stdout), mock.patch("sys.stderr", stderr):
with mock.patch.object(builder_check.shutil, "which", side_effect=fake_which):
code = builder_check.main([str(project), *flags])
return code, stdout.getvalue() + stderr.getvalue()
class BuilderCheckTests(unittest.TestCase):
def test_skill_documents_init_and_does_not_call_create_makefile(self) -> None:
skill = (REPO_ROOT / "skills" / "builder" / "SKILL.md").read_text(encoding="utf-8")
contract = (
REPO_ROOT / "skills" / "builder" / "references" / "contract.md"
).read_text(encoding="utf-8")
self.assertIn("## 初始化", skill)
self.assertIn("check.py", skill)
self.assertIn("--ready", skill)
self.assertIn("makefile.builder", skill)
self.assertIn(".env.builder", skill)
self.assertIn("不要改用户的 `Makefile`", skill)
self.assertIn("不要调用 create-makefile", skill)
self.assertIn("不要用 create-makefile", contract)
self.assertIn("makefile.builder", contract)
self.assertIn(".env.builder", contract)
self.assertIn("不要读取或改写用户 `.env`", contract)
def test_no_makefile_without_ready_is_usage_error(self) -> None:
with tempfile.TemporaryDirectory() as temp:
project = Path(temp)
code, text = run_check(project)
self.assertEqual(code, 2)
self.assertIn("no makefile.builder", text)
def test_ready_without_makefile_fails_with_repair_hint(self) -> None:
with tempfile.TemporaryDirectory() as temp:
project = Path(temp)
code, text = run_check(project, "--ready")
self.assertEqual(code, 1)
self.assertIn("[FAIL] 1. makefile.builder 存在", text)
self.assertIn("makefile.builder", text)
self.assertIn("RESULT: FAILED", text)
def test_contract_makefile_without_env_passes_build_and_skips_publish_keys(self) -> None:
with tempfile.TemporaryDirectory() as temp:
project = Path(temp)
init_repo(project)
write_contract_makefile(project)
code, text = run_check(
project, "--ready", which={"dpkg-deb": "/usr/bin/dpkg-deb"}
)
self.assertEqual(code, 0, text)
self.assertIn("RESULT: PASSED", text)
self.assertIn("[SKIP] 11. 发布环境变量键名", text)
self.assertIn("DEB_SERVER_URL: MISSING", text)
self.assertIn("blocks publish, not build", text)
self.assertNotRegex(text, r"DEB_TOKEN: (?!MISSING|present).+")
def test_env_keys_present_without_printing_values(self) -> None:
with tempfile.TemporaryDirectory() as temp:
project = Path(temp)
init_repo(project)
write_contract_makefile(project)
(project / ".env.builder").write_text(
"DEB_SERVER_URL=https://secret.example.com\n"
"DEB_TOKEN=super-secret-token-value\n"
"DEB_REPOSITORY=main\n",
encoding="utf-8",
)
code, text = run_check(
project, "--ready", which={"dpkg-deb": "/usr/bin/dpkg-deb"}
)
self.assertEqual(code, 0, text)
self.assertIn("DEB_SERVER_URL: present", text)
self.assertIn("DEB_TOKEN: present", text)
self.assertNotIn("super-secret-token-value", text)
self.assertNotIn("https://secret.example.com", text)
def test_user_dotenv_is_ignored(self) -> None:
with tempfile.TemporaryDirectory() as temp:
project = Path(temp)
init_repo(project)
write_contract_makefile(project)
(project / ".env").write_text(
"DEB_SERVER_URL=https://user.example.com\n"
"DEB_TOKEN=user-env-secret-token\n"
"DEB_REPOSITORY=main\n",
encoding="utf-8",
)
code, text = run_check(
project, "--ready", which={"dpkg-deb": "/usr/bin/dpkg-deb"}
)
self.assertEqual(code, 0, text)
self.assertIn("DEB_SERVER_URL: MISSING", text)
self.assertNotIn("user-env-secret-token", text)
self.assertNotIn("https://user.example.com", text)
def test_empty_env_builder_values_count_as_missing(self) -> None:
with tempfile.TemporaryDirectory() as temp:
project = Path(temp)
init_repo(project)
write_contract_makefile(project)
(project / ".env.builder").write_text(
"DEB_SERVER_URL=\nDEB_TOKEN=\nDEB_REPOSITORY=\n",
encoding="utf-8",
)
code, text = run_check(
project, "--ready", which={"dpkg-deb": "/usr/bin/dpkg-deb"}
)
self.assertEqual(code, 0, text)
self.assertIn("DEB_TOKEN: MISSING", text)
def test_ready_fails_when_docker_track_missing_docker(self) -> None:
with tempfile.TemporaryDirectory() as temp:
project = Path(temp)
init_repo(project)
write_contract_makefile(project)
(project / "Dockerfile").write_text("FROM scratch\n", encoding="utf-8")
code, text = run_check(
project,
"--ready",
which={"docker": None, "dpkg-deb": "/usr/bin/dpkg-deb"},
)
self.assertEqual(code, 1, text)
self.assertIn("[FAIL] 10. 轨道工具链", text)
self.assertIn("docker: MISSING", text)
def test_user_makefile_does_not_satisfy_contract(self) -> None:
with tempfile.TemporaryDirectory() as temp:
project = Path(temp)
(project / "Makefile").write_text(
"help:\n\t@echo user\nbuild:\n\t@echo user-build\n",
encoding="utf-8",
)
code, text = run_check(project, "--ready")
self.assertEqual(code, 1, text)
self.assertIn("no makefile.builder", text)
def test_user_makefile_is_ignored_when_builder_file_exists(self) -> None:
with tempfile.TemporaryDirectory() as temp:
project = Path(temp)
init_repo(project)
write_contract_makefile(project)
(project / "Makefile").write_text(
"TOKEN=super-secret-user-makefile-token\n"
"help:\n\t@echo hijacked\n"
"docker:\n\tdocker push example:latest\n",
encoding="utf-8",
)
code, text = run_check(
project, "--ready", which={"dpkg-deb": "/usr/bin/dpkg-deb"}
)
self.assertEqual(code, 0, text)
self.assertNotIn("super-secret-user-makefile-token", text)
self.assertNotIn("hijacked", text)
self.assertNotIn(":latest", text)
if __name__ == "__main__":
unittest.main()
+289
View File
@@ -0,0 +1,289 @@
from __future__ import annotations
import os
import stat
import subprocess
import tempfile
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
SCRIPTS = REPO_ROOT / "skills" / "builder" / "scripts"
VERSION_SH = SCRIPTS / "version.sh"
PUBLISH_DOCKER = SCRIPTS / "publish_docker.sh"
VERSION_MK = SCRIPTS / "version.mk"
def git(cwd: Path, *args: str, env: dict[str, str] | None = None) -> str:
merged = os.environ.copy()
if env:
merged.update(env)
merged.setdefault("GIT_AUTHOR_NAME", "Test")
merged.setdefault("GIT_AUTHOR_EMAIL", "test@example.com")
merged.setdefault("GIT_COMMITTER_NAME", "Test")
merged.setdefault("GIT_COMMITTER_EMAIL", "test@example.com")
result = subprocess.run(
["git", *args],
cwd=cwd,
env=merged,
text=True,
capture_output=True,
check=False,
)
if result.returncode != 0:
raise AssertionError(f"git {args} failed: {result.stderr}")
return result.stdout.strip()
def commit(cwd: Path, message: str) -> str:
git(cwd, "add", "-A")
git(cwd, "commit", "-m", message)
return git(cwd, "rev-parse", "HEAD")
def sha7(cwd: Path) -> str:
return git(cwd, "rev-parse", "HEAD")[:7]
def version_sh(*args: str, cwd: Path, env: dict[str, str] | None = None) -> subprocess.CompletedProcess[str]:
merged = os.environ.copy()
if env:
merged.update(env)
return subprocess.run(
["bash", str(VERSION_SH), *args],
cwd=cwd,
env=merged,
text=True,
capture_output=True,
check=False,
)
def init_repo(path: Path) -> None:
git(path, "init", "-b", "main")
git(path, "config", "user.email", "test@example.com")
git(path, "config", "user.name", "Test")
class BuilderVersionTests(unittest.TestCase):
def test_version_sh_is_executable(self) -> None:
mode = VERSION_SH.stat().st_mode
self.assertTrue(mode & stat.S_IXUSR, "version.sh must be executable")
def test_official_on_stable_tag(self) -> None:
with tempfile.TemporaryDirectory() as temp:
repo = Path(temp) / "repo"
repo.mkdir()
init_repo(repo)
(repo / "a").write_text("1\n", encoding="utf-8")
commit(repo, "init")
git(repo, "tag", "-a", "v1.4.2", "-m", "1.4.2")
result = version_sh(cwd=repo)
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(result.stdout, "1.4.2\n")
docker = version_sh("--docker", cwd=repo)
self.assertEqual(docker.returncode, 0, docker.stderr)
self.assertEqual(docker.stdout, "1.4.2\n")
def test_test_version_uses_ancestor_not_global_max(self) -> None:
with tempfile.TemporaryDirectory() as temp:
root = Path(temp)
repo = root / "repo"
repo.mkdir()
init_repo(repo)
(repo / "a").write_text("1\n", encoding="utf-8")
commit(repo, "base")
git(repo, "tag", "v1.4.2")
git(repo, "checkout", "-b", "feat/login-v2")
(repo / "b").write_text("2\n", encoding="utf-8")
commit(repo, "feature")
(repo / "c").write_text("3\n", encoding="utf-8")
commit(repo, "feature 2")
feature_sha = sha7(repo)
git(repo, "checkout", "main")
(repo / "d").write_text("4\n", encoding="utf-8")
commit(repo, "release")
git(repo, "tag", "v1.4.3")
git(repo, "checkout", "feat/login-v2")
result = version_sh(cwd=repo)
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(
result.stdout.strip(),
f"1.4.2~feat-login-v2.2+g{feature_sha}",
)
docker = version_sh("--docker", cwd=repo)
self.assertEqual(
docker.stdout.strip(),
f"1.4.2-feat-login-v2.2.g{feature_sha}",
)
def test_ignores_prerelease_and_app_tags(self) -> None:
with tempfile.TemporaryDirectory() as temp:
repo = Path(temp) / "repo"
repo.mkdir()
init_repo(repo)
(repo / "a").write_text("1\n", encoding="utf-8")
commit(repo, "init")
git(repo, "tag", "v1.0.0")
(repo / "b").write_text("2\n", encoding="utf-8")
commit(repo, "next")
git(repo, "tag", "v1.1.0-rc.1")
git(repo, "tag", "v1.1.0-app-1")
sha = sha7(repo)
result = version_sh(cwd=repo)
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(result.stdout.strip(), f"1.0.0~main.1+g{sha}")
def test_no_stable_tag(self) -> None:
with tempfile.TemporaryDirectory() as temp:
repo = Path(temp) / "repo"
repo.mkdir()
init_repo(repo)
(repo / "a").write_text("1\n", encoding="utf-8")
commit(repo, "init")
sha = sha7(repo)
result = version_sh(cwd=repo)
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(result.stdout.strip(), f"0.0.0~main+g{sha}")
def test_detached_uses_env_branch(self) -> None:
with tempfile.TemporaryDirectory() as temp:
repo = Path(temp) / "repo"
repo.mkdir()
init_repo(repo)
(repo / "a").write_text("1\n", encoding="utf-8")
commit(repo, "init")
git(repo, "tag", "v0.1.0")
(repo / "b").write_text("2\n", encoding="utf-8")
commit(repo, "next")
sha = sha7(repo)
git(repo, "checkout", "--detach", "HEAD")
result = version_sh(cwd=repo, env={"BUILD_BRANCH": "ci_job"})
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(result.stdout.strip(), f"0.1.0~ci-job.1+g{sha}")
def test_override_official_rejected_off_tag(self) -> None:
with tempfile.TemporaryDirectory() as temp:
repo = Path(temp) / "repo"
repo.mkdir()
init_repo(repo)
(repo / "a").write_text("1\n", encoding="utf-8")
commit(repo, "init")
git(repo, "tag", "v1.4.2")
(repo / "b").write_text("2\n", encoding="utf-8")
commit(repo, "next")
result = version_sh("--version", "1.4.3", cwd=repo)
self.assertEqual(result.returncode, 2)
self.assertIn("looks official", result.stderr)
def test_override_official_ok_on_tag(self) -> None:
with tempfile.TemporaryDirectory() as temp:
repo = Path(temp) / "repo"
repo.mkdir()
init_repo(repo)
(repo / "a").write_text("1\n", encoding="utf-8")
commit(repo, "init")
git(repo, "tag", "v1.4.2")
result = version_sh("--version", "v1.4.2", cwd=repo)
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(result.stdout.strip(), "1.4.2")
def test_override_test_shaped_accepted(self) -> None:
with tempfile.TemporaryDirectory() as temp:
repo = Path(temp) / "repo"
repo.mkdir()
init_repo(repo)
(repo / "a").write_text("1\n", encoding="utf-8")
commit(repo, "init")
result = version_sh("--version", "1.4.2~feat.1+gabc1234", "--docker", cwd=repo)
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(result.stdout.strip(), "1.4.2-feat.1.gabc1234")
def test_version_mk_sets_make_version(self) -> None:
with tempfile.TemporaryDirectory() as temp:
repo = Path(temp) / "repo"
repo.mkdir()
init_repo(repo)
(repo / "a").write_text("1\n", encoding="utf-8")
commit(repo, "init")
git(repo, "tag", "v2.0.0")
makefile = repo / "Makefile"
makefile.write_text(
"include {mk}\n"
".PHONY: version\n"
"version:\n"
"\t@echo \"$(VERSION)\"\n".format(mk=VERSION_MK),
encoding="utf-8",
)
result = subprocess.run(
["make", "--no-print-directory", "-C", str(repo), "version"],
text=True,
capture_output=True,
check=False,
)
self.assertEqual(result.returncode, 0, result.stderr + result.stdout)
self.assertEqual(result.stdout.strip(), "2.0.0")
def test_publish_docker_dry_run_uses_derived_tag(self) -> None:
with tempfile.TemporaryDirectory() as temp:
repo = Path(temp) / "repo"
repo.mkdir()
init_repo(repo)
(repo / "Dockerfile").write_text("FROM scratch\n", encoding="utf-8")
commit(repo, "init")
git(repo, "tag", "v3.1.4")
result = subprocess.run(
[
"bash",
str(PUBLISH_DOCKER),
"--registry",
"registry.example.com",
"--repository",
"ns/app",
"--dry-run",
],
cwd=repo,
text=True,
capture_output=True,
check=False,
)
self.assertEqual(result.returncode, 0, result.stderr + result.stdout)
self.assertIn("Image: registry.example.com/ns/app:3.1.4", result.stdout)
def test_publish_docker_rejects_official_tag_off_head(self) -> None:
with tempfile.TemporaryDirectory() as temp:
repo = Path(temp) / "repo"
repo.mkdir()
init_repo(repo)
(repo / "Dockerfile").write_text("FROM scratch\n", encoding="utf-8")
commit(repo, "init")
git(repo, "tag", "v1.0.0")
(repo / "b").write_text("2\n", encoding="utf-8")
commit(repo, "next")
result = subprocess.run(
[
"bash",
str(PUBLISH_DOCKER),
"--registry",
"registry.example.com",
"--repository",
"ns/app",
"--tag",
"1.0.1",
"--dry-run",
],
cwd=repo,
text=True,
capture_output=True,
check=False,
)
self.assertEqual(result.returncode, 2)
self.assertIn("looks official", result.stderr)
if __name__ == "__main__":
unittest.main()
+20 -20
View File
@@ -9,8 +9,8 @@ import unittest
from pathlib import Path from pathlib import Path
from unittest.mock import patch from unittest.mock import patch
from skiff import catalog from pouch import catalog
from skiff.catalog import catalog_checkout_path, catalog_repo from pouch.catalog import catalog_checkout_path, catalog_repo
REPO_ROOT = Path(__file__).resolve().parents[1] REPO_ROOT = Path(__file__).resolve().parents[1]
@@ -40,7 +40,7 @@ class CatalogCollectionTests(unittest.TestCase):
def setUp(self) -> None: def setUp(self) -> None:
self.temp_dir = tempfile.TemporaryDirectory() self.temp_dir = tempfile.TemporaryDirectory()
self.home = Path(self.temp_dir.name) self.home = Path(self.temp_dir.name)
self.skills_home = self.home / ".skills" self.skills_home = self.home / ".pouch"
(self.skills_home / "skills").mkdir(parents=True) (self.skills_home / "skills").mkdir(parents=True)
self.upstream = self.home / "upstream" self.upstream = self.home / "upstream"
@@ -79,12 +79,12 @@ class CatalogCollectionTests(unittest.TestCase):
def tearDown(self) -> None: def tearDown(self) -> None:
self.temp_dir.cleanup() self.temp_dir.cleanup()
def run_skiff(self, *args: str) -> subprocess.CompletedProcess[str]: def run_pouch(self, *args: str) -> subprocess.CompletedProcess[str]:
env = os.environ.copy() env = os.environ.copy()
env["HOME"] = str(self.home) env["HOME"] = str(self.home)
env["PYTHONPATH"] = str(REPO_ROOT) env["PYTHONPATH"] = str(REPO_ROOT)
return subprocess.run( return subprocess.run(
[sys.executable, "-m", "skiff", *args], [sys.executable, "-m", "pouch", *args],
cwd=REPO_ROOT, cwd=REPO_ROOT,
env=env, env=env,
text=True, text=True,
@@ -95,16 +95,16 @@ class CatalogCollectionTests(unittest.TestCase):
def test_catalog_repo_expands_home_relative_local_path(self) -> None: def test_catalog_repo_expands_home_relative_local_path(self) -> None:
with patch.dict(os.environ, {"HOME": str(self.home)}): with patch.dict(os.environ, {"HOME": str(self.home)}):
self.assertEqual( self.assertEqual(
catalog_repo({"repo": "~/.skills"}), catalog_repo({"repo": "~/.pouch"}),
str(self.skills_home), str(self.skills_home),
) )
self.assertEqual( self.assertEqual(
catalog_checkout_path("skills", {"repo": "~/.skills"}), catalog_checkout_path("skills", {"repo": "~/.pouch"}),
self.skills_home.resolve(), self.skills_home.resolve(),
) )
def test_add_collection_installs_every_discovered_skill(self) -> None: def test_add_collection_installs_every_discovered_skill(self) -> None:
result = self.run_skiff("add", "test-pack", "-g", "-a", "codex") result = self.run_pouch("add", "test-pack", "-g", "-a", "codex")
self.assertEqual(result.returncode, 0, result.stderr) self.assertEqual(result.returncode, 0, result.stderr)
skill_dir = self.home / ".codex" / "skills" skill_dir = self.home / ".codex" / "skills"
@@ -115,7 +115,7 @@ class CatalogCollectionTests(unittest.TestCase):
self.assertFalse((skill_dir / "test-pack").exists()) self.assertFalse((skill_dir / "test-pack").exists())
def test_add_qualified_collection_skill_installs_only_that_skill(self) -> None: def test_add_qualified_collection_skill_installs_only_that_skill(self) -> None:
result = self.run_skiff("add", "test-pack/second-skill", "-g", "-a", "codex") result = self.run_pouch("add", "test-pack/second-skill", "-g", "-a", "codex")
self.assertEqual(result.returncode, 0, result.stderr) self.assertEqual(result.returncode, 0, result.stderr)
skill_dir = self.home / ".codex" / "skills" skill_dir = self.home / ".codex" / "skills"
@@ -124,7 +124,7 @@ class CatalogCollectionTests(unittest.TestCase):
self.assertTrue((skill_dir / "second-skill" / "SKILL.md").is_file()) self.assertTrue((skill_dir / "second-skill" / "SKILL.md").is_file())
def test_add_collection_with_catalog_source_installs_all(self) -> None: def test_add_collection_with_catalog_source_installs_all(self) -> None:
result = self.run_skiff( result = self.run_pouch(
"add", "add",
"test-pack", "test-pack",
"--source", "--source",
@@ -140,7 +140,7 @@ class CatalogCollectionTests(unittest.TestCase):
self.assertTrue((skill_dir / "second-skill").is_symlink()) self.assertTrue((skill_dir / "second-skill").is_symlink())
def test_legacy_registry_source_alias_still_installs(self) -> None: def test_legacy_registry_source_alias_still_installs(self) -> None:
result = self.run_skiff( result = self.run_pouch(
"add", "add",
"test-pack", "test-pack",
"--source", "--source",
@@ -159,7 +159,7 @@ class CatalogCollectionTests(unittest.TestCase):
project = self.home / "project" project = self.home / "project"
project.mkdir() project.mkdir()
added = self.run_skiff( added = self.run_pouch(
"add", "add",
"test-pack/first-skill", "test-pack/first-skill",
"--project", "--project",
@@ -169,8 +169,8 @@ class CatalogCollectionTests(unittest.TestCase):
) )
link = project / ".agents" / "skills" / "first-skill" link = project / ".agents" / "skills" / "first-skill"
link.unlink() link.unlink()
shutil.rmtree(self.home / ".local" / "share" / "skills" / "externals") shutil.rmtree(self.home / ".local" / "share" / "pouch" / "externals")
synced = self.run_skiff( synced = self.run_pouch(
"sync", "sync",
"--project", "--project",
str(project), str(project),
@@ -179,7 +179,7 @@ class CatalogCollectionTests(unittest.TestCase):
) )
self.assertEqual(added.returncode, 0, added.stderr) self.assertEqual(added.returncode, 0, added.stderr)
self.assertIn('source: "catalog:test-pack"', project.joinpath(".skills.yaml").read_text()) self.assertIn('source: "catalog:test-pack"', project.joinpath(".pouch.yaml").read_text())
self.assertEqual(synced.returncode, 0, synced.stderr) self.assertEqual(synced.returncode, 0, synced.stderr)
self.assertTrue(link.is_symlink()) self.assertTrue(link.is_symlink())
self.assertTrue((link / "SKILL.md").is_file()) self.assertTrue((link / "SKILL.md").is_file())
@@ -188,15 +188,15 @@ class CatalogCollectionTests(unittest.TestCase):
blocked = self.home / ".codex" / "skills" / "second-skill" blocked = self.home / ".codex" / "skills" / "second-skill"
blocked.mkdir(parents=True) blocked.mkdir(parents=True)
result = self.run_skiff("add", "test-pack", "-g", "-a", "codex") result = self.run_pouch("add", "test-pack", "-g", "-a", "codex")
self.assertNotEqual(result.returncode, 0) self.assertNotEqual(result.returncode, 0)
self.assertFalse((self.home / ".codex" / "skills" / "first-skill").exists()) self.assertFalse((self.home / ".codex" / "skills" / "first-skill").exists())
self.assertTrue(blocked.is_dir()) self.assertTrue(blocked.is_dir())
def test_remove_collection_removes_all_child_links(self) -> None: def test_remove_collection_removes_all_child_links(self) -> None:
installed = self.run_skiff("add", "test-pack", "-g", "-a", "codex") installed = self.run_pouch("add", "test-pack", "-g", "-a", "codex")
removed = self.run_skiff("remove", "test-pack", "-g", "-a", "codex") removed = self.run_pouch("remove", "test-pack", "-g", "-a", "codex")
self.assertEqual(installed.returncode, 0, installed.stderr) self.assertEqual(installed.returncode, 0, installed.stderr)
self.assertEqual(removed.returncode, 0, removed.stderr) self.assertEqual(removed.returncode, 0, removed.stderr)
@@ -205,8 +205,8 @@ class CatalogCollectionTests(unittest.TestCase):
self.assertFalse((skill_dir / "second-skill").exists()) self.assertFalse((skill_dir / "second-skill").exists())
def test_status_expands_collection_children(self) -> None: def test_status_expands_collection_children(self) -> None:
installed = self.run_skiff("add", "test-pack", "-g", "-a", "codex") installed = self.run_pouch("add", "test-pack", "-g", "-a", "codex")
status = self.run_skiff("status", "-a", "codex") status = self.run_pouch("status", "-a", "codex")
self.assertEqual(installed.returncode, 0, installed.stderr) self.assertEqual(installed.returncode, 0, installed.stderr)
self.assertEqual(status.returncode, 0, status.stderr) self.assertEqual(status.returncode, 0, status.stderr)
+29 -29
View File
@@ -9,7 +9,7 @@ import unittest
from pathlib import Path from pathlib import Path
from unittest.mock import patch from unittest.mock import patch
from skiff import cli from pouch import cli
REPO_ROOT = Path(__file__).resolve().parents[1] REPO_ROOT = Path(__file__).resolve().parents[1]
@@ -19,7 +19,7 @@ class CreateWorkflowTests(unittest.TestCase):
def setUp(self) -> None: def setUp(self) -> None:
self.temp_dir = tempfile.TemporaryDirectory() self.temp_dir = tempfile.TemporaryDirectory()
self.home = Path(self.temp_dir.name) self.home = Path(self.temp_dir.name)
self.skills_home = self.home / ".skills" self.skills_home = self.home / ".pouch"
template = self.skills_home / "skills" / "_template" template = self.skills_home / "skills" / "_template"
template.mkdir(parents=True) template.mkdir(parents=True)
template.joinpath("SKILL.md").write_text( template.joinpath("SKILL.md").write_text(
@@ -35,28 +35,28 @@ class CreateWorkflowTests(unittest.TestCase):
"给出一条可以直接交给 Agent 的示例请求。\n", "给出一条可以直接交给 Agent 的示例请求。\n",
encoding="utf-8", encoding="utf-8",
) )
project_skill = self.skills_home / "skills" / "skiff" project_skill = self.skills_home / "skills" / "pouch"
project_skill.mkdir() project_skill.mkdir()
project_skill.joinpath("SKILL.md").write_text( project_skill.joinpath("SKILL.md").write_text(
"---\nname: skiff\ndescription: >-\n" "---\nname: pouch\ndescription: >-\n"
" 创建和维护自研 skill。用于创建、安装、反馈或更新 skill 时。\n" " 创建和维护自研 skill。用于创建、安装、反馈或更新 skill 时。\n"
"---\n\n# skiff\n\n## 步骤\n\n1. 维护 skill。\n", "---\n\n# pouch\n\n## 步骤\n\n1. 维护 skill。\n",
encoding="utf-8", encoding="utf-8",
) )
project_skill.joinpath("README.md").write_text( project_skill.joinpath("README.md").write_text(
"# skiff\n\n供人类使用的 skiff 说明。\n", "# pouch\n\n供人类使用的 pouch 说明。\n",
encoding="utf-8", encoding="utf-8",
) )
def tearDown(self) -> None: def tearDown(self) -> None:
self.temp_dir.cleanup() self.temp_dir.cleanup()
def run_skiff(self, *args: str) -> subprocess.CompletedProcess[str]: def run_pouch(self, *args: str) -> subprocess.CompletedProcess[str]:
env = os.environ.copy() env = os.environ.copy()
env["HOME"] = str(self.home) env["HOME"] = str(self.home)
env["PYTHONPATH"] = str(REPO_ROOT) env["PYTHONPATH"] = str(REPO_ROOT)
return subprocess.run( return subprocess.run(
[sys.executable, "-m", "skiff", *args], [sys.executable, "-m", "pouch", *args],
cwd=REPO_ROOT, cwd=REPO_ROOT,
env=env, env=env,
text=True, text=True,
@@ -65,25 +65,25 @@ class CreateWorkflowTests(unittest.TestCase):
) )
def test_setup_command_is_not_exposed(self) -> None: def test_setup_command_is_not_exposed(self) -> None:
help_result = self.run_skiff("--help") help_result = self.run_pouch("--help")
setup_result = self.run_skiff("setup", str(self.skills_home)) setup_result = self.run_pouch("setup", str(self.skills_home))
self.assertEqual(help_result.returncode, 0, help_result.stderr) self.assertEqual(help_result.returncode, 0, help_result.stderr)
self.assertNotIn("setup", help_result.stdout) self.assertNotIn("setup", help_result.stdout)
self.assertNotEqual(setup_result.returncode, 0) self.assertNotEqual(setup_result.returncode, 0)
def test_bootstrap_installs_project_skill_globally_for_all_agents(self) -> None: def test_bootstrap_installs_project_skill_globally_for_all_agents(self) -> None:
first = self.run_skiff("bootstrap") first = self.run_pouch("bootstrap")
second = self.run_skiff("bootstrap") second = self.run_pouch("bootstrap")
self.assertEqual(first.returncode, 0, first.stderr) self.assertEqual(first.returncode, 0, first.stderr)
self.assertEqual(second.returncode, 0, second.stderr) self.assertEqual(second.returncode, 0, second.stderr)
expected = (self.skills_home / "skills" / "skiff").resolve() expected = (self.skills_home / "skills" / "pouch").resolve()
for relative in ( for relative in (
".cursor/skills/skiff", ".cursor/skills/pouch",
".claude/skills/skiff", ".claude/skills/pouch",
".codex/skills/skiff", ".codex/skills/pouch",
".agents/skills/skiff", ".agents/skills/pouch",
): ):
link = self.home / relative link = self.home / relative
self.assertTrue(link.is_symlink(), relative) self.assertTrue(link.is_symlink(), relative)
@@ -93,8 +93,8 @@ class CreateWorkflowTests(unittest.TestCase):
def test_update_pulls_skills_home(self) -> None: def test_update_pulls_skills_home(self) -> None:
with ( with (
patch.object(cli, "SKILLS_HOME", self.skills_home), patch.object(cli, "POUCH_HOME", self.skills_home),
patch.object(cli, "ensure_skills_home"), patch.object(cli, "ensure_pouch_home"),
patch.object(cli.subprocess, "run") as run, patch.object(cli.subprocess, "run") as run,
): ):
cli.cmd_update(argparse.Namespace()) cli.cmd_update(argparse.Namespace())
@@ -108,7 +108,7 @@ class CreateWorkflowTests(unittest.TestCase):
project = self.home / "project" project = self.home / "project"
project.mkdir() project.mkdir()
result = self.run_skiff( result = self.run_pouch(
"create", "create",
"migration-review", "migration-review",
"--idea", "--idea",
@@ -128,19 +128,19 @@ class CreateWorkflowTests(unittest.TestCase):
self.assertIn("idea: 检查数据库迁移", brief) self.assertIn("idea: 检查数据库迁移", brief)
self.assertIn(f"source_project: {project.resolve()}", brief) self.assertIn(f"source_project: {project.resolve()}", brief)
self.assertFalse((self.skills_home / "skills" / "migration-review").exists()) self.assertFalse((self.skills_home / "skills" / "migration-review").exists())
self.assertIn("请完善 skiff 草稿 migration-review", result.stdout) self.assertIn("请完善 pouch 草稿 migration-review", result.stdout)
def test_check_rejects_template_placeholders(self) -> None: def test_check_rejects_template_placeholders(self) -> None:
created = self.run_skiff("create", "migration-review", "--idea", "检查数据库迁移") created = self.run_pouch("create", "migration-review", "--idea", "检查数据库迁移")
self.assertEqual(created.returncode, 0, created.stderr) self.assertEqual(created.returncode, 0, created.stderr)
result = self.run_skiff("check", "migration-review") result = self.run_pouch("check", "migration-review")
self.assertNotEqual(result.returncode, 0) self.assertNotEqual(result.returncode, 0)
self.assertIn("模板占位", result.stderr) self.assertIn("模板占位", result.stderr)
def test_finalize_moves_valid_draft_and_removes_brief(self) -> None: def test_finalize_moves_valid_draft_and_removes_brief(self) -> None:
created = self.run_skiff("create", "migration-review", "--idea", "检查数据库迁移") created = self.run_pouch("create", "migration-review", "--idea", "检查数据库迁移")
self.assertEqual(created.returncode, 0, created.stderr) self.assertEqual(created.returncode, 0, created.stderr)
draft = self.skills_home / ".drafts" / "migration-review" draft = self.skills_home / ".drafts" / "migration-review"
draft.joinpath("SKILL.md").write_text( draft.joinpath("SKILL.md").write_text(
@@ -156,7 +156,7 @@ class CreateWorkflowTests(unittest.TestCase):
encoding="utf-8", encoding="utf-8",
) )
result = self.run_skiff("finalize", "migration-review") result = self.run_pouch("finalize", "migration-review")
self.assertEqual(result.returncode, 0, result.stderr) self.assertEqual(result.returncode, 0, result.stderr)
final = self.skills_home / "skills" / "migration-review" final = self.skills_home / "skills" / "migration-review"
@@ -179,7 +179,7 @@ class CreateWorkflowTests(unittest.TestCase):
encoding="utf-8", encoding="utf-8",
) )
result = self.run_skiff("check", "reference-check") result = self.run_pouch("check", "reference-check")
self.assertNotEqual(result.returncode, 0) self.assertNotEqual(result.returncode, 0)
self.assertIn("引用文件不存在", result.stderr) self.assertIn("引用文件不存在", result.stderr)
@@ -194,19 +194,19 @@ class CreateWorkflowTests(unittest.TestCase):
encoding="utf-8", encoding="utf-8",
) )
result = self.run_skiff("check", "missing-readme") result = self.run_pouch("check", "missing-readme")
self.assertNotEqual(result.returncode, 0) self.assertNotEqual(result.returncode, 0)
self.assertIn("缺少 README.md", result.stderr) self.assertIn("缺少 README.md", result.stderr)
def test_finalize_does_not_overwrite_existing_owned_skill(self) -> None: def test_finalize_does_not_overwrite_existing_owned_skill(self) -> None:
created = self.run_skiff("create", "collision-check", "--idea", "检查名称冲突") created = self.run_pouch("create", "collision-check", "--idea", "检查名称冲突")
self.assertEqual(created.returncode, 0, created.stderr) self.assertEqual(created.returncode, 0, created.stderr)
final = self.skills_home / "skills" / "collision-check" final = self.skills_home / "skills" / "collision-check"
final.mkdir() final.mkdir()
final.joinpath("marker").write_text("keep", encoding="utf-8") final.joinpath("marker").write_text("keep", encoding="utf-8")
result = self.run_skiff("finalize", "collision-check") result = self.run_pouch("finalize", "collision-check")
self.assertNotEqual(result.returncode, 0) self.assertNotEqual(result.returncode, 0)
self.assertEqual(final.joinpath("marker").read_text(encoding="utf-8"), "keep") self.assertEqual(final.joinpath("marker").read_text(encoding="utf-8"), "keep")
+31 -31
View File
@@ -8,8 +8,8 @@ import unittest
from pathlib import Path from pathlib import Path
from unittest.mock import patch from unittest.mock import patch
from skiff.project import normalize_skill_entry from pouch.project import normalize_skill_entry
from skiff.sources import fetch_source from pouch.sources import fetch_source
REPO_ROOT = Path(__file__).resolve().parents[1] REPO_ROOT = Path(__file__).resolve().parents[1]
@@ -41,19 +41,19 @@ class CustomSourceTests(unittest.TestCase):
def setUp(self) -> None: def setUp(self) -> None:
self.temp_dir = tempfile.TemporaryDirectory() self.temp_dir = tempfile.TemporaryDirectory()
self.home = Path(self.temp_dir.name) self.home = Path(self.temp_dir.name)
self.skills_home = self.home / ".skills" self.skills_home = self.home / ".pouch"
(self.skills_home / "skills").mkdir(parents=True) (self.skills_home / "skills").mkdir(parents=True)
(self.skills_home / "catalog.yaml").write_text("", encoding="utf-8") (self.skills_home / "catalog.yaml").write_text("", encoding="utf-8")
def tearDown(self) -> None: def tearDown(self) -> None:
self.temp_dir.cleanup() self.temp_dir.cleanup()
def run_skiff(self, *args: str) -> subprocess.CompletedProcess[str]: def run_pouch(self, *args: str) -> subprocess.CompletedProcess[str]:
env = os.environ.copy() env = os.environ.copy()
env["HOME"] = str(self.home) env["HOME"] = str(self.home)
env["PYTHONPATH"] = str(REPO_ROOT) env["PYTHONPATH"] = str(REPO_ROOT)
return subprocess.run( return subprocess.run(
[sys.executable, "-m", "skiff", *args], [sys.executable, "-m", "pouch", *args],
cwd=REPO_ROOT, cwd=REPO_ROOT,
env=env, env=env,
text=True, text=True,
@@ -65,7 +65,7 @@ class CustomSourceTests(unittest.TestCase):
company = self.home / "company" company = self.home / "company"
expected = write_skill(company / "internal" / "skills", "code-review") expected = write_skill(company / "internal" / "skills", "code-review")
added = self.run_skiff( added = self.run_pouch(
"source", "source",
"add", "add",
"company", "company",
@@ -74,8 +74,8 @@ class CustomSourceTests(unittest.TestCase):
"--skills-path", "--skills-path",
"internal/skills", "internal/skills",
) )
listed = self.run_skiff("list", "--source", "company") listed = self.run_pouch("list", "--source", "company")
installed = self.run_skiff("add", "company/code-review", "-g", "-a", "codex") installed = self.run_pouch("add", "company/code-review", "-g", "-a", "codex")
self.assertEqual(added.returncode, 0, added.stderr) self.assertEqual(added.returncode, 0, added.stderr)
self.assertEqual(listed.returncode, 0, listed.stderr) self.assertEqual(listed.returncode, 0, listed.stderr)
@@ -84,7 +84,7 @@ class CustomSourceTests(unittest.TestCase):
link = self.home / ".codex" / "skills" / "code-review" link = self.home / ".codex" / "skills" / "code-review"
self.assertTrue(link.is_symlink()) self.assertTrue(link.is_symlink())
self.assertEqual(link.resolve(), expected.resolve()) self.assertEqual(link.resolve(), expected.resolve())
config = self.home / ".config" / "skiff" / "config.yaml" config = self.home / ".config" / "pouch" / "config.yaml"
self.assertIn("company:", config.read_text(encoding="utf-8")) self.assertIn("company:", config.read_text(encoding="utf-8"))
def test_local_source_can_expose_a_single_skill(self) -> None: def test_local_source_can_expose_a_single_skill(self) -> None:
@@ -94,7 +94,7 @@ class CustomSourceTests(unittest.TestCase):
"---\nname: solo\ndescription: Test single source.\n---\n", "---\nname: solo\ndescription: Test single source.\n---\n",
encoding="utf-8", encoding="utf-8",
) )
added = self.run_skiff( added = self.run_pouch(
"source", "source",
"add", "add",
"solo", "solo",
@@ -103,7 +103,7 @@ class CustomSourceTests(unittest.TestCase):
"--skills-path", "--skills-path",
".", ".",
) )
installed = self.run_skiff( installed = self.run_pouch(
"add", "add",
"solo", "solo",
"-g", "-g",
@@ -122,10 +122,10 @@ class CustomSourceTests(unittest.TestCase):
expected = write_skill(company / "skills", "code-review") expected = write_skill(company / "skills", "code-review")
project = self.home / "project" project = self.home / "project"
project.mkdir() project.mkdir()
added = self.run_skiff("source", "add", "company", "--local", str(company)) added = self.run_pouch("source", "add", "company", "--local", str(company))
self.assertEqual(added.returncode, 0, added.stderr) self.assertEqual(added.returncode, 0, added.stderr)
result = self.run_skiff( result = self.run_pouch(
"add", "add",
"company/code-review", "company/code-review",
"--project", "--project",
@@ -135,7 +135,7 @@ class CustomSourceTests(unittest.TestCase):
) )
self.assertEqual(result.returncode, 0, result.stderr) self.assertEqual(result.returncode, 0, result.stderr)
manifest = project.joinpath(".skills.yaml").read_text(encoding="utf-8") manifest = project.joinpath(".pouch.yaml").read_text(encoding="utf-8")
self.assertIn('name: "code-review"', manifest) self.assertIn('name: "code-review"', manifest)
self.assertIn("source: company", manifest) self.assertIn("source: company", manifest)
self.assertEqual( self.assertEqual(
@@ -149,14 +149,14 @@ class CustomSourceTests(unittest.TestCase):
write_skill(company / "skills", "code-review") write_skill(company / "skills", "code-review")
project = self.home / "project" project = self.home / "project"
project.mkdir() project.mkdir()
project.joinpath(".skills.yaml").write_text( project.joinpath(".pouch.yaml").write_text(
"skills:\n - code-review\n", "skills:\n - code-review\n",
encoding="utf-8", encoding="utf-8",
) )
added = self.run_skiff("source", "add", "company", "--local", str(company)) added = self.run_pouch("source", "add", "company", "--local", str(company))
self.assertEqual(added.returncode, 0, added.stderr) self.assertEqual(added.returncode, 0, added.stderr)
result = self.run_skiff( result = self.run_pouch(
"add", "add",
"company/code-review", "company/code-review",
"--project", "--project",
@@ -166,17 +166,17 @@ class CustomSourceTests(unittest.TestCase):
) )
self.assertEqual(result.returncode, 0, result.stderr) self.assertEqual(result.returncode, 0, result.stderr)
manifest = project.joinpath(".skills.yaml").read_text(encoding="utf-8") manifest = project.joinpath(".pouch.yaml").read_text(encoding="utf-8")
self.assertIn("source: company", manifest) self.assertIn("source: company", manifest)
def test_unqualified_duplicate_requires_explicit_source(self) -> None: def test_unqualified_duplicate_requires_explicit_source(self) -> None:
write_skill(self.skills_home / "skills", "code-review") write_skill(self.skills_home / "skills", "code-review")
company = self.home / "company" company = self.home / "company"
write_skill(company / "skills", "code-review") write_skill(company / "skills", "code-review")
added = self.run_skiff("source", "add", "company", "--local", str(company)) added = self.run_pouch("source", "add", "company", "--local", str(company))
self.assertEqual(added.returncode, 0, added.stderr) self.assertEqual(added.returncode, 0, added.stderr)
result = self.run_skiff("add", "code-review", "-g", "-a", "codex") result = self.run_pouch("add", "code-review", "-g", "-a", "codex")
self.assertNotEqual(result.returncode, 0) self.assertNotEqual(result.returncode, 0)
self.assertIn("builtin/code-review", result.stderr) self.assertIn("builtin/code-review", result.stderr)
@@ -194,9 +194,9 @@ class CustomSourceTests(unittest.TestCase):
" path: skills\n", " path: skills\n",
encoding="utf-8", encoding="utf-8",
) )
added = self.run_skiff("source", "add", "company", "--local", str(company)) added = self.run_pouch("source", "add", "company", "--local", str(company))
result = self.run_skiff( result = self.run_pouch(
"add", "add",
"company/code-review", "company/code-review",
"-g", "-g",
@@ -216,15 +216,15 @@ class CustomSourceTests(unittest.TestCase):
expected = write_skill(company / "skills", "code-review") expected = write_skill(company / "skills", "code-review")
project = self.home / "project" project = self.home / "project"
project.mkdir() project.mkdir()
project.joinpath(".skills.yaml").write_text( project.joinpath(".pouch.yaml").write_text(
"skills:\n - name: code-review\n source: company\n" "skills:\n - name: code-review\n source: company\n"
"targets:\n - codex\n", "targets:\n - codex\n",
encoding="utf-8", encoding="utf-8",
) )
added = self.run_skiff("source", "add", "company", "--local", str(company)) added = self.run_pouch("source", "add", "company", "--local", str(company))
self.assertEqual(added.returncode, 0, added.stderr) self.assertEqual(added.returncode, 0, added.stderr)
result = self.run_skiff("sync", "--project", str(project), "-a", "codex") result = self.run_pouch("sync", "--project", str(project), "-a", "codex")
self.assertEqual(result.returncode, 0, result.stderr) self.assertEqual(result.returncode, 0, result.stderr)
link = project / ".agents" / "skills" / "code-review" link = project / ".agents" / "skills" / "code-review"
@@ -233,16 +233,16 @@ class CustomSourceTests(unittest.TestCase):
def test_sync_reports_missing_machine_source(self) -> None: def test_sync_reports_missing_machine_source(self) -> None:
project = self.home / "project" project = self.home / "project"
project.mkdir() project.mkdir()
project.joinpath(".skills.yaml").write_text( project.joinpath(".pouch.yaml").write_text(
"skills:\n - name: code-review\n source: company\n", "skills:\n - name: code-review\n source: company\n",
encoding="utf-8", encoding="utf-8",
) )
result = self.run_skiff("sync", "--project", str(project), "-a", "codex") result = self.run_pouch("sync", "--project", str(project), "-a", "codex")
self.assertNotEqual(result.returncode, 0) self.assertNotEqual(result.returncode, 0)
self.assertIn("本机尚未配置", result.stderr) self.assertIn("本机尚未配置", result.stderr)
self.assertIn("skiff source add company", result.stderr) self.assertIn("pouch source add company", result.stderr)
def test_git_source_is_cloned_to_default_checkout(self) -> None: def test_git_source_is_cloned_to_default_checkout(self) -> None:
upstream = self.home / "upstream" upstream = self.home / "upstream"
@@ -266,10 +266,10 @@ class CustomSourceTests(unittest.TestCase):
capture_output=True, capture_output=True,
) )
result = self.run_skiff("source", "add", "company", str(upstream)) result = self.run_pouch("source", "add", "company", str(upstream))
self.assertEqual(result.returncode, 0, result.stderr) self.assertEqual(result.returncode, 0, result.stderr)
checkout = self.home / ".local" / "share" / "skiff" / "sources" / "company" checkout = self.home / ".local" / "share" / "pouch" / "sources" / "company"
self.assertTrue((checkout / ".git").is_dir()) self.assertTrue((checkout / ".git").is_dir())
self.assertTrue((checkout / "skills" / "release-check" / "SKILL.md").is_file()) self.assertTrue((checkout / "skills" / "release-check" / "SKILL.md").is_file())
@@ -281,7 +281,7 @@ class CustomSourceTests(unittest.TestCase):
"checkout": str(checkout), "checkout": str(checkout),
} }
with patch("skiff.sources.subprocess.run") as run: with patch("pouch.sources.subprocess.run") as run:
fetch_source("company", entry) fetch_source("company", entry)
run.assert_called_once_with( run.assert_called_once_with(
+122
View File
@@ -0,0 +1,122 @@
from __future__ import annotations
import importlib.util
import os
import tempfile
import unittest
from io import StringIO
from pathlib import Path
from unittest import mock
REPO_ROOT = Path(__file__).resolve().parents[1]
CHECK_PY = REPO_ROOT / "skills" / "deployer" / "scripts" / "deploy" / "check.py"
LIB_PY = REPO_ROOT / "skills" / "deployer" / "scripts" / "deploy" / "lib.py"
lib_spec = importlib.util.spec_from_file_location("deployer_lib", LIB_PY)
assert lib_spec is not None and lib_spec.loader is not None
deployer_lib = importlib.util.module_from_spec(lib_spec)
lib_spec.loader.exec_module(deployer_lib)
check_spec = importlib.util.spec_from_file_location("deployer_check", CHECK_PY)
assert check_spec is not None and check_spec.loader is not None
deployer_check = importlib.util.module_from_spec(check_spec)
check_spec.loader.exec_module(deployer_check)
def run_check(project: Path, hosts: set[str] | None = None) -> tuple[int, str]:
stdout = StringIO()
stderr = StringIO()
deployer_lib.PROJECT_ROOT = None
deployer_lib._SSH_HOSTS = None
deployer_check.lib.PROJECT_ROOT = None
deployer_check.lib._SSH_HOSTS = None
patched_hosts = hosts if hosts is not None else set()
with mock.patch("sys.stdout", stdout), mock.patch("sys.stderr", stderr):
with mock.patch.object(deployer_check.lib, "ssh_config_hosts", return_value=patched_hosts):
with mock.patch.dict(os.environ, {}, clear=False):
os.environ.pop("DEPLOYER_ROOT", None)
code = deployer_check.main(["--project", str(project)])
return code, stdout.getvalue() + stderr.getvalue()
class DeployerCheckTests(unittest.TestCase):
def tearDown(self) -> None:
deployer_lib.PROJECT_ROOT = None
deployer_lib._SSH_HOSTS = None
deployer_check.lib.PROJECT_ROOT = None
deployer_check.lib._SSH_HOSTS = None
def test_skill_documents_init_and_check_script(self) -> None:
skill = (REPO_ROOT / "skills" / "deployer" / "SKILL.md").read_text(
encoding="utf-8"
)
self.assertIn("## 初始化", skill)
self.assertIn("scripts/deploy/check.py", skill)
self.assertIn("不要写假 node", skill)
def test_missing_layout_fails(self) -> None:
with tempfile.TemporaryDirectory() as temp:
project = Path(temp)
code, text = run_check(project)
self.assertEqual(code, 1, text)
self.assertIn("[FAIL] 1. 部署根存在", text)
self.assertIn("test/compose.yaml", text)
def test_compose_without_node_is_partial_failure(self) -> None:
with tempfile.TemporaryDirectory() as temp:
project = Path(temp)
env = project / ".pouch" / "deployer" / "test"
env.mkdir(parents=True)
(env / "compose.yaml").write_text("services:\n web:\n image: nginx\n", encoding="utf-8")
code, text = run_check(project, hosts={"my-vps"})
self.assertEqual(code, 1, text)
self.assertIn("[PASS] 1. 部署根存在", text)
self.assertIn("[PASS] 4. 至少有一个 compose.yaml", text)
self.assertIn("[FAIL] 5. 每个服务能解析 node", text)
self.assertIn("MISSING node", text)
def test_node_missing_from_ssh_config_fails(self) -> None:
with tempfile.TemporaryDirectory() as temp:
project = Path(temp)
root = project / ".pouch" / "deployer"
env = root / "test"
env.mkdir(parents=True)
(root / "_config.yaml").write_text("node: my-vps\n", encoding="utf-8")
(env / "compose.yaml").write_text("services:\n web:\n image: nginx\n", encoding="utf-8")
code, text = run_check(project, hosts=set())
self.assertEqual(code, 1, text)
self.assertIn("[PASS] 5. 每个服务能解析 node", text)
self.assertIn("[FAIL] 6. node 出现在 SSH config", text)
self.assertIn("my-vps NOT in ~/.ssh/config", text)
def test_ready_when_node_and_compose_present(self) -> None:
with tempfile.TemporaryDirectory() as temp:
project = Path(temp)
root = project / ".pouch" / "deployer"
env = root / "test"
env.mkdir(parents=True)
(root / "_config.yaml").write_text("node: my-vps\nbase_path: /opt/app\n", encoding="utf-8")
(env / "compose.yaml").write_text("services:\n web:\n image: nginx\n", encoding="utf-8")
code, text = run_check(project, hosts={"my-vps"})
self.assertEqual(code, 0, text)
self.assertIn("RESULT: PASSED", text)
self.assertIn("[PASS] 7. list 可发现服务", text)
def test_argocd_only_passes_compose_as_skip(self) -> None:
with tempfile.TemporaryDirectory() as temp:
project = Path(temp)
root = project / ".pouch" / "deployer"
root.mkdir(parents=True)
(root / "argocd.yaml").write_text(
"repo: git@git.example.com:org/infra-gitops.git\n",
encoding="utf-8",
)
code, text = run_check(project)
self.assertEqual(code, 0, text)
self.assertIn("[PASS] 3. Argo CD 指针", text)
self.assertIn("[SKIP] 4. 至少有一个 compose.yaml", text)
if __name__ == "__main__":
unittest.main()
+8 -8
View File
@@ -11,10 +11,10 @@ REPO_ROOT = Path(__file__).resolve().parents[1]
class InstallScriptTests(unittest.TestCase): class InstallScriptTests(unittest.TestCase):
def test_install_bootstraps_skiff_skill_for_all_agents(self) -> None: def test_install_bootstraps_pouch_skill_for_all_agents(self) -> None:
with tempfile.TemporaryDirectory() as temp: with tempfile.TemporaryDirectory() as temp:
home = Path(temp) home = Path(temp)
(home / ".skills").symlink_to(REPO_ROOT, target_is_directory=True) (home / ".pouch").symlink_to(REPO_ROOT, target_is_directory=True)
env = os.environ.copy() env = os.environ.copy()
env["HOME"] = str(home) env["HOME"] = str(home)
@@ -29,15 +29,15 @@ class InstallScriptTests(unittest.TestCase):
self.assertEqual(result.returncode, 0, result.stderr) self.assertEqual(result.returncode, 0, result.stderr)
for relative in ( for relative in (
".cursor/skills/skiff", ".cursor/skills/pouch",
".claude/skills/skiff", ".claude/skills/pouch",
".codex/skills/skiff", ".codex/skills/pouch",
".agents/skills/skiff", ".agents/skills/pouch",
): ):
link = home / relative link = home / relative
self.assertTrue(link.is_symlink(), relative) self.assertTrue(link.is_symlink(), relative)
self.assertEqual(link.resolve(), (REPO_ROOT / "skills" / "skiff").resolve()) self.assertEqual(link.resolve(), (REPO_ROOT / "skills" / "pouch").resolve())
self.assertIn("已全局安装 builtin skiff skill", result.stdout) self.assertIn("已全局安装 builtin pouch skill", result.stdout)
if __name__ == "__main__": if __name__ == "__main__":

Some files were not shown because too many files have changed in this diff Show More