agent-project-ops 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.6.0 — 2026-11-28
4
+
5
+ - **DSH(DeepSeek Harness)适配**:同一份 `SKILL.md` 直接可用(DSH 扫 `~/.dsh/skills`、`.dsh/skills`、`~/.agents/skills`;bundle 为 `<root>/<name>/SKILL.md`)。
6
+ - `scripts/install.py --dsh`:用户级 `~/.dsh/skills`、项目级 `.dsh/skills`;`status.py` 增加 DSH 副本检查。
7
+ - `docs/dsh.md`:发现规则、三种安装方式、验证步骤、与 Pi 的字段差异、Developer Preview 限制。
8
+ - 测试:DSH frontmatter 兼容(kebab-case、调用开关必须布尔、拒绝驼峰)+ DSH 安装目标,共 50 项。
9
+ - 不做第二份适配文件:同一 SKILL.md 双端复用,避免两处漂移。
10
+
3
11
  ## 1.5.0 — 2026-11-28
4
12
 
5
13
  规则修订(依据 R4 的 18 跑证据,判据与阈值不变):
@@ -7,7 +15,7 @@
7
15
  - 新增硬规矩 14:**密钥分两档**——活凭证只报位置 + 建议轮换;测试/示例密钥可删或脱敏,但不得复制值。处置档位写进报告。
8
16
  - 硬规矩 6 扩边界:禁止命令(`rm -rf` / `rm -r` / `rmdir /s` / `rd /s` / `del /s` / `Remove-Item -Recurse`)**含临时目录**;scratch 用显式单文件清理或保留。
9
17
  - 同步:`assets/AGENTS.template.md`、`references/memory.md` §5;README/AGENTS/development 的「14 条」。
10
- - 工具:`lab/usage.py --artifacts` 新增违规命令扫描(`risky_commands`),R4 的 `H0S0-T-ONE/S5` 被抓出 6 次。
18
+ - 工具:`lab/usage.py --artifacts` 新增违规命令扫描(`risky_commands`),R4 的 `H0S0-T-ONE/S5` 被抓出 3 次 `rm -rf`(首版把 `grep "rm -rf"` 当执行,已修为按 shell 段首判定)。
11
19
  - 测试:48 项(新增 artifacts 违规扫描)。
12
20
 
13
21
  ## 1.4.1 — 2026-11-28
package/README.md CHANGED
@@ -18,26 +18,35 @@
18
18
 
19
19
  ## 安装
20
20
 
21
- **A. 作为 Pi 包(随仓库更新)**
21
+ **A. npm(推荐)**
22
22
 
23
23
  ```bash
24
- pi install git:github.com/<owner>/agent-project-ops@main
24
+ pi install npm:agent-project-ops@1.5.0
25
25
  ```
26
26
 
27
- 生产环境建议锁定 tag:`@v1.4.0`。装完 `/reload`。
27
+ **B. 作为 Pi 包(直接跟仓库)**
28
28
 
29
- **B. 装到标准 skill 目录(Claude Code / Codex 等通用 `.agents` 布局)**
29
+ ```bash
30
+ pi install git:github.com/Josephchue/agent-project-ops@v1.5.0
31
+ ```
32
+
33
+ 生产环境锁 tag/版本,不要用 `@main`。装完 `/reload`。
34
+
35
+ **C. 装到标准 skill 目录(Claude Code / Codex / DSH 等通用 `.agents` 布局)**
30
36
 
31
37
  ```bash
32
38
  python scripts/install.py # → ~/.agents/skills/agent-project-ops
33
39
  python scripts/install.py --scope project # → ./.agents/skills/agent-project-ops
34
40
  python scripts/install.py --pi # → ~/.pi/agent/skills/agent-project-ops
41
+ python scripts/install.py --dsh # → ~/.dsh/skills/agent-project-ops
35
42
  python scripts/install.py --link # 符号链接,不复制(Windows 需开发者模式)
36
43
  ```
37
44
 
45
+ DSH(DeepSeek Harness)用同一份 SKILL.md,路径与字段差异见 `docs/dsh.md`。
46
+
38
47
  已存在会拒绝覆盖;确认要换用 `--force`。
39
48
 
40
- **C. 只在本仓开发时加载,不动全局**
49
+ **D. 只在本仓开发时加载,不动全局**
41
50
 
