harness-config-manager 0.1.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.
Files changed (175) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1547 -0
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +584 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/commands/config.d.ts +7 -0
  7. package/dist/commands/config.js +49 -0
  8. package/dist/commands/config.js.map +1 -0
  9. package/dist/commands/context.d.ts +24 -0
  10. package/dist/commands/context.js +329 -0
  11. package/dist/commands/context.js.map +1 -0
  12. package/dist/commands/export.d.ts +19 -0
  13. package/dist/commands/export.js +116 -0
  14. package/dist/commands/export.js.map +1 -0
  15. package/dist/commands/import.d.ts +33 -0
  16. package/dist/commands/import.js +81 -0
  17. package/dist/commands/import.js.map +1 -0
  18. package/dist/commands/info.d.ts +19 -0
  19. package/dist/commands/info.js +235 -0
  20. package/dist/commands/info.js.map +1 -0
  21. package/dist/commands/init.d.ts +5 -0
  22. package/dist/commands/init.js +116 -0
  23. package/dist/commands/init.js.map +1 -0
  24. package/dist/commands/install.d.ts +119 -0
  25. package/dist/commands/install.js +533 -0
  26. package/dist/commands/install.js.map +1 -0
  27. package/dist/commands/list.d.ts +9 -0
  28. package/dist/commands/list.js +102 -0
  29. package/dist/commands/list.js.map +1 -0
  30. package/dist/commands/params.d.ts +58 -0
  31. package/dist/commands/params.js +366 -0
  32. package/dist/commands/params.js.map +1 -0
  33. package/dist/commands/refs.d.ts +60 -0
  34. package/dist/commands/refs.js +329 -0
  35. package/dist/commands/refs.js.map +1 -0
  36. package/dist/commands/registry.d.ts +18 -0
  37. package/dist/commands/registry.js +173 -0
  38. package/dist/commands/registry.js.map +1 -0
  39. package/dist/commands/status.d.ts +10 -0
  40. package/dist/commands/status.js +83 -0
  41. package/dist/commands/status.js.map +1 -0
  42. package/dist/commands/targets.d.ts +8 -0
  43. package/dist/commands/targets.js +61 -0
  44. package/dist/commands/targets.js.map +1 -0
  45. package/dist/commands/uninstall.d.ts +71 -0
  46. package/dist/commands/uninstall.js +322 -0
  47. package/dist/commands/uninstall.js.map +1 -0
  48. package/dist/commands/update.d.ts +66 -0
  49. package/dist/commands/update.js +384 -0
  50. package/dist/commands/update.js.map +1 -0
  51. package/dist/commands/validate.d.ts +3 -0
  52. package/dist/commands/validate.js +38 -0
  53. package/dist/commands/validate.js.map +1 -0
  54. package/dist/core/bundle.d.ts +49 -0
  55. package/dist/core/bundle.js +326 -0
  56. package/dist/core/bundle.js.map +1 -0
  57. package/dist/core/config.d.ts +65 -0
  58. package/dist/core/config.js +112 -0
  59. package/dist/core/config.js.map +1 -0
  60. package/dist/core/conflicts.d.ts +67 -0
  61. package/dist/core/conflicts.js +300 -0
  62. package/dist/core/conflicts.js.map +1 -0
  63. package/dist/core/context.d.ts +139 -0
  64. package/dist/core/context.js +432 -0
  65. package/dist/core/context.js.map +1 -0
  66. package/dist/core/deps.d.ts +62 -0
  67. package/dist/core/deps.js +339 -0
  68. package/dist/core/deps.js.map +1 -0
  69. package/dist/core/errors.d.ts +21 -0
  70. package/dist/core/errors.js +26 -0
  71. package/dist/core/errors.js.map +1 -0
  72. package/dist/core/executor.d.ts +9 -0
  73. package/dist/core/executor.js +139 -0
  74. package/dist/core/executor.js.map +1 -0
  75. package/dist/core/flavors.d.ts +128 -0
  76. package/dist/core/flavors.js +386 -0
  77. package/dist/core/flavors.js.map +1 -0
  78. package/dist/core/frontmatter.d.ts +6 -0
  79. package/dist/core/frontmatter.js +20 -0
  80. package/dist/core/frontmatter.js.map +1 -0
  81. package/dist/core/fsx.d.ts +40 -0
  82. package/dist/core/fsx.js +180 -0
  83. package/dist/core/fsx.js.map +1 -0
  84. package/dist/core/github.d.ts +37 -0
  85. package/dist/core/github.js +157 -0
  86. package/dist/core/github.js.map +1 -0
  87. package/dist/core/harnesses.d.ts +142 -0
  88. package/dist/core/harnesses.js +215 -0
  89. package/dist/core/harnesses.js.map +1 -0
  90. package/dist/core/hash.d.ts +12 -0
  91. package/dist/core/hash.js +34 -0
  92. package/dist/core/hash.js.map +1 -0
  93. package/dist/core/logger.d.ts +16 -0
  94. package/dist/core/logger.js +36 -0
  95. package/dist/core/logger.js.map +1 -0
  96. package/dist/core/overlap.d.ts +79 -0
  97. package/dist/core/overlap.js +155 -0
  98. package/dist/core/overlap.js.map +1 -0
  99. package/dist/core/parameters.d.ts +249 -0
  100. package/dist/core/parameters.js +944 -0
  101. package/dist/core/parameters.js.map +1 -0
  102. package/dist/core/paths.d.ts +20 -0
  103. package/dist/core/paths.js +35 -0
  104. package/dist/core/paths.js.map +1 -0
  105. package/dist/core/planner.d.ts +36 -0
  106. package/dist/core/planner.js +364 -0
  107. package/dist/core/planner.js.map +1 -0
  108. package/dist/core/prompt.d.ts +52 -0
  109. package/dist/core/prompt.js +197 -0
  110. package/dist/core/prompt.js.map +1 -0
  111. package/dist/core/refmap.d.ts +91 -0
  112. package/dist/core/refmap.js +331 -0
  113. package/dist/core/refmap.js.map +1 -0
  114. package/dist/core/refs.d.ts +297 -0
  115. package/dist/core/refs.js +801 -0
  116. package/dist/core/refs.js.map +1 -0
  117. package/dist/core/registry.d.ts +119 -0
  118. package/dist/core/registry.js +363 -0
  119. package/dist/core/registry.js.map +1 -0
  120. package/dist/core/rename.d.ts +36 -0
  121. package/dist/core/rename.js +74 -0
  122. package/dist/core/rename.js.map +1 -0
  123. package/dist/core/rollback.d.ts +38 -0
  124. package/dist/core/rollback.js +226 -0
  125. package/dist/core/rollback.js.map +1 -0
  126. package/dist/core/semver.d.ts +56 -0
  127. package/dist/core/semver.js +214 -0
  128. package/dist/core/semver.js.map +1 -0
  129. package/dist/core/state.d.ts +99 -0
  130. package/dist/core/state.js +196 -0
  131. package/dist/core/state.js.map +1 -0
  132. package/dist/core/store.d.ts +30 -0
  133. package/dist/core/store.js +54 -0
  134. package/dist/core/store.js.map +1 -0
  135. package/dist/core/types.d.ts +515 -0
  136. package/dist/core/types.js +49 -0
  137. package/dist/core/types.js.map +1 -0
  138. package/dist/index.d.ts +16 -0
  139. package/dist/index.js +16 -0
  140. package/dist/index.js.map +1 -0
  141. package/dist/merge/blocks.d.ts +48 -0
  142. package/dist/merge/blocks.js +0 -0
  143. package/dist/merge/blocks.js.map +1 -0
  144. package/dist/merge/json-merge.d.ts +66 -0
  145. package/dist/merge/json-merge.js +176 -0
  146. package/dist/merge/json-merge.js.map +1 -0
  147. package/dist/merge/toml.d.ts +48 -0
  148. package/dist/merge/toml.js +118 -0
  149. package/dist/merge/toml.js.map +1 -0
  150. package/dist/targets/claude-code.d.ts +11 -0
  151. package/dist/targets/claude-code.js +94 -0
  152. package/dist/targets/claude-code.js.map +1 -0
  153. package/dist/targets/copilot.d.ts +13 -0
  154. package/dist/targets/copilot.js +126 -0
  155. package/dist/targets/copilot.js.map +1 -0
  156. package/dist/targets/index.d.ts +20 -0
  157. package/dist/targets/index.js +60 -0
  158. package/dist/targets/index.js.map +1 -0
  159. package/dist/targets/opencode.d.ts +32 -0
  160. package/dist/targets/opencode.js +172 -0
  161. package/dist/targets/opencode.js.map +1 -0
  162. package/dist/targets/pi.d.ts +42 -0
  163. package/dist/targets/pi.js +134 -0
  164. package/dist/targets/pi.js.map +1 -0
  165. package/dist/targets/reasonix.d.ts +27 -0
  166. package/dist/targets/reasonix.js +192 -0
  167. package/dist/targets/reasonix.js.map +1 -0
  168. package/dist/targets/shared.d.ts +33 -0
  169. package/dist/targets/shared.js +109 -0
  170. package/dist/targets/shared.js.map +1 -0
  171. package/dist/targets/types.d.ts +40 -0
  172. package/dist/targets/types.js +17 -0
  173. package/dist/targets/types.js.map +1 -0
  174. package/docs/authoring-bundles.md +828 -0
  175. package/package.json +74 -0
