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.
- package/LICENSE +21 -0
- package/README.md +1547 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +584 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/config.d.ts +7 -0
- package/dist/commands/config.js +49 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/context.d.ts +24 -0
- package/dist/commands/context.js +329 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/export.d.ts +19 -0
- package/dist/commands/export.js +116 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/import.d.ts +33 -0
- package/dist/commands/import.js +81 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/info.d.ts +19 -0
- package/dist/commands/info.js +235 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/init.d.ts +5 -0
- package/dist/commands/init.js +116 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/install.d.ts +119 -0
- package/dist/commands/install.js +533 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/list.d.ts +9 -0
- package/dist/commands/list.js +102 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/params.d.ts +58 -0
- package/dist/commands/params.js +366 -0
- package/dist/commands/params.js.map +1 -0
- package/dist/commands/refs.d.ts +60 -0
- package/dist/commands/refs.js +329 -0
- package/dist/commands/refs.js.map +1 -0
- package/dist/commands/registry.d.ts +18 -0
- package/dist/commands/registry.js +173 -0
- package/dist/commands/registry.js.map +1 -0
- package/dist/commands/status.d.ts +10 -0
- package/dist/commands/status.js +83 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/targets.d.ts +8 -0
- package/dist/commands/targets.js +61 -0
- package/dist/commands/targets.js.map +1 -0
- package/dist/commands/uninstall.d.ts +71 -0
- package/dist/commands/uninstall.js +322 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/commands/update.d.ts +66 -0
- package/dist/commands/update.js +384 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/validate.d.ts +3 -0
- package/dist/commands/validate.js +38 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/core/bundle.d.ts +49 -0
- package/dist/core/bundle.js +326 -0
- package/dist/core/bundle.js.map +1 -0
- package/dist/core/config.d.ts +65 -0
- package/dist/core/config.js +112 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/conflicts.d.ts +67 -0
- package/dist/core/conflicts.js +300 -0
- package/dist/core/conflicts.js.map +1 -0
- package/dist/core/context.d.ts +139 -0
- package/dist/core/context.js +432 -0
- package/dist/core/context.js.map +1 -0
- package/dist/core/deps.d.ts +62 -0
- package/dist/core/deps.js +339 -0
- package/dist/core/deps.js.map +1 -0
- package/dist/core/errors.d.ts +21 -0
- package/dist/core/errors.js +26 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/executor.d.ts +9 -0
- package/dist/core/executor.js +139 -0
- package/dist/core/executor.js.map +1 -0
- package/dist/core/flavors.d.ts +128 -0
- package/dist/core/flavors.js +386 -0
- package/dist/core/flavors.js.map +1 -0
- package/dist/core/frontmatter.d.ts +6 -0
- package/dist/core/frontmatter.js +20 -0
- package/dist/core/frontmatter.js.map +1 -0
- package/dist/core/fsx.d.ts +40 -0
- package/dist/core/fsx.js +180 -0
- package/dist/core/fsx.js.map +1 -0
- package/dist/core/github.d.ts +37 -0
- package/dist/core/github.js +157 -0
- package/dist/core/github.js.map +1 -0
- package/dist/core/harnesses.d.ts +142 -0
- package/dist/core/harnesses.js +215 -0
- package/dist/core/harnesses.js.map +1 -0
- package/dist/core/hash.d.ts +12 -0
- package/dist/core/hash.js +34 -0
- package/dist/core/hash.js.map +1 -0
- package/dist/core/logger.d.ts +16 -0
- package/dist/core/logger.js +36 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/overlap.d.ts +79 -0
- package/dist/core/overlap.js +155 -0
- package/dist/core/overlap.js.map +1 -0
- package/dist/core/parameters.d.ts +249 -0
- package/dist/core/parameters.js +944 -0
- package/dist/core/parameters.js.map +1 -0
- package/dist/core/paths.d.ts +20 -0
- package/dist/core/paths.js +35 -0
- package/dist/core/paths.js.map +1 -0
- package/dist/core/planner.d.ts +36 -0
- package/dist/core/planner.js +364 -0
- package/dist/core/planner.js.map +1 -0
- package/dist/core/prompt.d.ts +52 -0
- package/dist/core/prompt.js +197 -0
- package/dist/core/prompt.js.map +1 -0
- package/dist/core/refmap.d.ts +91 -0
- package/dist/core/refmap.js +331 -0
- package/dist/core/refmap.js.map +1 -0
- package/dist/core/refs.d.ts +297 -0
- package/dist/core/refs.js +801 -0
- package/dist/core/refs.js.map +1 -0
- package/dist/core/registry.d.ts +119 -0
- package/dist/core/registry.js +363 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core/rename.d.ts +36 -0
- package/dist/core/rename.js +74 -0
- package/dist/core/rename.js.map +1 -0
- package/dist/core/rollback.d.ts +38 -0
- package/dist/core/rollback.js +226 -0
- package/dist/core/rollback.js.map +1 -0
- package/dist/core/semver.d.ts +56 -0
- package/dist/core/semver.js +214 -0
- package/dist/core/semver.js.map +1 -0
- package/dist/core/state.d.ts +99 -0
- package/dist/core/state.js +196 -0
- package/dist/core/state.js.map +1 -0
- package/dist/core/store.d.ts +30 -0
- package/dist/core/store.js +54 -0
- package/dist/core/store.js.map +1 -0
- package/dist/core/types.d.ts +515 -0
- package/dist/core/types.js +49 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/merge/blocks.d.ts +48 -0
- package/dist/merge/blocks.js +0 -0
- package/dist/merge/blocks.js.map +1 -0
- package/dist/merge/json-merge.d.ts +66 -0
- package/dist/merge/json-merge.js +176 -0
- package/dist/merge/json-merge.js.map +1 -0
- package/dist/merge/toml.d.ts +48 -0
- package/dist/merge/toml.js +118 -0
- package/dist/merge/toml.js.map +1 -0
- package/dist/targets/claude-code.d.ts +11 -0
- package/dist/targets/claude-code.js +94 -0
- package/dist/targets/claude-code.js.map +1 -0
- package/dist/targets/copilot.d.ts +13 -0
- package/dist/targets/copilot.js +126 -0
- package/dist/targets/copilot.js.map +1 -0
- package/dist/targets/index.d.ts +20 -0
- package/dist/targets/index.js +60 -0
- package/dist/targets/index.js.map +1 -0
- package/dist/targets/opencode.d.ts +32 -0
- package/dist/targets/opencode.js +172 -0
- package/dist/targets/opencode.js.map +1 -0
- package/dist/targets/pi.d.ts +42 -0
- package/dist/targets/pi.js +134 -0
- package/dist/targets/pi.js.map +1 -0
- package/dist/targets/reasonix.d.ts +27 -0
- package/dist/targets/reasonix.js +192 -0
- package/dist/targets/reasonix.js.map +1 -0
- package/dist/targets/shared.d.ts +33 -0
- package/dist/targets/shared.js +109 -0
- package/dist/targets/shared.js.map +1 -0
- package/dist/targets/types.d.ts +40 -0
- package/dist/targets/types.js +17 -0
- package/dist/targets/types.js.map +1 -0
- package/docs/authoring-bundles.md +828 -0
- package/package.json +74 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal questions.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately tiny and dependency-free: a numbered menu and a line of text.
|
|
5
|
+
* Everything that asks something goes through here so that non-interactive
|
|
6
|
+
* runs have exactly one place to be detected and refused.
|
|
7
|
+
*/
|
|
8
|
+
import readline from 'node:readline';
|
|
9
|
+
import { AbortedError } from './errors.js';
|
|
10
|
+
import { color } from './logger.js';
|
|
11
|
+
/** True when there is a human on the other end of both stdin and stdout. */
|
|
12
|
+
export function isInteractive() {
|
|
13
|
+
return Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
14
|
+
}
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// Reading lines
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
/**
|
|
19
|
+
* One reader for the whole process, with a queue in front of it.
|
|
20
|
+
*
|
|
21
|
+
* Both halves matter. A fresh interface per question throws away whatever is
|
|
22
|
+
* already buffered on stdin, and a bare `rl.question` loses any line that
|
|
23
|
+
* arrives before its listener is attached -- which is exactly what happens when
|
|
24
|
+
* the answers are piped in rather than typed. Queueing makes a two-part
|
|
25
|
+
* question (choose "rename", then type the name) work either way.
|
|
26
|
+
*/
|
|
27
|
+
let reader;
|
|
28
|
+
let pending = [];
|
|
29
|
+
let waiting;
|
|
30
|
+
let ended = false;
|
|
31
|
+
function open() {
|
|
32
|
+
if (reader)
|
|
33
|
+
return;
|
|
34
|
+
// terminal:false leaves echo and line editing to the terminal itself, so
|
|
35
|
+
// typed and piped input behave identically.
|
|
36
|
+
reader = readline.createInterface({ input: process.stdin, terminal: false });
|
|
37
|
+
ended = false;
|
|
38
|
+
reader.on('line', (line) => {
|
|
39
|
+
const resolve = waiting;
|
|
40
|
+
if (resolve) {
|
|
41
|
+
waiting = undefined;
|
|
42
|
+
resolve(line);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
pending.push(line);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
reader.on('close', () => {
|
|
49
|
+
ended = true;
|
|
50
|
+
const resolve = waiting;
|
|
51
|
+
if (resolve) {
|
|
52
|
+
waiting = undefined;
|
|
53
|
+
resolve(undefined);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** Release stdin so the process can exit. Safe to call when nothing was asked. */
|
|
58
|
+
export function closePrompt() {
|
|
59
|
+
reader?.close();
|
|
60
|
+
reader = undefined;
|
|
61
|
+
waiting = undefined;
|
|
62
|
+
pending = [];
|
|
63
|
+
ended = false;
|
|
64
|
+
}
|
|
65
|
+
async function ask(question) {
|
|
66
|
+
open();
|
|
67
|
+
process.stdout.write(question);
|
|
68
|
+
const buffered = pending.shift();
|
|
69
|
+
if (buffered !== undefined)
|
|
70
|
+
return buffered.trim();
|
|
71
|
+
if (ended)
|
|
72
|
+
throw new AbortedError('Aborted: no answer, and stdin has closed');
|
|
73
|
+
const line = await new Promise((resolve) => {
|
|
74
|
+
waiting = resolve;
|
|
75
|
+
});
|
|
76
|
+
if (line === undefined)
|
|
77
|
+
throw new AbortedError('Aborted: no answer, and stdin has closed');
|
|
78
|
+
return line.trim();
|
|
79
|
+
}
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
// Questions
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
/**
|
|
84
|
+
* Numbered single-choice menu. Repeats until the answer is one of the options;
|
|
85
|
+
* an empty answer takes `defaultValue` when one is offered.
|
|
86
|
+
*/
|
|
87
|
+
export async function select(title, choices, defaultValue) {
|
|
88
|
+
process.stdout.write(`${title}\n`);
|
|
89
|
+
for (const [index, choice] of choices.entries()) {
|
|
90
|
+
const marker = choice.value === defaultValue ? color.bold('*') : ' ';
|
|
91
|
+
const detail = choice.detail ? color.dim(` -- ${choice.detail}`) : '';
|
|
92
|
+
process.stdout.write(` ${marker}${index + 1}) ${choice.label}${detail}\n`);
|
|
93
|
+
}
|
|
94
|
+
const fallback = defaultValue === undefined
|
|
95
|
+
? ''
|
|
96
|
+
: color.dim(` [${choices.findIndex((choice) => choice.value === defaultValue) + 1}]`);
|
|
97
|
+
for (;;) {
|
|
98
|
+
const answer = await ask(`${color.cyan('?')} choose 1-${choices.length}${fallback}: `);
|
|
99
|
+
if (answer === '' && defaultValue !== undefined)
|
|
100
|
+
return defaultValue;
|
|
101
|
+
const byNumber = Number.parseInt(answer, 10);
|
|
102
|
+
if (byNumber >= 1 && byNumber <= choices.length)
|
|
103
|
+
return choices[byNumber - 1].value;
|
|
104
|
+
// Accept the value itself too, so "skip" works as well as "1".
|
|
105
|
+
const byName = choices.find((choice) => choice.value === answer.toLowerCase());
|
|
106
|
+
if (byName)
|
|
107
|
+
return byName.value;
|
|
108
|
+
process.stdout.write(color.yellow(' not one of the options\n'));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Numbered multiple-choice menu: pick any number of the options, by number or
|
|
113
|
+
* by value, separated by spaces or commas, with `all` for every one.
|
|
114
|
+
*
|
|
115
|
+
* `selected` is what is ticked when the menu opens and what an empty answer
|
|
116
|
+
* takes -- which is how a question can carry a sensible default without the
|
|
117
|
+
* default being applied silently. Repeats until the answer names something, so
|
|
118
|
+
* an empty answer with nothing preselected asks again rather than returning a
|
|
119
|
+
* selection of nothing.
|
|
120
|
+
*
|
|
121
|
+
* The result is in menu order however the answer was typed, so two people who
|
|
122
|
+
* choose the same options get the same list.
|
|
123
|
+
*/
|
|
124
|
+
export async function multiSelect(title, choices, selected = []) {
|
|
125
|
+
const ticked = new Set(selected);
|
|
126
|
+
process.stdout.write(`${title}\n`);
|
|
127
|
+
for (const [index, choice] of choices.entries()) {
|
|
128
|
+
const mark = ticked.has(choice.value) ? color.bold('x') : ' ';
|
|
129
|
+
const detail = choice.detail ? color.dim(` -- ${choice.detail}`) : '';
|
|
130
|
+
process.stdout.write(` [${mark}] ${index + 1}) ${choice.label}${detail}\n`);
|
|
131
|
+
}
|
|
132
|
+
const preset = choices
|
|
133
|
+
.map((choice, index) => (ticked.has(choice.value) ? String(index + 1) : undefined))
|
|
134
|
+
.filter((entry) => entry !== undefined);
|
|
135
|
+
const fallback = preset.length > 0 ? color.dim(` [${preset.join(',')}]`) : '';
|
|
136
|
+
for (;;) {
|
|
137
|
+
const answer = await ask(`${color.cyan('?')} choose 1-${choices.length}, or "${ALL_CHOICES}"${fallback}: `);
|
|
138
|
+
if (answer === '' && ticked.size > 0) {
|
|
139
|
+
return choices.filter((choice) => ticked.has(choice.value)).map((choice) => choice.value);
|
|
140
|
+
}
|
|
141
|
+
const picked = readSelection(answer, choices);
|
|
142
|
+
if (picked)
|
|
143
|
+
return picked;
|
|
144
|
+
process.stdout.write(color.yellow(' pick one or more of the options, by number or by name\n'));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/** The word a multiple-choice menu accepts for "every option". */
|
|
148
|
+
export const ALL_CHOICES = 'all';
|
|
149
|
+
/**
|
|
150
|
+
* Read a multiple-choice answer, or undefined when it names nothing or names
|
|
151
|
+
* something that is not on the menu -- either way the question is asked again,
|
|
152
|
+
* because a typo that quietly selected less than was meant is the one outcome
|
|
153
|
+
* a menu must not have.
|
|
154
|
+
*/
|
|
155
|
+
export function readSelection(answer, choices) {
|
|
156
|
+
const tokens = answer.split(/[\s,]+/u).filter(Boolean);
|
|
157
|
+
if (tokens.length === 0)
|
|
158
|
+
return undefined;
|
|
159
|
+
if (tokens.some((token) => token.toLowerCase() === ALL_CHOICES)) {
|
|
160
|
+
return choices.map((choice) => choice.value);
|
|
161
|
+
}
|
|
162
|
+
const picked = new Set();
|
|
163
|
+
for (const token of tokens) {
|
|
164
|
+
const byNumber = Number.parseInt(token, 10);
|
|
165
|
+
if (String(byNumber) === token && byNumber >= 1 && byNumber <= choices.length) {
|
|
166
|
+
picked.add(choices[byNumber - 1].value);
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
const byName = choices.find((choice) => choice.value.toLowerCase() === token.toLowerCase());
|
|
170
|
+
if (!byName)
|
|
171
|
+
return undefined;
|
|
172
|
+
picked.add(byName.value);
|
|
173
|
+
}
|
|
174
|
+
return choices.filter((choice) => picked.has(choice.value)).map((choice) => choice.value);
|
|
175
|
+
}
|
|
176
|
+
/** Yes or no, defaulting to the safe answer unless told otherwise. */
|
|
177
|
+
export async function confirm(question, defaultValue = false) {
|
|
178
|
+
const answer = await select(question, [
|
|
179
|
+
{ value: 'no', label: 'no', detail: 'leave the file as it is' },
|
|
180
|
+
{ value: 'yes', label: 'yes', detail: 'go ahead' },
|
|
181
|
+
], defaultValue ? 'yes' : 'no');
|
|
182
|
+
return answer === 'yes';
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Free-text answer, re-asked until `validate` accepts it. `validate` returns
|
|
186
|
+
* an error message to reject, or undefined to accept.
|
|
187
|
+
*/
|
|
188
|
+
export async function text(question, validate) {
|
|
189
|
+
for (;;) {
|
|
190
|
+
const answer = await ask(`${color.cyan('?')} ${question}: `);
|
|
191
|
+
const problem = validate(answer);
|
|
192
|
+
if (!problem)
|
|
193
|
+
return answer;
|
|
194
|
+
process.stdout.write(color.yellow(` ${problem}\n`));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/core/prompt.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AASpC,4EAA4E;AAC5E,MAAM,UAAU,aAAa;IAC3B,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC;AAED,8EAA8E;AAC9E,gBAAgB;AAChB,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,IAAI,MAAsC,CAAC;AAC3C,IAAI,OAAO,GAAa,EAAE,CAAC;AAC3B,IAAI,OAAyD,CAAC;AAC9D,IAAI,KAAK,GAAG,KAAK,CAAC;AAElB,SAAS,IAAI;IACX,IAAI,MAAM;QAAE,OAAO;IAEnB,yEAAyE;IACzE,4CAA4C;IAC5C,MAAM,GAAG,QAAQ,CAAC,eAAe,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7E,KAAK,GAAG,KAAK,CAAC;IAEd,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;QACjC,MAAM,OAAO,GAAG,OAAO,CAAC;QACxB,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,GAAG,SAAS,CAAC;YACpB,OAAO,CAAC,IAAI,CAAC,CAAC;Q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AC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC5F,CAAC;AAED,sEAAsE;AACtE,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,QAAgB,EAAE,YAAY,GAAG,KAAK;IAClE,MAAM,MAAM,GAAG,MAAM,MAAM,CACzB,QAAQ,EACR;QACE,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,yBAAyB,EAAE;QAC/D,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE;KACnD,EACD,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAC5B,CAAC;IACF,OAAO,MAAM,KAAK,KAAK,CAAC;AAC1B,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CACxB,QAAgB,EAChB,QAA+C;IAE/C,SAAS,CAAC;QACR,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,QAAQ,IAAI,CAAC,CAAC;QAC7D,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;QACjC,IAAI,CAAC,OAAO;YAAE,OAAO,MAAM,CAAC;QAC5B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;IACvD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeping a bundle's internal file references true after installation.
|
|
3
|
+
*
|
|
4
|
+
* Inside a bundle, one file points at another the way the bundle is laid out:
|
|
5
|
+
*
|
|
6
|
+
* skills/dependency-audit/SKILL.md -> `checklist.md`
|
|
7
|
+
* commands/review-pr.md -> `skills/dependency-audit/checklist.md`
|
|
8
|
+
*
|
|
9
|
+
* Installation takes that layout apart. The same two files land in
|
|
10
|
+
* `.claude/skills/dependency-audit/` and `.claude/commands/`, in
|
|
11
|
+
* `.github/skills/` and `.github/prompts/`, in `.pi/skills/` and `.pi/prompts/`
|
|
12
|
+
* -- and on Reasonix a rule is not a file at all, it is a block inside
|
|
13
|
+
* REASONIX.md. A reference written against the bundle's layout is wrong in
|
|
14
|
+
* every one of those places, and wrong in a different way in each.
|
|
15
|
+
*
|
|
16
|
+
* So references are authored against the *bundle*, and rewritten on the way in.
|
|
17
|
+
* The plan already knows where every file is going -- that is what a plan is --
|
|
18
|
+
* so the mapping is read straight off it, and the rewrite happens before
|
|
19
|
+
* conflict detection, which means hashes, receipts, `--dry-run` and `hcm info`
|
|
20
|
+
* all see the text that will actually be on disk.
|
|
21
|
+
*
|
|
22
|
+
* The rewritten form is always relative to the file doing the referring:
|
|
23
|
+
*
|
|
24
|
+
* skills/audit/SKILL.md -> checklist.md `checklist.md`
|
|
25
|
+
* commands/review.md -> skills/audit/x.md `../skills/audit/x.md`
|
|
26
|
+
* context/notes.md -> skills/audit/x.md `.claude/skills/audit/x.md`
|
|
27
|
+
* (a context section lands in
|
|
28
|
+
* CLAUDE.md, at the scope
|
|
29
|
+
* root, with nothing to climb)
|
|
30
|
+
*
|
|
31
|
+
* One rule, not two: a reference means the same thing to whoever reads the file
|
|
32
|
+
* it is written in, wherever that file ended up and whichever scope it went
|
|
33
|
+
* into. `checklist.md` next to a SKILL.md was already relative and comes out
|
|
34
|
+
* unchanged, which is also what the harnesses document for a skill's own
|
|
35
|
+
* supporting files.
|
|
36
|
+
*
|
|
37
|
+
* Nothing is guessed: a reference is rewritten only when it resolves to a file
|
|
38
|
+
* the bundle actually ships and the plan actually installs. One that resolves
|
|
39
|
+
* to a file this target drops -- a rule on a harness with no rule files -- is
|
|
40
|
+
* left alone and reported, because a broken reference the user is told about is
|
|
41
|
+
* better than a plausible one that is wrong.
|
|
42
|
+
*/
|
|
43
|
+
import type { LoadedBundle, PlanAction } from './types.js';
|
|
44
|
+
export interface RefMap {
|
|
45
|
+
/** Bundle-relative POSIX path -> scope-root-relative path it installs to. */
|
|
46
|
+
installed: Map<string, string>;
|
|
47
|
+
/** Every file the bundle ships, whether or not this target installs it. */
|
|
48
|
+
known: Set<string>;
|
|
49
|
+
/** Which action renders which bundle file, so a rewrite knows where it is. */
|
|
50
|
+
origins: Map<PlanAction, string>;
|
|
51
|
+
}
|
|
52
|
+
export interface RefRewrite {
|
|
53
|
+
/** Scope-root-relative path of the file that was rewritten. */
|
|
54
|
+
path: string;
|
|
55
|
+
from: string;
|
|
56
|
+
to: string;
|
|
57
|
+
}
|
|
58
|
+
export interface DroppedRef {
|
|
59
|
+
path: string;
|
|
60
|
+
ref: string;
|
|
61
|
+
reason: string;
|
|
62
|
+
}
|
|
63
|
+
export interface RemapReport {
|
|
64
|
+
/** Rewritten copies; actions with nothing to change are returned unchanged. */
|
|
65
|
+
actions: PlanAction[];
|
|
66
|
+
rewrites: RefRewrite[];
|
|
67
|
+
/** References to bundle files this target does not install. */
|
|
68
|
+
dropped: DroppedRef[];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Pair each action with the bundle file it renders, and each bundle file with
|
|
72
|
+
* where it lands.
|
|
73
|
+
*
|
|
74
|
+
* Targets are not asked to declare any of this. They already answer the only
|
|
75
|
+
* question that matters -- what path does this resource write to -- so the
|
|
76
|
+
* pairing is done here by matching a resource's files against its actions, and
|
|
77
|
+
* a target stays a description of one harness's conventions.
|
|
78
|
+
*/
|
|
79
|
+
export declare function buildRefMap(bundle: LoadedBundle, actions: PlanAction[]): RefMap;
|
|
80
|
+
/**
|
|
81
|
+
* Rewrite every reference in `actions` that points at another file in the same
|
|
82
|
+
* bundle. `only` limits what is rewritten without limiting what the map knows
|
|
83
|
+
* about -- which is what a conflict rename needs, having regenerated one
|
|
84
|
+
* resource's actions after the rest were already done.
|
|
85
|
+
*/
|
|
86
|
+
export declare function remapReferences(bundle: LoadedBundle, actions: PlanAction[], only?: PlanAction[]): RemapReport;
|
|
87
|
+
/** Exported for the install log: one line per file, not one per reference. */
|
|
88
|
+
export declare function summarizeRewrites(rewrites: RefRewrite[]): {
|
|
89
|
+
path: string;
|
|
90
|
+
count: number;
|
|
91
|
+
}[];
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeping a bundle's internal file references true after installation.
|
|
3
|
+
*
|
|
4
|
+
* Inside a bundle, one file points at another the way the bundle is laid out:
|
|
5
|
+
*
|
|
6
|
+
* skills/dependency-audit/SKILL.md -> `checklist.md`
|
|
7
|
+
* commands/review-pr.md -> `skills/dependency-audit/checklist.md`
|
|
8
|
+
*
|
|
9
|
+
* Installation takes that layout apart. The same two files land in
|
|
10
|
+
* `.claude/skills/dependency-audit/` and `.claude/commands/`, in
|
|
11
|
+
* `.github/skills/` and `.github/prompts/`, in `.pi/skills/` and `.pi/prompts/`
|
|
12
|
+
* -- and on Reasonix a rule is not a file at all, it is a block inside
|
|
13
|
+
* REASONIX.md. A reference written against the bundle's layout is wrong in
|
|
14
|
+
* every one of those places, and wrong in a different way in each.
|
|
15
|
+
*
|
|
16
|
+
* So references are authored against the *bundle*, and rewritten on the way in.
|
|
17
|
+
* The plan already knows where every file is going -- that is what a plan is --
|
|
18
|
+
* so the mapping is read straight off it, and the rewrite happens before
|
|
19
|
+
* conflict detection, which means hashes, receipts, `--dry-run` and `hcm info`
|
|
20
|
+
* all see the text that will actually be on disk.
|
|
21
|
+
*
|
|
22
|
+
* The rewritten form is always relative to the file doing the referring:
|
|
23
|
+
*
|
|
24
|
+
* skills/audit/SKILL.md -> checklist.md `checklist.md`
|
|
25
|
+
* commands/review.md -> skills/audit/x.md `../skills/audit/x.md`
|
|
26
|
+
* context/notes.md -> skills/audit/x.md `.claude/skills/audit/x.md`
|
|
27
|
+
* (a context section lands in
|
|
28
|
+
* CLAUDE.md, at the scope
|
|
29
|
+
* root, with nothing to climb)
|
|
30
|
+
*
|
|
31
|
+
* One rule, not two: a reference means the same thing to whoever reads the file
|
|
32
|
+
* it is written in, wherever that file ended up and whichever scope it went
|
|
33
|
+
* into. `checklist.md` next to a SKILL.md was already relative and comes out
|
|
34
|
+
* unchanged, which is also what the harnesses document for a skill's own
|
|
35
|
+
* supporting files.
|
|
36
|
+
*
|
|
37
|
+
* Nothing is guessed: a reference is rewritten only when it resolves to a file
|
|
38
|
+
* the bundle actually ships and the plan actually installs. One that resolves
|
|
39
|
+
* to a file this target drops -- a rule on a harness with no rule files -- is
|
|
40
|
+
* left alone and reported, because a broken reference the user is told about is
|
|
41
|
+
* better than a plausible one that is wrong.
|
|
42
|
+
*/
|
|
43
|
+
import { extractRefs, INSTALL_POLICY, looksLikePath } from './refs.js';
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
// Building the map
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
/**
|
|
48
|
+
* Pair each action with the bundle file it renders, and each bundle file with
|
|
49
|
+
* where it lands.
|
|
50
|
+
*
|
|
51
|
+
* Targets are not asked to declare any of this. They already answer the only
|
|
52
|
+
* question that matters -- what path does this resource write to -- so the
|
|
53
|
+
* pairing is done here by matching a resource's files against its actions, and
|
|
54
|
+
* a target stays a description of one harness's conventions.
|
|
55
|
+
*/
|
|
56
|
+
export function buildRefMap(bundle, actions) {
|
|
57
|
+
const installed = new Map();
|
|
58
|
+
const known = new Set();
|
|
59
|
+
const origins = new Map();
|
|
60
|
+
for (const resource of bundle.resources) {
|
|
61
|
+
for (const bundlePath of resourceFiles(resource))
|
|
62
|
+
known.add(bundlePath);
|
|
63
|
+
}
|
|
64
|
+
for (const [resource, group] of byResource(actions)) {
|
|
65
|
+
// A skill is many files and many actions; everything else is one file that
|
|
66
|
+
// may imply several writes (a rule on OpenCode is a file *and* a config
|
|
67
|
+
// entry), and only the first of those is the file itself.
|
|
68
|
+
if (resource.kind === 'skill') {
|
|
69
|
+
for (const file of resource.files) {
|
|
70
|
+
const bundlePath = `${resource.bundlePath}/${file.relativePath}`;
|
|
71
|
+
const action = group.find((candidate) => candidate.payload.kind === 'file' &&
|
|
72
|
+
!origins.has(candidate) &&
|
|
73
|
+
(candidate.path === file.relativePath ||
|
|
74
|
+
candidate.path.endsWith(`/${file.relativePath}`)));
|
|
75
|
+
if (!action)
|
|
76
|
+
continue;
|
|
77
|
+
origins.set(action, bundlePath);
|
|
78
|
+
installed.set(bundlePath, action.path);
|
|
79
|
+
}
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const primary = group.find((action) => action.payload.kind === 'file') ??
|
|
83
|
+
group.find((action) => action.payload.kind === 'block') ??
|
|
84
|
+
group[0];
|
|
85
|
+
if (!primary)
|
|
86
|
+
continue;
|
|
87
|
+
origins.set(primary, resource.bundlePath);
|
|
88
|
+
installed.set(resource.bundlePath, primary.path);
|
|
89
|
+
// A settings fragment or an MCP server is one bundle file split across many
|
|
90
|
+
// writes into one config; all of them may carry a path to remap.
|
|
91
|
+
for (const action of group) {
|
|
92
|
+
if (!origins.has(action))
|
|
93
|
+
origins.set(action, resource.bundlePath);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return { installed, known, origins };
|
|
97
|
+
}
|
|
98
|
+
/** Every file a resource is made of, as bundle-relative POSIX paths. */
|
|
99
|
+
function resourceFiles(resource) {
|
|
100
|
+
if (resource.kind === 'skill') {
|
|
101
|
+
return resource.files.map((file) => `${resource.bundlePath}/${file.relativePath}`);
|
|
102
|
+
}
|
|
103
|
+
return [resource.bundlePath];
|
|
104
|
+
}
|
|
105
|
+
function byResource(actions) {
|
|
106
|
+
const groups = new Map();
|
|
107
|
+
for (const action of actions) {
|
|
108
|
+
if (!action.resource)
|
|
109
|
+
continue;
|
|
110
|
+
const existing = groups.get(action.resource);
|
|
111
|
+
if (existing)
|
|
112
|
+
existing.push(action);
|
|
113
|
+
else
|
|
114
|
+
groups.set(action.resource, [action]);
|
|
115
|
+
}
|
|
116
|
+
return groups;
|
|
117
|
+
}
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
119
|
+
// Rewriting
|
|
120
|
+
// ---------------------------------------------------------------------------
|
|
121
|
+
/**
|
|
122
|
+
* Rewrite every reference in `actions` that points at another file in the same
|
|
123
|
+
* bundle. `only` limits what is rewritten without limiting what the map knows
|
|
124
|
+
* about -- which is what a conflict rename needs, having regenerated one
|
|
125
|
+
* resource's actions after the rest were already done.
|
|
126
|
+
*/
|
|
127
|
+
export function remapReferences(bundle, actions, only) {
|
|
128
|
+
const map = buildRefMap(bundle, actions);
|
|
129
|
+
const rewriting = new Set(only ?? actions);
|
|
130
|
+
const rewrites = [];
|
|
131
|
+
const dropped = [];
|
|
132
|
+
const rewritten = actions.map((action) => {
|
|
133
|
+
if (!rewriting.has(action))
|
|
134
|
+
return action;
|
|
135
|
+
const from = map.origins.get(action);
|
|
136
|
+
if (from === undefined)
|
|
137
|
+
return action;
|
|
138
|
+
const { payload } = action;
|
|
139
|
+
if (payload.kind === 'file' && typeof payload.contents === 'string') {
|
|
140
|
+
const result = remapText(payload.contents, from, action.path, map);
|
|
141
|
+
collect(result, action.path, rewrites, dropped);
|
|
142
|
+
if (result.text === payload.contents)
|
|
143
|
+
return action;
|
|
144
|
+
return { ...action, payload: { ...payload, contents: result.text } };
|
|
145
|
+
}
|
|
146
|
+
if (payload.kind === 'block') {
|
|
147
|
+
const result = remapText(payload.body, from, action.path, map);
|
|
148
|
+
collect(result, action.path, rewrites, dropped);
|
|
149
|
+
if (result.text === payload.body)
|
|
150
|
+
return action;
|
|
151
|
+
return { ...action, payload: { ...payload, body: result.text } };
|
|
152
|
+
}
|
|
153
|
+
// MCP servers and settings fragments: a path can be an argument, a cwd or
|
|
154
|
+
// an entry in an allowlist. Only whole string values that name a bundle
|
|
155
|
+
// file are touched -- nothing here goes looking inside a command line.
|
|
156
|
+
if (payload.kind === 'json-value') {
|
|
157
|
+
const result = remapJson(payload.value, from, action.path, map);
|
|
158
|
+
collect(result, action.path, rewrites, dropped);
|
|
159
|
+
if (!result.changed)
|
|
160
|
+
return action;
|
|
161
|
+
return { ...action, payload: { ...payload, value: result.value } };
|
|
162
|
+
}
|
|
163
|
+
if (payload.kind === 'json-array-item') {
|
|
164
|
+
const result = remapJson(payload.items, from, action.path, map);
|
|
165
|
+
collect(result, action.path, rewrites, dropped);
|
|
166
|
+
if (!result.changed)
|
|
167
|
+
return action;
|
|
168
|
+
return { ...action, payload: { ...payload, items: result.value } };
|
|
169
|
+
}
|
|
170
|
+
return action;
|
|
171
|
+
});
|
|
172
|
+
return { actions: rewritten, rewrites, dropped };
|
|
173
|
+
}
|
|
174
|
+
function collect(result, at, rewrites, dropped) {
|
|
175
|
+
for (const rewrite of result.rewrites)
|
|
176
|
+
rewrites.push({ path: at, ...rewrite });
|
|
177
|
+
for (const miss of result.dropped)
|
|
178
|
+
dropped.push({ path: at, ...miss });
|
|
179
|
+
}
|
|
180
|
+
function remapText(text, from, installedFrom, map) {
|
|
181
|
+
const found = extractRefs(from, text, INSTALL_POLICY);
|
|
182
|
+
const rewrites = [];
|
|
183
|
+
const dropped = [];
|
|
184
|
+
const edits = [];
|
|
185
|
+
for (const ref of found) {
|
|
186
|
+
const outcome = translate(ref.ref, from, installedFrom, map);
|
|
187
|
+
if (outcome.kind === 'dropped') {
|
|
188
|
+
dropped.push({ ref: ref.ref, reason: outcome.reason });
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (outcome.kind !== 'rewrite')
|
|
192
|
+
continue;
|
|
193
|
+
edits.push({ start: ref.start, end: ref.end, value: outcome.to });
|
|
194
|
+
rewrites.push({ from: ref.ref, to: outcome.to });
|
|
195
|
+
}
|
|
196
|
+
// Back to front, so an earlier edit cannot move a later offset. Overlapping
|
|
197
|
+
// candidates (a link inside inline code) are applied once, outermost wins.
|
|
198
|
+
let updated = text;
|
|
199
|
+
let boundary = text.length;
|
|
200
|
+
for (const edit of edits.sort((a, b) => b.start - a.start)) {
|
|
201
|
+
if (edit.end > boundary)
|
|
202
|
+
continue;
|
|
203
|
+
updated = updated.slice(0, edit.start) + edit.value + updated.slice(edit.end);
|
|
204
|
+
boundary = edit.start;
|
|
205
|
+
}
|
|
206
|
+
return { text: updated, rewrites, dropped };
|
|
207
|
+
}
|
|
208
|
+
function remapJson(value, from, installedFrom, map) {
|
|
209
|
+
const rewrites = [];
|
|
210
|
+
const dropped = [];
|
|
211
|
+
let changed = false;
|
|
212
|
+
const walk = (node) => {
|
|
213
|
+
if (typeof node === 'string') {
|
|
214
|
+
if (!looksLikePath(node, 'config'))
|
|
215
|
+
return node;
|
|
216
|
+
const outcome = translate(node, from, installedFrom, map);
|
|
217
|
+
if (outcome.kind === 'dropped') {
|
|
218
|
+
dropped.push({ ref: node, reason: outcome.reason });
|
|
219
|
+
return node;
|
|
220
|
+
}
|
|
221
|
+
if (outcome.kind !== 'rewrite')
|
|
222
|
+
return node;
|
|
223
|
+
changed = true;
|
|
224
|
+
rewrites.push({ from: node, to: outcome.to });
|
|
225
|
+
return outcome.to;
|
|
226
|
+
}
|
|
227
|
+
if (Array.isArray(node))
|
|
228
|
+
return node.map(walk);
|
|
229
|
+
if (node && typeof node === 'object') {
|
|
230
|
+
return Object.fromEntries(Object.entries(node).map(([key, item]) => [key, walk(item)]));
|
|
231
|
+
}
|
|
232
|
+
return node;
|
|
233
|
+
};
|
|
234
|
+
return { value: walk(value), rewrites, dropped, changed };
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* What one reference should say after installation.
|
|
238
|
+
*
|
|
239
|
+
* Both readings of a relative path are tried, bundle root first -- the same
|
|
240
|
+
* order `hcm refs` resolves in, so what the checker calls resolved is what the
|
|
241
|
+
* installer can remap.
|
|
242
|
+
*/
|
|
243
|
+
function translate(ref, from, installedFrom, map) {
|
|
244
|
+
const trimmed = ref.trim();
|
|
245
|
+
const hash = trimmed.indexOf('#');
|
|
246
|
+
const anchor = hash === -1 ? '' : trimmed.slice(hash);
|
|
247
|
+
const cleaned = (hash === -1 ? trimmed : trimmed.slice(0, hash)).replace(/^\.\//, '');
|
|
248
|
+
if (!cleaned)
|
|
249
|
+
return { kind: 'external' };
|
|
250
|
+
const fromBundleRoot = normalize(cleaned);
|
|
251
|
+
const fromThisFile = normalize(`${posixDirname(from)}/${cleaned}`);
|
|
252
|
+
const bundlePath = [fromBundleRoot, fromThisFile].find((candidate) => candidate !== undefined && map.installed.has(candidate));
|
|
253
|
+
if (bundlePath === undefined) {
|
|
254
|
+
const missing = [fromBundleRoot, fromThisFile].find((candidate) => candidate !== undefined && map.known.has(candidate));
|
|
255
|
+
if (missing !== undefined) {
|
|
256
|
+
return {
|
|
257
|
+
kind: 'dropped',
|
|
258
|
+
reason: 'the file it names is not installed into this harness',
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
return { kind: 'external' };
|
|
262
|
+
}
|
|
263
|
+
const target = map.installed.get(bundlePath);
|
|
264
|
+
const to = relativeTo(installedFrom, target) + anchor;
|
|
265
|
+
return to === trimmed ? { kind: 'unchanged' } : { kind: 'rewrite', to };
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* The path to write for `target` in a file that lives at `installedFrom`,
|
|
269
|
+
* always relative to that file's own directory.
|
|
270
|
+
*
|
|
271
|
+
* .claude/skills/audit/SKILL.md -> .claude/skills/audit/checklist.md
|
|
272
|
+
* becomes `checklist.md`
|
|
273
|
+
* .claude/commands/review.md -> .claude/skills/audit/checklist.md
|
|
274
|
+
* becomes `../skills/audit/checklist.md`
|
|
275
|
+
* CLAUDE.md -> .claude/skills/audit/checklist.md
|
|
276
|
+
* becomes `.claude/skills/audit/checklist.md`
|
|
277
|
+
*
|
|
278
|
+
* One rule for every reference, so a file says the same thing about its
|
|
279
|
+
* neighbours wherever the bundle is installed and whatever scope it went into
|
|
280
|
+
* -- a file at the scope root simply has nothing to climb out of, which is why
|
|
281
|
+
* the third case looks like a rooted path without being one.
|
|
282
|
+
*
|
|
283
|
+
* The rule holds only where paths are resolved against the file that contains
|
|
284
|
+
* them. That is how the harnesses read the markdown they load; it is not
|
|
285
|
+
* necessarily how they read a path *inside a config value*, where the working
|
|
286
|
+
* directory is usually the project root -- see the note in the README.
|
|
287
|
+
*/
|
|
288
|
+
function relativeTo(installedFrom, target) {
|
|
289
|
+
const here = posixDirname(installedFrom).split('/').filter(Boolean);
|
|
290
|
+
const there = target.split('/').filter(Boolean);
|
|
291
|
+
let shared = 0;
|
|
292
|
+
while (shared < here.length && shared < there.length && here[shared] === there[shared]) {
|
|
293
|
+
shared += 1;
|
|
294
|
+
}
|
|
295
|
+
const up = here.slice(shared).map(() => '..');
|
|
296
|
+
const down = there.slice(shared);
|
|
297
|
+
// A file referring to itself: the only way both halves come out empty.
|
|
298
|
+
return [...up, ...down].join('/') || posixBasename(target);
|
|
299
|
+
}
|
|
300
|
+
function posixBasename(value) {
|
|
301
|
+
const at = value.lastIndexOf('/');
|
|
302
|
+
return at === -1 ? value : value.slice(at + 1);
|
|
303
|
+
}
|
|
304
|
+
function posixDirname(value) {
|
|
305
|
+
const at = value.lastIndexOf('/');
|
|
306
|
+
return at === -1 ? '' : value.slice(0, at);
|
|
307
|
+
}
|
|
308
|
+
/** POSIX normalisation that refuses to leave the bundle. */
|
|
309
|
+
function normalize(value) {
|
|
310
|
+
const out = [];
|
|
311
|
+
for (const segment of value.split('/')) {
|
|
312
|
+
if (segment === '' || segment === '.')
|
|
313
|
+
continue;
|
|
314
|
+
if (segment === '..') {
|
|
315
|
+
if (out.length === 0)
|
|
316
|
+
return undefined;
|
|
317
|
+
out.pop();
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
out.push(segment);
|
|
321
|
+
}
|
|
322
|
+
return out.length === 0 ? undefined : out.join('/');
|
|
323
|
+
}
|
|
324
|
+
/** Exported for the install log: one line per file, not one per reference. */
|
|
325
|
+
export function summarizeRewrites(rewrites) {
|
|
326
|
+
const counts = new Map();
|
|
327
|
+
for (const rewrite of rewrites)
|
|
328
|
+
counts.set(rewrite.path, (counts.get(rewrite.path) ?? 0) + 1);
|
|
329
|
+
return [...counts].map(([file, count]) => ({ path: file, count }));
|
|
330
|
+
}
|
|
331
|
+
//# sourceMappingURL=refmap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refmap.js","sourceRoot":"","sources":["../../src/core/refmap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAqCvE,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,MAAoB,EAAE,OAAqB;IACrE,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC5C,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAsB,CAAC;IAE9C,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QACxC,KAAK,MAAM,UAAU,IAAI,aAAa,CAAC,QAAQ,CAAC;YAAE,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC1E,CAAC;IAED,KAAK,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACpD,2EAA2E;QAC3E,wEAAwE;QACxE,0DAA0D;QAC1D,IAAI,QAAQ,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC9B,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;gBAClC,MAAM,UAAU,GAAG,GAAG,QAAQ,CAAC,UAAU,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBACjE,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CACvB,CAAC,SAAS,EAAE,E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