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 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAA6B,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAOhD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAsB;IACxD,MAAM,MAAM,GACV,OAAO,CAAC,KAAK,KAAK,KAAK,IAAI,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GAAG;gBACd,GAAG,IAAI,GAAG,CACR,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CACxF;aACY,CAAC;YAChB,GAAG,CAAC,KAAK,CACP,KAAK,CAAC,GAAG,CACP,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,cAAc;gBACxC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM;gBAC5D,oDAAoD,CACvD,CACF,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Show the supported harnesses and where each scope writes on this machine --
|
|
3
|
+
* and, since a folder can be used by several of them at once, which ones are
|
|
4
|
+
* actually set up here and which files they would be sharing.
|
|
5
|
+
*/
|
|
6
|
+
export declare function targetsCommand(options: {
|
|
7
|
+
cwd: string;
|
|
8
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { detectHarnesses, describeEvidence } from '../core/harnesses.js';
|
|
2
|
+
import { color, log } from '../core/logger.js';
|
|
3
|
+
import { allSharedFiles } from '../core/overlap.js';
|
|
4
|
+
import { getTarget, TARGETS } from '../targets/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* Show the supported harnesses and where each scope writes on this machine --
|
|
7
|
+
* and, since a folder can be used by several of them at once, which ones are
|
|
8
|
+
* actually set up here and which files they would be sharing.
|
|
9
|
+
*/
|
|
10
|
+
export async function targetsCommand(options) {
|
|
11
|
+
const detected = await detectHarnesses('project', options.cwd);
|
|
12
|
+
const found = new Map(detected.map((harness) => [harness.target, harness]));
|
|
13
|
+
for (const target of TARGETS) {
|
|
14
|
+
const here = found.get(target.id);
|
|
15
|
+
const mark = here ? `${color.green(' ●')} ${color.dim('in this folder')}` : '';
|
|
16
|
+
log.plain(`${color.bold(target.title)} ${color.dim(`(${target.id})`)}${mark}`);
|
|
17
|
+
log.plain(color.dim(` docs: ${target.docs}`));
|
|
18
|
+
for (const scope of ['project', 'user']) {
|
|
19
|
+
log.plain(color.dim(` ${scope.padEnd(8)} ${target.scopeRoot(scope, options.cwd)}`));
|
|
20
|
+
}
|
|
21
|
+
log.plain(color.dim(` kinds: ${target.supports.join(', ')}`));
|
|
22
|
+
if (here)
|
|
23
|
+
log.plain(color.dim(` found: ${describeEvidence(here)}`));
|
|
24
|
+
for (const [index, note] of (target.notes ?? []).entries()) {
|
|
25
|
+
log.plain(color.dim(` ${index === 0 ? 'note: ' : ' '} ${note}`));
|
|
26
|
+
}
|
|
27
|
+
log.plain('');
|
|
28
|
+
}
|
|
29
|
+
reportSharedFiles(detected, options.cwd);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The files that are not any one harness's.
|
|
33
|
+
*
|
|
34
|
+
* Listed for the harnesses actually here rather than for all five, because that
|
|
35
|
+
* is the list that matters: an overlap between two harnesses you do not use is
|
|
36
|
+
* a fact about the world, not about this folder.
|
|
37
|
+
*/
|
|
38
|
+
function reportSharedFiles(detected, cwd) {
|
|
39
|
+
if (detected.length < 2)
|
|
40
|
+
return;
|
|
41
|
+
const here = new Set(detected.map((harness) => harness.target));
|
|
42
|
+
const shared = allSharedFiles('project', cwd).filter((file) => {
|
|
43
|
+
const readers = new Set(file.readers.map((reader) => reader.target));
|
|
44
|
+
return [...readers].filter((id) => here.has(id)).length > 1;
|
|
45
|
+
});
|
|
46
|
+
log.plain(color.bold('Shared between the harnesses in this folder'));
|
|
47
|
+
if (shared.length === 0) {
|
|
48
|
+
log.plain(color.dim(' nothing: each of them writes only its own files'));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
for (const file of shared) {
|
|
52
|
+
const readers = file.readers
|
|
53
|
+
.filter((reader) => here.has(reader.target))
|
|
54
|
+
.map((reader) => `${getTarget(reader.target).title} (${reader.kinds.join(', ')})`);
|
|
55
|
+
log.plain(` ${color.bold(file.readers[0]?.path ?? file.key)} ${color.dim(readers.join(' · '))}`);
|
|
56
|
+
}
|
|
57
|
+
log.plain('');
|
|
58
|
+
log.plain(color.dim(' One file, several readers: what one harness installs there the others also see, ' +
|
|
59
|
+
'and it is removed only when the last bundle claiming it is uninstalled.'));
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=targets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"targets.js","sourceRoot":"","sources":["../../src/commands/targets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAwB,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC/F,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAwB;IAC3D,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAC/D,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAE5E,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAClC,MAAM,IAAI,GAAG,IAAI,CAAC,CA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CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;aAC3C,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACrF,GAAG,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;IACrG,CAAC;IAED,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACd,GAAG,CAAC,KAAK,CACP,KAAK,CAAC,GAAG,CACP,oFAAoF;QAClF,yEAAyE,CAC5E,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `hcm uninstall` -- take back exactly what a bundle installed.
|
|
3
|
+
*
|
|
4
|
+
* Two things stand between a record and its removal:
|
|
5
|
+
*
|
|
6
|
+
* dependents another installed bundle requires this one. Removing it would
|
|
7
|
+
* leave that bundle referring to subagents and servers that are
|
|
8
|
+
* no longer there, so it is refused unless you say what to do.
|
|
9
|
+
* claims an individual item is also claimed by an installation that is
|
|
10
|
+
* staying -- a shared asset, a permission two bundles both ask
|
|
11
|
+
* for. Those items are held; the last uninstall removes them.
|
|
12
|
+
*
|
|
13
|
+
* And one thing follows it: a dependency that was pulled in automatically and
|
|
14
|
+
* is now needed by nobody goes too, the way it arrived.
|
|
15
|
+
*/
|
|
16
|
+
import { type InstallationRecord, type Scope, type TargetId } from '../core/types.js';
|
|
17
|
+
export interface UninstallOptions {
|
|
18
|
+
targets?: string[];
|
|
19
|
+
scope: Scope;
|
|
20
|
+
dryRun?: boolean;
|
|
21
|
+
force?: boolean;
|
|
22
|
+
/** Remove the bundles that depend on this one as well. */
|
|
23
|
+
cascade?: boolean;
|
|
24
|
+
/** Remove it anyway, leaving its dependents installed but incomplete. */
|
|
25
|
+
ignoreDependents?: boolean;
|
|
26
|
+
/** Keep dependencies that were pulled in automatically and are now unused. */
|
|
27
|
+
keepOrphans?: boolean;
|
|
28
|
+
/** Harnesses set up in this folder; see `core/harnesses.ts`. Detected when absent. */
|
|
29
|
+
presentTargets?: TargetId[];
|
|
30
|
+
cwd: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Uninstall one bundle, or several.
|
|
34
|
+
*
|
|
35
|
+
* Several at once is not the same as several commands. The removals are worked
|
|
36
|
+
* out together, so a bundle that depends on another one being removed in the
|
|
37
|
+
* same breath is not a reason to stop, and an item both of them claim comes out
|
|
38
|
+
* once the last of them has gone -- rather than being held by a claim that this
|
|
39
|
+
* very command is about to drop.
|
|
40
|
+
*/
|
|
41
|
+
export declare function uninstallCommand(references: string | string[], options: UninstallOptions): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Roll one installation back and drop its ledger entry. Returns false when
|
|
44
|
+
* hand-edited items blocked it, or when this was a dry run -- `hcm update`
|
|
45
|
+
* uses that to decide whether reinstalling on top is safe.
|
|
46
|
+
*
|
|
47
|
+
* Blocked means *partly* removed by default, which is what `hcm uninstall`
|
|
48
|
+
* wants: you asked for the items to go, so the seven that can go should go and
|
|
49
|
+
* the one that cannot should say so. `allOrNothing` is for the caller that
|
|
50
|
+
* cannot live with a half-removal -- see below.
|
|
51
|
+
*/
|
|
52
|
+
export declare function rollbackInstallation(record: InstallationRecord, options: {
|
|
53
|
+
cwd: string;
|
|
54
|
+
dryRun?: boolean;
|
|
55
|
+
force?: boolean;
|
|
56
|
+
/** Other installations going away in the same run; their claims do not count. */
|
|
57
|
+
alsoRemoving?: string[];
|
|
58
|
+
/** Harnesses set up in this folder; see `core/harnesses.ts`. Detected when absent. */
|
|
59
|
+
presentTargets?: TargetId[];
|
|
60
|
+
/**
|
|
61
|
+
* Remove everything or nothing: if any item is blocked, leave the whole
|
|
62
|
+
* installation exactly as it is.
|
|
63
|
+
*
|
|
64
|
+
* `hcm update` needs this. It is rollback-then-install, and it refuses to
|
|
65
|
+
* install over a removal that did not finish -- so with the default
|
|
66
|
+
* behaviour one hand-edited file would take the rest of the installation
|
|
67
|
+
* away and put nothing back, which is the opposite of the promise that an
|
|
68
|
+
* update never discards local changes.
|
|
69
|
+
*/
|
|
70
|
+
allOrNothing?: boolean;
|
|
71
|
+
}): Promise<boolean>;
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `hcm uninstall` -- take back exactly what a bundle installed.
|
|
3
|
+
*
|
|
4
|
+
* Two things stand between a record and its removal:
|
|
5
|
+
*
|
|
6
|
+
* dependents another installed bundle requires this one. Removing it would
|
|
7
|
+
* leave that bundle referring to subagents and servers that are
|
|
8
|
+
* no longer there, so it is refused unless you say what to do.
|
|
9
|
+
* claims an individual item is also claimed by an installation that is
|
|
10
|
+
* staying -- a shared asset, a permission two bundles both ask
|
|
11
|
+
* for. Those items are held; the last uninstall removes them.
|
|
12
|
+
*
|
|
13
|
+
* And one thing follows it: a dependency that was pulled in automatically and
|
|
14
|
+
* is now needed by nobody goes too, the way it arrived.
|
|
15
|
+
*/
|
|
16
|
+
import { forgetContext } from '../core/context.js';
|
|
17
|
+
import { HcmError } from '../core/errors.js';
|
|
18
|
+
import { detectHarnesses, expandTargets, requireTargetChoice } from '../core/harnesses.js';
|
|
19
|
+
import { color, log } from '../core/logger.js';
|
|
20
|
+
import { describeReaders, sharedFileNotices } from '../core/overlap.js';
|
|
21
|
+
import { asList, resolveInstalledName } from '../core/registry.js';
|
|
22
|
+
import { rollback } from '../core/rollback.js';
|
|
23
|
+
import { collectClaims, findDependents, findInstallation, findInstallations, removeInstallation, } from '../core/state.js';
|
|
24
|
+
import { describeReceipt, } from '../core/types.js';
|
|
25
|
+
import { getTarget } from '../targets/index.js';
|
|
26
|
+
const STATUS_STYLE = {
|
|
27
|
+
removed: color.green,
|
|
28
|
+
restored: color.green,
|
|
29
|
+
missing: color.dim,
|
|
30
|
+
partial: color.yellow,
|
|
31
|
+
modified: color.yellow,
|
|
32
|
+
kept: color.dim,
|
|
33
|
+
held: color.cyan,
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Uninstall one bundle, or several.
|
|
37
|
+
*
|
|
38
|
+
* Several at once is not the same as several commands. The removals are worked
|
|
39
|
+
* out together, so a bundle that depends on another one being removed in the
|
|
40
|
+
* same breath is not a reason to stop, and an item both of them claim comes out
|
|
41
|
+
* once the last of them has gone -- rather than being held by a claim that this
|
|
42
|
+
* very command is about to drop.
|
|
43
|
+
*/
|
|
44
|
+
export async function uninstallCommand(references, options) {
|
|
45
|
+
const wanted = asList(references);
|
|
46
|
+
const chosen = expandTargets(options.targets);
|
|
47
|
+
// Every name is resolved before anything is removed: a typo in the third of
|
|
48
|
+
// three should not leave the first two uninstalled.
|
|
49
|
+
const selected = [];
|
|
50
|
+
const bundleNames = new Set();
|
|
51
|
+
for (const reference of wanted) {
|
|
52
|
+
// Accepts a registry id as well as a name; an unregistered bundle can still
|
|
53
|
+
// be installed, so anything unrecognised is taken as a name.
|
|
54
|
+
const bundleName = await resolveInstalledName(reference);
|
|
55
|
+
const records = await findInstallations(options.scope, options.cwd, bundleName);
|
|
56
|
+
const matching = chosen ? records.filter((record) => chosen.includes(record.target)) : records;
|
|
57
|
+
if (matching.length === 0) {
|
|
58
|
+
throw new HcmError(`"${bundleName}" is not installed in ${options.scope} scope` +
|
|
59
|
+
(chosen ? ` in ${chosen.join(', ')}` : ''), 'Run "hcm list --installed" to see what is installed.');
|
|
60
|
+
}
|
|
61
|
+
bundleNames.add(bundleName);
|
|
62
|
+
for (const record of matching) {
|
|
63
|
+
if (!selected.some((existing) => existing.id === record.id))
|
|
64
|
+
selected.push(record);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// Only ambiguous if it is actually installed into several harnesses: a bundle
|
|
68
|
+
// that only ever went into one needs no `-t`, however many harnesses the
|
|
69
|
+
// folder holds.
|
|
70
|
+
const found = await requireTargetChoice({
|
|
71
|
+
...(chosen ? { chosen } : {}),
|
|
72
|
+
affected: [...new Set(selected.map((record) => record.target))],
|
|
73
|
+
command: `hcm uninstall ${wanted.join(' ')}`,
|
|
74
|
+
scope: options.scope,
|
|
75
|
+
cwd: options.cwd,
|
|
76
|
+
});
|
|
77
|
+
const presentTargets = found.map((harness) => harness.target);
|
|
78
|
+
const removing = await withDependents(selected, options);
|
|
79
|
+
const pendingIds = removing.map((record) => record.id);
|
|
80
|
+
for (const record of removing) {
|
|
81
|
+
const target = getTarget(record.target);
|
|
82
|
+
const scopeRoot = target.scopeRoot(record.scope, options.cwd);
|
|
83
|
+
// Named bundles get the plain header; anything --cascade dragged in says
|
|
84
|
+
// whose account it is being removed on.
|
|
85
|
+
const cascaded = bundleNames.has(record.bundle)
|
|
86
|
+
? ''
|
|
87
|
+
: ` ${color.bold(record.bundle)}${color.dim(' (depends on it)')}`;
|
|
88
|
+
log.info('');
|
|
89
|
+
log.info(`${color.bold(target.title)} ${color.dim(`· ${record.scope} · ${scopeRoot}`)}${cascaded}`);
|
|
90
|
+
const removed = await rollbackInstallation(record, {
|
|
91
|
+
...options,
|
|
92
|
+
alsoRemoving: pendingIds,
|
|
93
|
+
presentTargets,
|
|
94
|
+
});
|
|
95
|
+
if (removed)
|
|
96
|
+
log.success(` uninstalled ${record.bundle} from ${target.title}`);
|
|
97
|
+
}
|
|
98
|
+
if (!options.keepOrphans)
|
|
99
|
+
await pruneOrphans(removing, { ...options, presentTargets });
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The records this run should take away.
|
|
103
|
+
*
|
|
104
|
+
* Anything still depending on the bundle stops the run: an installed bundle
|
|
105
|
+
* whose dependency has gone is broken in a way `hcm status` cannot see, since
|
|
106
|
+
* every item it owns is still exactly where it left it. `--cascade` says to
|
|
107
|
+
* remove those bundles too (and whatever depends on *them*); `--ignore-dependents`
|
|
108
|
+
* says to go ahead and leave them as they are.
|
|
109
|
+
*/
|
|
110
|
+
async function withDependents(selected, options) {
|
|
111
|
+
const chosen = new Map(selected.map((record) => [record.id, record]));
|
|
112
|
+
const blocked = [];
|
|
113
|
+
// Breadth-first over "who needs what is going away", so a chain of three
|
|
114
|
+
// bundles unwinds in one command.
|
|
115
|
+
const queue = [...selected];
|
|
116
|
+
while (queue.length > 0) {
|
|
117
|
+
const record = queue.shift();
|
|
118
|
+
const dependents = (await findDependents(record.scope, options.cwd, record.bundle, record.target)).filter((dependent) => !chosen.has(dependent.id));
|
|
119
|
+
if (dependents.length === 0)
|
|
120
|
+
continue;
|
|
121
|
+
if (!options.cascade) {
|
|
122
|
+
blocked.push({ record, dependents });
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
for (const dependent of dependents) {
|
|
126
|
+
chosen.set(dependent.id, dependent);
|
|
127
|
+
queue.push(dependent);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (blocked.length > 0 && !options.ignoreDependents) {
|
|
131
|
+
const detail = blocked
|
|
132
|
+
.map(({ record, dependents }) => `${record.bundle} (${record.target}) is required by ` +
|
|
133
|
+
[...new Set(dependents.map((dependent) => dependent.bundle))].join(', '))
|
|
134
|
+
.join('; ');
|
|
135
|
+
throw new HcmError(`Other installed bundles still depend on this one: ${detail}`, 'Use --cascade to remove them too, or --ignore-dependents to leave them installed without it.');
|
|
136
|
+
}
|
|
137
|
+
if (blocked.length > 0) {
|
|
138
|
+
for (const { record, dependents } of blocked) {
|
|
139
|
+
log.warn(` ${[...new Set(dependents.map((dependent) => dependent.bundle))].join(', ')} ` +
|
|
140
|
+
`still expect ${record.bundle}; removing it anyway (--ignore-dependents)`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return dependentsFirst([...chosen.values()]);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Order records so nothing is removed before the things that require it. A
|
|
147
|
+
* chain of three unwinds from the top; anything left in a cycle (which the
|
|
148
|
+
* resolver refuses, but an old ledger could still hold) keeps its place rather
|
|
149
|
+
* than looping.
|
|
150
|
+
*/
|
|
151
|
+
function dependentsFirst(records) {
|
|
152
|
+
const remaining = [...records];
|
|
153
|
+
const ordered = [];
|
|
154
|
+
while (remaining.length > 0) {
|
|
155
|
+
const index = remaining.findIndex((candidate) => !remaining.some((other) => other !== candidate &&
|
|
156
|
+
other.target === candidate.target &&
|
|
157
|
+
other.scope === candidate.scope &&
|
|
158
|
+
dependsOn(other, candidate.bundle)));
|
|
159
|
+
ordered.push(...remaining.splice(index < 0 ? 0 : index, 1));
|
|
160
|
+
}
|
|
161
|
+
return ordered;
|
|
162
|
+
}
|
|
163
|
+
function dependsOn(record, bundle) {
|
|
164
|
+
return (record.dependencies ?? []).some((dependency) => dependency.name === bundle);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Roll one installation back and drop its ledger entry. Returns false when
|
|
168
|
+
* hand-edited items blocked it, or when this was a dry run -- `hcm update`
|
|
169
|
+
* uses that to decide whether reinstalling on top is safe.
|
|
170
|
+
*
|
|
171
|
+
* Blocked means *partly* removed by default, which is what `hcm uninstall`
|
|
172
|
+
* wants: you asked for the items to go, so the seven that can go should go and
|
|
173
|
+
* the one that cannot should say so. `allOrNothing` is for the caller that
|
|
174
|
+
* cannot live with a half-removal -- see below.
|
|
175
|
+
*/
|
|
176
|
+
export async function rollbackInstallation(record, options) {
|
|
177
|
+
const target = getTarget(record.target);
|
|
178
|
+
const scopeRoot = target.scopeRoot(record.scope, options.cwd);
|
|
179
|
+
const claims = await collectClaims(options.cwd, {
|
|
180
|
+
excludeIds: [record.id, ...(options.alsoRemoving ?? [])],
|
|
181
|
+
});
|
|
182
|
+
// Asked in a pass that writes nothing, before the pass that does: whether an
|
|
183
|
+
// item is blocked is only known once its hash has been compared, and by then
|
|
184
|
+
// the removal is already several files in. `--force` removes edited items
|
|
185
|
+
// anyway, so it has nothing to ask.
|
|
186
|
+
if (options.allOrNothing && !options.dryRun && !options.force) {
|
|
187
|
+
const blocked = (await rollback(record, scopeRoot, { dryRun: true, claims })).filter((result) => result.status === 'modified');
|
|
188
|
+
if (blocked.length > 0) {
|
|
189
|
+
for (const result of blocked) {
|
|
190
|
+
const detail = result.detail ? color.dim(` (${result.detail})`) : '';
|
|
191
|
+
log.info(` ${STATUS_STYLE.modified(pad(result.status))} ${describeReceipt(result.receipt)}${detail}`);
|
|
192
|
+
}
|
|
193
|
+
log.warn(` ${blocked.length} item(s) were modified since install; nothing was removed and ` +
|
|
194
|
+
'this installation was left exactly as it is.');
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
const results = await rollback(record, scopeRoot, {
|
|
199
|
+
force: options.force ?? false,
|
|
200
|
+
dryRun: options.dryRun ?? false,
|
|
201
|
+
claims,
|
|
202
|
+
});
|
|
203
|
+
for (const result of results) {
|
|
204
|
+
const style = STATUS_STYLE[result.status];
|
|
205
|
+
const detail = result.detail ? color.dim(` (${result.detail})`) : '';
|
|
206
|
+
log.info(` ${style(pad(result.status))} ${describeReceipt(result.receipt)}${detail}`);
|
|
207
|
+
}
|
|
208
|
+
await reportSharedFiles(record, results, options);
|
|
209
|
+
const blocked = results.filter((result) => result.status === 'modified');
|
|
210
|
+
if (options.dryRun) {
|
|
211
|
+
log.info(color.dim(' (dry run -- nothing changed)'));
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
if (blocked.length > 0 && !options.force) {
|
|
215
|
+
log.warn(` ${blocked.length} item(s) were modified since install and were left in place; ` +
|
|
216
|
+
'the installation record is kept so you can retry with --force.');
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
await removeInstallation(record.scope, options.cwd, record.id);
|
|
220
|
+
// The cached context sections went with the blocks; nothing should offer to
|
|
221
|
+
// put back instructions from a bundle that is no longer installed.
|
|
222
|
+
await forgetContext(record.bundle, record.target, record.scope, options.cwd);
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Say what removing from one harness did to the others.
|
|
227
|
+
*
|
|
228
|
+
* `-t reasonix` reads as "only Reasonix", and for `.reasonix/` it is. For a
|
|
229
|
+
* file two harnesses read it cannot be, and it goes wrong in both directions:
|
|
230
|
+
*
|
|
231
|
+
* held another installation still claims the item, so it stays in the
|
|
232
|
+
* file -- and the harness you removed it from goes on reading that
|
|
233
|
+
* same file, so it still has it. This is the one that surprises
|
|
234
|
+
* people: `hcm uninstall -t reasonix` reports success and Reasonix
|
|
235
|
+
* still has the MCP server, because Claude Code's claim kept the
|
|
236
|
+
* entry in `.mcp.json`.
|
|
237
|
+
* removed nothing else claimed it, so it is gone from the file -- including
|
|
238
|
+
* for the harnesses that were not named.
|
|
239
|
+
*/
|
|
240
|
+
async function reportSharedFiles(record, results, options) {
|
|
241
|
+
const present = options.presentTargets ??
|
|
242
|
+
(await detectHarnesses(record.scope, options.cwd)).map((harness) => harness.target);
|
|
243
|
+
const notices = sharedFileNotices({
|
|
244
|
+
target: record.target,
|
|
245
|
+
paths: results.map((result) => result.receipt.path),
|
|
246
|
+
scope: record.scope,
|
|
247
|
+
cwd: options.cwd,
|
|
248
|
+
present,
|
|
249
|
+
...(record.targetOptions ? { options: record.targetOptions } : {}),
|
|
250
|
+
});
|
|
251
|
+
for (const notice of notices) {
|
|
252
|
+
const touched = results.filter((result) => result.receipt.path === notice.path);
|
|
253
|
+
const held = touched.filter((result) => result.status === 'held').length;
|
|
254
|
+
const gone = touched.filter((result) => result.status === 'removed' || result.status === 'partial').length;
|
|
255
|
+
const readers = describeReaders(notice.others);
|
|
256
|
+
if (held > 0) {
|
|
257
|
+
log.warn(` ${notice.path} is shared with ${readers}: ${held} item(s) were left in place, ` +
|
|
258
|
+
`so ${getTarget(record.target).title} still reads them from this file`);
|
|
259
|
+
}
|
|
260
|
+
if (gone > 0) {
|
|
261
|
+
log.warn(` ${notice.path} is shared with ${readers}: ${gone} item(s) were removed from it, ` +
|
|
262
|
+
`so ${readers} lost them too`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Remove dependencies that were only ever installed for the bundles just taken
|
|
268
|
+
* away. A bundle the user installed by name is never pruned, even if it later
|
|
269
|
+
* became somebody's dependency -- `auto` records that difference.
|
|
270
|
+
*/
|
|
271
|
+
async function pruneOrphans(removed, options) {
|
|
272
|
+
// A dry run gets the same reckoning -- the records are all still in the
|
|
273
|
+
// ledger, but `gone` already holds the ids this run would have taken.
|
|
274
|
+
const gone = new Set(removed.map((record) => record.id));
|
|
275
|
+
const queue = removed.flatMap((record) => (record.dependencies ?? []).map((dependency) => ({
|
|
276
|
+
name: dependency.name,
|
|
277
|
+
scope: record.scope,
|
|
278
|
+
target: record.target,
|
|
279
|
+
})));
|
|
280
|
+
const orphans = [];
|
|
281
|
+
while (queue.length > 0) {
|
|
282
|
+
const wanted = queue.shift();
|
|
283
|
+
const record = await findInstallation(wanted.scope, options.cwd, wanted.name, wanted.target);
|
|
284
|
+
if (!record || !record.auto || gone.has(record.id))
|
|
285
|
+
continue;
|
|
286
|
+
const dependents = (await findDependents(record.scope, options.cwd, record.bundle, record.target)).filter((dependent) => !gone.has(dependent.id));
|
|
287
|
+
if (dependents.length > 0)
|
|
288
|
+
continue;
|
|
289
|
+
gone.add(record.id);
|
|
290
|
+
orphans.push(record);
|
|
291
|
+
// Its own automatic dependencies may now be unused too.
|
|
292
|
+
for (const dependency of record.dependencies ?? []) {
|
|
293
|
+
queue.push({ name: dependency.name, scope: record.scope, target: record.target });
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (orphans.length === 0)
|
|
297
|
+
return;
|
|
298
|
+
log.info('');
|
|
299
|
+
log.info(`${options.dryRun ? 'Would remove' : 'Removing'} ${orphans.length} ` +
|
|
300
|
+
'bundle(s) installed only as dependencies: ' +
|
|
301
|
+
[...new Set(orphans.map((record) => record.bundle))].join(', '));
|
|
302
|
+
// Everything this run has taken away, not just the orphans: on a dry run the
|
|
303
|
+
// earlier records are all still in the ledger, and counting them would make
|
|
304
|
+
// each look like a reason to keep the others' shared items.
|
|
305
|
+
const pendingIds = [...gone];
|
|
306
|
+
for (const orphan of orphans) {
|
|
307
|
+
const target = getTarget(orphan.target);
|
|
308
|
+
log.info('');
|
|
309
|
+
log.info(`${color.bold(target.title)} ${color.dim(`· ${orphan.scope}`)} ${color.bold(orphan.bundle)}`);
|
|
310
|
+
const done = await rollbackInstallation(orphan, {
|
|
311
|
+
...options,
|
|
312
|
+
alsoRemoving: pendingIds,
|
|
313
|
+
...(options.presentTargets ? { presentTargets: options.presentTargets } : {}),
|
|
314
|
+
});
|
|
315
|
+
if (done)
|
|
316
|
+
log.success(` uninstalled ${orphan.bundle} from ${target.title}`);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
function pad(status) {
|
|
320
|
+
return status.padEnd(8);
|
|
321
|
+
}
|
|
322
|
+
//# sourceMappingURL=uninstall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uninstall.js","sourceRoot":"","sources":["../../src/commands/uninstall.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3F,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAA0C,MAAM,qBAAqB,CAAC;AACvF,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K,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACxC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACb,GAAG,CAAC,IAAI,CACN,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAC7F,CAAC;QACF,MAAM,IAAI,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE;YAC9C,GAAG,OAAO;YACV,YAAY,EAAE,UAAU;YACxB,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9E,CAAC,CAAC;QACH,IAAI,IAAI;YAAE,GAAG,CAAC,OAAO,CAAC,iBAAiB,MAAM,CAAC,MAAM,SAAS,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IAC/E,CAAC;AACH,CAAC;AAED,SAAS,GAAG,CAAC,MAAc;IACzB,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
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 type { ConflictPolicy, Resolution } from '../core/conflicts.js';
|
|
19
|
+
import { type ParameterOverrides } from '../core/parameters.js';
|
|
20
|
+
import type { Scope, TargetOptions } from '../core/types.js';
|
|
21
|
+
export interface UpdateOptions {
|
|
22
|
+
targets?: string[];
|
|
23
|
+
scope?: Scope | 'all';
|
|
24
|
+
dryRun?: boolean;
|
|
25
|
+
force?: boolean;
|
|
26
|
+
onConflict?: ConflictPolicy;
|
|
27
|
+
/** Answers shared across every bundle and target this run touches. */
|
|
28
|
+
decisions?: Map<string, Resolution>;
|
|
29
|
+
/** Parameter answers shared across every bundle and target this run touches. */
|
|
30
|
+
answers?: Map<string, string>;
|
|
31
|
+
/**
|
|
32
|
+
* Overrides what each installation recorded. Given nothing, every one is
|
|
33
|
+
* reinstalled the way it was installed -- an update should put the new
|
|
34
|
+
* version where the old one was, not quietly relocate it.
|
|
35
|
+
*/
|
|
36
|
+
targetOptions?: TargetOptions;
|
|
37
|
+
/**
|
|
38
|
+
* `--param` assignments, overriding the values each installation recorded.
|
|
39
|
+
* Given nothing, every one is rendered with exactly what it was rendered with
|
|
40
|
+
* before -- an update should not rename the agent behind your back.
|
|
41
|
+
*/
|
|
42
|
+
params?: string[];
|
|
43
|
+
/** `--params-file`: files of parameter values, later ones winning. */
|
|
44
|
+
paramsFiles?: string[];
|
|
45
|
+
/** `params` and `paramsFiles` already parsed and merged; filled in by this command. */
|
|
46
|
+
parameterOverrides?: ParameterOverrides;
|
|
47
|
+
/**
|
|
48
|
+
* Ask again for every parameter, ignoring what was recorded. The way to
|
|
49
|
+
* change an answer without remembering how it was originally spelled.
|
|
50
|
+
*/
|
|
51
|
+
reconfigure?: boolean;
|
|
52
|
+
/** Never ask; use what is recorded, then the defaults. */
|
|
53
|
+
prompt?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Overrides the subset each installation recorded. Given nothing, every one
|
|
56
|
+
* is reinstalled as the same set of flavors it already was -- `--flavor all`
|
|
57
|
+
* is how you widen a narrowed installation back to the whole bundle.
|
|
58
|
+
*/
|
|
59
|
+
flavors?: string[];
|
|
60
|
+
cwd: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* No argument updates everything installed here; `all` updates everything
|
|
64
|
+
* registered; anything else names bundles -- one, or as many as you like.
|
|
65
|
+
*/
|
|
66
|
+
export declare function updateCommand(references: string | string[] | undefined, options: UpdateOptions): Promise<void>;
|