harnessbrew 0.6.0 → 0.6.2

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
@@ -2,6 +2,24 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## Unreleased
6
+
7
+ ## 0.6.2 - 2026-08-13
8
+
9
+ ### Security
10
+
11
+ - replace personal account identifiers in README and architecture examples with neutral `your-name` placeholders
12
+
13
+ ## 0.6.1 - 2026-08-13
14
+
15
+ ### Changed
16
+
17
+ - upgrade GitHub CI and release workflows to `actions/checkout@v6` and `actions/setup-node@v6` while keeping HarnessBrew builds on Node.js 22
18
+ - require Node.js 22 or later consistently in package metadata, CI, and installation documentation
19
+ - make English the default README and architecture language while retaining complete Simplified Chinese editions
20
+ - move historical release notes under `docs/releases` and remove obsolete roadmap, task-breakdown, and legacy walkthrough documents
21
+ - add CI, npm version, Node.js support, and license badges to both README editions
22
+
5
23
  ## 0.6.0 - 2026-08-13
6
24
 
7
25
  ### Added
package/README.md CHANGED
@@ -1,67 +1,74 @@
1
1
  # HarnessBrew
2
2
 
3
- HarnessBrew 是面向 AI Agent 资产的 Git 包管理器。它的定位类似 Homebrew:通过 Git Tap 发现资产,通过 Formula 描述资产,通过 Cellar 与 Receipt 安装、升级和安全卸载资产。
3
+ English | [简体中文](README.zh-CN.md)
4
4
 