@@ -0,0 +1,828 @@
1
+ # Authoring bundles
2
+
3
+ A practical guide to writing a bundle that installs cleanly into all three
4
+ harnesses. See the [README](../README.md) for the CLI reference, and
5
+ [`bundles/ts-review-kit`](../bundles/ts-review-kit) for a complete example.
6
+
7
+ ## Start from the scaffold
8
+
9
+ ```bash
10
+ hcm init my-kit --name my-kit
11
+ hcm validate ./my-kit
12
+ hcm registry add ./my-kit --dev
13
+ ```
14
+
15
+ `--dev` matters while you are authoring. Registering normally copies the bundle
16
+ into `~/.hcm/store`, so what you install is a snapshot taken at that moment and
17
+ later edits need an `hcm update`. A `--dev` entry is read from your working
18
+ directory every time, so the loop is edit → `hcm install my-kit` → look at the
19
+ result, with nothing to refresh in between.
20
+
21
+ `hcm validate` checks for the mistakes that actually bite: subagents and skills
22
+ without a `description`, MCP servers with neither `command` nor `url`, malformed
23
+ `appliesTo`, duplicate names within a kind, and flavors that do not line up with
24
+ the resources claiming them.
25
+
26
+ ## The manifest
27
+
28
+ ```yaml
29
+ name: my-kit # required; must be usable as a filename
30
+ version: 1.0.0 # required
31
+ description: ... # shown by `hcm list` and `hcm info`
32
+ author: ...
33
+ homepage: ...
34
+ tags: [review, typescript]
35
+ targets: [claude-code, copilot] # optional; omit to support all
36
+ # known ids: claude-code, copilot, reasonix,
37
+ # opencode, pi
38
+ dependencies: # optional; see below
39
+ - jira-board@^1.2.0
40
+ flavors: # optional; subsets, see below
41
+ python: Python tooling
42
+ parameters: # optional; values asked for at install, see below
43
+ AGENT_NAME:
44
+ default: Claude
45
+ ```
46
+
47
+ Set `targets` only when a bundle genuinely does not make sense elsewhere.
48
+ Installing into an unlisted target is refused rather than silently partial.
49
+
50
+ ## Depending on another bundle
51
+
52
+ When several of your kits assume the same background — how the team's JIRA board
53
+ is laid out, which database the services use — write that once and require it:
54
+
55
+ ```yaml
56
+ dependencies:
57
+ - jira-board # any version
58
+ - team-conventions@^2.0.0 # a range
59
+ - name: db-kit # the long form
60
+ version: ">=2.1 <3"
61
+ source: acme/agent-kits/db-kit # where to find it, if it is not registered
62
+ ```
63
+
64
+ `hcm install my-kit` then installs `jira-board` first, and `hcm uninstall
65
+ my-kit` takes it away again unless something else still needs it. Users see the
66
+ tree before anything is written.
67
+
68
+ **Give a `source` to anything you publish.** A dependency is looked for in the
69
+ registry, then beside your bundle in the same collection, then at its `source`.
70
+ The first two are what make authoring pleasant — a monorepo of kits resolves
71
+ with nothing registered — but neither is available to someone who has just
72
+ pasted your repo URL. `hcm validate` runs the same lookup and will tell you:
73
+
74
+ ```
75
+ $ hcm validate ./my-kit
76
+ my-kit v1.0.0
77
+ 4 resource(s)
78
+ ! "my-kit" requires the bundle "jira-board", which hcm cannot find
79
+ ```
80
+
81
+ A `source` is a GitHub reference (`acme/agent-kits/db-kit`) or a path. A
82
+ relative path is read against the manifest that declares it, so
83
+ `../shared/jira-board` means that folder beside your bundle whichever directory
84
+ the user runs `hcm` from. Publishing to somebody else's machine needs the
85
+ GitHub form.
86
+
87
+ **Version ranges** are the familiar subset: `1.2.3`, `^1.2.3`, `~1.2.3`,
88
+ `>=1.2.3`, `1.2.x`, `*`, and those joined by a space (*and*) or `||` (*or*). A
89
+ range hcm does not understand is refused when the manifest is read, rather than
90
+ matching nothing later. Only one version of a bundle can be installed in a
91
+ scope, so prefer a wide range (`^1.2.0`) over a pinned one: two kits that pin
92
+ different patch versions of the same dependency cannot both be installed.
93
+
94
+ **Keep the graph shallow, and never circular.** A cycle is refused with the loop
95
+ named; if two bundles genuinely need each other, the shared part wants to be a
96
+ third bundle they both require.
97
+
98
+ Depending on a bundle is also the way to *share* resources deliberately. If your
99
+ kit ships the same `skills/jira-board/` as the bundle it requires, byte for
100
+ byte, the second install writes nothing and both claim the one copy — see
101
+ [Conventions that avoid conflicts](#conventions-that-avoid-conflicts).
102
+
103
+ ## Flavors: letting users take part of your kit
104
+
105
+ Some kits split cleanly down the middle. A coding kit that covers Python and C#
106
+ has a common half — the review command, the house conventions, the PR checklist —
107
+ and two language halves that most users only want one of. A **flavor** names a
108
+ half so users can ask for it:
109
+
110
+ ```bash
111
+ hcm install coding-kit --flavor python
112
+ ```
113
+
114
+ Everything in no flavor is *common* and installs either way. That default is the
115
+ important one: it means adding flavors to an existing kit changes nothing for
116
+ anyone who does not pass `--flavor`, and it means you only tag the parts that are
117
+ genuinely optional.
118
+
119
+ **Markdown resources tag themselves**, which keeps the fact next to the thing:
120
+
121
+ ```markdown
122
+ ---
123
+ description: Runs pytest, reads the failures, and reports the shortest path to green.
124
+ flavors: [python]
125
+ ---
126
+ ```
127
+
128
+ The key is stripped before the file is installed, so no harness ever sees it. A
129
+ resource can be in more than one flavor (`flavors: [python, csharp]`), and
130
+ `flavor: python` in the singular works too.
131
+
132
+ **`mcp/`, `settings/` and `assets/` have no frontmatter to write in**, so the
133
+ manifest names them by path. A pattern that names a directory takes everything
134
+ under it, and `*`, `**` and `?` work as you would expect:
135
+
136
+ ```yaml
137
+ flavors:
138
+ python:
139
+ description: Python typing, linting and test tooling
140
+ includes:
141
+ - rules/python.md
142
+ - mcp/pyright.json
143
+ - assets/python # …and every file inside it
144
+ - skills/pytest-*
145
+ csharp:
146
+ description: C# analyzers and conventions
147
+ includes: [rules/csharp.md]
148
+ ```
149
+
150
+ Both ways feed one list, so use whichever suits each resource. Three shapes are
151
+ accepted: a bare list of names (`flavors: [python, csharp]`), a mapping of name
152
+ to description, and the mapping-of-mappings above.
153
+
154
+ **Declaring them in the manifest is optional but worth it.** Leave `flavors:` out
155
+ entirely and the flavors are whatever your resources named for themselves — which
156
+ is the shortest thing that works for an all-markdown kit. Put them in the
157
+ manifest and you get three things: a description for `hcm registry list` and
158
+ `hcm info`, somewhere to write path patterns, and `hcm validate` checking your
159
+ work:
160
+
161
+ ```
162
+ $ hcm validate ./coding-kit
163
+ coding-kit v1.0.0
164
+ 12 resource(s)
165
+ ! subagents/rust-clippy.md: flavor "rust" is not declared in the manifest (it declares: python, csharp)
166
+ ! Flavor "python": "rules/pythn.md" matches nothing in the bundle
167
+ ! Flavor "csharp" has no resources; "--flavor csharp" would install the common part and nothing else
168
+ ```
169
+
170
+ That first one is the mistake worth catching. A misspelled tag in a resource's
171
+ frontmatter silently excludes it from the flavor its author meant, and the
172
+ symptom — a bundle that installs slightly less than it should — is one nobody
173
+ looks for.
174
+
175
+ **Check the split with `hcm info`** before you publish. It lists every flavor,
176
+ what belongs to it, and how many resources are common:
177
+
178
+ ```bash
179
+ hcm info ./coding-kit --flavor python
180
+ ```
181
+
182
+ Two things to keep in mind while dividing a kit up:
183
+
184
+ - **`all` is not available as a flavor name.** Users type `--flavor all` to widen
185
+ a narrowed installation back to the whole bundle.
186
+ - **A flavor is not a substitute for a separate bundle.** Users install and
187
+ uninstall at bundle granularity, and dependencies, versions and updates are all
188
+ per-bundle. Reach for a flavor when the pieces genuinely share a common half
189
+ and a version number; reach for a
190
+ [collection](#shipping-several-bundles-together) when they do not.
191
+
192
+ ## Parameters: finishing the kit at install time
193
+
194
+ Some of what a bundle says is different in every project it lands in — the
195
+ agent's name, the team that owns the code, the ticket prefix. Hard-coding those
196
+ means one bundle per project; leaving them out means vague instructions. A
197
+ *parameter* is the third option: you name the hole, and the install fills it.
198
+
199
+ ```yaml
200
+ # hcm.yaml
201
+ parameters:
202
+ AGENT_NAME:
203
+ description: What the agent should call itself
204
+ default: Claude
205
+ TEAM:
206
+ description: The team that owns this project
207
+ ```
208
+
209
+ ```markdown
210
+ <!-- context/10-identity.md -->
211
+ You are a coding agent called <%AGENT_NAME%>, working for the <%TEAM%> team.
212
+ ```
213
+
214
+ ```bash
215
+ hcm install ./my-kit --param TEAM=Platform --param AGENT_NAME=Ada
216
+ ```
217
+
218
+ and the installed `CLAUDE.md` reads *You are a coding agent called Ada, working
219
+ for the Platform team.*
220
+
221
+ ### Where placeholders work
222
+
223
+ `<%NAME%>` is filled in everywhere the text of an installed item can hold one:
224
+
225
+ - markdown bodies, and the frontmatter above them
226
+ - context sections, as they go into `CLAUDE.md` / `AGENTS.md` / friends
227
+ - a skill's `SKILL.md` **and** the supporting files beside it
228
+ - the string values inside `mcp/*.json` and `settings/settings.json`
229
+ - assets, when they are text — a shell script yes, a PNG no
230
+
231
+ It is **never** applied to a path. Where a file lands is a fact about your
232
+ bundle's layout, not about one install, so a `name:` in frontmatter holding a
233
+ placeholder is a mistake `hcm validate` reports rather than a filename it
234
+ invents.
235
+
236
+ Spaces inside the delimiters are fine (`<% NAME %>`). Anything that is not
237
+ simply a name between them is left alone, so a file carrying another template
238
+ language's `<% if user.admin %>` survives untouched. To write a literal
239
+ placeholder — documenting this feature, say — double the first `%`:
240
+ `<%%NAME%>` installs as `<%NAME%>`.
241
+
242
+ ### Declaring one
243
+
244
+ Three spellings, exactly as `flavors:` has:
245
+
246
+ ```yaml
247
+ parameters: [AGENT_NAME, TEAM] # names alone, each one required
248
+
249
+ parameters:
250
+ AGENT_NAME: What it calls itself # name with a description
251
+
252
+ parameters:
253
+ AGENT_NAME: # name with the full shape
254
+ description: What it calls itself
255
+ default: Claude # also the prompt's suggestion
256
+ required: false # defaults to true when there is no default
257
+ choices: [Claude, Codey] # turns the prompt into a menu
258
+ pattern: '^[A-Za-z ]+$' # a regular expression the value must match
259
+ secret: false # true: used, but never recorded
260
+ flavors: [python] # only asked for with --flavor python
261
+ targets: [claude-code] # only asked for in that harness
262
+ ```
263
+
264
+ A parameter with a `default` is not one an install has to be told, so the
265
+ shortest useful bundle asks nothing at all and still customises cleanly.
266
+
267
+ ### Global, per-flavor and per-harness
268
+
269
+ Naming neither `flavors` nor `targets` makes a parameter **global**: every
270
+ install answers it. Naming either narrows *what is asked for*:
271
+
272
+ | Declaration | Asked for |
273
+ | --- | --- |
274
+ | neither | always |
275
+ | `flavors: [python]` | when `--flavor python` is installed (or no `--flavor` at all) |
276
+ | `targets: [claude-code]` | when installing into Claude Code |
277
+
278
+ Narrowing changes what is **asked**, not what is **substituted**. A parameter
279
+ scoped to Claude Code still has a default, and a file every harness gets that
280
+ mentions it reads as that default in the others. Only a narrowed parameter with
281
+ *no default* leaves a real hole elsewhere — and `hcm validate` reports exactly
282
+ that case, so you find out before your users do.
283
+
284
+ A harness-scoped parameter is also asked once per harness rather than once per
285
+ bundle, which is how one name takes a different value in each:
286
+
287
+ ```bash
288
+ hcm install my-kit -t claude-code copilot \
289
+ --param my-kit@claude-code:AGENT_NAME=Ada \
290
+ --param my-kit@copilot:AGENT_NAME=Cop
291
+ ```
292
+
293
+ ### Secrets
294
+
295
+ `secret: true` means the value is used but never written to the installation
296
+ ledger — which for project scope is `.hcm/state.json`, a file people commit.
297
+ The trade is that `hcm update` cannot reuse it, so it has to be supplied again:
298
+
299
+ ```bash
300
+ hcm update my-kit --param API_TOKEN="$TOKEN"
301
+ ```
302
+
303
+ ### What your users will do
304
+
305
+ Every parameter can be answered four ways, so a bundle that asks for things is
306
+ still installable from a script:
307
+
308
+ ```bash
309
+ hcm install my-kit --param TEAM=Platform # a flag
310
+ hcm install my-kit --params-file team.yaml # a file, committable
311
+ HCM_PARAM_TEAM=Platform hcm install my-kit # the environment, for CI
312
+ hcm install my-kit # answering when asked
313
+ ```
314
+
315
+ With no terminal and no value supplied, a required parameter stops the run
316
+ rather than installing something half-written. `hcm install --no-prompt` asks
317
+ for that behaviour deliberately.
318
+
319
+ Nobody has to work out what belongs in that file by reading your manifest —
320
+ `hcm params init <bundle>` writes it, one commented entry per parameter, with
321
+ every value it can already work out filled in and the rest left blank:
322
+
323
+ ```bash
324
+ hcm params init my-kit # writes params.yaml
325
+ $EDITOR params.yaml # fill in the blanks
326
+ hcm install my-kit --params-file params.yaml
327
+ ```
328
+
329
+ Two things follow for you as an author. A `description` is not decoration — it
330
+ is the comment above the blank, and it is the only place a user finds out what
331
+ the value is *for*. And a parameter with no `default` is the one that shows up
332
+ as `# REQUIRED — no default`, so give a default to everything that can sensibly
333
+ have one and leave it off only where a wrong guess would be worse than a stop.
334
+
335
+ The values are recorded with the installation, so `hcm update` renders the new
336
+ version with the same ones without being told again — an update that quietly
337
+ renamed the agent would be worse than no update at all. `hcm params` shows what
338
+ each installation holds.
339
+
340
+ ### Keeping them honest
341
+
342
+ `hcm validate` reports the four mistakes that would otherwise ship:
343
+
344
+ - a `<%PLACEHOLDER%>` naming a parameter you never declared
345
+ - a parameter declared and never used
346
+ - a narrowed parameter with no default, used where it is not asked for
347
+ - a placeholder in a `name:`, which decides a filename and is never substituted
348
+
349
+ ## Writing each resource kind
350
+
351
+ ### Subagents — `subagents/<name>.md`
352
+
353
+ ```markdown
354
+ ---
355
+ description: Reviews changed code for correctness and security. Use before opening a PR.
356
+ tools: [Read, Grep, Glob, Bash]
357
+ model: sonnet
358
+ ---
359
+
360
+ You are a meticulous code reviewer...
361
+ ```
362
+
363
+ The filename is the subagent name unless frontmatter sets `name`. Write `tools` as a
364
+ YAML list; `hcm` converts it to the comma-separated string Claude Code expects,
365
+ leaves it a list for Copilot, and renames it `allowed-tools` for Reasonix. The
366
+ body becomes the system prompt.
367
+
368
+ The `description` is what the harness uses to decide when to delegate, so write
369
+ it as *when to use this*, not *what this is*.
370
+
371
+ Reasonix has no separate agents directory: a subagent profile is a skill carrying
372
+ `runAs: subagent` and `invocation: manual`, so it installs to
373
+ `.reasonix/skills/<name>/SKILL.md`. Subagents and skills therefore share one
374
+ namespace there — don't give a subagent the same name as a skill in the same
375
+ bundle, and `hcm validate` will tell you if you have. Two further Reasonix-only
376
+ frontmatter keys are passed through when present: `effort` and `readOnly`
377
+ (rendered as `read-only`, which strips writer tools).
378
+
379
+ OpenCode files subagents at `.opencode/agents/<name>.md` with `mode: subagent`,
380
+ and passes `model`, `temperature` and `color` through. It does *not* take a tool
381
+ allowlist: access there is a `permission` object keyed by OpenCode's own
382
+ categories (`edit`, `bash`, `read`, …), which a list of tool names cannot be
383
+ translated into, so `tools` is dropped for that target.
384
+
385
+ Pi has no agents directory either, and no delegation at all — that is extension
386
+ territory there. A subagent installs as a skill, `.pi/skills/<name>/SKILL.md`,
387
+ invoked as `/skill:<name>`. Pi follows the Agent Skills standard, whose
388
+ frontmatter is just `name` and `description`, so `tools` and `model` have
389
+ nowhere to go and are dropped; and without delegation the prompt runs in the
390
+ main context rather than its own. As on Reasonix, subagents and skills share one
391
+ namespace — `hcm validate` flags a name used by both.
392
+
393
+ Users who have installed [`pi-subagents`](https://github.com/nicobailon/pi-subagents)
394
+ get the better mapping by passing `hcm install --pi-subagents`: the subagent is
395
+ written to `.pi/agents/<name>.md`, which is the directory that extension scans,
396
+ and `tools` and `model` survive because it has fields for them. Nothing in the
397
+ bundle changes — this is a fact about the user's machine, not about your kit —
398
+ so write `tools` and `model` as you would for any other target and let the
399
+ people who have the extension benefit from them.
400
+
401
+ One thing to know if you ship a `tools` allowlist: `hcm` translates the *shape*
402
+ of frontmatter between harnesses, never the tool names themselves, and the
403
+ names differ. `pi-subagents` documents `tools` as a **strict** allowlist over
404
+ its own vocabulary (`read, grep, bash`, plus `mcp:<server>` entries), so a list
405
+ written as Claude Code's `[Read, Grep]` will not match anything there. Either
406
+ leave `tools` off — the extension's default is unrestricted — or accept that the
407
+ allowlist is meaningful on one harness at a time.
408
+
409
+ ### Skills — `skills/<name>/SKILL.md` plus supporting files
410
+
411
+ ```
412
+ skills/dependency-audit/
413
+ ├── SKILL.md
414
+ └── checklist.md
415
+ ```
416
+
417
+ Every file in the directory is copied. `SKILL.md` is re-rendered so its
418
+ frontmatter matches the target; supporting files are copied byte-for-byte.
419
+ Reference them by relative path from `SKILL.md` — see
420
+ [Referring to other files](#referring-to-other-files), which is also how to
421
+ point at anything outside the skill's own directory.
422
+
423
+ ### Commands — `commands/<name>.md`
424
+
425
+ ```markdown
426
+ ---
427
+ description: Review the current branch against a base branch
428
+ argumentHint: "[base-branch]"
429
+ allowedTools: [Read, Grep, Bash]
430
+ ---
431
+
432
+ Review this branch against `$ARGUMENTS`...
433
+ ```
434
+
435
+ Becomes a slash command in Claude Code, Reasonix and OpenCode, a `.prompt.md`
436
+ file for Copilot, and a prompt template in `.pi/prompts/` for Pi. `argumentHint`
437
+ survives everywhere that has a field for it; OpenCode has none, so it is dropped
438
+ there.
439
+
440
+ ### Rules — `rules/<name>.md`
441
+
442
+ ```markdown
443
+ ---
444
+ description: TypeScript conventions
445
+ appliesTo:
446
+ - "**/*.ts"
447
+ - "**/*.tsx"
448
+ ---
449
+
450
+ - Prefer named exports.
451
+ ```
452
+
453
+ `appliesTo` is the canonical field. It becomes `paths:` for Claude Code and
454
+ `applyTo: '**/*.ts, **/*.tsx'` for Copilot. Omit it and the rule loads at session
455
+ start everywhere (Copilot gets `applyTo: '**'`).
456
+
457
+ Reasonix and Pi are the exceptions: their standing instructions are the
458
+ `REASONIX.md` / `AGENTS.md` hierarchy, scoped by directory rather than by glob,
459
+ so a rule is appended to that file as a marker block with its globs stated in
460
+ prose:
461
+
462
+ ```markdown
463
+ <!-- hcm:begin my-kit/rules/typescript -->
464
+ **Applies to:** `**/*.ts`, `**/*.tsx`
465
+
466
+ - Prefer named exports.
467
+ <!-- hcm:end my-kit/rules/typescript -->
468
+ ```
469
+
470
+ That means a Reasonix or Pi rule costs context in every session, the way
471
+ `context/` does. Keep rules short, or prefer `context/` when the instruction is
472
+ universal anyway.
473
+
474
+ OpenCode sits between the two. It has no glob-scoped rule format either, but it
475
+ does load extra instruction files named in `instructions`, so the rule keeps its
476
+ own file — `.opencode/rules/<name>.md`, with the same prose header — and one
477
+ entry is *appended* to that array in `opencode.json`. Appending rather than
478
+ replacing is what lets several bundles list rules in the same config and each
479
+ take back only its own on uninstall. The file is still loaded in full every
480
+ session, so the same brevity advice applies.
481
+
482
+ ### Context — `context/<name>.md`
483
+
484
+ Always-loaded instructions. These are merged into the harness's top-level
485
+ instruction file (`CLAUDE.md`, `.github/copilot-instructions.md`, `REASONIX.md`,
486
+ or `AGENTS.md` for OpenCode and Pi) inside a marker block:
487
+
488
+ ```markdown
489
+ <!-- hcm:begin my-kit/10-conventions -->
490
+ ## Review conventions
491
+ ...
492
+ <!-- hcm:end my-kit/10-conventions -->
493
+ ```
494
+
495
+ Start the body at heading level 2 — it is being pasted into someone else's
496
+ document. Keep it short; this text costs context in every single session.
497
+
498
+ **One section per file.** Every file in `context/` becomes its own block, and
499
+ the blocks are concatenated in filename order — so number them when the order
500
+ matters:
501
+
502
+ ```
503
+ context/
504
+ ├── 10-conventions.md
505
+ ├── 20-pull-requests.md
506
+ └── 30-glossary.md
507
+ ```
508
+
509
+ Splitting is not cosmetic. This is the one file the harness's own agent writes
510
+ back to, and when it rewrites `CLAUDE.md` your instructions can go with it.
511
+ `hcm` keeps a copy of each section under the project's `.hcm/context/` and
512
+ restores them a section at a time:
513
+
514
+ ```bash
515
+ hcm context # is everything still in place?
516
+ hcm context append # put back what is missing, leaving the rest alone
517
+ ```
518
+
519
+ Small sections survive that far better than one long one: a rewrite that keeps
520
+ half your text leaves `append` able to tell what is missing from what is not.
521
+ See [Context in the README](../README.md#context-sections-that-survive-being-overwritten)
522
+ for `override` and `remove`.
523
+
524
+ The block id is `<bundle>/<section>`, so renaming a context file after people
525
+ have installed the bundle orphans the old block until they run `hcm update`.
526
+
527
+ ### MCP servers — `mcp/<name>.json`
528
+
529
+ One file per server. The filename is the server name.
530
+
531
+ ```json
532
+ {
533
+ "command": "npx",
534
+ "args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
535
+ }
536
+ ```
537
+
538
+ Recognised keys: `command`, `args`, `env`, `type`, `url`, `headers`,
539
+ `startupTimeoutSeconds`, `callTimeoutSeconds`, `toolTimeoutSeconds`. Timeout keys
540
+ may also be written in the snake_case form the Reasonix spec uses
541
+ (`startup_timeout_seconds`).
542
+
543
+ A remote server needs a `url`; the transport is inferred as `http` when you do
544
+ not state a `type`, so this is enough:
545
+
546
+ ```json
547
+ {
548
+ "url": "https://mcp.stripe.com",
549
+ "headers": { "Authorization": "Bearer ${STRIPE_KEY}" }
550
+ }
551
+ ```
552
+
553
+ Each target gets the form it expects:
554
+
555
+ | Canonical | Claude Code `.mcp.json` | Copilot `.vscode/mcp.json` | Reasonix `reasonix.toml` | OpenCode `opencode.json` |
556
+ | --- | --- | --- | --- | --- |
557
+ | `command`, `args` | as written | as written | as written | merged into one `command` argv array |
558
+ | `env` | as written | as written | as written | `environment` |
559
+ | `url`, `headers` | as written | as written | as written | as written |
560
+ | *(transport)* | inferred by the harness | `type` added (`stdio`/`http`) | `type` added unless stdio, which is the documented default | `type` added (`local`/`remote`) |
561
+ | `startupTimeoutSeconds` | as written | as written | `startup_timeout_seconds` | — |
562
+ | `callTimeoutSeconds` | as written | as written | `call_timeout_seconds` | — |
563
+ | `toolTimeoutSeconds` | as written | as written | `tool_timeout_seconds` | — |
564
+
565
+ OpenCode names its transports `local` and `remote` rather than `stdio` and
566
+ `http`, and takes the command as a single argv array, so
567
+ `{"command": "npx", "args": ["-y", "server"]}` is written out as
568
+ `{"type": "local", "command": ["npx", "-y", "server"]}`. Its own `cwd`,
569
+ `enabled` and `timeout` keys pass through when you set them.
570
+
571
+ Pi has no built-in MCP client of its own — servers there come from extensions —
572
+ but those extensions read the same `.mcp.json`, in the same `mcpServers` shape,
573
+ that Claude Code uses. So the definition is written there unchanged and sits
574
+ inert until you install one. At user scope it lands in Pi's own config
575
+ directory, `~/.pi/agent/.mcp.json`, alongside its other resources.
576
+
577
+ `hcm targets` prints the kinds each harness accepts; today that is all eight
578
+ everywhere, so a bundle installs in full wherever you send it.
579
+
580
+ That does mean Claude Code and Pi share `.mcp.json` at project scope, which needs
581
+ no special handling: whichever target you install second finds the server
582
+ already there and identical, adopts it rather than claiming it, and leaves it
583
+ alone on uninstall. Installing a bundle into both targets and removing it from
584
+ one keeps the other working.
585
+
586
+ `${VAR}` references are passed through untouched — every one of these harnesses
587
+ expands them itself, so keep secrets in the environment rather than the bundle.
588
+
589
+ Never commit secrets. Reference an environment variable instead:
590
+
591
+ ```json
592
+ { "command": "my-server", "env": { "API_KEY": "${MY_API_KEY}" } }
593
+ ```
594
+
595
+ ### Settings — `settings/settings.json`
596
+
597
+ A fragment deep-merged into the harness's settings file.
598
+
599
+ ```json
600
+ {
601
+ "permissions": {
602
+ "allow": ["Bash(git diff:*)", "Bash(npm test:*)"]
603
+ }
604
+ }
605
+ ```
606
+
607
+ Each **leaf** becomes its own receipt, so two bundles can own different keys in
608
+ the same file and uninstall independently. Arrays are *appended to*, not
609
+ replaced, and de-duplicated — which is what permission lists need. Scalars are
610
+ *set*; one already present with a different value is a conflict the user is
611
+ asked about, key by key.
612
+
613
+ Keep fragments minimal. Every key you set is a key the user cannot change
614
+ without `hcm status` reporting drift.
615
+
616
+ ### Assets — `assets/**`
617
+
618
+ Copied verbatim into the harness directory. Use for scripts, templates and images
619
+ that your subagents or skills reference.
620
+
621
+ ## Referring to other files
622
+
623
+ Write paths **from the bundle root**, the way the bundle is laid out:
624
+
625
+ ```markdown
626
+ Follow the checklist at `skills/dependency-audit/checklist.md`.
627
+ See [the reviewer](subagents/code-reviewer.md) for the tone to use.
628
+ Run `assets/scripts/audit.sh` first.
629
+ ```
630
+
631
+ Do not write where the file will end up. `hcm` works that out per target and
632
+ rewrites the reference as it installs, because there is no single answer:
633
+ `subagents/code-reviewer.md` becomes `.claude/agents/code-reviewer.md` on Claude
634
+ Code, `.github/agents/code-reviewer.agent.md` on Copilot, and
635
+ `.reasonix/skills/code-reviewer/SKILL.md` on Reasonix — where a subagent is a
636
+ skill. A `context/` file becomes a *section of* `CLAUDE.md`, `AGENTS.md` or
637
+ `REASONIX.md`, and references to it are pointed at that file.
638
+
639
+ What is written on the way out is always relative to the file doing the
640
+ referring, so a file lands next to the neighbours it talks about:
641
+
642
+ ```
643
+ .claude/skills/audit/SKILL.md → checklist.md (same directory)
644
+ .claude/commands/review.md → ../skills/audit/checklist.md
645
+ .claude/skills/audit/SKILL.md → ../../agents/code-reviewer.md
646
+ ```
647
+
648
+ A file that lands beside the one referring to it therefore keeps its plain name,
649
+ and a skill's own supporting files read exactly as they always have:
650
+
651
+ ```markdown
652
+ Work through `checklist.md`, then report what you found.
653
+ ```
654
+
655
+ Both forms resolve going in, bundle root first. This works in markdown links,
656
+ images, link definitions, inline code and `@paths`, and on whole string values in
657
+ `mcp/` and `settings/` — `"args": ["assets/scripts/audit.sh"]` is repointed too,
658
+ though a path a *harness* resolves rather than an agent is worth checking with
659
+ `hcm info` first; see the note in the [README](../README.md#references-written-once-repointed-on-the-way-in).
660
+
661
+ What is *not* rewritten: URLs, anchors, absolute paths, `${VAR}` paths, paths
662
+ into the user's own project (`src/index.ts`), anything inside a fenced code
663
+ block, and `[[wikilinks]]` — a wikilink is a name rather than a path, it
664
+ survives the move on its own, and turning one into a relative path would break
665
+ it. A reference naming a file this target does not install is left as written
666
+ and reported — worth reading, because it is an instruction the agent will follow.
667
+
668
+ Check the ones that point at nothing before you publish:
669
+
670
+ ```bash
671
+ hcm refs check --path . # report
672
+ hcm refs fix --path . # repair, by picking from a ranked list
673
+ ```
674
+
675
+ `check` reads what you **wrote as a reference**: markdown links, images, link
676
+ definitions, `[[wikilinks]]`, `@paths`, and any path carrying an explicit `./`
677
+ or `../`. A bare filename in a sentence is prose and is left alone —
678
+
679
+ ```markdown
680
+ A file will be created named `report.txt`.
681
+ ```
682
+
683
+ — which is why a reference to one of the bundle's own files is worth writing
684
+ `./like-this.md`, even where the bare form would resolve. Two flags move the
685
+ line: `--links` narrows to links and wikilinks only, and `--all-paths` (or
686
+ `--strict`, which is louder still) widens to every path-shaped thing in the
687
+ bundle, prose included.
688
+
689
+ `hcm info <bundle>` prints the rewrites per target, so you can see what each
690
+ harness will actually read.
691
+
692
+ ## Sharing a bundle
693
+
694
+ ```bash
695
+ git init && git add . && git commit -m "Add my-kit"
696
+ git remote add origin git@github.com:acme/my-kit.git && git push -u origin main
697
+ ```
698
+
699
+ Then anywhere else — paste whatever GitHub gave you, whether that's the short
700
+ form, the browser address bar, or the clone box:
701
+
702
+ ```bash
703
+ hcm registry add acme/my-kit
704
+ hcm registry add https://github.com/acme/my-kit
705
+ hcm registry add git@github.com:acme/my-kit.git
706
+ hcm install my-kit
707
+ ```
708
+
709
+ A monorepo of bundles works too — point at the subdirectory. Linking straight at
710
+ a bundle's `hcm.yaml` in the GitHub file viewer works as well; `hcm` takes the
711
+ directory containing it:
712
+
713
+ ```bash
714
+ hcm registry add acme/agent-kits/bundles/my-kit#v1.2.0
715
+ hcm registry add https://github.com/acme/agent-kits/tree/v1.2.0/bundles/my-kit
716
+ hcm registry add https://github.com/acme/agent-kits/blob/v1.2.0/bundles/my-kit/hcm.yaml
717
+ ```
718
+
719
+ Pin a tag for anything a team depends on; `#ref` accepts branches, tags and SHAs.
720
+ If your branch name contains a slash, use the shorthand form
721
+ (`acme/agent-kits/bundles/my-kit#feature/login`) — a `/tree/` URL can't express
722
+ that unambiguously.
723
+
724
+ ## Shipping several bundles together
725
+
726
+ Put each bundle in its own folder at the same level and the parent becomes a
727
+ *collection*:
728
+
729
+ ```
730
+ agent-kits/
731
+ ├── README.md
732
+ ├── review-kit/
733
+ │ ├── hcm.yaml
734
+ │ └── subagents/code-reviewer.md
735
+ └── db-kit/
736
+ ├── hcm.yaml
737
+ └── mcp/postgres.json
738
+ ```
739
+
740
+ ```bash
741
+ hcm registry add acme/agent-kits # registers review-kit and db-kit
742
+ hcm install acme/agent-kits # installs both
743
+ hcm install acme/agent-kits/db-kit # or just one
744
+ ```
745
+
746
+ Bundle names must be unique within a collection, since each is registered and
747
+ installed under its own name. Files in the collection root that are not bundle
748
+ directories — a README, a LICENSE, CI config — are ignored.
749
+
750
+ Prefer a collection over one giant bundle when the pieces are independently
751
+ useful: users install and uninstall at bundle granularity, so splitting lets
752
+ them take the review kit without the database tooling.
753
+
754
+ ## Testing a bundle before publishing
755
+
756
+ ```bash
757
+ hcm info my-kit # every planned write, per target
758
+ hcm install my-kit --dry-run # includes conflict detection
759
+ mkdir /tmp/probe && cd /tmp/probe
760
+ hcm install /path/to/my-kit && hcm status && hcm uninstall my-kit
761
+ ```
762
+
763
+ A clean install/uninstall round-trip in an empty directory should leave nothing
764
+ behind. If it does not, that is a bug worth reporting.
765
+
766
+ Reinstalling a `--dev` bundle over itself is fine: items you installed and
767
+ nobody has touched are replaced without `--force`, and an item somebody
768
+ hand-edited stops to ask rather than being overwritten. To check what your users
769
+ will get when you ship a change, use `hcm update my-kit --dry-run` — that shows
770
+ the removals as well as the writes, which is where a renamed or deleted resource
771
+ shows up.
772
+
773
+ Worth testing deliberately: overwrite `CLAUDE.md` with something else entirely,
774
+ then run `hcm context list` and `hcm context append`. That is the state a user's
775
+ project reaches on its own, and it will tell you whether your sections are
776
+ divided the way you think they are.
777
+
778
+ Also worth testing: install into a directory that already has a
779
+ `.mcp.json` containing one of your servers. If the definitions match, the
780
+ install reports the server as adopted and leaves the file untouched; if they
781
+ differ, you are asked what to do. Seeing both tells you how your bundle lands in
782
+ a project that is not empty.
783
+
784
+ If your bundle has dependencies, install it into an empty directory and then
785
+ uninstall it: everything it pulled in should go too, and the directory should be
786
+ as it started. Then install the dependency by name first and repeat — this time
787
+ it should stay, because you asked for it yourself.
788
+
789
+ If it has flavors, install each one into its own empty directory and read the
790
+ file list. What you are checking is not that the flavor's own files arrived — it
791
+ is that the *common* half is complete without them: a command that references a
792
+ skill you tagged `python` is a broken reference for everyone who installed
793
+ `--flavor csharp`, and `hcm install` reports exactly that:
794
+
795
+ ```
796
+ ! .claude/commands/review-pr.md: "skills/pytest-runner/SKILL.md" the file it names is not installed into this harness
797
+ ```
798
+
799
+ ## Conventions that avoid conflicts
800
+
801
+ Bundles collide when two of them want the same item and want it to say something
802
+ *different*. Wanting the same item identically is not a collision: hcm writes it
803
+ once, records a claim for each bundle, and removes it when the last of them is
804
+ uninstalled. So two kits can both ship `skills/jira-board/` — as long as the
805
+ files really are identical, which in practice means one of them depends on the
806
+ other and copies it, or both are generated from the same place.
807
+
808
+ Cheap habits that prevent the collisions that remain:
809
+
810
+ - **Namespace MCP server filenames** when wrapping a common service:
811
+ `mcp/acme-postgres.json`, not `mcp/postgres.json`.
812
+ - **Prefix subagent and command names** with something recognisable if the bundle
813
+ is for a specific team or product.
814
+ - **Prefer `context/` over `settings/`** for anything advisory. Instruction text
815
+ merges additively; settings keys are exclusive.
816
+ - **Keep one concern per bundle.** Users install and uninstall at bundle
817
+ granularity, so a bundle bundling unrelated things forces all-or-nothing.
818
+ Where two kits share a concern, a `dependencies:` entry beats a copy — the
819
+ shared part is then installed once, kept up to date in one place, and removed
820
+ when the last kit that needed it goes.
821
+ - **Refer to your MCP servers by name, plainly.** When a user hits a name clash
822
+ they can install your server under a different name, and `hcm` rewrites the
823
+ mentions in the rest of your bundle to match. That works on `mcp__<name>__tool`
824
+ prefixes and on the bare name; it cannot follow a name you assembled at
825
+ runtime or split across a line break.
826
+
827
+ A conflict is never resolved silently: `hcm install` asks, naming the owning
828
+ bundle where there is one, and writes nothing until you answer.