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,384 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `hcm update` — re-read a registered bundle from its origin, then put the new
|
|
3
|
+
* version wherever the old one was.
|
|
4
|
+
*
|
|
5
|
+
* Reinstalling is rollback-then-install rather than write-over-the-top, because
|
|
6
|
+
* a new version is defined as much by what it *removed* as by what it changed:
|
|
7
|
+
* a subagent deleted upstream has to disappear from the harness too. Items you
|
|
8
|
+
* hand-edited since install still block the way they do for `hcm uninstall`,
|
|
9
|
+
* so an update never silently discards local changes.
|
|
10
|
+
*
|
|
11
|
+
* Three ways to say what to update, and the difference between the last two
|
|
12
|
+
* matters:
|
|
13
|
+
*
|
|
14
|
+
* hcm update <bundle> one bundle
|
|
15
|
+
* hcm update everything installed here -- the working default
|
|
16
|
+
* hcm update all every *registered* bundle, installed here or not
|
|
17
|
+
*/
|
|
18
|
+
import { installedDependencies, resolveDependencyGraph, } from '../core/deps.js';
|
|
19
|
+
import { loadBundle } from '../core/bundle.js';
|
|
20
|
+
import { assertFlavorsAvailable, expandFlavors } from '../core/flavors.js';
|
|
21
|
+
import { expandTargets, requireTargetChoice } from '../core/harnesses.js';
|
|
22
|
+
import { color, log } from '../core/logger.js';
|
|
23
|
+
import { emptyOverrides, mergeOverrides, parseAssignments, readParametersFile, } from '../core/parameters.js';
|
|
24
|
+
import { asList, entryDir, readRegistry, refreshEntry, requireEntry } from '../core/registry.js';
|
|
25
|
+
import { findInstallation, readState } from '../core/state.js';
|
|
26
|
+
import { installBundle, installInto, logTargetHeader } from './install.js';
|
|
27
|
+
import { rollbackInstallation } from './uninstall.js';
|
|
28
|
+
/**
|
|
29
|
+
* No argument updates everything installed here; `all` updates everything
|
|
30
|
+
* registered; anything else names bundles -- one, or as many as you like.
|
|
31
|
+
*/
|
|
32
|
+
export async function updateCommand(references, options) {
|
|
33
|
+
const wanted = references === undefined ? undefined : asList(references);
|
|
34
|
+
const chosen = expandTargets(options.targets);
|
|
35
|
+
// Read up front, so a malformed assignment stops the run before the first
|
|
36
|
+
// bundle has been rolled back and reinstalled.
|
|
37
|
+
const parameterOverrides = await collectOverrides(options);
|
|
38
|
+
options = {
|
|
39
|
+
...options,
|
|
40
|
+
decisions: options.decisions ?? new Map(),
|
|
41
|
+
answers: options.answers ?? new Map(),
|
|
42
|
+
parameterOverrides,
|
|
43
|
+
...(chosen ? { targets: chosen } : {}),
|
|
44
|
+
// Three states, not two: no flag reinstalls what each record says, while
|
|
45
|
+
// `--flavor all` is an empty selection, meaning the whole bundle.
|
|
46
|
+
...(options.flavors === undefined ? {} : { flavors: expandFlavors(options.flavors) ?? [] }),
|
|
47
|
+
};
|
|
48
|
+
await assertTargetChosen(wanted, chosen, options);
|
|
49
|
+
const selection = await select(wanted, options);
|
|
50
|
+
if (selection.entries.length === 0) {
|
|
51
|
+
reportEmpty(selection, options);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
// Said once, before the run, so a long update does not bury it: these are
|
|
55
|
+
// installed here but have nowhere to be re-read from.
|
|
56
|
+
for (const name of selection.unregistered) {
|
|
57
|
+
log.warn(`${name} is installed here but not registered; nothing to update it from`);
|
|
58
|
+
log.warn(color.dim(` register its source with: hcm registry add <path|owner/repo>`));
|
|
59
|
+
}
|
|
60
|
+
for (const [index, entry] of selection.entries.entries()) {
|
|
61
|
+
if (index > 0)
|
|
62
|
+
log.plain('');
|
|
63
|
+
await updateOne(entry, options);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* An update reinstalls wherever the ledger says the bundle already is, which in
|
|
68
|
+
* a multi-harness folder is several harnesses at once -- so it needs `-t` for
|
|
69
|
+
* the same reason install and uninstall do.
|
|
70
|
+
*
|
|
71
|
+
* Checked a scope at a time, because presence is a fact about a scope: a folder
|
|
72
|
+
* with three harnesses in it says nothing about the home directory, and
|
|
73
|
+
* `hcm update -s all` covers both.
|
|
74
|
+
*/
|
|
75
|
+
async function assertTargetChosen(references, chosen, options) {
|
|
76
|
+
const records = await installations(options);
|
|
77
|
+
for (const scope of scopesOf(options)) {
|
|
78
|
+
const affected = [
|
|
79
|
+
...new Set(records.filter((record) => record.scope === scope).map((record) => record.target)),
|
|
80
|
+
];
|
|
81
|
+
if (affected.length < 2)
|
|
82
|
+
continue;
|
|
83
|
+
await requireTargetChoice({
|
|
84
|
+
...(chosen ? { chosen } : {}),
|
|
85
|
+
affected,
|
|
86
|
+
command: `hcm update${references?.length ? ` ${references.join(' ')}` : ''}`,
|
|
87
|
+
scope,
|
|
88
|
+
cwd: options.cwd,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* "all" is a literal, not a name -- but a bundle actually called `all` (or with
|
|
94
|
+
* `all` as its id) wins, so nobody is locked out of their own bundle. The same
|
|
95
|
+
* courtesy is why no argument means "what is installed" rather than "all":
|
|
96
|
+
* refreshing a registered bundle that is not installed anywhere does nothing
|
|
97
|
+
* useful, and in a project with a large registry it is a lot of nothing.
|
|
98
|
+
*
|
|
99
|
+
* Several names select several entries, in registry order rather than the order
|
|
100
|
+
* they were typed, so `hcm update 3 1` and `hcm update 1 3` walk the same
|
|
101
|
+
* bundles in the same sequence. A bundle named twice is updated once.
|
|
102
|
+
*/
|
|
103
|
+
async function select(references, options) {
|
|
104
|
+
const registry = await readRegistry();
|
|
105
|
+
if (references !== undefined && references.length > 0) {
|
|
106
|
+
const selected = new Map();
|
|
107
|
+
for (const reference of references) {
|
|
108
|
+
const named = registry.entries.find((entry) => entry.name === reference || entry.id === reference);
|
|
109
|
+
if (named) {
|
|
110
|
+
selected.set(named.id, named);
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (reference === 'all') {
|
|
114
|
+
for (const entry of registry.entries)
|
|
115
|
+
selected.set(entry.id, entry);
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const found = await requireEntry(reference);
|
|
119
|
+
selected.set(found.id, found);
|
|
120
|
+
}
|
|
121
|
+
const entries = registry.entries.filter((entry) => selected.has(entry.id));
|
|
122
|
+
return { entries, unregistered: [], fromLedger: false };
|
|
123
|
+
}
|
|
124
|
+
const installed = new Set((await installations(options)).map((record) => record.bundle));
|
|
125
|
+
// Registry order, not ledger order, so `hcm update` and `hcm update all`
|
|
126
|
+
// walk the same bundles in the same sequence.
|
|
127
|
+
const entries = registry.entries.filter((entry) => installed.has(entry.name));
|
|
128
|
+
const claimed = new Set(entries.map((entry) => entry.name));
|
|
129
|
+
for (const entry of await aliasedEntries(registry.entries, installed, claimed)) {
|
|
130
|
+
entries.push(entry);
|
|
131
|
+
}
|
|
132
|
+
entries.sort((a, b) => registry.entries.indexOf(a) - registry.entries.indexOf(b));
|
|
133
|
+
const unregistered = [...installed].filter((name) => !claimed.has(name)).sort();
|
|
134
|
+
return { entries, unregistered, fromLedger: true };
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Entries whose *manifest* name is installed, when their *registry* name is not.
|
|
138
|
+
*
|
|
139
|
+
* `registry add --name` renames the entry, not the bundle, so an alias records
|
|
140
|
+
* its installation under the manifest name and a name match alone would miss
|
|
141
|
+
* it -- and then report it as unregistered, which is worse than missing it.
|
|
142
|
+
* The real name is only written down inside the bundle, so read it from the
|
|
143
|
+
* copy already on disk: no refresh, no network, and only for the entries a name
|
|
144
|
+
* match did not already account for. An unreadable copy is skipped rather than
|
|
145
|
+
* thrown from, since one broken entry must not stop the other updates.
|
|
146
|
+
*
|
|
147
|
+
* `claimed` is extended in place, so the caller's "installed but not
|
|
148
|
+
* registered" list stays correct.
|
|
149
|
+
*/
|
|
150
|
+
async function aliasedEntries(entries, installed, claimed) {
|
|
151
|
+
if ([...installed].every((name) => claimed.has(name)))
|
|
152
|
+
return [];
|
|
153
|
+
const matched = [];
|
|
154
|
+
for (const entry of entries) {
|
|
155
|
+
if (claimed.has(entry.name))
|
|
156
|
+
continue;
|
|
157
|
+
let name;
|
|
158
|
+
try {
|
|
159
|
+
const dir = await entryDir(entry, { refresh: false });
|
|
160
|
+
name = (await loadBundle(dir, entry.source)).manifest.name;
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
if (!installed.has(name) || claimed.has(name))
|
|
166
|
+
continue;
|
|
167
|
+
claimed.add(name);
|
|
168
|
+
matched.push(entry);
|
|
169
|
+
}
|
|
170
|
+
return matched;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Everything `--param` and `--params-file` said, in one place. Files first,
|
|
174
|
+
* flags second -- the same reading `hcm install` gives them.
|
|
175
|
+
*/
|
|
176
|
+
async function collectOverrides(options) {
|
|
177
|
+
const fromFiles = [];
|
|
178
|
+
for (const file of options.paramsFiles ?? []) {
|
|
179
|
+
fromFiles.push(await readParametersFile(file, options.cwd));
|
|
180
|
+
}
|
|
181
|
+
return mergeOverrides(options.parameterOverrides ?? emptyOverrides(), ...fromFiles, parseAssignments(options.params));
|
|
182
|
+
}
|
|
183
|
+
/** Nothing to do -- say which "nothing" this is, since the fixes differ. */
|
|
184
|
+
function reportEmpty(selection, options) {
|
|
185
|
+
if (!selection.fromLedger) {
|
|
186
|
+
log.info('No bundles registered.');
|
|
187
|
+
log.info(color.dim('Add one with: hcm registry add <path|owner/repo>'));
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
for (const name of selection.unregistered) {
|
|
191
|
+
log.warn(`${name} is installed here but not registered; nothing to update it from`);
|
|
192
|
+
}
|
|
193
|
+
if (selection.unregistered.length === 0) {
|
|
194
|
+
log.info(`No bundles installed in ${scopesOf(options).join(' or ')} scope.`);
|
|
195
|
+
log.info(color.dim('Install one with: hcm install <bundle>'));
|
|
196
|
+
}
|
|
197
|
+
log.info(color.dim('"hcm update all" refreshes every registered bundle.'));
|
|
198
|
+
}
|
|
199
|
+
async function updateOne(entry, options) {
|
|
200
|
+
const { entry: updated, bundle, previousVersion } = await refreshEntry(entry, {
|
|
201
|
+
dryRun: options.dryRun ?? false,
|
|
202
|
+
});
|
|
203
|
+
const version = previousVersion && previousVersion !== bundle.manifest.version
|
|
204
|
+
? `${color.dim(`v${previousVersion}`)} → ${color.bold(`v${bundle.manifest.version}`)}`
|
|
205
|
+
: color.dim(`v${bundle.manifest.version} (unchanged)`);
|
|
206
|
+
log.info(`${color.dim(`[${updated.id}]`)} ${color.bold(updated.name)} ${version}` +
|
|
207
|
+
(updated.dev ? color.yellow(' [dev]') : ''));
|
|
208
|
+
// A `--flavor` this bundle does not have is refused here rather than left to
|
|
209
|
+
// narrow the install to nothing. `hcm update all` can name bundles that have
|
|
210
|
+
// no flavors at all, so this only applies where one was asked for.
|
|
211
|
+
if (options.flavors?.length)
|
|
212
|
+
assertFlavorsAvailable([bundle], options.flavors);
|
|
213
|
+
// Installations are keyed by the manifest name, which `registry add --name`
|
|
214
|
+
// can differ from -- the alias is a registry convenience, not a rename.
|
|
215
|
+
const records = await installedRecords(bundle.manifest.name, options);
|
|
216
|
+
if (records.length === 0) {
|
|
217
|
+
log.info(color.dim(options.dryRun
|
|
218
|
+
? ' not installed anywhere; nothing else would change'
|
|
219
|
+
: ' not installed anywhere; the registered copy is now up to date'));
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
// A new version can require something the old one did not. Those bundles are
|
|
223
|
+
// installed first, exactly as `hcm install` would have done, so the reinstall
|
|
224
|
+
// below lands on a complete set.
|
|
225
|
+
//
|
|
226
|
+
// A dependency that cannot be resolved is reported and the update carries on:
|
|
227
|
+
// `hcm update all` should not stop at the first bundle whose requirement has
|
|
228
|
+
// gone missing, and the installed copy is no worse for being refreshed.
|
|
229
|
+
let graph;
|
|
230
|
+
try {
|
|
231
|
+
graph = await resolveDependencyGraph([bundle], options.cwd, {});
|
|
232
|
+
await installNewDependencies(bundle, graph, records, options);
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
log.warn(` ${error.message}`);
|
|
236
|
+
log.warn(' updating it anyway; run "hcm install" once the dependency is available');
|
|
237
|
+
graph = { order: [], byName: new Map(), hasDependencies: false };
|
|
238
|
+
}
|
|
239
|
+
for (const record of records) {
|
|
240
|
+
logTargetHeader(record.target, { scope: record.scope, cwd: options.cwd });
|
|
241
|
+
await reinstall(record, bundle, graph, options);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Install the dependencies this bundle has gained, into the places it is
|
|
246
|
+
* already installed. Dependencies that are there stay as they are -- updating
|
|
247
|
+
* one bundle should not silently update another; `hcm update all` does that.
|
|
248
|
+
*/
|
|
249
|
+
async function installNewDependencies(bundle, graph, records, options) {
|
|
250
|
+
// Walked in graph order, so a dependency's own dependencies come first and
|
|
251
|
+
// a whole new subtree can arrive in one update.
|
|
252
|
+
for (const resolved of graph.order) {
|
|
253
|
+
const name = resolved.bundle.manifest.name;
|
|
254
|
+
if (name === bundle.manifest.name)
|
|
255
|
+
continue;
|
|
256
|
+
const where = { scopes: new Set(), targets: new Set() };
|
|
257
|
+
for (const record of records) {
|
|
258
|
+
const installed = await findInstallation(record.scope, options.cwd, name, record.target);
|
|
259
|
+
if (installed)
|
|
260
|
+
continue;
|
|
261
|
+
where.scopes.add(record.scope);
|
|
262
|
+
where.targets.add(record.target);
|
|
263
|
+
}
|
|
264
|
+
if (where.scopes.size === 0)
|
|
265
|
+
continue;
|
|
266
|
+
log.info(color.dim(` ${name} v${resolved.bundle.manifest.version} is now required and not installed here`));
|
|
267
|
+
// Installed from the copy already resolved rather than by name: a
|
|
268
|
+
// dependency found beside its dependent, or at the source its manifest
|
|
269
|
+
// names, need never have been registered on this machine.
|
|
270
|
+
for (const scope of where.scopes) {
|
|
271
|
+
await installBundle(resolved.bundle, {
|
|
272
|
+
scope,
|
|
273
|
+
cwd: options.cwd,
|
|
274
|
+
targets: [...where.targets],
|
|
275
|
+
dryRun: options.dryRun ?? false,
|
|
276
|
+
force: options.force ?? false,
|
|
277
|
+
...(options.onConflict ? { onConflict: options.onConflict } : {}),
|
|
278
|
+
...(options.decisions ? { decisions: options.decisions } : {}),
|
|
279
|
+
...(options.answers ? { answers: options.answers } : {}),
|
|
280
|
+
...(options.targetOptions ? { targetOptions: options.targetOptions } : {}),
|
|
281
|
+
// A dependency arriving mid-update is narrowed the same way the run
|
|
282
|
+
// is; one that has no such flavor is all common part, so it comes
|
|
283
|
+
// whole. See `core/flavors.ts`.
|
|
284
|
+
...(options.flavors?.length ? { flavors: options.flavors } : {}),
|
|
285
|
+
// It has never been installed here, so it has nothing recorded and
|
|
286
|
+
// asks for its own parameters from scratch -- with whatever this run
|
|
287
|
+
// supplied on the command line available to answer them.
|
|
288
|
+
...(options.parameterOverrides
|
|
289
|
+
? { parameterOverrides: options.parameterOverrides }
|
|
290
|
+
: {}),
|
|
291
|
+
...(options.prompt === false ? { prompt: false } : {}),
|
|
292
|
+
}, {
|
|
293
|
+
auto: true,
|
|
294
|
+
dependencies: installedDependencies(resolved.bundle, graph),
|
|
295
|
+
requiredBy: resolved.requiredBy,
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/** Replace one installation with the refreshed bundle. */
|
|
301
|
+
async function reinstall(record, bundle, graph, options) {
|
|
302
|
+
const rolledBack = await rollbackInstallation(record, {
|
|
303
|
+
cwd: options.cwd,
|
|
304
|
+
dryRun: options.dryRun ?? false,
|
|
305
|
+
force: options.force ?? false,
|
|
306
|
+
// All of it or none of it. An update that could not remove the old version
|
|
307
|
+
// will not write the new one over the top -- so a removal that stopped
|
|
308
|
+
// half way would leave the harness with neither, which is exactly the
|
|
309
|
+
// local work the block was there to protect. See `rollbackInstallation`.
|
|
310
|
+
allOrNothing: true,
|
|
311
|
+
});
|
|
312
|
+
// A dry run reports the removal and then the install it *would* have done;
|
|
313
|
+
// a real run that could not remove the old items must not write new ones on
|
|
314
|
+
// top of them, or the two versions would be interleaved with no way back.
|
|
315
|
+
if (!rolledBack && !options.dryRun) {
|
|
316
|
+
log.warn(' skipped: the installed version is still there, unchanged');
|
|
317
|
+
log.warn(color.dim(' revert the edit(s), or re-run with --force to replace them'));
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
await installInto(bundle, record.target, {
|
|
321
|
+
scope: record.scope,
|
|
322
|
+
cwd: options.cwd,
|
|
323
|
+
dryRun: options.dryRun ?? false,
|
|
324
|
+
force: options.force ?? false,
|
|
325
|
+
// What was recorded, unless this run says otherwise -- so `hcm update` puts
|
|
326
|
+
// the new version exactly where the old one was, and no more of it.
|
|
327
|
+
targetOptions: options.targetOptions ?? record.targetOptions ?? {},
|
|
328
|
+
flavors: options.flavors ?? record.flavors ?? [],
|
|
329
|
+
// Handed over rather than looked up: the rollback above has already taken
|
|
330
|
+
// the record away, so by now there is nothing left on disk to read them
|
|
331
|
+
// from. This is what makes an update render the new version with the same
|
|
332
|
+
// values the old one had.
|
|
333
|
+
...(record.parameters ? { recordedParameters: record.parameters } : {}),
|
|
334
|
+
...(options.parameterOverrides ? { parameterOverrides: options.parameterOverrides } : {}),
|
|
335
|
+
...(options.reconfigure ? { reconfigure: true } : {}),
|
|
336
|
+
...(options.prompt === false ? { prompt: false } : {}),
|
|
337
|
+
...(options.onConflict ? { onConflict: options.onConflict } : {}),
|
|
338
|
+
...(options.decisions ? { decisions: options.decisions } : {}),
|
|
339
|
+
...(options.answers ? { answers: options.answers } : {}),
|
|
340
|
+
}, {
|
|
341
|
+
// An update does not change why a bundle is here, only what it holds.
|
|
342
|
+
...(record.auto ? { auto: true } : {}),
|
|
343
|
+
dependencies: resolvedDependencies(record, bundle, graph),
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* What to record as this installation's dependencies. Normally the versions
|
|
348
|
+
* just resolved -- but if resolution failed we keep what was recorded before,
|
|
349
|
+
* rather than writing an empty list that would let `hcm uninstall` take away a
|
|
350
|
+
* bundle something still needs.
|
|
351
|
+
*/
|
|
352
|
+
function resolvedDependencies(record, bundle, graph) {
|
|
353
|
+
const resolved = installedDependencies(bundle, graph);
|
|
354
|
+
if (resolved.length > 0 || bundle.dependencies.length === 0)
|
|
355
|
+
return resolved;
|
|
356
|
+
return record.dependencies ?? [];
|
|
357
|
+
}
|
|
358
|
+
/** Every installation of a bundle, filtered by the requested scopes and targets. */
|
|
359
|
+
async function installedRecords(bundle, options) {
|
|
360
|
+
return (await installations(options)).filter((record) => record.bundle === bundle);
|
|
361
|
+
}
|
|
362
|
+
/** The scopes this run covers. Omitted means both, as it does for `hcm list`. */
|
|
363
|
+
function scopesOf(options) {
|
|
364
|
+
return options.scope === undefined || options.scope === 'all'
|
|
365
|
+
? ['project', 'user']
|
|
366
|
+
: [options.scope];
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Every installation in scope, filtered by `--target`. One place, because the
|
|
370
|
+
* bare `hcm update` picks *which bundles to update* from the same ledger view
|
|
371
|
+
* that then decides *where each one goes* -- if those two disagreed, a bundle
|
|
372
|
+
* could be selected here and updated nowhere.
|
|
373
|
+
*/
|
|
374
|
+
async function installations(options) {
|
|
375
|
+
const records = [];
|
|
376
|
+
for (const scope of scopesOf(options)) {
|
|
377
|
+
const state = await readState(scope, options.cwd);
|
|
378
|
+
records.push(...state.installations);
|
|
379
|
+
}
|
|
380
|
+
if (!options.targets?.length)
|
|
381
|
+
return records;
|
|
382
|
+
return records.filter((record) => options.targets?.includes(record.target));
|
|
383
|
+
}
|
|
384
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAEL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EACL,cAAc,EACd,cAAc,EAEd,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACjG,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAS/D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AA4CtD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,UAAyC,EACzC,OAAsB;IAEtB,MAAM,MAAM,GAAG,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC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C;QACtC,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QAClD,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC;IACvC,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM;QAAE,OAAO,OAAO,CAAC;IAC7C,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { validateBundle } from '../core/bundle.js';
|
|
2
|
+
import { resolveDependencyGraph } from '../core/deps.js';
|
|
3
|
+
import { color, log } from '../core/logger.js';
|
|
4
|
+
import { resolveBundles } from '../core/registry.js';
|
|
5
|
+
export async function validateCommand(reference, options) {
|
|
6
|
+
const bundles = await resolveBundles(reference, options.cwd);
|
|
7
|
+
let ok = true;
|
|
8
|
+
for (const bundle of bundles) {
|
|
9
|
+
const problems = [...validateBundle(bundle), ...(await dependencyProblems(bundle, options.cwd))];
|
|
10
|
+
log.plain(`${color.bold(bundle.manifest.name)} ${color.dim(`v${bundle.manifest.version}`)}`);
|
|
11
|
+
log.plain(color.dim(` ${bundle.resources.length} resource(s)`));
|
|
12
|
+
if (problems.length === 0) {
|
|
13
|
+
log.success(' No problems found.');
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
ok = false;
|
|
17
|
+
for (const problem of problems)
|
|
18
|
+
log.warn(` ${problem}`);
|
|
19
|
+
}
|
|
20
|
+
return ok;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Can everything this bundle requires actually be found from here? Authors hit
|
|
24
|
+
* this the moment they publish: the dependency resolves on their machine
|
|
25
|
+
* because it is registered there, and nowhere else.
|
|
26
|
+
*/
|
|
27
|
+
async function dependencyProblems(bundle, cwd) {
|
|
28
|
+
if (bundle.dependencies.length === 0)
|
|
29
|
+
return [];
|
|
30
|
+
try {
|
|
31
|
+
await resolveDependencyGraph([bundle], cwd);
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
return [error.message];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/commands/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,SAAiB,EAAE,OAAwB;IAC/E,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAC7D,IAAI,EAAE,GAAG,IAAI,CAAC;IAEd,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAEjG,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;QAC7F,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,SAAS,CAAC,MAAM,cAAc,CAAC,CAAC,CAAC;QAEjE,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,GAAG,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;YACpC,SAAS;QACX,CAAC;QAED,EAAE,GAAG,KAAK,CAAC;QACX,KAAK,MAAM,OAAO,IAAI,QAAQ;YAAE,GAAG,CAAC,IAAI,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,kBAAkB,CAAC,MAAoB,EAAE,GAAW;IACjE,IAAI,MAAM,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAChD,IAAI,CAAC;QACH,MAAM,sBAAsB,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC;QAC5C,OAAO,EAAE,CAAC;IACZ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAE,KAAe,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundle loading.
|
|
3
|
+
*
|
|
4
|
+
* A bundle is just a directory with a manifest and a handful of
|
|
5
|
+
* conventionally-named subdirectories. Resources are discovered from the
|
|
6
|
+
* layout -- there is no resource list to keep in sync by hand.
|
|
7
|
+
*
|
|
8
|
+
* my-bundle/
|
|
9
|
+
* hcm.yaml
|
|
10
|
+
* subagents/code-reviewer.md
|
|
11
|
+
* skills/security-review/SKILL.md
|
|
12
|
+
* commands/fix-issue.md
|
|
13
|
+
* rules/testing.md
|
|
14
|
+
* context/PROJECT.md
|
|
15
|
+
* mcp/github.json
|
|
16
|
+
* settings/settings.json
|
|
17
|
+
* assets/logo.png
|
|
18
|
+
*/
|
|
19
|
+
import { type BundleDependency, type BundleManifest, type BundleSource, type LoadedBundle } from './types.js';
|
|
20
|
+
export declare const MANIFEST_NAMES: string[];
|
|
21
|
+
export declare function findManifest(root: string): Promise<string | undefined>;
|
|
22
|
+
export declare function loadManifest(root: string): Promise<BundleManifest>;
|
|
23
|
+
/**
|
|
24
|
+
* Accept both ways of writing a dependency and return the one shape the rest of
|
|
25
|
+
* hcm works with:
|
|
26
|
+
*
|
|
27
|
+
* dependencies:
|
|
28
|
+
* - jira-board # any version
|
|
29
|
+
* - team-conventions@^2.0.0 # a range, npm-style
|
|
30
|
+
* - name: db-kit
|
|
31
|
+
* version: ">=1.2 <2"
|
|
32
|
+
* source: acme/agent-kits/db-kit
|
|
33
|
+
*/
|
|
34
|
+
export declare function normalizeDependencies(manifest: BundleManifest, where?: string): BundleDependency[];
|
|
35
|
+
/**
|
|
36
|
+
* Find the bundles in a directory.
|
|
37
|
+
*
|
|
38
|
+
* A directory is either a bundle itself, or a *collection*: a folder whose
|
|
39
|
+
* immediate children are each a bundle. That covers the common case of one
|
|
40
|
+
* repository holding several kits side by side. Only one level is searched --
|
|
41
|
+
* nesting collections inside collections would make `hcm install <path>`
|
|
42
|
+
* unpredictable.
|
|
43
|
+
*
|
|
44
|
+
* Returns absolute directory paths, sorted, empty when nothing was found.
|
|
45
|
+
*/
|
|
46
|
+
export declare function discoverBundleDirs(root: string): Promise<string[]>;
|
|
47
|
+
export declare function loadBundle(root: string, source?: BundleSource): Promise<LoadedBundle>;
|
|
48
|
+
/** Basic sanity checks, surfaced by `hcm validate`. */
|
|
49
|
+
export declare function validateBundle(bundle: LoadedBundle): string[];
|