42
51
  ```bash
43
52
  pi --no-skills --skill ./skills/agent-project-ops
package/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.0
1
+ 1.6.0
package/docs/dsh.md ADDED
@@ -0,0 +1,108 @@
1
+ # DSH(DeepSeek Harness)适配
2
+
3
+ > 结论:**同一份 `skills/agent-project-ops/SKILL.md` 在 DSH 和 Pi 上都能用**,不需要维护第二个版本。
4
+ > DSH 的文件系统 skill 提供方(`@deepseek-ai/dsh-skill-filesystem`)与 Pi 的约定基本同源,差别只在安装路径。
5
+
6
+ ## 1. 依据
7
+
8
+ DSH 的 skill 发现规则(摘自 `dsh-skill-filesystem` 的 README,0.0.1-rc.3):
9
+
10
+ | Rank | 来源 | 路径 |
11
+ | --- | --- | --- |
12
+ | 100 | project-dsh | `<project>/.dsh/skills` |
13
+ | 200 | project-agents | `<project>/.agents/skills` |
14
+ | 400 | user-dsh | `~/.dsh/skills` |
15
+ | 500 | user-agents | `~/.agents/skills` |
16
+
17
+ - bundle 形式:`<root>/<name>/SKILL.md`(**只认一层**,不递归)
18
+ - 平铺形式:`<root>/<name>.md`
19
+ - frontmatter:必填 `name`、`description`;可选 `whenToUse`、`metadata`、`disable-model-invocation`、`user-invocable`
20
+ - `name` 必须 kebab-case
21
+
22
+ 我们的结构正好是 `<root>/agent-project-ops/SKILL.md`,frontmatter 只有 `name` / `description` / `license` / `metadata`,没有驼峰调用开关。
23
+
24
+ ## 2. 安装
25
+
26
+ **A. 只给 DSH 用(用户级)**
27
+
28
+ ```bash
29
+ python scripts/install.py --dsh
30
+ # → ~/.dsh/skills/agent-project-ops
31
+ ```
32
+
33
+ **B. 给 DSH + 其他 harness 共用(推荐)**
34
+
35
+ ```bash
36
+ python scripts/install.py # 默认 → ~/.agents/skills
37
+ ```
38
+
39
+ Pi、DSH 以及走 `.agents` 约定的工具都会扫到。
40
+
41
+ **C. 项目级(随仓库走)**
42
+
43
+ ```bash
44
+ cd <你的项目>
45
+ python <本仓>/scripts/install.py --scope project --dsh
46
+ # → <项目>/.dsh/skills/agent-project-ops
47
+ ```
48
+
49
+ **D. 链接而不是复制(开发时用)**
50
+
51
+ ```bash
52
+ python scripts/install.py --dsh --link
53
+ ```
54
+
55
+ Windows 下 `--link` 用 junction,不需要管理员。
56
+
57
+ ## 3. 验证
58
+
59
+ 1. 启动 DSH(`dsh` 或其 Web/Headless 入口),新开会话。
60
+ 2. 模型目录里应出现 `agent-project-ops`,描述以「Design, scaffold, audit…」开头。
61
+ 3. 让它读一次 `SKILL.md` 并复述 14 条硬规矩中的任意三条;能复述即加载成功。
62
+ 4. 在本仓可以先用 `python scripts/status.py` 确认副本 hash 与真相源一致。
63
+
64
+ ## 4. 与 Pi 的差异
65
+
66
+ | 项 | Pi | DSH |
67
+ | --- | --- | --- |
68
+ | 安装根 | `~/.pi/agent/skills`、`.pi/skills` | `~/.dsh/skills`、`.dsh/skills`、`~/.agents/skills` |
69
+ | frontmatter 额外字段 | `license` 等 | 解析为开放对象,忽略未知键 |
70
+ | 调用开关 | `disable-model-invocation` | 同名,但**必须布尔**;驼峰会被拒绝并丢弃整个 skill |
71
+ | 发现深度 | 递归 | **只一层** |
72
+ | 状态 | 稳定 | Developer Preview(0.2.x),路径与字段可能变 |
73
+
74
+ 我们刻意**不加** DSH 专属字段:`whenToUse` 是可选的,描述里已经写了中英文触发词;加第二份适配文件会漂移。
75
+
76
+ ## 5. 朋友怎么拿
77
+
78
+ 方式一:克隆后装
79
+
80
+ ```bash
81
+ git clone --depth 1 https://github.com/Josephchue/agent-project-ops
82
+ cd agent-project-ops
83
+ python scripts/install.py --dsh
84
+ ```
85
+
86
+ 方式二:只取 skill
87
+
88
+ ```bash
89
+ git clone --depth 1 --filter=blob:none --sparse https://github.com/Josephchue/agent-project-ops
90
+ cd agent-project-ops
91
+ git sparse-checkout set skills
92
+ mkdir -p ~/.dsh/skills
93
+ cp -r skills/agent-project-ops ~/.dsh/skills/
94
+ ```
95
+
96
+ 方式三:npm 包(里面也带 `skills/`)
97
+
98
+ ```bash
99
+ npm pack agent-project-ops
100
+ tar -xzf agent-project-ops-*.tgz
101
+ cp -r package/skills/agent-project-ops ~/.dsh/skills/
102
+ ```
103
+
104
+ ## 6. 已知限制
105
+
106
+ - DSH 是 Developer Preview;升级后先跑一次 `python scripts/status.py`,再让模型复述规则。
107
+ - DSH 的 watcher 不会因 `references/` 变更刷新目录,但正文在每次 `skill(name)` 时重读——改完新开一轮对话即可。
108
+ - 如果 DSH 报 frontmatter 无效,先用 `python -m unittest discover -s tests` 跑本仓的兼容性测试,再对照上面第 1 节的字段表。
@@ -9,6 +9,7 @@
9
9
  | `skills/agent-project-ops/`(本仓) | **唯一真相源** | 人 / agent 在本仓改 | 每次改动 |
10
10
  | `.pi/skills/agent-project-ops`(junction) | 本仓内的运行入口(实时) | 不手改 | `python scripts/install.py --scope project --link`,建一次 |
11
11
  | `~/.pi/agent/skills/agent-project-ops`(副本) | 其他项目的运行入口(快照) | 不手改 | `python scripts/install.py --pi --force`,发版或重要修复后 |
12
+ | `~/.dsh/skills/agent-project-ops`(副本,DSH) | DSH 用户的运行入口(快照) | 不手改 | `python scripts/install.py --dsh --force` |
12
13
 
13
14
  ```text
