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,297 @@
1
+ /**
2
+ * Finding the file references a bundle's own text makes, and deciding which of
3
+ * them point at nothing.
4
+ *
5
+ * A bundle is prose plus config, and both are full of paths: a SKILL.md that
6
+ * says to work through `./checklist.md`, a command that links to
7
+ * [the conventions](context/10-conventions.md), an MCP server whose args name a
8
+ * script under `assets/`. Rename the file and every one of those becomes a lie
9
+ * the agent will follow.
10
+ *
11
+ * The hard part is not finding paths. It is not finding the things that merely
12
+ * look like paths. Prose about files is still prose:
13
+ *
14
+ * A file will be created named `output.txt`.
15
+ * Identify the manifest (`package.json`) and read `tsconfig.json`.
16
+ *
17
+ * Not one of those is a reference to a file the bundle ships, and a checker
18
+ * that says otherwise is a checker nobody runs. Filename-shaped text is far too
19
+ * common in writing about software to be treated as a claim about the tree.
20
+ *
21
+ * So a reference has to be *written as one*, in one of two ways:
22
+ *
23
+ * declared the syntax says outright that its target is a path --
24
+ * [text](path), ![img](path), a [id]: definition, a [[wikilink]],
25
+ * or an @path mention. Nobody writes a markdown link to a turn of
26
+ * phrase.
27
+ * relative written with an explicit `./` or `../`. That prefix is a
28
+ * deliberate act: `./output.txt` says "the file beside this one"
29
+ * where `output.txt` says only "a file called that".
30
+ *
31
+ * Everything else -- a bare filename or an implicit path in inline code or a
32
+ * config value -- is left alone unless `--all-paths` asks for it, which is the
33
+ * older, noisier behaviour kept for the bundles that were written against it.
34
+ *
35
+ * What a reference is relative to is still not stated anywhere, so resolution
36
+ * tries both roots: `./checklist.md` next to a SKILL.md means the sibling;
37
+ * `skills/audit/checklist.md` in a command means the same file, from the bundle
38
+ * root.
39
+ *
40
+ * Under `--all-paths`, references also carry a confidence, and it decides how
41
+ * loud the report is:
42
+ *
43
+ * strong declared, explicitly relative, or holding a separator. Always
44
+ * reported.
45
+ * weak a bare filename in inline code or a config value. Reported only
46
+ * when something similar exists in the tree, which is also exactly
47
+ * when we have a fix to offer. `--strict` reports these regardless.
48
+ *
49
+ * @see refmap.ts for what happens to these references at install time.
50
+ */
51
+ export type RefConfidence = 'strong' | 'weak';
52
+ export type RefSyntax = 'link' | 'image' | 'definition' | 'wikilink' | 'code' | 'mention' | 'config';
53
+ export declare const REF_SYNTAXES: readonly RefSyntax[];
54
+ /**
55
+ * The syntaxes whose target is a path by construction.
56
+ *
57
+ * `[the rules](rules/typescript.md)` cannot be a turn of phrase the way
58
+ * `` `rules.md` `` can: markdown has already said the thing in the parentheses
59
+ * is somewhere to go. The same holds for a wikilink and for the `@file`
60
+ * convention several harnesses read as "open this". These are checked as
61
+ * written, without needing a `./` in front of them.
62
+ */
63
+ export declare const DECLARED_SYNTAXES: ReadonlySet<RefSyntax>;
64
+ /** What `--links` narrows to: the syntaxes that are a link of some kind. */
65
+ export declare const LINK_SYNTAXES: ReadonlySet<RefSyntax>;
66
+ export interface FoundRef {
67
+ /** Absolute path of the file the reference is written in. */
68
+ file: string;
69
+ /** `file`, relative to the scan root, POSIX separators. */
70
+ fileRelative: string;
71
+ /** The bundle `file` belongs to, absolute; absent for files outside any bundle. */
72
+ bundleRoot?: string;
73
+ /** The reference exactly as written. */
74
+ ref: string;
75
+ syntax: RefSyntax;
76
+ confidence: RefConfidence;
77
+ /** 1-based line of the reference, for the report. */
78
+ line: number;
79
+ /** Character offsets of `ref` within the file, for editing it in place. */
80
+ start: number;
81
+ end: number;
82
+ }
83
+ export interface ResolvedRef extends FoundRef {
84
+ /** Absolute path the reference resolves to, when it resolves at all. */
85
+ target?: string;
86
+ /**
87
+ * How it resolved -- against the containing file, against the bundle root,
88
+ * or, for a wikilink, by the name of a file somewhere in the same bundle.
89
+ */
90
+ via?: 'file' | 'bundle' | 'name';
91
+ }
92
+ export interface RefSuggestion {
93
+ /** The replacement, written the way the reference should be. */
94
+ ref: string;
95
+ /** Absolute path of the file suggested. */
96
+ target: string;
97
+ /** 0..1; only used for ordering. */
98
+ score: number;
99
+ /** True when the file is in a different bundle than the reference. */
100
+ crossBundle: boolean;
101
+ }
102
+ export interface BrokenRef extends ResolvedRef {
103
+ suggestions: RefSuggestion[];
104
+ }
105
+ export interface ScanResult {
106
+ /** Absolute path that `fileRelative` values are relative to. */
107
+ root: string;
108
+ /** The rules this scan ran under, so a report can say what it looked at. */
109
+ scope: RefScope;
110
+ /** Every file that was read. */
111
+ scanned: string[];
112
+ /** Bundle roots found under the scan root. */
113
+ bundles: string[];
114
+ /** Every reference found, resolved or not. */
115
+ refs: ResolvedRef[];
116
+ broken: BrokenRef[];
117
+ }
118
+ /**
119
+ * Which references a scan is about.
120
+ *
121
+ * The default -- every flag off -- is the narrow one: declared references, and
122
+ * paths written with an explicit `./` or `../`. The flags widen or narrow it
123
+ * from there, and they are the same three the CLI exposes.
124
+ */
125
+ export interface RefScope {
126
+ /** Only links, images, link definitions and wikilinks. */
127
+ links?: boolean;
128
+ /**
129
+ * Also treat implicit paths and bare filenames in inline code and config
130
+ * values as references -- noisier, and how this worked before.
131
+ */
132
+ allPaths?: boolean;
133
+ /**
134
+ * Implies `allPaths`, and additionally reports a bare filename even when
135
+ * there is nothing similar in the tree to offer as a fix.
136
+ */
137
+ strict?: boolean;
138
+ }
139
+ export interface ScanOptions extends RefScope {
140
+ /** How many replacements to offer per broken reference. */
141
+ suggestions?: number;
142
+ }
143
+ /** The scope, resolved into the two questions extraction actually asks. */
144
+ export interface RefPolicy {
145
+ /** Syntaxes worth looking at. */
146
+ syntaxes: ReadonlySet<RefSyntax>;
147
+ /**
148
+ * Whether a path in a syntax that merely *might* hold one -- inline code, a
149
+ * config value -- has to be written `./like/this` before it counts.
150
+ */
151
+ requireExplicitRelative: boolean;
152
+ }
153
+ /**
154
+ * The scope a scan was asked for, as the rules extraction follows.
155
+ *
156
+ * `--strict` is a louder `--all-paths` rather than a scope of its own: it
157
+ * changes which of the found references get *reported*, not which get found.
158
+ */
159
+ export declare function refPolicy(scope?: RefScope): RefPolicy;
160
+ /**
161
+ * What the installer reads, which is not what the checker reads.
162
+ *
163
+ * Remapping rewrites references it can prove point at a bundle file (see
164
+ * refmap.ts), so a false positive costs nothing there -- an implicit
165
+ * `skills/audit/checklist.md` that resolves is repointed, and prose that only
166
+ * looks like a path resolves to nothing and is left alone. Wikilinks are the
167
+ * exception in the other direction: they are resolved by *name* rather than by
168
+ * path, so rewriting one into a relative path would break it.
169
+ */
170
+ export declare const INSTALL_POLICY: RefPolicy;
171
+ /**
172
+ * Read every markdown file and config under `root`, extract the references, and
173
+ * work out which of them point at nothing.
174
+ *
175
+ * `root` is normally a bundle or a collection of bundles; it does not have to
176
+ * be either -- files outside any bundle are still read, they simply have no
177
+ * bundle root to resolve against.
178
+ */
179
+ export declare function scanReferences(root: string, options?: ScanOptions): Promise<ScanResult>;
180
+ export declare function isScannable(file: string): boolean;
181
+ /**
182
+ * Every reference candidate in one file, with its offsets.
183
+ *
184
+ * `policy` decides what counts as one. It defaults to `INSTALL_POLICY` -- the
185
+ * permissive reading the installer needs -- so that a caller who has not
186
+ * thought about scope gets the same answer this always gave. `scanReferences`
187
+ * passes the checker's narrower policy explicitly.
188
+ */
189
+ export declare function extractRefs(file: string, text: string, policy?: RefPolicy): Omit<FoundRef, 'fileRelative'>[];
190
+ /**
191
+ * The rule that keeps prose out of the report.
192
+ *
193
+ * A declared reference is in scope whatever it says -- the syntax has already
194
+ * vouched for it. Anything else has to have been written as a path on purpose,
195
+ * and `./` or `../` is the only mark of that a bundle author can make. A bare
196
+ * `output.txt` in a sentence about creating a file is indistinguishable from a
197
+ * bare `output.txt` meant as a reference, so neither is treated as one.
198
+ */
199
+ export declare function isInScope(ref: string, syntax: RefSyntax, policy: RefPolicy): boolean;
200
+ /** `./here.md` and `../up/there.md`, and nothing else. */
201
+ export declare function isExplicitlyRelative(ref: string): boolean;
202
+ /**
203
+ * The filter that keeps the report worth reading.
204
+ *
205
+ * A link's target is a path by construction, so only the obvious non-paths are
206
+ * dropped. Everything else has to look like one: a name with a plausible
207
+ * extension, no spaces, no shell in it, and not one of the filenames prose
208
+ * mentions about projects in general.
209
+ */
210
+ export declare function looksLikePath(ref: string, syntax: RefSyntax): boolean;
211
+ export interface ResolveOptions {
212
+ /** Wikilinks resolve by name as well as by path; nothing else does. */
213
+ syntax?: RefSyntax;
214
+ /** Files under the scan root, for the name lookup a wikilink needs. */
215
+ index?: readonly RefIndexEntry[];
216
+ }
217
+ export interface Resolution {
218
+ target?: string;
219
+ via?: 'file' | 'bundle' | 'name';
220
+ }
221
+ /**
222
+ * Where a reference points, trying both roots a bundle author might have meant.
223
+ *
224
+ * The bundle root comes first: that is the convention `hcm` installs against
225
+ * (see refmap.ts), so a path that resolves both ways is read as the bundle-
226
+ * relative one. The file-relative fallback is what makes a skill's
227
+ * `./checklist.md` work, and what keeps every bundle written before this
228
+ * existed resolving as it always did.
229
+ *
230
+ * A wikilink is the exception, because it is a name and not a path. `[[release
231
+ * checklist]]` gets its extension guessed, and then, failing both roots, is
232
+ * looked up by name anywhere in the same bundle -- which is how every tool that
233
+ * reads wikilinks resolves them, and the only reading under which the common
234
+ * form of one resolves at all.
235
+ */
236
+ export declare function resolveRef(ref: string, file: string, bundleRoot?: string, options?: ResolveOptions): Promise<Resolution>;
237
+ export interface RefIndexEntry {
238
+ absolute: string;
239
+ /** Relative to the scan root, POSIX. */
240
+ relative: string;
241
+ base: string;
242
+ extension: string;
243
+ bundleRoot?: string;
244
+ }
245
+ /**
246
+ * The files this reference most plausibly meant.
247
+ *
248
+ * Ranked on the name first -- a rename is what usually breaks a reference, and
249
+ * a renamed file keeps most of its name -- then nudged by the things that make
250
+ * one candidate likelier than another with the same name: the same extension,
251
+ * a matching parent directory, and being in the bundle doing the referring.
252
+ */
253
+ export declare function suggestFixes(ref: ResolvedRef, index: RefIndexEntry[], limit?: number): RefSuggestion[];
254
+ /**
255
+ * 0..1 over two filename stems.
256
+ *
257
+ * Three views, each of which catches renames the others miss, and the best of
258
+ * them wins. Averaging them instead would be worse than any one alone: a
259
+ * one-character typo scores 0.9 on edit distance and 0 on token overlap --
260
+ * filenames are usually a single token -- and blending those into 0.55 buries
261
+ * the likeliest fix there is.
262
+ *
263
+ * distance `conventions` -> `convetions`, a typo
264
+ * tokens `pull-requests` -> `requests-pull`, reordered
265
+ * containment `checklist` -> `audit-checklist`, qualified
266
+ */
267
+ export declare function similarity(a: string, b: string): number;
268
+ /** One reference to replace, as read back from the fix file. */
269
+ export interface RefEdit {
270
+ file: string;
271
+ /** The reference as it was reported, used to find it again. */
272
+ original: string;
273
+ replacement: string;
274
+ /** Where it was when the file was scanned; re-checked before editing. */
275
+ start?: number;
276
+ end?: number;
277
+ }
278
+ export interface EditOutcome {
279
+ file: string;
280
+ original: string;
281
+ replacement: string;
282
+ applied: boolean;
283
+ /** Why it was not applied. */
284
+ reason?: string;
285
+ }
286
+ /**
287
+ * Rewrite references in place.
288
+ *
289
+ * The offsets recorded at scan time are checked against what is on disk before
290
+ * anything is written -- the file may well have been edited while the JSON was
291
+ * open -- and fall back to a unique-occurrence search when they no longer line
292
+ * up. An occurrence that cannot be pinned down exactly is left alone and
293
+ * reported rather than guessed at.
294
+ */
295
+ export declare function applyRefEdits(edits: RefEdit[], options?: {
296
+ dryRun?: boolean;
297
+ }): Promise<EditOutcome[]>;