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,515 @@
1
+ /**
2
+ * Core domain types.
3
+ *
4
+ * The one genuinely tricky requirement: uninstalling must remove exactly the
5
+ * items a bundle contributed, even when several bundles wrote into the same
6
+ * file (`.mcp.json`, `settings.json`, `reasonix.toml`, `CLAUDE.md`) and the
7
+ * file has been reordered or reformatted since.
8
+ *
9
+ * So we never record line numbers or diffs. Each write leaves a `Receipt`
10
+ * expressed in terms the format itself understands:
11
+ * JSON -> structural pointer + hash of the value we wrote
12
+ * TOML/MD -> comment-delimited marker block
13
+ * files -> path + content hash
14
+ */
15
+ export type TargetId = 'claude-code' | 'copilot' | 'reasonix' | 'opencode' | 'pi';
16
+ export type Scope = 'project' | 'user';
17
+ /** Harness-neutral resource kinds. Each target decides where they land. */
18
+ export type ResourceKind = 'subagent' | 'skill' | 'command' | 'rule' | 'context' | 'mcp' | 'settings' | 'asset';
19
+ /**
20
+ * Facts about the machine being installed into that change how a target maps
21
+ * resources -- not preferences, but what is actually there to install onto.
22
+ *
23
+ * These are recorded with the installation, so `hcm update` reinstalls into the
24
+ * same places without being told again.
25
+ */
26
+ export interface TargetOptions {
27
+ /**
28
+ * The `pi-subagents` extension is installed, so Pi has real sub-agents and a
29
+ * directory to file them in (`.pi/agents/`) instead of only skills.
30
+ * https://github.com/nicobailon/pi-subagents
31
+ */
32
+ piSubagents?: boolean;
33
+ }
34
+ /** Bundle directory name -> canonical kind. This is the whole bundle schema. */
35
+ export declare const KIND_DIRECTORIES: Record<string, ResourceKind>;
36
+ /**
37
+ * One entry of a manifest's `dependencies`.
38
+ *
39
+ * A bundle that describes how to work with the team's JIRA board is worth
40
+ * writing once and requiring from the half-dozen bundles that assume it. The
41
+ * dependency names the bundle; `version` says which releases will do; `source`
42
+ * says where to get it when the machine has never heard of it.
43
+ *
44
+ * Authored either as a string (`jira-board`, `jira-board@^1.2.0`) or as a
45
+ * mapping; `normalizeDependencies` turns both into this shape.
46
+ */
47
+ export interface BundleDependency {
48
+ name: string;
49
+ /** Semver range; absent means any version will do. See `core/semver.ts`. */
50
+ version?: string;
51
+ /**
52
+ * Where to fetch it from when it is not registered and not a sibling in the
53
+ * same collection -- any reference `hcm install` accepts.
54
+ */
55
+ source?: string;
56
+ }
57
+ /**
58
+ * A flavor as it is written down for people: a name, and what it is for.
59
+ *
60
+ * This much is stored in the registry, so `hcm registry list` can say what a
61
+ * bundle can be narrowed to without reading the bundle's files.
62
+ */
63
+ export interface FlavorSummary {
64
+ name: string;
65
+ description?: string;
66
+ }
67
+ /**
68
+ * A flavor as the installer uses it: the summary, plus the bundle-relative path
69
+ * patterns whose resources belong to it.
70
+ *
71
+ * `includes` is how `mcp/`, `settings/` and `assets/` join a flavor -- they have
72
+ * no frontmatter to write `flavors:` in. Empty when every member declares
73
+ * itself.
74
+ */
75
+ export interface FlavorDefinition extends FlavorSummary {
76
+ includes: string[];
77
+ }
78
+ /**
79
+ * How `flavors:` may be written in a manifest -- names alone, names with a
80
+ * description, or names with patterns. `normalizeFlavors` turns all three into
81
+ * `FlavorDefinition[]`.
82
+ */
83
+ export type FlavorDeclaration = string[] | Record<string, string | null | {
84
+ description?: string;
85
+ includes?: string | string[];
86
+ }>;
87
+ /**
88
+ * One value a bundle is customised with when it is installed.
89
+ *
90
+ * The name is what `<%AGENT_NAME%>` in the bundle's files refers to; everything
91
+ * else says how the value is arrived at and where it applies. See
92
+ * `core/parameters.ts`.
93
+ */
94
+ export interface ParameterDefinition {
95
+ /** `AGENT_NAME` -- the spelling used inside `<% %>`. */
96
+ name: string;
97
+ description?: string;
98
+ /** Used when nothing else supplies a value; also the prompt's suggestion. */
99
+ default?: string;
100
+ /** Must end up with a value. Defaults to true when there is no `default`. */
101
+ required: boolean;
102
+ /** Only these values are accepted, and the prompt becomes a menu. */
103
+ choices?: string[];
104
+ /** A regular expression the value has to match, as written in the manifest. */
105
+ pattern?: string;
106
+ /**
107
+ * Never written to the installation ledger. `hcm update` therefore has to be
108
+ * given it again -- which is the trade for not keeping a token in a file that
109
+ * gets committed.
110
+ */
111
+ secret?: boolean;
112
+ /**
113
+ * Applies only when one of these flavors is being installed. Empty means it
114
+ * applies to every install -- a *global* parameter. See `core/flavors.ts`.
115
+ */
116
+ flavors: string[];
117
+ /** Applies only to these harnesses. Empty means all of them. */
118
+ targets: TargetId[];
119
+ }
120
+ /**
121
+ * How `parameters:` may be written in a manifest -- names alone, names with a
122
+ * description, or names with the full shape. `normalizeParameters` turns all
123
+ * three into `ParameterDefinition[]`.
124
+ */
125
+ export type ParameterDeclaration = string[] | Record<string, string | null | {
126
+ description?: string;
127
+ default?: string | number | boolean | null;
128
+ required?: boolean;
129
+ choices?: string[];
130
+ pattern?: string;
131
+ secret?: boolean;
132
+ flavors?: string | string[];
133
+ flavor?: string | string[];
134
+ targets?: string | string[];
135
+ target?: string | string[];
136
+ }>;
137
+ /**
138
+ * A parameter as the registry records it: enough to say what a bundle will ask
139
+ * for without reading the bundle's files.
140
+ */
141
+ export interface ParameterSummary {
142
+ name: string;
143
+ description?: string;
144
+ default?: string;
145
+ required?: boolean;
146
+ secret?: boolean;
147
+ flavors?: string[];
148
+ targets?: TargetId[];
149
+ }
150
+ /** Resolved parameter values, by name. */
151
+ export type ParameterValues = Record<string, string>;
152
+ export interface BundleManifest {
153
+ name: string;
154
+ version: string;
155
+ description?: string;
156
+ author?: string;
157
+ homepage?: string;
158
+ tags?: string[];
159
+ /** Targets this bundle supports. Defaults to all. */
160
+ targets?: TargetId[];
161
+ /** Bundles that have to be installed for this one to work. */
162
+ dependencies?: (string | BundleDependency)[];
163
+ /** Subsets this bundle can be installed as. See `core/flavors.ts`. */
164
+ flavors?: FlavorDeclaration;
165
+ /** Values asked for at install time. See `core/parameters.ts`. */
166
+ parameters?: ParameterDeclaration;
167
+ }
168
+ export interface BundleResource {
169
+ kind: ResourceKind;
170
+ /** Logical name, e.g. `code-reviewer`. */
171
+ name: string;
172
+ /** Path relative to the bundle root, POSIX separators. */
173
+ bundlePath: string;
174
+ /** Absolute path to the primary file (the .md, the .json, the SKILL.md). */
175
+ primaryFile: string;
176
+ /** For skills/assets: every file, with paths relative to the resource root. */
177
+ files: {
178
+ absolutePath: string;
179
+ relativePath: string;
180
+ }[];
181
+ /** Parsed frontmatter, for markdown resources. Any `flavors:` is taken out. */
182
+ frontmatter: Record<string, unknown>;
183
+ /** Markdown body, for markdown resources. */
184
+ body?: string;
185
+ /** Parsed payload, for mcp/settings resources. */
186
+ data?: unknown;
187
+ /**
188
+ * The flavors this resource belongs to, from its own frontmatter and from the
189
+ * manifest's patterns. Empty means *common*: it installs whatever was asked
190
+ * for. See `core/flavors.ts`.
191
+ */
192
+ flavors: string[];
193
+ }
194
+ export interface LoadedBundle {
195
+ manifest: BundleManifest;
196
+ root: string;
197
+ resources: BundleResource[];
198
+ source: BundleSource;
199
+ /** `manifest.dependencies`, in one shape, validated at load time. */
200
+ dependencies: BundleDependency[];
201
+ /**
202
+ * Every flavor this bundle has: what the manifest declares, or -- when it
203
+ * declares none -- whatever its resources named for themselves.
204
+ */
205
+ flavors: FlavorDefinition[];
206
+ /** `manifest.parameters`, in one shape, validated at load time. */
207
+ parameters: ParameterDefinition[];
208
+ }
209
+ export type BundleSource = {
210
+ type: 'local';
211
+ path: string;
212
+ } | {
213
+ type: 'github';
214
+ owner: string;
215
+ repo: string;
216
+ ref: string;
217
+ subdir?: string;
218
+ };
219
+ export interface RegistryEntry {
220
+ /**
221
+ * Short alphanumeric handle -- `1`, `2`, ... `a`, `b` -- usable anywhere a
222
+ * bundle name is. Assigned on registration and stable until the entry goes.
223
+ */
224
+ id: string;
225
+ name: string;
226
+ /** Where the bundle came from, and where `hcm update` re-reads it. */
227
+ source: BundleSource;
228
+ version?: string;
229
+ description?: string;
230
+ tags?: string[];
231
+ /**
232
+ * What the bundle's manifest required when it was registered, so the tree can
233
+ * be shown without reading every stored bundle from disk.
234
+ */
235
+ dependencies?: BundleDependency[];
236
+ /**
237
+ * The subsets it can be installed as, as its manifest had them when it was
238
+ * registered -- so `hcm registry list` and `hcm list` can offer them without
239
+ * reading every stored bundle from disk.
240
+ */
241
+ flavors?: FlavorSummary[];
242
+ /**
243
+ * The values it will ask for at install time, as its manifest had them when
244
+ * it was registered -- so `hcm registry list` can warn that installing it is
245
+ * not going to be silent.
246
+ */
247
+ parameters?: ParameterSummary[];
248
+ /**
249
+ * Directory name inside the store holding this bundle's files. Absent for
250
+ * `--dev` entries, which are read from `source` in place.
251
+ */
252
+ store?: string;
253
+ /** Registered with `--dev`: referenced in place so edits take effect at once. */
254
+ dev?: boolean;
255
+ addedAt?: string;
256
+ updatedAt?: string;
257
+ }
258
+ export interface RegistryFile {
259
+ version: 1;
260
+ entries: RegistryEntry[];
261
+ }
262
+ /** A whole file we wrote. */
263
+ export interface FileReceipt {
264
+ op: 'file';
265
+ /** Scope-root-relative POSIX path. */
266
+ path: string;
267
+ /** sha256 of the bytes we wrote. */
268
+ hash: string;
269
+ /**
270
+ * The item was already there, byte-for-byte what we would have written, and
271
+ * nobody claimed it. We adopt it -- the bundle depends on it, but it is not
272
+ * ours to delete, so uninstall leaves it alone.
273
+ */
274
+ preexisting?: boolean;
275
+ }
276
+ /** A value merged into a JSON document at `pointer` (a list of object keys). */
277
+ export interface JsonValueReceipt {
278
+ op: 'json-value';
279
+ path: string;
280
+ pointer: string[];
281
+ /** sha256 of the canonical JSON of the value we wrote. */
282
+ hash: string;
283
+ /** Restored on uninstall when we overwrote something. */
284
+ previous?: unknown;
285
+ hadPrevious: boolean;
286
+ /** Adopted rather than written -- see `FileReceipt.preexisting`. */
287
+ preexisting?: boolean;
288
+ }
289
+ /** Items appended to a JSON array; removed by value hash, so order is irrelevant. */
290
+ export interface JsonArrayItemReceipt {
291
+ op: 'json-array-item';
292
+ path: string;
293
+ pointer: string[];
294
+ /** sha256 of each appended item. */
295
+ hashes: string[];
296
+ }
297
+ /** A marker-delimited block in a comment-supporting text format. */
298
+ export interface BlockReceipt {
299
+ op: 'block';
300
+ path: string;
301
+ blockId: string;
302
+ syntax: 'markdown' | 'toml';
303
+ }
304
+ export type Receipt = FileReceipt | JsonValueReceipt | JsonArrayItemReceipt | BlockReceipt;
305
+ /** True for receipts recording an item we adopted rather than wrote. */
306
+ export declare function isPreexisting(receipt: Receipt): boolean;
307
+ export declare function describeReceipt(receipt: Receipt): string;
308
+ /** A dependency as it stood when the dependent was installed. */
309
+ export interface InstalledDependency {
310
+ name: string;
311
+ /** The version actually installed, not the range that was asked for. */
312
+ version: string;
313
+ /** The range the manifest asked for, when it asked for one. */
314
+ range?: string;
315
+ }
316
+ export interface InstallationRecord {
317
+ /** `${bundle}@${target}@${scope}` */
318
+ id: string;
319
+ bundle: string;
320
+ version: string;
321
+ target: TargetId;
322
+ scope: Scope;
323
+ source: BundleSource;
324
+ installedAt: string;
325
+ receipts: Receipt[];
326
+ /**
327
+ * What the target was told about this machine. Absent means the defaults --
328
+ * which is what every record written before these existed meant too.
329
+ */
330
+ targetOptions?: TargetOptions;
331
+ /**
332
+ * The flavors this installation was narrowed to. Absent means the whole
333
+ * bundle -- which is what every record written before flavors existed meant.
334
+ * `hcm update` reinstalls the same subset without being told again.
335
+ */
336
+ flavors?: string[];
337
+ /**
338
+ * The values this installation's templates were rendered with. Absent means
339
+ * the bundle asked for none -- which is what every record written before
340
+ * parameters existed meant too.
341
+ *
342
+ * `hcm update` renders the new version with these same values, so an update
343
+ * never silently renames the agent. Parameters marked `secret` are not here:
344
+ * they have to be supplied again.
345
+ */
346
+ parameters?: ParameterValues;
347
+ /**
348
+ * The bundles this one required, resolved at install time. `hcm uninstall`
349
+ * reads these to know what is still needed, and what has been orphaned.
350
+ */
351
+ dependencies?: InstalledDependency[];
352
+ /**
353
+ * Pulled in to satisfy somebody else's dependency rather than asked for.
354
+ * Uninstalling the last bundle that needed it takes it away again.
355
+ */
356
+ auto?: boolean;
357
+ }
358
+ export interface StateFile {
359
+ version: 1;
360
+ installations: InstallationRecord[];
361
+ }
362
+ export declare function installationId(bundle: string, target: TargetId, scope: Scope): string;
363
+ /**
364
+ * Where one context section has been written. A section installed into two
365
+ * harnesses has two placements; OpenCode and Pi both write `AGENTS.md`, so two
366
+ * placements can name the same file.
367
+ */
368
+ export interface ContextPlacement {
369
+ target: TargetId;
370
+ /** Scope-root-relative POSIX path of the instruction file. */
371
+ path: string;
372
+ /** The marker block id, the same one the install receipt records. */
373
+ blockId: string;
374
+ /** When hcm last wrote this section into that file. */
375
+ updatedAt: string;
376
+ }
377
+ /**
378
+ * One `context/<name>.md` from a bundle, cached under `.hcm` so it can be put
379
+ * back after something rewrote the harness's instruction file.
380
+ */
381
+ export interface ContextSection {
382
+ bundle: string;
383
+ name: string;
384
+ /** Position within its bundle, taken from the order of the bundle's files. */
385
+ order: number;
386
+ /** Path of the cached copy, relative to the context cache directory. */
387
+ file: string;
388
+ /** sha256 of the cached body. */
389
+ hash: string;
390
+ capturedAt: string;
391
+ placements: ContextPlacement[];
392
+ }
393
+ export interface ContextLedger {
394
+ version: 1;
395
+ sections: ContextSection[];
396
+ }
397
+ export type PlanPayload = {
398
+ kind: 'file';
399
+ contents: string | Buffer;
400
+ } | {
401
+ kind: 'json-value';
402
+ pointer: string[];
403
+ value: unknown;
404
+ } | {
405
+ kind: 'json-array-item';
406
+ pointer: string[];
407
+ items: unknown[];
408
+ } | {
409
+ kind: 'block';
410
+ blockId: string;
411
+ syntax: 'markdown' | 'toml';
412
+ body: string;
413
+ };
414
+ export interface PlanAction {
415
+ /** Scope-root-relative POSIX path of the file being touched. */
416
+ path: string;
417
+ /** Shown by --dry-run. */
418
+ describe: string;
419
+ payload: PlanPayload;
420
+ /**
421
+ * The bundle resource this write came from. Targets do not set it -- the
422
+ * planner attaches it, so conflicts can be resolved a resource at a time
423
+ * rather than a file at a time (one skill is many files, one decision).
424
+ */
425
+ resource?: BundleResource;
426
+ /** Already present and identical: record it, but do not write or own it. */
427
+ adopt?: boolean;
428
+ /**
429
+ * Another installation already wrote exactly this item. Nothing needs
430
+ * writing, but we do claim it: the item stays until the last claimant goes.
431
+ * This is how two bundles ship the same shared asset without a second copy
432
+ * and without one uninstall breaking the other.
433
+ */
434
+ share?: boolean;
435
+ /**
436
+ * For appends to a JSON array: hashes of items another installation already
437
+ * contributed. They are recorded as ours too, so the item survives until
438
+ * every bundle that wanted it has gone.
439
+ */
440
+ shareItems?: string[];
441
+ }
442
+ /** Stable key for "the same resource", used to group and remember decisions. */
443
+ export declare function resourceKey(resource: BundleResource): string;
444
+ export interface PlanConflict {
445
+ path: string;
446
+ detail: string;
447
+ /** The bundle that already owns the item, when known. */
448
+ owner?: string;
449
+ /** The resource whose write collided, when known. */
450
+ resource?: BundleResource;
451
+ /** Set for JSON conflicts, so a resolution can name the colliding key. */
452
+ pointer?: string[];
453
+ }
454
+ /**
455
+ * What became of the bundle's internal file references on the way into this
456
+ * target -- see `core/refmap.ts`. Reported rather than silently applied: a
457
+ * reference that could not be remapped is one the agent will follow anyway.
458
+ */
459
+ export interface PlanReferences {
460
+ /** Rewritten to match where the file landed. */
461
+ rewrites: {
462
+ path: string;
463
+ from: string;
464
+ to: string;
465
+ }[];
466
+ /** Pointed at a bundle file this target does not install. */
467
+ dropped: {
468
+ path: string;
469
+ ref: string;
470
+ reason: string;
471
+ }[];
472
+ }
473
+ /**
474
+ * What became of the `<%PLACEHOLDERS%>` in the bundle's text on the way into
475
+ * this target -- see `core/parameters.ts`. Reported rather than silently
476
+ * applied, for the same reason references are: a placeholder left standing is
477
+ * one the agent will read out loud.
478
+ */
479
+ export interface PlanTemplating {
480
+ /** The values everything was rendered with. */
481
+ values: ParameterValues;
482
+ /** Filled in, one entry per file and name. */
483
+ substituted: {
484
+ path: string;
485
+ name: string;
486
+ count: number;
487
+ }[];
488
+ /** Left in the text verbatim, because nothing here had a value for it. */
489
+ unresolved: {
490
+ path: string;
491
+ name: string;
492
+ reason: string;
493
+ }[];
494
+ }
495
+ export interface InstallPlan {
496
+ bundle: LoadedBundle;
497
+ target: TargetId;
498
+ scope: Scope;
499
+ /** Carried on the plan so a resolved conflict can regenerate actions the same way. */
500
+ targetOptions: TargetOptions;
501
+ /** The flavors asked for. Empty is the whole bundle. */
502
+ flavors: string[];
503
+ /** Absent on plans built before parameters existed, or for an empty plan. */
504
+ templating?: PlanTemplating;
505
+ /** Absolute root the action paths are relative to. */
506
+ scopeRoot: string;
507
+ actions: PlanAction[];
508
+ conflicts: PlanConflict[];
509
+ skipped: {
510
+ resource: BundleResource;
511
+ reason: string;
512
+ }[];
513
+ /** Absent on plans built before references were remapped. */
514
+ references?: PlanReferences;
515
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Core domain types.
3
+ *
4
+ * The one genuinely tricky requirement: uninstalling must remove exactly the
5
+ * items a bundle contributed, even when several bundles wrote into the same
6
+ * file (`.mcp.json`, `settings.json`, `reasonix.toml`, `CLAUDE.md`) and the
7
+ * file has been reordered or reformatted since.
8
+ *
9
+ * So we never record line numbers or diffs. Each write leaves a `Receipt`
10
+ * expressed in terms the format itself understands:
11
+ * JSON -> structural pointer + hash of the value we wrote
12
+ * TOML/MD -> comment-delimited marker block
13
+ * files -> path + content hash
14
+ */
15
+ /** Bundle directory name -> canonical kind. This is the whole bundle schema. */
16
+ export const KIND_DIRECTORIES = {
17
+ subagents: 'subagent',
18
+ skills: 'skill',
19
+ commands: 'command',
20
+ rules: 'rule',
21
+ context: 'context',
22
+ mcp: 'mcp',
23
+ settings: 'settings',
24
+ assets: 'asset',
25
+ };
26
+ /** True for receipts recording an item we adopted rather than wrote. */
27
+ export function isPreexisting(receipt) {
28
+ return (receipt.op === 'file' || receipt.op === 'json-value') && receipt.preexisting === true;
29
+ }
30
+ export function describeReceipt(receipt) {
31
+ switch (receipt.op) {
32
+ case 'file':
33
+ return receipt.path;
34
+ case 'json-value':
35
+ return `${receipt.path} → ${receipt.pointer.join('.')}`;
36
+ case 'json-array-item':
37
+ return `${receipt.path} → ${receipt.pointer.join('.')}[] (${receipt.hashes.length})`;
38
+ case 'block':
39
+ return `${receipt.path} → block ${receipt.blockId}`;
40
+ }
41
+ }
42
+ export function installationId(bundle, target, scope) {
43
+ return `${bundle}@${target}@${scope}`;
44
+ }
45
+ /** Stable key for "the same resource", used to group and remember decisions. */
46
+ export function resourceKey(resource) {
47
+ return `${resource.kind}:${resource.name}`;
48
+ }
49
+ //# sourceMappingURL=types.js.map
@@ -0,0 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;AAChF,MAAM,UAAU,WAAW,CAAC,QAAwB;IAClD,OAAO,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,16 @@
1
+ /** Programmatic entry point, for using hcm as a library. */
2
+ export { discoverBundleDirs, loadBundle, loadManifest, validateBundle } from './core/bundle.js';
3
+ export { readConfig, resolveCacheDir, writeConfig } from './core/config.js';
4
+ export { appendContext, captureContext, contextFiles, forgetContext, inspectContext, overrideContext, readContextLedger, removeContext, trackedBundles, } from './core/context.js';
5
+ export { applyPlan } from './core/executor.js';
6
+ export { ALL_FLAVORS, assertFlavorsAvailable, expandFlavors, hasFlavor, inFlavors, matchesPattern, normalizeFlavors, } from './core/flavors.js';
7
+ export { applicableParameters, appliesTo, applyParameters, emptyOverrides, mergeOverrides, normalizeParameters, overridesFor, parameterEnvName, parameterProblems, parseAssignments, placeholderNames, readParametersFile, renderTemplate, resolveParameters, storableValues, summarizeParameters, withDefaults, } from './core/parameters.js';
8
+ export { buildPlan } from './core/planner.js';
9
+ export { buildRefMap, remapReferences } from './core/refmap.js';
10
+ export type { BrokenRef, FoundRef, RefConfidence, RefEdit, RefPolicy, RefScope, RefSuggestion, RefSyntax, ResolvedRef, ResolveOptions, ScanOptions, ScanResult, } from './core/refs.js';
11
+ export { applyRefEdits, DECLARED_SYNTAXES, extractRefs, INSTALL_POLICY, isExplicitlyRelative, isInScope, LINK_SYNTAXES, REF_SYNTAXES, refPolicy, resolveRef, scanReferences, suggestFixes, } from './core/refs.js';
12
+ export { auditInstallation, rollback } from './core/rollback.js';
13
+ export { addToRegistry, readRegistry, resolveBundle, resolveBundles } from './core/registry.js';
14
+ export { findInstallations, readState, upsertInstallation } from './core/state.js';
15
+ export { getTarget, TARGETS, TARGET_IDS } from './targets/index.js';
16
+ export * from './core/types.js';
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ /** Programmatic entry point, for using hcm as a library. */
2
+ export { discoverBundleDirs, loadBundle, loadManifest, validateBundle } from './core/bundle.js';
3
+ export { readConfig, resolveCacheDir, writeConfig } from './core/config.js';
4
+ export { appendContext, captureContext, contextFiles, forgetContext, inspectContext, overrideContext, readContextLedger, removeContext, trackedBundles, } from './core/context.js';
5
+ export { applyPlan } from './core/executor.js';
6
+ export { ALL_FLAVORS, assertFlavorsAvailable, expandFlavors, hasFlavor, inFlavors, matchesPattern, normalizeFlavors, } from './core/flavors.js';
7
+ export { applicableParameters, appliesTo, applyParameters, emptyOverrides, mergeOverrides, normalizeParameters, overridesFor, parameterEnvName, parameterProblems, parseAssignments, placeholderNames, readParametersFile, renderTemplate, resolveParameters, storableValues, summarizeParameters, withDefaults, } from './core/parameters.js';
8
+ export { buildPlan } from './core/planner.js';
9
+ export { buildRefMap, remapReferences } from './core/refmap.js';
10
+ export { applyRefEdits, DECLARED_SYNTAXES, extractRefs, INSTALL_POLICY, isExplicitlyRelative, isInScope, LINK_SYNTAXES, REF_SYNTAXES, refPolicy, resolveRef, scanReferences, suggestFixes, } from './core/refs.js';
11
+ export { auditInstallation, rollback } from './core/rollback.js';
12
+ export { addToRegistry, readRegistry, resolveBundle, resolveBundles } from './core/registry.js';
13
+ export { findInstallations, readState, upsertInstallation } from './core/state.js';
14
+ export { getTarget, TARGETS, TARGET_IDS } from './targets/index.js';
15
+ export * from './core/types.js';
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EACL,aAAa,EACb,cAAc,EACd,YAAY,EACZ,aAAa,EACb,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,cAAc,GACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,aAAa,EACb,SAAS,EACT,SAAS,EACT,cAAc,EACd,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,oBAAoB,EACpB,SAAS,EACT,eAAe,EACf,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAehE,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,SAAS,EACT,aAAa,EACb,YAAY,EACZ,SAAS,EACT,UAAU,EACV,cAAc,EACd,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAChG,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACpE,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Marker blocks for formats that support comments (Markdown, TOML).
3
+ *
4
+ * Instead of tracking positions, we wrap our contribution in comment markers
5
+ * carrying a stable block id. Removal is then an exact textual excision no
6
+ * matter how much the surrounding file changed, and a human reading the file
7
+ * can see which bundle owns which section.
8
+ */
9
+ export type BlockSyntax = 'markdown' | 'toml';
10
+ /** Build the block id that identifies one bundle's contribution to one file. */
11
+ export declare function blockId(bundle: string, resourceName: string): string;
12
+ export declare function hasBlock(content: string, syntax: BlockSyntax, id: string): boolean;
13
+ /** A complete `begin`...`end` pair, with the markers included. */
14
+ export interface MarkedBlock {
15
+ id: string;
16
+ /** The block verbatim, markers and all. */
17
+ text: string;
18
+ }
19
+ /**
20
+ * Every well-formed block in a file. Unlike `listBlockIds` this matches pairs,
21
+ * so a begin marker whose end was deleted is not reported -- the text after it
22
+ * is no longer ours to move or delete.
23
+ */
24
+ export declare function extractBlocks(content: string, syntax: BlockSyntax): MarkedBlock[];
25
+ /**
26
+ * Throw away everything that is not one of our blocks, keeping the blocks in
27
+ * the order they appeared. `hcm context override` uses this to clear a file an
28
+ * agent has rewritten without destroying blocks other bundles still own.
29
+ *
30
+ * `discardedLines` counts the non-blank lines that went, so the caller can say
31
+ * how much is about to be lost before doing it.
32
+ */
33
+ export declare function keepOnlyBlocks(content: string, syntax: BlockSyntax): {
34
+ content: string;
35
+ blocks: MarkedBlock[];
36
+ discardedLines: number;
37
+ };
38
+ /** List the block ids present in a file, in order of appearance. */
39
+ export declare function listBlockIds(content: string, syntax: BlockSyntax): string[];
40
+ /**
41
+ * Insert or replace a block. Appends at the end of the file when absent, so
42
+ * existing content (and other bundles' blocks) stays exactly where it was.
43
+ */
44
+ export declare function upsertBlock(content: string, syntax: BlockSyntax, id: string, body: string): string;
45
+ /** Remove a block. Returns the new content, or `undefined` when not present. */
46
+ export declare function removeBlock(content: string, syntax: BlockSyntax, id: string): string | undefined;
47
+ /** True when nothing but whitespace remains -- caller may delete the file. */
48
+ export declare function isEffectivelyEmpty(content: string): boolean;
Binary file
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blocks.js","sourceRoot":"","sources":["../../src/merge/blocks.ts"],"names":[],"mappings":"AAAA;;;;;;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