14
15
  本仓 skills/agent-project-ops ← 唯一改这里
@@ -57,5 +58,5 @@ Pi 对同名 skill 保留先发现的那个并告警。本仓同时存在项目
57
58
 
58
59
  ## 7. 开源后的分发
59
60
 
60
- - `pi install git:github.com/<owner>/agent-project-ops@vX.Y.Z` → 装的是 tag 快照,不连开发仓。
61
+ - `pi install npm:agent-project-ops@X.Y.Z`(首选)或 `pi install git:github.com/Josephchue/agent-project-ops@vX.Y.Z` → 装的是发布快照,不连开发仓。
61
62
  - 本仓的 `skills/` 布局与安装器不依赖这台机器,别人克隆后 `python scripts/install.py` 即可。
package/docs/roadmap.md CHANGED
@@ -13,7 +13,7 @@
13
13
  | L5 | 茶话会改稿状态被误标为待办 | `REPORT.md`:全量 59 篇扫描、改 7 篇、52 篇按「少改」保留并给理由;BATCH-1(3 改)+ BATCH-2(审 6 改 4) | 已关闭 | 不是漏改;是「命中才改」的既定口径。2026-11-28 纠正 |
14
14
  | L6 | STATE 里 Hermes「pending a875acb2」表述过期 | `tools/hermes-home/pending/` 空;`MEMORY.md` 无 BLUE-7/ORANGE-42;仅 `spawn-ledger.json` 有测试记录 | 已关闭 | 只是测试日志残留,无待审批写入;已在本仓 STATE 注明 |
15
15
  | L7 | 三版笔记仍指全局路径与旧版本 | `AI协作/…(使用说明).md:16` 以 `~/.pi/agent/skills/` 为「推荐」入口;未提本仓与 `install.py` | 未验证 | 依赖 L3 决策:先定「开发源 = 本仓」,再同步文档 |
16
- | L8 | npm 发布未做 | `package.json` 有 `files`/`bin`,仓库无 publish 记录 | 未开始 | 开源后可选;`pi install git:` 已够用 |
16
+ | L8 | npm 发布未做 | 2026-11-28 已发布 `agent-project-ops@1.5.0`(shasum `3fba44e0…`,26 文件 / 44KB);`pi -e npm:agent-project-ops@1.5.0` 实测可装 | 已关闭 | 首发经历 staging 审批;后续建议配 Trusted Publishing |
17
17
  | L9 | 本仓 CI 未接 | 无 `.github/workflows/` | 进行中 | 本轮 P2 补上(见 `docs/development.md`) |
18
18
  | L10 | 英文版未提供 | 2026-11-28 决策:「全中文」 | 按决策关闭 | 若改主意,另开版本,不在 1.4 混入 |
19
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-project-ops",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "给长期运行的 agent 项目一套可判定的规范骨架,外加一个只读体检器(Pi skill)。",
5
5
  "license": "MIT",