5
- HarnessBrew 不托管资产。个人、团队和第三方资产都保存在各自的 Git 仓库中,并使用完全相同的安装机制。
5
+ [![CI](https://github.com/anzihenry/HarnessBrew/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/anzihenry/HarnessBrew/actions/workflows/ci.yml)
6
+ [![npm version](https://img.shields.io/npm/v/harnessbrew.svg?logo=npm)](https://www.npmjs.com/package/harnessbrew)
7
+ [![Node.js](https://img.shields.io/node/v/harnessbrew.svg?logo=nodedotjs)](https://www.npmjs.com/package/harnessbrew)
8
+ [![License](https://img.shields.io/github/license/anzihenry/HarnessBrew.svg)](https://github.com/anzihenry/HarnessBrew/blob/main/LICENSE)
6
9
 
7
- ## 主要能力
10
+ HarnessBrew is a Git package manager for AI agent assets. Like Homebrew, it discovers assets through Git Taps, describes them with Formulae, and uses a Cellar and Receipts to install, upgrade, and safely uninstall them.
8
11
 
9
- - 注册、更新和移除 Git Tap
10
- - 校验并搜索 skill、agent、workflow、instruction、prompt、MCP 和 adapter Formula
11
- - 解析依赖、循环、缺失项与冲突
12
- - 按 Git commit 将不可变内容安装到 Cellar
13
- - 链接到 OpenAI Codex 和 Claude Code
14
- - 以原生格式投递 Skill、Agent、Workflow、Prompt、Instruction 和 MCP
15
- - 支持 user/project scope,以及同一 Target 的多实例
16
- - 通过 Receipt 跟踪文件、配置键、受管区块所有权和 SHA-256 摘要
17
- - 使用 `doctor` 诊断并通过 `relink` 修复 Target 漂移
18
- - 检测可用升级,并在升级后保留 Agent target 链接
19
- - 使用 `Harnessfile` 和 lockfile 在不同设备上复现环境
20
- - 从 npm 安装并通过 GitHub Release 发布
12
+ HarnessBrew does not host assets. Personal, team, and third-party assets remain in their own Git repositories and use the same installation mechanism.
21
13
 
22
- ## 安装
14
+ ## Features
23
15
 
24
- 要求:Node.js 20 或更高版本,系统中可用 Git
16
+ - Register, update, and remove Git Taps
17
+ - Validate and search skill, agent, workflow, instruction, prompt, MCP, and adapter Formulae
18
+ - Resolve dependencies, cycles, missing entries, and conflicts
19
+ - Install immutable content into the Cellar at a specific Git commit
20
+ - Link assets into OpenAI Codex and Claude Code
21
+ - Deliver Skills, Agents, Workflows, Prompts, Instructions, and MCP configuration in native formats
22
+ - Support user and project scopes, including multiple instances of one Target
23
+ - Track file, configuration-key, managed-block, and SHA-256 ownership in Receipts
24
+ - Diagnose Target drift with `doctor` and repair it with `relink`
25
+ - Detect upgrades while preserving Agent Target links
26
+ - Reproduce environments across machines with a `Harnessfile` and lockfile
27
+ - Install from npm and publish through GitHub Releases
28
+
29
+ ## Installation
30
+
31
+ Requirements: Node.js 22 or later and Git available on the system.
25
32
 
26
33
  ```bash
27
34
  npm install --global harnessbrew
28
35
  harnessbrew --version
29
36
  ```
30
37
 
31
- 也可以直接使用:
38
+ You can also run it directly:
32
39
 
33
40
  ```bash
34
41
  npx harnessbrew help
35
42
  ```
36
43
 
37
- HarnessBrew 默认将受管状态保存到 `~/.harnessbrew`。测试或隔离环境可以设置 `HARNESSBREW_HOME`。
44
+ HarnessBrew stores managed state in `~/.harnessbrew` by default. Set `HARNESSBREW_HOME` for tests or isolated environments.
38
45
 
39
- ## 快速开始
46
+ ## Quick start
40
47
 
41
- 注册自己的资产 Tap
48
+ Register an asset Tap:
42
49
 
43
50
  ```bash
44
- harnessbrew tap add xiejinheng/agents git@github.com:xiejinheng/agent-assets.git --trust
51
+ harnessbrew tap add your-name/agents git@github.com:your-name/agent-assets.git --trust
45
52
  ```
46
53
 
47
- 搜索并查看 Formula:
54
+ Search for and inspect Formulae:
48
55
 
49
56
  ```bash
50
57
  harnessbrew search review
51
58
  harnessbrew search --kind skill --target openai-codex
52
- harnessbrew info xiejinheng/agents/code-review
59
+ harnessbrew info your-name/agents/code-review
53
60
  ```
54
61
 
55
- 安装到 Cellar,并链接到 Codex
62
+ Install into the Cellar and link into Codex:
56
63
 
57
64
  ```bash
58
- harnessbrew install xiejinheng/agents/code-review \
65
+ harnessbrew install your-name/agents/code-review \
59
66
  --target openai-codex
60
67
  ```
61
68
 
62
- 如果只希望保存到 Cellar,不写入 Agent 配置目录,可以省略 `--target`。
69
+ Omit `--target` to keep the asset in the Cellar without modifying an Agent configuration directory.
63
70
 
64
- 更新和升级:
71
+ Update and upgrade:
65
72
 
66
73
  ```bash
67
74
  harnessbrew update [--allow-rewind]
@@ -69,29 +76,29 @@ harnessbrew outdated
69
76
  harnessbrew upgrade code-review
70
77
  ```
71
78
 
72
- 安全卸载:
79
+ Safely uninstall:
73
80
 
74
81
  ```bash
75
82
  harnessbrew uninstall code-review
76
83
  ```
77
84
 
78
- 若受管文件或链接已被修改,HarnessBrew 会停止卸载。确认需要删除时可以显式传入 `--force`。
85
+ HarnessBrew stops if a managed file or link has changed. Pass `--force` explicitly when the modified target should still be removed.
79
86
 
80
- ## Homebrew 概念对应
87
+ ## Homebrew concepts
81
88
 
82
89
  | Homebrew | HarnessBrew |
83
90
  | --- | --- |
84
91
  | `brew` | `harnessbrew` |
85
- | Tap | Git 资产源仓库 |
86
- | Formula / Cask | Agent 资产 Formula |
87
- | Cellar | Git commit 隔离的本地安装区 |
88
- | Link | CodexClaude Code target 的链接 |
92
+ | Tap | Git asset-source repository |
93
+ | Formula / Cask | Agent asset Formula |
94
+ | Cellar | Commit-isolated local installation area |
95
+ | Link | Link into Codex, Claude Code, or another Target |
89
96
  | `Brewfile` | `Harnessfile` |
90
- | Receipt | 安装来源、文件摘要与所有权记录 |
97
+ | Receipt | Installation source, digest, and ownership record |
91
98
 
92
- ## 创建 Tap
99
+ ## Creating a Tap
93
100
 
94
- Tap 是普通 Git 仓库。推荐按资产集合建立 Tap,不需要为每个 skill 单独建立仓库。
101
+ A Tap is a regular Git repository. Prefer one repository per asset collection instead of one repository per Skill.
95
102
 
96
103
  ```text
97
104
  my-agent-tap/
@@ -108,7 +115,7 @@ my-agent-tap/
108
115
  └── adapters/
109
116
  ```
110
117
 
111
- 最小 `tap.json`:
118
+ Minimal `tap.json`:
112
119
 
113
120
  ```json
114
121
  {
@@ -116,7 +123,7 @@ my-agent-tap/
116
123
  }
117
124
  ```
118
125
 
119
- Formula 的目录名称必须与 `name` 一致,目录类型必须与 `kind` 一致:
126
+ The Formula directory name must match `name`, and its parent directory must match `kind`:
120
127
 
121
128
  ```json
122
129
  {
@@ -127,36 +134,39 @@ Formula 的目录名称必须与 `name` 一致,目录类型必须与 `kind`
127
134
  "entry": "SKILL.md",
128
135
  "targets": ["openai-codex", "claude-code"],
129
136
  "dependencies": [
130
- "xiejinheng/agents/repository-guardrails"
137
+ "your-name/agents/repository-guardrails"
131
138
  ],
132
139
  "conflicts": [],
133
140
  "tags": ["review", "quality"]
134
141
  }
135
142
  ```
136
143
 
137
- 完整坐标为 `<owner>/<tap>/<formula>`。依赖和冲突必须使用完整坐标,以避免跨 Tap 名称歧义。
144
+ The full coordinate is `<owner>/<tap>/<formula>`. Dependencies and conflicts must use full coordinates to avoid ambiguity across Taps.
138
145
 
139
- Git commit 是安装版本的唯一事实来源;Formula 不维护 `.snapshots` 或重复的 `history`。
146
+ The Git commit is the single source of truth for an installed version. Formulae do not maintain duplicate `.snapshots` or `history` data.
140
147
 
141
- MCP Formula 的入口是统一 JSON。stdio 配置使用 `command`、可选 `args` 和只包含环境变量名称的 `envVars`;HTTP 配置使用 `transport: "http"`、`url`、可选 `bearerTokenEnvVar` `headersFromEnv`。HarnessBrew 不接受入口中的明文 `env` 密钥值。
148
+ An MCP Formula uses a common JSON entry format. Stdio configuration uses `command`, optional `args`, and `envVars` containing environment-variable names only. HTTP configuration uses `transport: "http"`, `url`, optional `bearerTokenEnvVar`, and `headersFromEnv`. HarnessBrew rejects plaintext `env` secret values in entries.
142
149
 
143
- `adapter` Formula 是可由 Git/Cellar 管理的扩展资产,但不会作为代码自动执行。Target Adapter 运行时使用单独的可信模块机制:先审查并安装 npm 包,
144
- 再通过 `harnessbrew adapter add <module>` 显式授权。这样 Tap 仍保持声明式、不执行任意代码,而第三方 Target 可以接入版本化 Adapter SDK。
150
+ An `adapter` Formula is a Git/Cellar-managed extension asset, but it is never executed automatically. Target Adapter runtime modules use a separate trust mechanism: review and install an npm package, then authorize it explicitly with `harnessbrew adapter add <module>`. Taps therefore remain declarative while third-party Targets can use the versioned Adapter SDK.
145
151
 
146
- ## Target
152
+ ## Targets
147
153
 
148
- 当前内置:
154
+ Built-in Targets:
149
155
 
150
156
  - `openai-codex`
151
157
  - `claude-code`
152
158
 
153
- 可以在安装时指定 target:
159
+ Select a Target during installation:
154
160
 
155
161
  ```bash
156
162
  harnessbrew install code-review --target openai-codex
157
163
  ```
158
164
 
159
- Codex Skill 默认安装到 `~/.agents/skills`,其他 Codex 配置使用 `~/.codex`;Claude Code 使用 `~/.claude`。Skill 以完整目录软链安装,因此 `scripts/`、`references/` `assets/` 等相对资源会与 `SKILL.md` 一起生效。Workflow Prompt 会被投影为带标准 frontmatter Target Skill。Agent 则以统一 Markdown 作为源码:投递到 Codex 时确定性渲染为 `.codex/agents/<name>.toml`,投递到 Claude Code 时渲染为 `.claude/agents/<name>.md`。Instruction 在 Codex 的 `AGENTS.md` 中使用带所有权标记的受管区块,在 Claude Code 中链接为 `.claude/rules/<name>.md`;MCP 分别按 TOML 区块或 JSON 键合并。卸载这些共享配置不会覆盖用户内容。需要隔离安装时可使用:
165
+ Codex Skills are installed in `~/.agents/skills` by default, while other Codex configuration uses `~/.codex`; Claude Code uses `~/.claude`. Skills are linked as complete directories, preserving relative resources such as `scripts/`, `references/`, and `assets/` alongside `SKILL.md`.
166
+
167
+ Workflows and Prompts are projected as Target Skills with standard frontmatter. Agents use portable Markdown source and are rendered deterministically to `.codex/agents/<name>.toml` for Codex or `.claude/agents/<name>.md` for Claude Code. Instructions use owned managed blocks in Codex `AGENTS.md` and links under `.claude/rules/<name>.md` in Claude Code. MCP configuration is merged as TOML blocks or JSON keys. Removing shared configuration never overwrites user-owned content.
168
+
169
+ Use an isolated Target root when needed:
160
170
 
161
171
  ```bash
162
172
  harnessbrew install code-review \
@@ -164,7 +174,7 @@ harnessbrew install code-review \
164
174
  --target-root /path/to/sandbox/.codex
165
175
  ```
166
176
 
167
- Target 支持用户级与项目级 scope;`--project` 会隐式选择 project scope。同一 Formula 可以同时存在于两个 scope,Receipt 会按实际目标路径分别记录操作:
177
+ Targets support user and project scopes. `--project` implicitly selects project scope. The same Formula can exist in both scopes, and its Receipt records operations by their actual destination:
168
178
 
169
179
  ```bash
170
180
  harnessbrew link code-review --target openai-codex --scope user
@@ -172,11 +182,11 @@ harnessbrew link code-review --target openai-codex --scope project --project /pa
172
182
  harnessbrew unlink code-review --target openai-codex --scope project --project /path/to/repo
173
183
  ```
174
184
 
175
- 项目级 Codex 资产使用项目中的 `.agents/skills`、`.codex/agents`、根 `AGENTS.md` `.codex/config.toml`;Claude Code 使用 `.claude/skills`、`.claude/agents`、`.claude/rules` 和根 `.mcp.json`。当同一 Target 有多个实例时,unlink 必须指定 scope
185
+ Project-scoped Codex assets use `.agents/skills`, `.codex/agents`, the root `AGENTS.md`, and `.codex/config.toml`. Claude Code uses `.claude/skills`, `.claude/agents`, `.claude/rules`, and the root `.mcp.json`. When a Target has multiple instances, `unlink` requires an explicit scope.
176
186
 
177
- `harnessbrew doctor [formula]` 会校验 Cellar 文件摘要和每条 Target operation,区分目标缺失与被修改;`harnessbrew relink <formula>` 会在 Cellar 完整的前提下,按 Receipt 记录的 scope/root 强制重建 HarnessBrew 拥有的目标。可用 `--target`、`--scope` `--project` 只修复一个实例。
187
+ `harnessbrew doctor [formula]` validates Cellar file digests and every Target operation, distinguishing missing targets from modified ones. If the Cellar is intact, `harnessbrew relink <formula>` forcibly reconstructs HarnessBrew-owned targets using the scope and root recorded in the Receipt. Use `--target`, `--scope`, and `--project` to repair one instance.
178
188
 
179
- 也可以单独管理链接:
189
+ Links can also be managed separately:
180
190
 
181
191
  ```bash
182
192
  harnessbrew link code-review --target openai-codex
@@ -185,18 +195,18 @@ harnessbrew unlink code-review --target openai-codex
185
195
 
186
196
  ## Harnessfile
187
197
 
188
- `Harnessfile` 适合提交到个人 dotfiles 或项目仓库:
198
+ A `Harnessfile` can be committed to a dotfiles or project repository:
189
199
 
190
200
  ```yaml
191
201
  schemaVersion: 2
192
202
  taps:
193
- - name: xiejinheng/agents
194
- git: git@github.com:xiejinheng/agent-assets.git
203
+ - name: your-name/agents
204
+ git: git@github.com:your-name/agent-assets.git
195
205
  ref: main
196
206
  trust: true
197
207
 
198
208
  assets:
199
- - formula: xiejinheng/agents/code-review
209
+ - formula: your-name/agents/code-review
200
210
  targets:
201
211
  - target: openai-codex
202
212
  scope: user
@@ -205,32 +215,29 @@ assets:
205
215
  project: .
206
216
  ```
207
217
 
208
- v2 Target placement 可以声明 `user` `project` scope,并可使用相对于 `Harnessfile` `project` `root` 路径。
209
- schema v1 的 `targets: [openai-codex]` 仍然兼容,并按 user scope 解释。
218
+ Target placements in v2 declare `user` or `project` scope and may use `project` and `root` paths relative to the `Harnessfile`. Schema v1 `targets: [openai-codex]` remains compatible and is interpreted as user scope.
210
219
 
211
- 安装并生成 `Harnessfile.lock`:
220
+ Install and generate `Harnessfile.lock`:
212
221
 
213
222
  ```bash
214
223
  harnessbrew bundle install
215
224
  ```
216
225
 
217
- v2 lockfile 会记录 Manifest 摘要、HarnessBrew Adapter 版本、每个 Tap 的准确 commit、Formula 内容摘要、依赖闭包和完整 Target placement,
218
- 应与 `Harnessfile` 一起提交到 Git。
226
+ The v2 lockfile records the manifest digest, HarnessBrew Adapter versions, exact commit for every Tap, Formula content digests, dependency closure, and full Target placements. Commit it together with the `Harnessfile`.
219
227
 
220
- 在其他设备运行同一命令时,HarnessBrew 会检出 lockfile 固定的 commit,而不是未经确认地使用 Tap 最新版本。
221
- 修改 v2 Harnessfile 后需要显式更新 lockfile:
228
+ On another machine, the same command checks out commits pinned by the lockfile instead of silently using the latest Tap versions. After changing a v2 Harnessfile, update the lockfile explicitly:
222
229
 
223
230
  ```bash
224
231
  harnessbrew bundle install --update-lock
225
232
  ```
226
233
 
227
- 清理清单之外的受管资产:
234
+ Remove managed assets not present in the manifest:
228
235
 
229
236
  ```bash
230
237
  harnessbrew bundle cleanup
231
238
  ```
232
239
 
233
- 使用其他文件路径:
240
+ Use a different manifest path:
234
241
 
235
242
  ```bash
236
243
  harnessbrew bundle install --file ./config/Harnessfile
@@ -262,42 +269,40 @@ harnessbrew bundle install [--file <path>] [--update-lock]
262
269
  harnessbrew bundle cleanup [--file <path>]
263
270
  ```
264
271
 
265
- 所有命令都可追加 `--json`,stdout 将只包含一个 schema v1 JSON envelope:`result` 是命令级结构化结果,`output` 保留人类文本,
266
- 失败时包含 `error.code`、`error.message`、`diagnostics` 和非零 `exitCode`。
272
+ Every command accepts `--json`. Standard output then contains one schema v1 JSON envelope: `result` is the command-specific structured result, `output` retains human-readable text, and failures include `error.code`, `error.message`, `diagnostics`, and a non-zero `exitCode`.
267
273
 
268
- 变更命令可追加 `--dry-run`。HarnessBrew 会在同一 Home 写锁下完整执行校验和安装事务,收集每个路径的 before/after 类型与摘要,
269
- 随后回滚 Cellar、Receipt、Tap checkout 和 Agent Target;与 `--json` 组合时,预览位于 `changes` 数组。dry-run 可能执行 Git fetch/clone 等只读网络操作。
274
+ Mutating commands also accept `--dry-run`. Under the same Home write lock, HarnessBrew runs full validation and the installation transaction, collects before/after types and digests for each path, then rolls back the Cellar, Receipts, Tap checkouts, and Agent Targets. With `--json`, the preview appears in `changes`. A dry run can still perform read-only network operations such as Git fetch or clone.
270
275
 
271
276
  ```bash
272
277
  harnessbrew install code-review --target openai-codex --dry-run --json
273
278
  ```
274
279
 
275
- ## 本地目录
280
+ ## Local directories
276
281
 
277
282
  ```text
278
283
  ~/.harnessbrew/
279
- ├── taps/ # HarnessBrew 管理的 Git 工作树
280
- ├── cellar/ # Formula commit 隔离的不可变内容
281
- ├── receipts/ # 安装、依赖、target 链接和摘要
282
- └── state.json # Tap 注册状态
284
+ ├── taps/ # Git worktrees managed by HarnessBrew
285
+ ├── cellar/ # Immutable content isolated by Formula and commit
286
+ ├── receipts/ # Installation, dependency, Target-link, and digest records
287
+ └── state.json # Tap registration state
283
288
  ```
284
289
 
285
- Tap 工作树和 Cellar 内容都由 HarnessBrew 管理,不应直接编辑。个人资产应在原始 Tap 仓库中修改、提交和推送,再通过 `update`/`upgrade` 安装。
290
+ HarnessBrew owns the Tap worktrees and Cellar contents; do not edit them directly. Change personal assets in the source Tap repository, commit and push, then install the changes with `update` and `upgrade`.
286
291
 
287
- ## 安全边界
292
+ ## Security boundaries
288
293
 
289
- - Formula 是声明式 JSONHarnessBrew 不执行 Tap 中的任意脚本。
290
- - 新注册的 Tap 默认不受信任:可以搜索和安装到 Cellar,但必须通过 `tap trust`、`tap add --trust` Harnessfile v2 `trust: true` 才能链接或渲染到 Agent Target。旧状态记录按兼容策略视为已信任。
291
- - Tap 更新默认只接受 Git fast-forward;仓库历史被重写时必须人工检查后使用 `--allow-rewind`。候选 commit 校验失败会恢复原 checkout 和状态。
292
- - Formula 入口不能逃逸所属目录。
293
- - 安装前会检查依赖、冲突和 target 兼容性。
294
- - HarnessBrew 不覆盖未由 Receipt 管理的目标文件。
295
- - 卸载前会检查 Cellar 文件摘要和符号链接目标。
296
- - 私有 Tap 凭据由系统 Git/SSH credential 机制管理。
294
+ - Formulae are declarative JSON; HarnessBrew does not execute arbitrary Tap scripts.
295
+ - Newly registered Taps are untrusted by default. They can be searched and installed into the Cellar, but linking or rendering into an Agent Target requires `tap trust`, `tap add --trust`, or `trust: true` in Harnessfile v2. Legacy state records are treated as trusted for compatibility.
296
+ - Tap updates accept Git fast-forwards only by default. Rewritten history must be reviewed and accepted with `--allow-rewind`. A failed candidate-commit validation restores the original checkout and state.
297
+ - Formula entries cannot escape their containing directories.
298
+ - Dependencies, conflicts, and Target compatibility are checked before installation.
299
+ - HarnessBrew does not overwrite target files it does not own through a Receipt.
300
+ - Uninstallation validates Cellar digests and symlink destinations first.
301
+ - Credentials for private Taps are handled by the system Git/SSH credential mechanism.
297
302
 
298
- ## 开发
303
+ ## Development
299
304
 
300
- 项目使用 TypeScript 7.0,并启用严格类型检查。
305
+ The project uses TypeScript 7.0 with strict type checking.
301
306
 
302
307
  ```bash
303
308
  npm ci
@@ -306,12 +311,11 @@ npm test
306
311
  npm run check
307
312
  ```
308
313
 
309
- `npm run check` 会执行 TypeScript 编译、全部 Node.js 测试、安装包冒烟测试和 `npm pack --dry-run`。
314
+ `npm run check` runs TypeScript compilation, all Node.js tests, a package smoke test, and `npm pack --dry-run`.
310
315
 
311
316
  ## Target Adapter SDK
312
317
 
313
- Node.js/TypeScript 宿主可以通过公开 API 注册第三方 Agent Target。Adapter API v1 只接收 Receipt Target Context,并返回一条声明式安装计划;
314
- 实际写入、冲突检测、Receipt、doctor、relink、upgrade、dry-run 和回滚仍由 HarnessBrew transaction layer 负责。
318
+ Node.js and TypeScript hosts can register third-party Agent Targets through the public API. Adapter API v1 receives only a Receipt and Target Context and returns a declarative installation plan. Writes, conflict detection, Receipts, `doctor`, `relink`, upgrades, dry runs, and rollback remain the responsibility of the HarnessBrew transaction layer.
315
319
 
316
320
  ```ts
317
321
  import { registerTargetAdapter, type TargetAdapter } from "harnessbrew";
@@ -338,12 +342,9 @@ const adapter: TargetAdapter = {
338
342
  const unregister = registerTargetAdapter(adapter);
339
343
  ```
340
344
 
341
- SDK 会校验 API 版本、名称、版本、完整能力矩阵、计划身份、绝对目标路径和 Cellar source 边界。v1 的第三方 Adapter 计划只允许
342
- `symlink-file`、`symlink-directory` 和 `unsupported`,不提供直接写文件或生成共享配置的操作。注册是显式、进程内操作;HarnessBrew 不会从 Tap
343
- 自动执行 Adapter Formula。第三方 Adapter 本身是具有宿主进程权限的可信代码,只应加载经过审查的 npm 包。
345
+ The SDK validates API version, name, version, the complete capability matrix, plan identity, absolute target paths, and Cellar source boundaries. Third-party Adapter plans in v1 may use only `symlink-file`, `symlink-directory`, and `unsupported`; they cannot write files directly or generate shared configuration. Registration is explicit and process-local. HarnessBrew never executes Adapter Formulae from a Tap automatically. A third-party Adapter has the host process's privileges and should be loaded only from a reviewed npm package.
344
346
 
345
- 独立 CLI 可以持久化管理可信 Adapter 模块。模块需已通过 npm 安装并可被 `harnessbrew` 解析,也可以使用绝对路径或 `file://` URL;它必须默认导出
346
- 一个 Adapter,或提供名为 `adapter` 的导出:
347
+ The standalone CLI can persist trusted Adapter modules. The module must already be installed and resolvable by `harnessbrew`, or be supplied as an absolute path or `file://` URL. It must default-export an Adapter or provide a named `adapter` export:
347
348
 
348
349
  ```bash
349
350
  harnessbrew adapter add @harnessbrew/adapter-cursor
@@ -352,14 +353,11 @@ harnessbrew install review --target cursor
352
353
  harnessbrew adapter remove cursor
353
354
  ```
354
355
 
355
- `adapter add` 是一次显式的代码执行授权。HarnessBrew 将模块标识及审核时的 nameversionAPI version 写入
356
- `~/.harnessbrew/adapters.json`;后续只在 install/link/unlink/relink/upgrade/bundle 需要 Target 时加载,并在每次加载时核对身份。
357
- 如果包升级改变身份,命令会关闭失败,要求先 remove、审查后再 add。`adapter list/remove` 本身不执行插件,HarnessBrew 也不会自动运行 `npm install`。
358
- CLI 加载的 Target 同样进入 Harnessfile v2 lock 的 Adapter 签名。
356
+ `adapter add` explicitly authorizes code execution. HarnessBrew records the module specifier and reviewed name, version, and API version in `~/.harnessbrew/adapters.json`. It loads the module only when install, link, unlink, relink, upgrade, or bundle operations need that Target, and verifies its identity every time. If a package upgrade changes identity, the command fails closed until the module is removed, reviewed, and added again. `adapter list` and `adapter remove` do not execute plugins, and HarnessBrew never runs `npm install` automatically. CLI-loaded Targets are also included in the Harnessfile v2 Adapter signature.
359
357
 
360
- ## 架构
358
+ ## Architecture
361
359
 
362
- 完整设计见 [docs/architecture.md](docs/architecture.md)
360
+ See [docs/architecture.md](docs/architecture.md) for the full design.
363
361
 
364
362
  ## License
365
363
 
@@ -0,0 +1,373 @@
1
+ # HarnessBrew
2
+
3
+ [English](README.md) | 简体中文
4
+
5
+ [![CI](https://github.com/anzihenry/HarnessBrew/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/anzihenry/HarnessBrew/actions/workflows/ci.yml)
6
+ [![npm version](https://img.shields.io/npm/v/harnessbrew.svg?logo=npm)](https://www.npmjs.com/package/harnessbrew)
7
+ [![Node.js](https://img.shields.io/node/v/harnessbrew.svg?logo=nodedotjs)](https://www.npmjs.com/package/harnessbrew)
8
+ [![License](https://img.shields.io/github/license/anzihenry/HarnessBrew.svg)](https://github.com/anzihenry/HarnessBrew/blob/main/LICENSE)
9
+
10
+ HarnessBrew 是面向 AI Agent 资产的 Git 包管理器。它的定位类似 Homebrew:通过 Git Tap 发现资产,通过 Formula 描述资产,通过 Cellar 与 Receipt 安装、升级和安全卸载资产。
11
+
12
+ HarnessBrew 不托管资产。个人、团队和第三方资产都保存在各自的 Git 仓库中,并使用完全相同的安装机制。
13
+
14
+ ## 主要能力
15
+
16
+ - 注册、更新和移除 Git Tap
17
+ - 校验并搜索 skill、agent、workflow、instruction、prompt、MCP 和 adapter Formula
18
+ - 解析依赖、循环、缺失项与冲突
19
+ - 按 Git commit 将不可变内容安装到 Cellar
20
+ - 链接到 OpenAI Codex 和 Claude Code
21
+ - 以原生格式投递 Skill、Agent、Workflow、Prompt、Instruction 和 MCP
22
+ - 支持 user/project scope,以及同一 Target 的多实例
23
+ - 通过 Receipt 跟踪文件、配置键、受管区块所有权和 SHA-256 摘要
24
+ - 使用 `doctor` 诊断并通过 `relink` 修复 Target 漂移
25
+ - 检测可用升级,并在升级后保留 Agent target 链接
26
+ - 使用 `Harnessfile` 和 lockfile 在不同设备上复现环境
27
+ - 从 npm 安装并通过 GitHub Release 发布
28
+
29
+ ## 安装
30
+
31
+ 要求:Node.js 22 或更高版本,系统中可用 Git。
32
+
33
+ ```bash
34
+ npm install --global harnessbrew
35
+ harnessbrew --version
36
+ ```
37
+
38
+ 也可以直接使用:
39
+
40
+ ```bash
41
+ npx harnessbrew help
42
+ ```
43
+
44
+ HarnessBrew 默认将受管状态保存到 `~/.harnessbrew`。测试或隔离环境可以设置 `HARNESSBREW_HOME`。
45
+
46
+ ## 快速开始
47
+
48
+ 注册自己的资产 Tap:
49
+
50
+ ```bash
51
+ harnessbrew tap add your-name/agents git@github.com:your-name/agent-assets.git --trust
52
+ ```
53
+
54
+ 搜索并查看 Formula:
55
+
56
+ ```bash
57
+ harnessbrew search review
58
+ harnessbrew search --kind skill --target openai-codex
59
+ harnessbrew info your-name/agents/code-review
60
+ ```
61
+
62
+ 安装到 Cellar,并链接到 Codex:
63
+
64
+ ```bash
65
+ harnessbrew install your-name/agents/code-review \
66
+ --target openai-codex
67
+ ```
68
+
69
+ 如果只希望保存到 Cellar,不写入 Agent 配置目录,可以省略 `--target`。
70
+
71
+ 更新和升级:
72
+
73
+ ```bash
74
+ harnessbrew update [--allow-rewind]
75
+ harnessbrew outdated
76
+ harnessbrew upgrade code-review
77
+ ```
78
+
79
+ 安全卸载:
80
+
81
+ ```bash
82
+ harnessbrew uninstall code-review
83
+ ```
84
+
85
+ 若受管文件或链接已被修改,HarnessBrew 会停止卸载。确认需要删除时可以显式传入 `--force`。
86
+
87
+ ## Homebrew 概念对应
88
+
89
+ | Homebrew | HarnessBrew |
90
+ | --- | --- |
91
+ | `brew` | `harnessbrew` |
92
+ | Tap | Git 资产源仓库 |
93
+ | Formula / Cask | Agent 资产 Formula |
94
+ | Cellar | 按 Git commit 隔离的本地安装区 |
95
+ | Link | 到 Codex、Claude Code 等 target 的链接 |
96
+ | `Brewfile` | `Harnessfile` |
97
+ | Receipt | 安装来源、文件摘要与所有权记录 |
98
+
99
+ ## 创建 Tap
100
+
101
+ Tap 是普通 Git 仓库。推荐按资产集合建立 Tap,不需要为每个 skill 单独建立仓库。
102
+
103
+ ```text
104
+ my-agent-tap/
105
+ ├── tap.json
106
+ ├── skills/
107
+ │ └── code-review/
108
+ │ ├── formula.json
109
+ │ └── SKILL.md
110
+ ├── workflows/
111
+ ├── agents/
112
+ ├── instructions/
113
+ ├── prompts/
114
+ ├── mcp/
115
+ └── adapters/
116
+ ```
117
+
118
+ 最小 `tap.json`:
119
+
120
+ ```json
121
+ {
122
+ "schemaVersion": 1
123
+ }
124
+ ```
125
+
126
+ Formula 的目录名称必须与 `name` 一致,目录类型必须与 `kind` 一致:
127
+
128
+ ```json
129
+ {
130
+ "schemaVersion": 1,
131
+ "name": "code-review",
132
+ "kind": "skill",
133
+ "description": "Review code changes with a consistent rubric.",
134
+ "entry": "SKILL.md",
135
+ "targets": ["openai-codex", "claude-code"],
136
+ "dependencies": [
137
+ "your-name/agents/repository-guardrails"
138
+ ],
139
+ "conflicts": [],
140
+ "tags": ["review", "quality"]
141
+ }
142
+ ```
143
+
144
+ 完整坐标为 `<owner>/<tap>/<formula>`。依赖和冲突必须使用完整坐标,以避免跨 Tap 名称歧义。
145
+
146
+ Git commit 是安装版本的唯一事实来源;Formula 不维护 `.snapshots` 或重复的 `history`。
147
+
148
+ MCP Formula 的入口是统一 JSON。stdio 配置使用 `command`、可选 `args` 和只包含环境变量名称的 `envVars`;HTTP 配置使用 `transport: "http"`、`url`、可选 `bearerTokenEnvVar` 与 `headersFromEnv`。HarnessBrew 不接受入口中的明文 `env` 密钥值。
149
+
150
+ `adapter` Formula 是可由 Git/Cellar 管理的扩展资产,但不会作为代码自动执行。Target Adapter 运行时使用单独的可信模块机制:先审查并安装 npm 包,
151
+ 再通过 `harnessbrew adapter add <module>` 显式授权。这样 Tap 仍保持声明式、不执行任意代码,而第三方 Target 可以接入版本化 Adapter SDK。
152
+
153
+ ## Target
154
+
155
+ 当前内置:
156
+
157
+ - `openai-codex`
158
+ - `claude-code`
159
+
160
+ 可以在安装时指定 target:
161
+
162
+ ```bash
163
+ harnessbrew install code-review --target openai-codex
164
+ ```
165
+
166
+ Codex Skill 默认安装到 `~/.agents/skills`,其他 Codex 配置使用 `~/.codex`;Claude Code 使用 `~/.claude`。Skill 以完整目录软链安装,因此 `scripts/`、`references/` 和 `assets/` 等相对资源会与 `SKILL.md` 一起生效。Workflow 和 Prompt 会被投影为带标准 frontmatter 的 Target Skill。Agent 则以统一 Markdown 作为源码:投递到 Codex 时确定性渲染为 `.codex/agents/<name>.toml`,投递到 Claude Code 时渲染为 `.claude/agents/<name>.md`。Instruction 在 Codex 的 `AGENTS.md` 中使用带所有权标记的受管区块,在 Claude Code 中链接为 `.claude/rules/<name>.md`;MCP 分别按 TOML 区块或 JSON 键合并。卸载这些共享配置不会覆盖用户内容。需要隔离安装时可使用:
167
+
168
+ ```bash
169
+ harnessbrew install code-review \
170
+ --target openai-codex \
171
+ --target-root /path/to/sandbox/.codex
172
+ ```
173
+
174
+ Target 支持用户级与项目级 scope;`--project` 会隐式选择 project scope。同一 Formula 可以同时存在于两个 scope,Receipt 会按实际目标路径分别记录操作:
175
+
176
+ ```bash
177
+ harnessbrew link code-review --target openai-codex --scope user
178
+ harnessbrew link code-review --target openai-codex --scope project --project /path/to/repo
179
+ harnessbrew unlink code-review --target openai-codex --scope project --project /path/to/repo
180
+ ```
181
+
182
+ 项目级 Codex 资产使用项目中的 `.agents/skills`、`.codex/agents`、根 `AGENTS.md` 和 `.codex/config.toml`;Claude Code 使用 `.claude/skills`、`.claude/agents`、`.claude/rules` 和根 `.mcp.json`。当同一 Target 有多个实例时,unlink 必须指定 scope。
183
+
184
+ `harnessbrew doctor [formula]` 会校验 Cellar 文件摘要和每条 Target operation,区分目标缺失与被修改;`harnessbrew relink <formula>` 会在 Cellar 完整的前提下,按 Receipt 记录的 scope/root 强制重建 HarnessBrew 拥有的目标。可用 `--target`、`--scope` 和 `--project` 只修复一个实例。
185
+
186
+ 也可以单独管理链接:
187
+
188
+ ```bash
189
+ harnessbrew link code-review --target openai-codex
190
+ harnessbrew unlink code-review --target openai-codex
191
+ ```
192
+
193
+ ## Harnessfile
194
+
195
+ `Harnessfile` 适合提交到个人 dotfiles 或项目仓库:
196
+
197
+ ```yaml
198
+ schemaVersion: 2
199
+ taps:
200
+ - name: your-name/agents
201
+ git: git@github.com:your-name/agent-assets.git
202
+ ref: main
203
+ trust: true
204
+
205
+ assets:
206
+ - formula: your-name/agents/code-review
207
+ targets:
208
+ - target: openai-codex
209
+ scope: user
210
+ - target: claude-code
211
+ scope: project
212
+ project: .
213
+ ```
214
+
215
+ v2 的 Target placement 可以声明 `user` 或 `project` scope,并可使用相对于 `Harnessfile` 的 `project` 和 `root` 路径。
216
+ schema v1 的 `targets: [openai-codex]` 仍然兼容,并按 user scope 解释。
217
+
218
+ 安装并生成 `Harnessfile.lock`:
219
+
220
+ ```bash
221
+ harnessbrew bundle install
222
+ ```
223
+
224
+ v2 lockfile 会记录 Manifest 摘要、HarnessBrew Adapter 版本、每个 Tap 的准确 commit、Formula 内容摘要、依赖闭包和完整 Target placement,
225
+ 应与 `Harnessfile` 一起提交到 Git。
226
+
227
+ 在其他设备运行同一命令时,HarnessBrew 会检出 lockfile 固定的 commit,而不是未经确认地使用 Tap 最新版本。
228
+ 修改 v2 Harnessfile 后需要显式更新 lockfile:
229
+
230
+ ```bash
231
+ harnessbrew bundle install --update-lock
232
+ ```
233
+
234
+ 清理清单之外的受管资产:
235
+
236
+ ```bash
237
+ harnessbrew bundle cleanup
238
+ ```
239
+
240
+ 使用其他文件路径:
241
+
242
+ ```bash
243
+ harnessbrew bundle install --file ./config/Harnessfile
244
+ ```
245
+
246
+ ## CLI
247
+
248
+ ```text
249
+ harnessbrew tap add <owner/name> <git-url> [--ref <ref>] [--trust]
250
+ harnessbrew tap list
251
+ harnessbrew tap update [owner/name] [--allow-rewind]
252
+ harnessbrew tap trust <owner/name>
253
+ harnessbrew tap untrust <owner/name>
254
+ harnessbrew tap remove <owner/name>
255
+ harnessbrew untap <owner/name>
256
+ harnessbrew search [query] [--kind <kind>] [--target <target>]
257
+ harnessbrew info <formula>
258
+ harnessbrew install <formula> [--target <target>] [--scope <user|project>] [--project <path>] [--target-root <path>]
259
+ harnessbrew list
260
+ harnessbrew link <formula> --target <target> [--scope <user|project>] [--project <path>] [--target-root <path>]
261
+ harnessbrew unlink <formula> --target <target> [--scope <user|project>] [--project <path>] [--force]
262
+ harnessbrew doctor [formula]
263
+ harnessbrew relink <formula> [--target <target>] [--scope <user|project>] [--project <path>]
264
+ harnessbrew update
265
+ harnessbrew outdated
266
+ harnessbrew upgrade [formula]
267
+ harnessbrew uninstall <formula> [--force]
268
+ harnessbrew bundle install [--file <path>] [--update-lock]
269
+ harnessbrew bundle cleanup [--file <path>]
270
+ ```
271
+
272
+ 所有命令都可追加 `--json`,stdout 将只包含一个 schema v1 JSON envelope:`result` 是命令级结构化结果,`output` 保留人类文本,
273
+ 失败时包含 `error.code`、`error.message`、`diagnostics` 和非零 `exitCode`。
274
+
275
+ 变更命令可追加 `--dry-run`。HarnessBrew 会在同一 Home 写锁下完整执行校验和安装事务,收集每个路径的 before/after 类型与摘要,
276
+ 随后回滚 Cellar、Receipt、Tap checkout 和 Agent Target;与 `--json` 组合时,预览位于 `changes` 数组。dry-run 可能执行 Git fetch/clone 等只读网络操作。
277
+
278
+ ```bash
279
+ harnessbrew install code-review --target openai-codex --dry-run --json
280
+ ```
281
+
282
+ ## 本地目录
283
+
284
+ ```text
285
+ ~/.harnessbrew/
286
+ ├── taps/ # HarnessBrew 管理的 Git 工作树
287
+ ├── cellar/ # 按 Formula 与 commit 隔离的不可变内容
288
+ ├── receipts/ # 安装、依赖、target 链接和摘要
289
+ └── state.json # Tap 注册状态
290
+ ```
291
+
292
+ Tap 工作树和 Cellar 内容都由 HarnessBrew 管理,不应直接编辑。个人资产应在原始 Tap 仓库中修改、提交和推送,再通过 `update`/`upgrade` 安装。
293
+
294
+ ## 安全边界
295
+
296
+ - Formula 是声明式 JSON;HarnessBrew 不执行 Tap 中的任意脚本。
297
+ - 新注册的 Tap 默认不受信任:可以搜索和安装到 Cellar,但必须通过 `tap trust`、`tap add --trust` 或 Harnessfile v2 的 `trust: true` 才能链接或渲染到 Agent Target。旧状态记录按兼容策略视为已信任。
298
+ - Tap 更新默认只接受 Git fast-forward;仓库历史被重写时必须人工检查后使用 `--allow-rewind`。候选 commit 校验失败会恢复原 checkout 和状态。
299
+ - Formula 入口不能逃逸所属目录。
300
+ - 安装前会检查依赖、冲突和 target 兼容性。
301
+ - HarnessBrew 不覆盖未由 Receipt 管理的目标文件。
302
+ - 卸载前会检查 Cellar 文件摘要和符号链接目标。
303
+ - 私有 Tap 凭据由系统 Git/SSH credential 机制管理。
304
+
305
+ ## 开发
306
+
307
+ 项目使用 TypeScript 7.0,并启用严格类型检查。
308
+
309
+ ```bash
310
+ npm ci
311
+ npm run build
312
+ npm test
313
+ npm run check
314
+ ```
315
+
316
+ `npm run check` 会执行 TypeScript 编译、全部 Node.js 测试、安装包冒烟测试和 `npm pack --dry-run`。
317
+
318
+ ## Target Adapter SDK
319
+
320
+ Node.js/TypeScript 宿主可以通过公开 API 注册第三方 Agent Target。Adapter API v1 只接收 Receipt 与 Target Context,并返回一条声明式安装计划;
321
+ 实际写入、冲突检测、Receipt、doctor、relink、upgrade、dry-run 和回滚仍由 HarnessBrew transaction layer 负责。
322
+
323
+ ```ts
324
+ import { registerTargetAdapter, type TargetAdapter } from "harnessbrew";
325
+
326
+ const adapter: TargetAdapter = {
327
+ apiVersion: 1,
328
+ name: "cursor",
329
+ version: "1.0.0",
330
+ capabilities: {
331
+ skill: "symlink-directory",
332
+ agent: "symlink-file",
333
+ workflow: "symlink-file",
334
+ instruction: "symlink-file",
335
+ prompt: "symlink-file",
336
+ mcp: "unsupported",
337
+ adapter: "unsupported"
338
+ },
339
+ plan(receipt, context = {}) {
340
+ // Return one absolute destination and a source inside receipt.cellarPath.
341
+ return { target: "cursor", coordinate: receipt.coordinate, operations: [/* ... */] };
342
+ }
343
+ };
344
+
345
+ const unregister = registerTargetAdapter(adapter);
346
+ ```
347
+
348
+ SDK 会校验 API 版本、名称、版本、完整能力矩阵、计划身份、绝对目标路径和 Cellar source 边界。v1 的第三方 Adapter 计划只允许
349
+ `symlink-file`、`symlink-directory` 和 `unsupported`,不提供直接写文件或生成共享配置的操作。注册是显式、进程内操作;HarnessBrew 不会从 Tap
350
+ 自动执行 Adapter Formula。第三方 Adapter 本身是具有宿主进程权限的可信代码,只应加载经过审查的 npm 包。
351
+
352
+ 独立 CLI 可以持久化管理可信 Adapter 模块。模块需已通过 npm 安装并可被 `harnessbrew` 解析,也可以使用绝对路径或 `file://` URL;它必须默认导出
353
+ 一个 Adapter,或提供名为 `adapter` 的导出:
354
+
355
+ ```bash
356
+ harnessbrew adapter add @harnessbrew/adapter-cursor
357
+ harnessbrew adapter list
358
+ harnessbrew install review --target cursor
359
+ harnessbrew adapter remove cursor
360
+ ```
361
+
362
+ `adapter add` 是一次显式的代码执行授权。HarnessBrew 将模块标识及审核时的 name、version、API version 写入
363
+ `~/.harnessbrew/adapters.json`;后续只在 install/link/unlink/relink/upgrade/bundle 需要 Target 时加载,并在每次加载时核对身份。
364
+ 如果包升级改变身份,命令会关闭失败,要求先 remove、审查后再 add。`adapter list/remove` 本身不执行插件,HarnessBrew 也不会自动运行 `npm install`。
365
+ CLI 加载的 Target 同样进入 Harnessfile v2 lock 的 Adapter 签名。
366
+
367
+ ## 架构
368
+
369
+ 完整设计见 [docs/architecture.zh-CN.md](docs/architecture.zh-CN.md)。
370
+
371
+ ## License
372
+
373
+ MIT
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.6.0";
1
+ export declare const VERSION = "0.6.2";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = "0.6.0";
1
+ export const VERSION = "0.6.2";
2
2
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "harnessbrew",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "A Git-native package manager for AI Agent assets.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -52,7 +52,7 @@
52
52
  },
53
53
  "packageManager": "npm@11.17.0",
54
54
  "engines": {
55
- "node": ">=20"
55
+ "node": ">=22"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/node": "^22.14.0",