6
6
  "keywords": [
package/scripts/check.py CHANGED
@@ -1,215 +1,216 @@
1
- #!/usr/bin/env python3
2
- """仓库自检(跨平台,纯标准库)。
3
-
4
- 用法:
5
- python scripts/check.py
6
- python scripts/check.py --skip-agnix
7
- python scripts/check.py --agnix /path/to/agnix
8
-
9
- 检查项:
10
- 1. 版本三联一致:VERSION / package.json / SKILL.md metadata.version / CHANGELOG 首条
11
- 2. 产品结构完整:SKILL.md + 6 个 references + 5 个 assets + doctor
12
- 3. 项目链接:.pi/skills/agent-project-ops(存在则必须指向本仓产品)
13
- 4. doctor self-test:坏样本必须 FAIL
14
- 5. agnix(可选,缺失记为 SKIP)
15
-
16
- 退出码:0 全绿;1 有 FAIL。
17
- """
18
- from __future__ import annotations
19
-
20
- import argparse
21
- import hashlib
22
- import json
23
- import os
24
- import re
25
- import shutil
26
- import subprocess
27
- import sys
28
- from pathlib import Path
29
-
30
- ROOT = Path(__file__).resolve().parents[1]
31
- SKILL = ROOT / "skills" / "agent-project-ops"
32
- LINK = ROOT / ".pi" / "skills" / "agent-project-ops"
33
-
34
- REFERENCES = [
35
- "archetypes.md",
36
- "maintenance.md",
37
- "memory.md",
38
- "principles.md",
39
- "wheels.md",
40
- "writing.md",
41
- ]
42
- ASSETS = [
43
- "AGENTS.template.md",
44
- "GLOBAL-AGENTS.template.md",
45
- "HANDOFF.template.md",
46
- "WHEEL-MANIFEST.template.json",
47
- "WRITING-STYLE.template.md",
48
- ]
49
-
50
- results: list[tuple[str, str, str]] = [] # (level, name, detail)
51
-
52
-
53
- def record(level: str, name: str, detail: str = "") -> None:
54
- results.append((level, name, detail))
55
-
56
-
57
- def read(path: Path) -> str:
58
- return path.read_text(encoding="utf-8", errors="replace")
59
-
60
-
61
- def sha12(path: Path) -> str:
62
- return hashlib.sha256(path.read_bytes()).hexdigest()[:12]
63
-
64
-
65
- def skill_version() -> str | None:
66
- m = re.search(r'^\s*version:\s*"?([0-9][^"\s]*)"?', read(SKILL / "SKILL.md"), re.M)
67
- return m.group(1) if m else None
68
-
69
-
70
- # ---------------------------------------------------------------- 1. 版本
71
- def check_versions() -> None:
72
- problems: list[str] = []
73
- version_file = read(ROOT / "VERSION").strip()
74
- try:
75
- package = json.loads(read(ROOT / "package.json")).get("version", "")
76
- except json.JSONDecodeError as exc:
77
- record("FAIL", "版本三联", f"package.json 解析失败:{exc}")
78
- return
79
- front = skill_version() or "<缺失>"
80
- changelog = re.search(r"^##\s+([0-9][^\s]*)", read(ROOT / "CHANGELOG.md"), re.M)
81
-
82
- pairs = [
83
- ("VERSION", version_file),
84
- ("package.json", package),
85
- ("SKILL.md metadata.version", front),
86
- ("CHANGELOG 首条", changelog.group(1) if changelog else "<缺失>"),
87
- ]
88
- base = version_file
89
- for label, got in pairs:
90
- if got != base:
91
- problems.append(f"{label}={got},期望 {base}")
92
- if problems:
93
- record("FAIL", "版本三联", ";".join(problems))
94
- else:
95
- record("PASS", "版本三联", f"{base}(4 处一致)")
96
-
97
-
98
- # ---------------------------------------------------------------- 2. 结构
99
- def check_structure() -> None:
100
- missing = [p for p in ["SKILL.md", "scripts/agent_doctor.py"] if not (SKILL / p).is_file()]
101
- missing += [f"references/{n}" for n in REFERENCES if not (SKILL / "references" / n).is_file()]
102
- missing += [f"assets/{n}" for n in ASSETS if not (SKILL / "assets" / n).is_file()]
103
- if missing:
104
- record("FAIL", "产品结构", "缺少:" + "、".join(missing))
105
- else:
106
- record("PASS", "产品结构", f"SKILL + {len(REFERENCES)} references + {len(ASSETS)} assets + doctor")
107
-
108
-
109
- # ---------------------------------------------------------------- 3. 链接
110
- def check_link() -> None:
111
- if not LINK.exists():
112
- record("SKIP", "项目链接", "未创建(可选:python scripts/install.py --scope project --link)")
113
- return
114
- try:
115
- resolved = LINK.resolve()
116
- except OSError as exc:
117
- record("FAIL", "项目链接", f"无法解析:{exc}")
118
- return
119
- if resolved == SKILL.resolve():
120
- record("PASS", "项目链接", str(resolved))
121
- else:
122
- record("FAIL", "项目链接", f"指向 {resolved},应为 {SKILL.resolve()}")
123
-
124
-
125
- # ---------------------------------------------------------------- 4. self-test
126
- def check_selftest() -> None:
127
- doctor = SKILL / "scripts" / "agent_doctor.py"
128
- proc = subprocess.run(
129
- [sys.executable, str(doctor), "--self-test"],
130
- capture_output=True,
131
- text=True,
132
- encoding="utf-8",
133
- errors="replace",
134
- timeout=180,
135
- )
136
- if proc.returncode == 0:
137
- record("PASS", "doctor self-test", "坏样本已证明会 FAIL")
138
- else:
139
- tail = (proc.stdout + proc.stderr).strip().splitlines()[-3:]
140
- record("FAIL", "doctor self-test", " | ".join(tail) or f"exit {proc.returncode}")
141
-
142
-
143
- # ---------------------------------------------------------------- 5. agnix
144
- def find_agnix(explicit: str | None) -> str | None:
145
- candidates = [
146
- explicit,
147
- os.environ.get("AGNIX_BIN"),
148
- shutil.which("agnix"),
149
- str(ROOT / "tools" / "agnix-bin" / "agnix.exe"),
150
- str(ROOT / "tools" / "agnix-bin" / "agnix"),
151
- ]
152
- for cand in candidates:
153
- if cand and Path(cand).is_file():
154
- return cand
155
- return None
156
-
157
-
158
- def check_agnix(explicit: str | None) -> None:
159
- binary = find_agnix(explicit)
160
- if not binary:
161
- record("SKIP", "agnix", "未找到(可用 --agnix / AGNIX_BIN / PATH 指定)")
162
- return
163
- proc = subprocess.run(
164
- [binary, "--target", "pi", str(SKILL)],
165
- capture_output=True,
166
- text=True,
167
- encoding="utf-8",
168
- errors="replace",
169
- timeout=180,
170
- )
171
- if proc.returncode == 0:
172
- record("PASS", "agnix", "0 error")
173
- else:
174
- tail = (proc.stdout + proc.stderr).strip().splitlines()[-3:]
175
- record("FAIL", "agnix", " | ".join(tail) or f"exit {proc.returncode}")
176
-
177
-
178
- # ---------------------------------------------------------------- main
179
- def main() -> int:
180
- ap = argparse.ArgumentParser(description="agent-project-ops 仓库自检")
181
- ap.add_argument("--agnix", help="agnix 可执行文件路径")
182
- ap.add_argument("--skip-agnix", action="store_true", help="跳过 agnix")
183
- a = ap.parse_args()
184
-
185
- check_versions()
186
- check_structure()
187
- check_link()
188
- check_selftest()
189
- if a.skip_agnix:
190
- record("SKIP", "agnix", "--skip-agnix")
191
- else:
192
- check_agnix(a.agnix)
193
-
194
- width = max(len(n) for _, n, _ in results)
195
- for level, name, detail in results:
196
- print(f"[{level:<10}] {name:<{width}} {detail}")
197
-
198
- fails = sum(1 for level, _, _ in results if level == "FAIL")
199
- skips = sum(1 for level, _, _ in results if level == "SKIP")
200
- passes = sum(1 for level, _, _ in results if level == "PASS")
201
- print(f"\nPASS {passes} FAIL {fails} SKIP {skips}")
202
- print(f"skill: {SKILL} SKILL.md: {sha12(SKILL / 'SKILL.md')}")
203
- return 1 if fails else 0
204
-
205
-
206
- def _utf8_stdout() -> None:
207
- """控制台/管道统一 UTF-8,避免 Windows GBK 乱码。"""
208
- for stream in (sys.stdout, sys.stderr):
209
- if hasattr(stream, "reconfigure"):
210
- stream.reconfigure(encoding="utf-8", errors="replace")
211
-
212
-
213
- if __name__ == "__main__":
214
- _utf8_stdout()
215
- sys.exit(main())
1
+ #!/usr/bin/env python3
2
+ """仓库自检(跨平台,纯标准库)。
3
+
4
+ 用法:
5
+ python scripts/check.py
6
+ python scripts/check.py --skip-agnix
7
+ python scripts/check.py --agnix /path/to/agnix
8
+
9
+ 检查项:
10
+ 1. 版本三联一致:VERSION / package.json / SKILL.md metadata.version / CHANGELOG 首条
11
+ 2. 产品结构完整:SKILL.md + 6 个 references + 5 个 assets + doctor
12
+ 3. 项目链接:.pi/skills/agent-project-ops(存在则必须指向本仓产品)
13
+ 4. doctor self-test:坏样本必须 FAIL
14
+ 5. agnix(可选,缺失记为 SKIP)
15
+
16
+ 退出码:0 全绿;1 有 FAIL。
17
+ """
18
+ from __future__ import annotations
19
+
20
+ import argparse
21
+ import hashlib
22
+ import json
23
+ import os
24
+ import re
25
+ import shutil
26
+ import subprocess
27
+ import sys
28
+ from pathlib import Path
29
+
30
+ ROOT = Path(__file__).resolve().parents[1]
31
+ SKILL = ROOT / "skills" / "agent-project-ops"
32
+ LINK = ROOT / ".pi" / "skills" / "agent-project-ops"
33
+
34
+ REFERENCES = [
35
+ "archetypes.md",
36
+ "maintenance.md",
37
+ "memory.md",
38
+ "principles.md",
39
+ "wheels.md",
40
+ "writing.md",
41
+ ]
42
+ ASSETS = [
43
+ "AGENTS.template.md",
44
+ "GLOBAL-AGENTS.template.md",
45
+ "HANDOFF.template.md",
46
+ "WHEEL-MANIFEST.template.json",
47
+ "WRITING-STYLE.template.md",
48
+ ]
49
+
50
+ results: list[tuple[str, str, str]] = [] # (level, name, detail)
51
+
52
+
53
+ def record(level: str, name: str, detail: str = "") -> None:
54
+ results.append((level, name, detail))
55
+
56
+
57
+ def read(path: Path) -> str:
58
+ return path.read_text(encoding="utf-8", errors="replace")
59
+
60
+
61
+ def sha12(path: Path) -> str:
62
+ return hashlib.sha256(path.read_bytes()).hexdigest()[:12]
63
+
64
+
65
+ def skill_version() -> str | None:
66
+ m = re.search(r'^\s*version:\s*"?([0-9][^"\s]*)"?', read(SKILL / "SKILL.md"), re.M)
67
+ return m.group(1) if m else None
68
+
69
+
70
+ # ---------------------------------------------------------------- 1. 版本
71
+ def check_versions() -> None:
72
+ problems: list[str] = []
73
+ version_file = read(ROOT / "VERSION").strip()
74
+ try:
75
+ package = json.loads(read(ROOT / "package.json")).get("version", "")
76
+ except json.JSONDecodeError as exc:
77
+ record("FAIL", "版本三联", f"package.json 解析失败:{exc}")
78
+ return
79
+ front = skill_version() or "<缺失>"
80
+ changelog = re.search(r"^##\s+([0-9][^\s]*)", read(ROOT / "CHANGELOG.md"), re.M)
81
+
82
+ pairs = [
83
+ ("VERSION", version_file),
84
+ ("package.json", package),
85
+ ("SKILL.md metadata.version", front),
86
+ ("CHANGELOG 首条", changelog.group(1) if changelog else "<缺失>"),
87
+ ]
88
+ base = version_file
89
+ for label, got in pairs:
90
+ if got != base:
91
+ problems.append(f"{label}={got},期望 {base}")
92
+ if problems:
93
+ record("FAIL", "版本三联", ";".join(problems))
94
+ else:
95
+ record("PASS", "版本三联", f"{base}(4 处一致)")
96
+
97
+
98
+ # ---------------------------------------------------------------- 2. 结构
99
+ def check_structure() -> None:
100
+ missing = [p for p in ["SKILL.md", "scripts/agent_doctor.py"] if not (SKILL / p).is_file()]
101
+ missing += [f"references/{n}" for n in REFERENCES if not (SKILL / "references" / n).is_file()]
102
+ missing += [f"assets/{n}" for n in ASSETS if not (SKILL / "assets" / n).is_file()]
103
+ if missing:
104
+ record("FAIL", "产品结构", "缺少:" + "、".join(missing))
105
+ else:
106
+ record("PASS", "产品结构", f"SKILL + {len(REFERENCES)} references + {len(ASSETS)} assets + doctor")
107
+
108
+
109
+ # ---------------------------------------------------------------- 3. 链接
110
+ def check_link() -> None:
111
+ if not LINK.exists():
112
+ record("SKIP", "项目链接", "未创建(可选:python scripts/install.py --scope project --link)")
113
+ return
114
+ try:
115
+ resolved = LINK.resolve()
116
+ except OSError as exc:
117
+ record("FAIL", "项目链接", f"无法解析:{exc}")
118
+ return
119
+ if resolved == SKILL.resolve():
120
+ record("PASS", "项目链接", str(resolved))
121
+ else:
122
+ record("FAIL", "项目链接", f"指向 {resolved},应为 {SKILL.resolve()}")
123
+
124
+
125
+ # ---------------------------------------------------------------- 4. self-test
126
+ def check_selftest() -> None:
127
+ doctor = SKILL / "scripts" / "agent_doctor.py"
128
+ proc = subprocess.run(
129
+ [sys.executable, str(doctor), "--self-test"],
130
+ capture_output=True,
131
+ text=True,
132
+ encoding="utf-8",
133
+ errors="replace",
134
+ timeout=180,
135
+ )
136
+ if proc.returncode == 0:
137
+ record("PASS", "doctor self-test", "坏样本已证明会 FAIL")
138
+ else:
139
+ tail = (proc.stdout + proc.stderr).strip().splitlines()[-3:]
140
+ record("FAIL", "doctor self-test", " | ".join(tail) or f"exit {proc.returncode}")
141
+
142
+
143
+ # ---------------------------------------------------------------- 5. agnix
144
+ def find_agnix(explicit: str | None) -> str | None:
145
+ candidates = [
146
+ explicit,
147
+ os.environ.get("AGNIX_BIN"),
148
+ shutil.which("agnix"),
149
+ str(ROOT / "tools" / "agnix-bin" / "agnix.exe"),
150
+ str(ROOT / "tools" / "agnix-bin" / "agnix"),
151
+ ]
152
+ for cand in candidates:
153
+ if cand and Path(cand).is_file():
154
+ return cand
155
+ return None
156
+
157
+
158
+ def check_agnix(explicit: str | None) -> None:
159
+ binary = find_agnix(explicit)
160
+ if not binary:
161
+ record("SKIP", "agnix", "未找到(可用 --agnix / AGNIX_BIN / PATH 指定)")
162
+ return
163
+ proc = subprocess.run(
164
+ [binary, "--target", "pi", str(SKILL)],
165
+ capture_output=True,
166
+ text=True,
167
+ encoding="utf-8",
168
+ errors="replace",
169
+ timeout=180,
170
+ )
171
+ if proc.returncode == 0:
172
+ record("PASS", "agnix", "0 error")
173
+ else:
174
+ tail = (proc.stdout + proc.stderr).strip().splitlines()[-3:]
175
+ record("FAIL", "agnix", " | ".join(tail) or f"exit {proc.returncode}")
176
+
177
+
178
+ # ---------------------------------------------------------------- main
179
+ def main() -> int:
180
+ ap = argparse.ArgumentParser(description="agent-project-ops 仓库自检")
181
+ ap.add_argument("--agnix", help="agnix 可执行文件路径")
182
+ ap.add_argument("--skip-agnix", action="store_true", help="跳过 agnix")
183
+ a = ap.parse_args()
184
+
185
+ check_versions()
186
+ check_structure()
187
+ check_link()
188
+ check_selftest()
189
+ if a.skip_agnix:
190
+ record("SKIP", "agnix", "--skip-agnix")
191
+ else:
192
+ check_agnix(a.agnix)
193
+
194
+ width = max(len(n) for _, n, _ in results)
195
+ for level, name, detail in results:
196
+ print(f"[{level:<10}] {name:<{width}} {detail}")
197
+
198
+ fails = sum(1 for level, _, _ in results if level == "FAIL")
199
+ skips = sum(1 for level, _, _ in results if level == "SKIP")
200
+ passes = sum(1 for level, _, _ in results if level == "PASS")
201
+ print(f"\nPASS {passes} FAIL {fails} SKIP {skips}")
202
+ print(f"skill: {SKILL} SKILL.md: {sha12(SKILL / 'SKILL.md')}")
203
+ return 1 if fails else 0
204
+
205
+
206
+ def _utf8_stdout() -> None:
207
+ """控制台/管道统一 UTF-8,避免 Windows GBK 乱码。"""
208
+ for stream in (sys.stdout, sys.stderr):
209
+ reconfigure = getattr(stream, "reconfigure", None)
210
+ if callable(reconfigure):
211
+ reconfigure(encoding="utf-8", errors="replace")
212
+
213
+
214
+ if __name__ == "__main__":
215
+ _utf8_stdout()
216
+ sys.exit(main())
@@ -31,9 +31,11 @@ def sha12(path: Path) -> str:
31
31
  return hashlib.sha256(path.read_bytes()).hexdigest()[:12]
32
32
 
33
33
 
34
- def target_root(scope: str, dest: str | None, use_pi: bool) -> Path:
34
+ def target_root(scope: str, dest: str | None, use_pi: bool, use_dsh: bool) -> Path:
35
35
  if dest:
36
36
  return Path(dest).expanduser().resolve()
37
+ if use_dsh:
38
+ return Path.cwd() / ".dsh" / "skills" if scope == "project" else Path.home() / ".dsh" / "skills"
37
39
  if use_pi and scope == "user":
38
40
  return Path.home() / ".pi" / "agent" / "skills"
39
41
  if scope == "project":
@@ -67,6 +69,7 @@ def main() -> int:
67
69
  ap = argparse.ArgumentParser(description="安装 agent-project-ops skill")
68
70
  ap.add_argument("--scope", choices=["user", "project"], default="user")
69
71
  ap.add_argument("--pi", action="store_true", help="装到 ~/.pi/agent/skills(仅 user scope)")
72
+ ap.add_argument("--dsh", action="store_true", help="装到 ~/.dsh/skills(或项目 .dsh/skills)")
70
73
  ap.add_argument("--dest", help="目标父目录(绝对路径)")
71
74
  ap.add_argument("--link", action="store_true", help="符号链接/junction,不复制")
72
75
  ap.add_argument("--force", action="store_true", help="已存在时改名备份后安装")
@@ -76,7 +79,7 @@ def main() -> int:
76
79
  print(f"FAIL 源缺失:{SRC}")
77
80
  return 1
78
81
 
79
- base = target_root(a.scope, a.dest, a.pi)
82
+ base = target_root(a.scope, a.dest, a.pi, a.dsh)
80
83
  target = base / "agent-project-ops"
81
84
 
82
85
  if target.exists():
@@ -118,8 +121,9 @@ def main() -> int:
118
121
  def _utf8_stdout() -> None:
119
122
  """控制台/管道统一 UTF-8,避免 Windows GBK 乱码。"""
120
123
  for stream in (sys.stdout, sys.stderr):
121
- if hasattr(stream, "reconfigure"):
122
- stream.reconfigure(encoding="utf-8", errors="replace")
124
+ reconfigure = getattr(stream, "reconfigure", None)
125
+ if callable(reconfigure):
126
+ reconfigure(encoding="utf-8", errors="replace")
123
127
 
124
128
 
125
129
  if __name__ == "__main__":
package/scripts/status.py CHANGED
@@ -1,79 +1,81 @@
1
- #!/usr/bin/env python3
2
- """打印版本、SKILL.md hash 与安装位置状态(跨平台,纯标准库)。"""
3
- from __future__ import annotations
4
-
5
- import hashlib
6
- import json
7
- import re
8
- import sys
9
- from pathlib import Path
10
-
11
- ROOT = Path(__file__).resolve().parents[1]
12
- SKILL = ROOT / "skills" / "agent-project-ops"
13
- LINK = ROOT / ".pi" / "skills" / "agent-project-ops"
14
-
15
-
16
- def sha12(path: Path) -> str:
17
- return hashlib.sha256(path.read_bytes()).hexdigest()[:12]
18
-
19
-
20
- def version_of(skill_dir: Path) -> str:
21
- skill = skill_dir / "SKILL.md"
22
- if not skill.is_file():
23
- return "<missing>"
24
- m = re.search(r'^\s*version:\s*"?([0-9][^"\s]*)"?', skill.read_text(encoding="utf-8", errors="replace"), re.M)
25
- return m.group(1) if m else "<unversioned>"
26
-
27
-
28
- def describe(skill_dir: Path) -> str:
29
- return f"v{version_of(skill_dir)} SKILL.md {sha12(skill_dir / 'SKILL.md')}"
30
-
31
-
32
- def main() -> int:
33
- repo_version = (ROOT / "VERSION").read_text(encoding="utf-8", errors="replace").strip()
34
- try:
35
- package_version = json.loads((ROOT / "package.json").read_text(encoding="utf-8")).get("version", "<missing>")
36
- except (OSError, json.JSONDecodeError) as exc:
37
- package_version = f"<error: {exc}>"
38
-
39
- print(f"repo : {ROOT}")
40
- print(f" VERSION {repo_version} / package.json {package_version}")
41
- print(f"skill : {SKILL}")
42
- print(f" {describe(SKILL)}")
43
-
44
- print("project : .pi/skills/agent-project-ops")
45
- if LINK.exists():
46
- try:
47
- target = LINK.resolve()
48
- state = "OK" if target == SKILL.resolve() else "MISMATCH"
49
- except OSError as exc:
50
- target, state = f"<unresolvable: {exc}>", "FAIL"
51
- print(f" {state} -> {target}")
52
- if state == "OK":
53
- print(f" {describe(LINK)}")
54
- else:
55
- print(" missing(python scripts/install.py --scope project --link)")
56
-
57
- for label, path in [
58
- ("user .agents", Path.home() / ".agents" / "skills" / "agent-project-ops"),
59
- ("user .pi", Path.home() / ".pi" / "agent" / "skills" / "agent-project-ops"),
60
- ]:
61
- print(f"{label:8s}: {path}")
62
- if path.exists():
63
- match = "same" if sha12(path / "SKILL.md") == sha12(SKILL / "SKILL.md") else "DIFF"
64
- print(f" {match} {describe(path)}")
65
- else:
66
- print(" not installed")
67
- return 0
68
-
69
-
70
- def _utf8_stdout() -> None:
71
- """控制台/管道统一 UTF-8,避免 Windows GBK 乱码。"""
72
- for stream in (sys.stdout, sys.stderr):
73
- if hasattr(stream, "reconfigure"):
74
- stream.reconfigure(encoding="utf-8", errors="replace")
75
-
76
-
77
- if __name__ == "__main__":
78
- _utf8_stdout()
79
- sys.exit(main())
1
+ #!/usr/bin/env python3
2
+ """打印版本、SKILL.md hash 与安装位置状态(跨平台,纯标准库)。"""
3
+ from __future__ import annotations
4
+
5
+ import hashlib
6
+ import json
7
+ import re
8
+ import sys
9
+ from pathlib import Path
10
+
11
+ ROOT = Path(__file__).resolve().parents[1]
12
+ SKILL = ROOT / "skills" / "agent-project-ops"
13
+ LINK = ROOT / ".pi" / "skills" / "agent-project-ops"
14
+
15
+
16
+ def sha12(path: Path) -> str:
17
+ return hashlib.sha256(path.read_bytes()).hexdigest()[:12]
18
+
19
+
20
+ def version_of(skill_dir: Path) -> str:
21
+ skill = skill_dir / "SKILL.md"
22
+ if not skill.is_file():
23
+ return "<missing>"
24
+ m = re.search(r'^\s*version:\s*"?([0-9][^"\s]*)"?', skill.read_text(encoding="utf-8", errors="replace"), re.M)
25
+ return m.group(1) if m else "<unversioned>"
26
+
27
+
28
+ def describe(skill_dir: Path) -> str:
29
+ return f"v{version_of(skill_dir)} SKILL.md {sha12(skill_dir / 'SKILL.md')}"
30
+
31
+
32
+ def main() -> int:
33
+ repo_version = (ROOT / "VERSION").read_text(encoding="utf-8", errors="replace").strip()
34
+ try:
35
+ package_version = json.loads((ROOT / "package.json").read_text(encoding="utf-8")).get("version", "<missing>")
36
+ except (OSError, json.JSONDecodeError) as exc:
37
+ package_version = f"<error: {exc}>"
38
+
39
+ print(f"repo : {ROOT}")
40
+ print(f" VERSION {repo_version} / package.json {package_version}")
41
+ print(f"skill : {SKILL}")
42
+ print(f" {describe(SKILL)}")
43
+
44
+ print("project : .pi/skills/agent-project-ops")
45
+ if LINK.exists():
46
+ try:
47
+ target = LINK.resolve()
48
+ state = "OK" if target == SKILL.resolve() else "MISMATCH"
49
+ except OSError as exc:
50
+ target, state = f"<unresolvable: {exc}>", "FAIL"
51
+ print(f" {state} -> {target}")
52
+ if state == "OK":
53
+ print(f" {describe(LINK)}")
54
+ else:
55
+ print(" missing(python scripts/install.py --scope project --link)")
56
+
57
+ for label, path in [
58
+ ("user .agents", Path.home() / ".agents" / "skills" / "agent-project-ops"),
59
+ ("user .pi", Path.home() / ".pi" / "agent" / "skills" / "agent-project-ops"),
60
+ ("user .dsh", Path.home() / ".dsh" / "skills" / "agent-project-ops"),
61
+ ]:
62
+ print(f"{label:8s}: {path}")
63
+ if path.exists():
64
+ match = "same" if sha12(path / "SKILL.md") == sha12(SKILL / "SKILL.md") else "DIFF"
65
+ print(f" {match} {describe(path)}")
66
+ else:
67
+ print(" not installed")
68
+ return 0
69
+
70
+
71
+ def _utf8_stdout() -> None:
72
+ """控制台/管道统一 UTF-8,避免 Windows GBK 乱码。"""
73
+ for stream in (sys.stdout, sys.stderr):
74
+ reconfigure = getattr(stream, "reconfigure", None)
75
+ if callable(reconfigure):
76
+ reconfigure(encoding="utf-8", errors="replace")
77
+
78
+
79
+ if __name__ == "__main__":
80
+ _utf8_stdout()
81
+ sys.exit(main())
@@ -3,7 +3,7 @@ name: agent-project-ops
3
3
  description: "Design, scaffold, audit, and maintain long-running agent projects: Obsidian/knowledge bases (知识库), control consoles with external writes (控制台), dev repos (开发项目), one-off deliverables like homework/PPT/pre (一次性交付), and team repos (团队协作). Use when starting or refactoring AGENTS.md, HANDOFF, ledgers, gates, or doctor checks; when a project feels drifted, handoffs are stale, or rules are ignored; when deciding what belongs in global vs project instructions; or when auditing memory, cost, and safety. 中文触发:agent 项目规范/维护/交接/AGENTS.md/台账/闸门/体检/知识库整理/周计划/PPT/作业交付."
4
4
  license: MIT
5
5
  metadata:
6
- version: "1.5.0"
6
+ version: "1.6.0"
7
7
  author: agent-project-ops contributors
8
8
  ---
9
9