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,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a bundles file back: register every source it lists, and optionally
|
|
3
|
+
* install them, recreating a setup on another machine.
|
|
4
|
+
*/
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { HcmError } from '../core/errors.js';
|
|
7
|
+
import { readTextIfExists } from '../core/fsx.js';
|
|
8
|
+
import { color, log } from '../core/logger.js';
|
|
9
|
+
import { addToRegistry } from '../core/registry.js';
|
|
10
|
+
import { DEFAULT_BUNDLES_FILE } from './export.js';
|
|
11
|
+
import { installCommand } from './install.js';
|
|
12
|
+
/** Strip comments and blank lines; everything else is a bundle reference. */
|
|
13
|
+
export function parseBundlesFile(contents) {
|
|
14
|
+
return contents
|
|
15
|
+
.split(/\r?\n/)
|
|
16
|
+
.map((line) => line.trim())
|
|
17
|
+
.filter((line) => line.length > 0 && !line.startsWith('#'));
|
|
18
|
+
}
|
|
19
|
+
export async function importCommand(file, options) {
|
|
20
|
+
const target = path.resolve(options.cwd, file ?? DEFAULT_BUNDLES_FILE);
|
|
21
|
+
const contents = await readTextIfExists(target);
|
|
22
|
+
if (contents === undefined) {
|
|
23
|
+
throw new HcmError(`No such file: ${target}`, 'Generate one with "hcm export".');
|
|
24
|
+
}
|
|
25
|
+
const references = parseBundlesFile(contents);
|
|
26
|
+
if (references.length === 0) {
|
|
27
|
+
log.warn(`${target} lists no bundles.`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
log.info(`Importing ${references.length} bundle(s) from ${target}`);
|
|
31
|
+
const registered = [];
|
|
32
|
+
const failed = [];
|
|
33
|
+
for (const reference of references) {
|
|
34
|
+
try {
|
|
35
|
+
const entries = await addToRegistry(reference, options.cwd);
|
|
36
|
+
for (const entry of entries) {
|
|
37
|
+
registered.push(entry.name);
|
|
38
|
+
log.success(` registered ${color.bold(entry.name)} ${color.dim(`v${entry.version}`)}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
// Keep going: one unreachable repo should not abandon the whole import.
|
|
43
|
+
failed.push({ reference, reason: error.message });
|
|
44
|
+
log.error(` ${reference}: ${error.message}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (options.install && registered.length > 0) {
|
|
48
|
+
log.info('');
|
|
49
|
+
// One memory of conflict answers across every bundle in the file, and one
|
|
50
|
+
// of parameter answers: a file listing five bundles that all want
|
|
51
|
+
// AGENT_NAME asks for it once.
|
|
52
|
+
const decisions = new Map();
|
|
53
|
+
const answers = new Map();
|
|
54
|
+
for (const name of registered) {
|
|
55
|
+
await installCommand(name, {
|
|
56
|
+
scope: options.scope,
|
|
57
|
+
cwd: options.cwd,
|
|
58
|
+
decisions,
|
|
59
|
+
answers,
|
|
60
|
+
...(options.targets ? { targets: options.targets } : {}),
|
|
61
|
+
...(options.force ? { force: true } : {}),
|
|
62
|
+
...(options.onConflict ? { onConflict: options.onConflict } : {}),
|
|
63
|
+
...(options.dryRun ? { dryRun: true } : {}),
|
|
64
|
+
...(options.noDeps ? { noDeps: true } : {}),
|
|
65
|
+
...(options.targetOptions ? { targetOptions: options.targetOptions } : {}),
|
|
66
|
+
...(options.flavors?.length ? { flavors: options.flavors } : {}),
|
|
67
|
+
...(options.params?.length ? { params: options.params } : {}),
|
|
68
|
+
...(options.paramsFiles?.length ? { paramsFiles: options.paramsFiles } : {}),
|
|
69
|
+
...(options.prompt === false ? { prompt: false } : {}),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
log.info('');
|
|
74
|
+
if (failed.length > 0) {
|
|
75
|
+
log.warn(`${registered.length} imported, ${failed.length} failed.`);
|
|
76
|
+
process.exitCode = 1;
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
log.success(`${registered.length} bundle(s) imported${options.install ? ' and installed' : ''}.`);
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=import.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.js","sourceRoot":"","sources":["../../src/commands/import.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AA2B9C,6EAA6E;AAC7E,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,OAAO,QAAQ;SACZ,KAAK,CAAC,OAAO,CAAC;SACd,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,C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AC,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,GAAG,CACrF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Scope, TargetOptions } from '../core/types.js';
|
|
2
|
+
export interface InfoOptions {
|
|
3
|
+
scope: Scope;
|
|
4
|
+
/** Preview the layout for a machine with these extensions installed. */
|
|
5
|
+
targetOptions?: TargetOptions;
|
|
6
|
+
/** Preview a narrowed install rather than the whole bundle. */
|
|
7
|
+
flavors?: string[];
|
|
8
|
+
/**
|
|
9
|
+
* `--param` assignments, so the preview shows the text an install with those
|
|
10
|
+
* values would really write. Anything not given falls back to the parameter's
|
|
11
|
+
* default -- `hcm info` asks nothing, being a way of *looking* at a bundle.
|
|
12
|
+
*/
|
|
13
|
+
params?: string[];
|
|
14
|
+
/** `--params-file`: files of parameter values, later ones winning. */
|
|
15
|
+
paramsFiles?: string[];
|
|
16
|
+
cwd: string;
|
|
17
|
+
}
|
|
18
|
+
/** Show what a bundle contains and where each item would land in every target. */
|
|
19
|
+
export declare function infoCommand(references: string | string[], options: InfoOptions): Promise<void>;
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { validateBundle } from '../core/bundle.js';
|
|
2
|
+
import { formatDependencyTree, resolveDependencyGraph } from '../core/deps.js';
|
|
3
|
+
import { assertFlavorsAvailable, expandFlavors } from '../core/flavors.js';
|
|
4
|
+
import { describeSource } from '../core/github.js';
|
|
5
|
+
import { color, log } from '../core/logger.js';
|
|
6
|
+
import { sharedFiles } from '../core/overlap.js';
|
|
7
|
+
import { applicableParameters, describeScope, emptyOverrides, mergeOverrides, overridesFor, parseAssignments, readParametersFile, withDefaults, } from '../core/parameters.js';
|
|
8
|
+
import { buildPlan } from '../core/planner.js';
|
|
9
|
+
import { asList, readRegistry, resolveBundles } from '../core/registry.js';
|
|
10
|
+
import { TARGET_IDS, getTarget } from '../targets/index.js';
|
|
11
|
+
/** Show what a bundle contains and where each item would land in every target. */
|
|
12
|
+
export async function infoCommand(references, options) {
|
|
13
|
+
const bundles = [];
|
|
14
|
+
for (const reference of asList(references)) {
|
|
15
|
+
bundles.push(...(await resolveBundles(reference, options.cwd)));
|
|
16
|
+
}
|
|
17
|
+
// The same refusal `hcm install` gives, so previewing a flavor you have
|
|
18
|
+
// misspelled says so rather than showing you a suspiciously small bundle.
|
|
19
|
+
options = { ...options, flavors: expandFlavors(options.flavors) ?? [] };
|
|
20
|
+
assertFlavorsAvailable(bundles, options.flavors);
|
|
21
|
+
const registry = await readRegistry();
|
|
22
|
+
const fromFiles = [];
|
|
23
|
+
for (const file of options.paramsFiles ?? []) {
|
|
24
|
+
fromFiles.push(await readParametersFile(file, options.cwd));
|
|
25
|
+
}
|
|
26
|
+
const overrides = mergeOverrides(...fromFiles, parseAssignments(options.params));
|
|
27
|
+
for (const [index, bundle] of bundles.entries()) {
|
|
28
|
+
if (index > 0)
|
|
29
|
+
log.plain(color.dim('\n' + '─'.repeat(60)));
|
|
30
|
+
const entry = registry.entries.find((candidate) => candidate.name === bundle.manifest.name);
|
|
31
|
+
await describeBundle(bundle, options, entry?.id, overrides);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function describeBundle(bundle, options, id, overrides = emptyOverrides()) {
|
|
35
|
+
const { manifest } = bundle;
|
|
36
|
+
const handle = id ? `${color.dim(`[${id}]`)} ` : '';
|
|
37
|
+
log.plain(`${handle}${color.bold(manifest.name)} ${color.dim(`v${manifest.version}`)}`);
|
|
38
|
+
if (manifest.description)
|
|
39
|
+
log.plain(manifest.description);
|
|
40
|
+
log.plain(color.dim(describeSource(bundle.source)));
|
|
41
|
+
if (manifest.author)
|
|
42
|
+
log.plain(color.dim(`author: ${manifest.author}`));
|
|
43
|
+
if (manifest.tags?.length)
|
|
44
|
+
log.plain(color.dim(`tags: ${manifest.tags.join(', ')}`));
|
|
45
|
+
await describeDependencies(bundle, options);
|
|
46
|
+
describeFlavors(bundle, options);
|
|
47
|
+
describeParameters(bundle);
|
|
48
|
+
const byKind = new Map();
|
|
49
|
+
for (const resource of bundle.resources) {
|
|
50
|
+
const list = byKind.get(resource.kind) ?? [];
|
|
51
|
+
// Marked rather than hidden: what a flavor leaves out is as much a part of
|
|
52
|
+
// reading a bundle as what it takes.
|
|
53
|
+
const flavors = resource.flavors.length ? color.dim(` (${resource.flavors.join('/')})`) : '';
|
|
54
|
+
list.push(`${resource.name}${flavors}`);
|
|
55
|
+
byKind.set(resource.kind, list);
|
|
56
|
+
}
|
|
57
|
+
log.plain(color.bold('\nContents'));
|
|
58
|
+
if (byKind.size === 0)
|
|
59
|
+
log.plain(color.dim(' (empty)'));
|
|
60
|
+
for (const [kind, names] of byKind) {
|
|
61
|
+
log.plain(` ${kind.padEnd(9)} ${names.join(', ')}`);
|
|
62
|
+
}
|
|
63
|
+
const targets = manifest.targets?.length ? manifest.targets : TARGET_IDS;
|
|
64
|
+
for (const targetId of targets) {
|
|
65
|
+
const target = getTarget(targetId);
|
|
66
|
+
const plan = await buildPlan(bundle, targetId, options.scope, options.cwd, options.targetOptions ?? {}, options.flavors ?? [], previewValues(bundle, targetId, options, overrides));
|
|
67
|
+
log.plain(color.bold(`\n${target.title}`) + color.dim(` · ${options.scope}`));
|
|
68
|
+
for (const action of plan.actions)
|
|
69
|
+
log.plain(` ${action.describe}`);
|
|
70
|
+
for (const skip of plan.skipped) {
|
|
71
|
+
log.plain(color.dim(` (skipped ${skip.resource.name}: ${skip.reason})`));
|
|
72
|
+
}
|
|
73
|
+
// A placeholder with nothing to fill it is the one thing a preview can tell
|
|
74
|
+
// you that reading the bundle cannot.
|
|
75
|
+
const seen = new Set();
|
|
76
|
+
for (const miss of plan.templating?.unresolved ?? []) {
|
|
77
|
+
const key = `${miss.path}::${miss.name}`;
|
|
78
|
+
if (seen.has(key))
|
|
79
|
+
continue;
|
|
80
|
+
seen.add(key);
|
|
81
|
+
log.plain(color.yellow(` ! ${miss.path}: "<%${miss.name}%>" ${miss.reason}`));
|
|
82
|
+
}
|
|
83
|
+
// Where this harness's layout forces a reference to be written differently
|
|
84
|
+
// -- the thing you cannot work out by reading the bundle.
|
|
85
|
+
for (const rewrite of plan.references?.rewrites ?? []) {
|
|
86
|
+
log.plain(color.dim(` ↳ ${rewrite.path}: ${rewrite.from} → ${rewrite.to}`));
|
|
87
|
+
}
|
|
88
|
+
for (const miss of plan.references?.dropped ?? []) {
|
|
89
|
+
log.plain(color.yellow(` ! ${miss.path}: "${miss.ref}" ${miss.reason}`));
|
|
90
|
+
}
|
|
91
|
+
if (plan.conflicts.length > 0) {
|
|
92
|
+
for (const conflict of plan.conflicts) {
|
|
93
|
+
log.plain(color.yellow(` ! ${conflict.path}: ${conflict.detail}`));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
describeSharedLandings(bundle, targets, options);
|
|
98
|
+
const problems = validateBundle(bundle);
|
|
99
|
+
if (problems.length > 0) {
|
|
100
|
+
log.plain(color.bold('\nWarnings'));
|
|
101
|
+
for (const problem of problems)
|
|
102
|
+
log.plain(color.yellow(` ${problem}`));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The landing places above that are not one harness's alone.
|
|
107
|
+
*
|
|
108
|
+
* The per-target listings read as if each harness had its own file, and for
|
|
109
|
+
* almost everything they do. Where they do not, installing into one harness
|
|
110
|
+
* installs into the other as well -- worth knowing before installing rather
|
|
111
|
+
* than after uninstalling.
|
|
112
|
+
*/
|
|
113
|
+
function describeSharedLandings(bundle, targets, options) {
|
|
114
|
+
if (targets.length < 2)
|
|
115
|
+
return;
|
|
116
|
+
const kinds = new Set(bundle.resources.map((resource) => resource.kind));
|
|
117
|
+
const shared = sharedFiles(targets, options.scope, options.cwd, options.targetOptions ?? {})
|
|
118
|
+
.filter((file) => file.readers.some((reader) => reader.kinds.some((kind) => kinds.has(kind))));
|
|
119
|
+
if (shared.length === 0)
|
|
120
|
+
return;
|
|
121
|
+
log.plain(color.bold('\nShared between targets'));
|
|
122
|
+
for (const file of shared) {
|
|
123
|
+
const readers = [...new Set(file.readers.map((reader) => reader.target))];
|
|
124
|
+
log.plain(` ${file.readers[0]?.path} ` +
|
|
125
|
+
color.dim(`← ${readers.map((id) => getTarget(id).title).join(', ')}`));
|
|
126
|
+
}
|
|
127
|
+
log.plain(color.dim(' Written once; uninstalling from one of them leaves it for the others.'));
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The subsets this bundle can be installed as, and what each one holds.
|
|
131
|
+
*
|
|
132
|
+
* Printed against the *whole* bundle even when `--flavor` narrowed the preview,
|
|
133
|
+
* because the question it answers -- what else could I have asked for -- is
|
|
134
|
+
* exactly the one a narrowed listing cannot.
|
|
135
|
+
*/
|
|
136
|
+
function describeFlavors(bundle, options) {
|
|
137
|
+
if (bundle.flavors.length === 0)
|
|
138
|
+
return;
|
|
139
|
+
const requested = new Set((options.flavors ?? []).map((name) => name.toLowerCase()));
|
|
140
|
+
log.plain(color.bold('\nFlavors'));
|
|
141
|
+
for (const flavor of bundle.flavors) {
|
|
142
|
+
const members = bundle.resources.filter((resource) => resource.flavors.some((name) => name.toLowerCase() === flavor.name.toLowerCase()));
|
|
143
|
+
const mark = requested.has(flavor.name.toLowerCase()) ? color.green('●') : color.dim('○');
|
|
144
|
+
log.plain(` ${mark} ${color.bold(flavor.name)} ` +
|
|
145
|
+
color.dim(`${members.length} resource(s)`) +
|
|
146
|
+
(flavor.description ? ` ${color.dim(`— ${flavor.description}`)}` : ''));
|
|
147
|
+
for (const member of members)
|
|
148
|
+
log.plain(color.dim(` ${member.bundlePath}`));
|
|
149
|
+
}
|
|
150
|
+
const common = bundle.resources.filter((resource) => resource.flavors.length === 0);
|
|
151
|
+
log.plain(color.dim(` ${common.length} resource(s) belong to no flavor and install whatever you ask for.`));
|
|
152
|
+
if (requested.size === 0) {
|
|
153
|
+
log.plain(color.dim(' Installing without --flavor installs all of it.'));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The values this preview renders with: whatever was passed, then each
|
|
158
|
+
* parameter's own default.
|
|
159
|
+
*
|
|
160
|
+
* Nothing is asked and nothing is read from the ledger. `hcm info` is for
|
|
161
|
+
* looking at a bundle you have not installed -- a preview that stopped to
|
|
162
|
+
* interrogate you would be a strange kind of looking, and one that quietly used
|
|
163
|
+
* another project's answers would be a misleading one.
|
|
164
|
+
*/
|
|
165
|
+
function previewValues(bundle, target, options, overrides) {
|
|
166
|
+
const supplied = overridesFor(overrides, bundle.manifest.name, target);
|
|
167
|
+
const values = {};
|
|
168
|
+
for (const parameter of applicableParameters(bundle.parameters, {
|
|
169
|
+
target,
|
|
170
|
+
flavors: options.flavors ?? [],
|
|
171
|
+
})) {
|
|
172
|
+
const value = supplied[parameter.name] ?? parameter.default;
|
|
173
|
+
if (value !== undefined)
|
|
174
|
+
values[parameter.name] = value;
|
|
175
|
+
}
|
|
176
|
+
// Anything narrowed away still renders as its default, exactly as it would
|
|
177
|
+
// in a real install of this harness.
|
|
178
|
+
return withDefaults(values, bundle.parameters);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* What installing this bundle will ask for.
|
|
182
|
+
*
|
|
183
|
+
* Printed against the whole bundle even when `--flavor` narrowed the preview,
|
|
184
|
+
* for the same reason the flavors are: the question it answers is what *could*
|
|
185
|
+
* be asked, which a narrowed listing cannot.
|
|
186
|
+
*/
|
|
187
|
+
function describeParameters(bundle) {
|
|
188
|
+
if (bundle.parameters.length === 0)
|
|
189
|
+
return;
|
|
190
|
+
log.plain(color.bold('\nParameters'));
|
|
191
|
+
for (const parameter of bundle.parameters) {
|
|
192
|
+
const fallback = parameter.default !== undefined
|
|
193
|
+
? color.dim(` [${parameter.default}]`)
|
|
194
|
+
: parameter.required
|
|
195
|
+
? color.yellow(' (required)')
|
|
196
|
+
: color.dim(' (optional)');
|
|
197
|
+
const scope = describeScope(parameter);
|
|
198
|
+
log.plain(` ${color.bold(parameter.name)}${fallback}` +
|
|
199
|
+
(parameter.description ? ` ${color.dim(`— ${parameter.description}`)}` : ''));
|
|
200
|
+
const notes = [
|
|
201
|
+
...(scope ? [`only for ${scope}`] : []),
|
|
202
|
+
...(parameter.choices ? [`one of: ${parameter.choices.join(', ')}`] : []),
|
|
203
|
+
...(parameter.pattern ? [`matching ${parameter.pattern}`] : []),
|
|
204
|
+
...(parameter.secret ? ['not stored; supply it again on update'] : []),
|
|
205
|
+
];
|
|
206
|
+
if (notes.length > 0)
|
|
207
|
+
log.plain(color.dim(` ${notes.join('; ')}`));
|
|
208
|
+
}
|
|
209
|
+
log.plain(color.dim(" Written as <%NAME%> in the bundle's files; set with --param NAME=value, with a " +
|
|
210
|
+
'--params-file, or by answering when hcm asks.'));
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* What this bundle needs, and whether hcm can find it. Resolution is attempted
|
|
214
|
+
* rather than assumed: a dependency that cannot be located is the thing you
|
|
215
|
+
* most want `hcm info` to tell you, and it costs nothing to look.
|
|
216
|
+
*/
|
|
217
|
+
async function describeDependencies(bundle, options) {
|
|
218
|
+
if (bundle.dependencies.length === 0)
|
|
219
|
+
return;
|
|
220
|
+
log.plain(color.bold('\nRequires'));
|
|
221
|
+
try {
|
|
222
|
+
const graph = await resolveDependencyGraph([bundle], options.cwd);
|
|
223
|
+
for (const line of formatDependencyTree(graph, [bundle.manifest.name]).slice(1)) {
|
|
224
|
+
log.plain(` ${line}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
for (const dependency of bundle.dependencies) {
|
|
229
|
+
const range = dependency.version ? ` ${dependency.version}` : '';
|
|
230
|
+
log.plain(` ${dependency.name}${color.dim(range)}`);
|
|
231
|
+
}
|
|
232
|
+
log.plain(color.yellow(` ! ${error.message}`));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"info.js","sourceRoot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-0,0 +1,116 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { HcmError } from '../core/errors.js';
|
|
3
|
+
import { pathExists, writeText } from '../core/fsx.js';
|
|
4
|
+
import { color, log } from '../core/logger.js';
|
|
5
|
+
/** Scaffold a minimal but complete bundle so the layout is self-evident. */
|
|
6
|
+
export async function initCommand(directory, options) {
|
|
7
|
+
const root = path.resolve(options.cwd, directory);
|
|
8
|
+
const name = options.name ?? path.basename(root);
|
|
9
|
+
if (await pathExists(path.join(root, 'hcm.yaml'))) {
|
|
10
|
+
throw new HcmError(`A bundle already exists at ${root}`);
|
|
11
|
+
}
|
|
12
|
+
const files = {
|
|
13
|
+
'hcm.yaml': `name: ${name}
|
|
14
|
+
version: 0.1.0
|
|
15
|
+
description: A harness config bundle
|
|
16
|
+
# Omit "targets" to support all of them.
|
|
17
|
+
# targets: [claude-code, copilot, reasonix, opencode, pi]
|
|
18
|
+
# Bundles this one needs. Installed first, and removed again when nothing else
|
|
19
|
+
# requires them. Give anything you publish a "source" so it resolves elsewhere.
|
|
20
|
+
# dependencies:
|
|
21
|
+
# - shared-conventions@^1.0.0
|
|
22
|
+
# - name: jira-board
|
|
23
|
+
# source: acme/agent-kits/jira-board
|
|
24
|
+
# Subsets users can install on their own ("hcm install ${name} --flavor python").
|
|
25
|
+
# Anything in no flavor is common and installs either way; markdown resources can
|
|
26
|
+
# also tag themselves with "flavors:" in their own frontmatter.
|
|
27
|
+
# flavors:
|
|
28
|
+
# python:
|
|
29
|
+
# description: Python tooling
|
|
30
|
+
# includes: [rules/python.md, mcp/pyright.json]
|
|
31
|
+
# Values filled into this bundle's files as it is installed, written there as
|
|
32
|
+
# <%AGENT_NAME%> -- context/10-project.md below uses this one. A parameter with
|
|
33
|
+
# a default is never asked for; one without has to be supplied. Add "flavors:"
|
|
34
|
+
# or "targets:" to ask for it only where it matters.
|
|
35
|
+
parameters:
|
|
36
|
+
AGENT_NAME:
|
|
37
|
+
description: What the agent should call itself
|
|
38
|
+
default: Claude
|
|
39
|
+
`,
|
|
40
|
+
'README.md': `# ${name}
|
|
41
|
+
|
|
42
|
+
Install with:
|
|
43
|
+
|
|
44
|
+
\`\`\`bash
|
|
45
|
+
hcm registry add ./${path.basename(root)}
|
|
46
|
+
hcm install ${name}
|
|
47
|
+
\`\`\`
|
|
48
|
+
`,
|
|
49
|
+
'subagents/example-subagent.md': `---
|
|
50
|
+
description: Describe when this subagent should be delegated to
|
|
51
|
+
tools: [Read, Grep, Glob]
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
You are a specialised assistant. Describe the subagent's behaviour here; this
|
|
55
|
+
body becomes its system prompt.
|
|
56
|
+
`,
|
|
57
|
+
'commands/example-command.md': `---
|
|
58
|
+
description: What this slash command does
|
|
59
|
+
argumentHint: "[file]"
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
Perform the task described here, using $ARGUMENTS when provided.
|
|
63
|
+
`,
|
|
64
|
+
'rules/example-rule.md': `---
|
|
65
|
+
description: Conventions for TypeScript files
|
|
66
|
+
appliesTo:
|
|
67
|
+
- "**/*.ts"
|
|
68
|
+
- "**/*.tsx"
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
- Prefer named exports.
|
|
72
|
+
- Keep functions under 50 lines.
|
|
73
|
+
`,
|
|
74
|
+
// One file per section, numbered so the order in the instruction file is
|
|
75
|
+
// the order you see in the directory listing.
|
|
76
|
+
'context/10-project.md': `## ${name}
|
|
77
|
+
|
|
78
|
+
You are a coding agent called <%AGENT_NAME%>. That name is a *parameter*: it is
|
|
79
|
+
filled in when this bundle is installed, so one bundle can introduce itself
|
|
80
|
+
differently in every project. Change it with
|
|
81
|
+
"hcm install ${name} --param AGENT_NAME=Ada", or delete the line and the
|
|
82
|
+
"parameters:" block in hcm.yaml together.
|
|
83
|
+
|
|
84
|
+
Instructions that should load in every session go here. They are merged into
|
|
85
|
+
CLAUDE.md / copilot-instructions.md / REASONIX.md / AGENTS.md inside a marker
|
|
86
|
+
block, so uninstalling removes exactly this section.
|
|
87
|
+
|
|
88
|
+
Keep each file to one section and one subject: "hcm context append" restores
|
|
89
|
+
them one at a time, so small sections survive an agent rewriting the file
|
|
90
|
+
better than one long one.
|
|
91
|
+
`,
|
|
92
|
+
'context/20-workflow.md': `## Workflow
|
|
93
|
+
|
|
94
|
+
A second section, to show how the pieces fit together. Every file in
|
|
95
|
+
\`context/\` becomes its own block, and the blocks are concatenated in filename
|
|
96
|
+
order to form this bundle's part of the instruction file.
|
|
97
|
+
`,
|
|
98
|
+
'mcp/example-server.json': `{
|
|
99
|
+
"command": "npx",
|
|
100
|
+
"args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
|
|
101
|
+
}
|
|
102
|
+
`,
|
|
103
|
+
'settings/settings.json': `{
|
|
104
|
+
"permissions": {
|
|
105
|
+
"allow": ["Read(**)"]
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
`,
|
|
109
|
+
};
|
|
110
|
+
for (const [relativePath, contents] of Object.entries(files)) {
|
|
111
|
+
await writeText(path.join(root, ...relativePath.split('/')), contents);
|
|
112
|
+
}
|
|
113
|
+
log.success(`Created bundle ${color.bold(name)} at ${root}`);
|
|
114
|
+
log.info(color.dim(`Next: hcm registry add ${directory} && hcm info ${name}`));
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAE/C,4EAA4E;AAC5E,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,SAAiB,EACjB,OAAuC;IAEvC,M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,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,0BAA0B,SAAS,gBAAgB,IAAI,EAAE,CAAC,CAAC,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { type ConflictPolicy, type ConflictResolver, type Resolution } from '../core/conflicts.js';
|
|
2
|
+
import { type TargetChooser } from '../core/harnesses.js';
|
|
3
|
+
import { type ParameterOverrides } from '../core/parameters.js';
|
|
4
|
+
import { type InstalledDependency, type LoadedBundle, type ParameterValues, type Scope, type TargetId, type TargetOptions } from '../core/types.js';
|
|
5
|
+
export interface InstallOptions {
|
|
6
|
+
targets?: string[];
|
|
7
|
+
scope: Scope;
|
|
8
|
+
dryRun?: boolean;
|
|
9
|
+
/** Shorthand for `onConflict: 'overwrite'`. */
|
|
10
|
+
force?: boolean;
|
|
11
|
+
/** What to do about collisions; defaults to asking when there is a terminal. */
|
|
12
|
+
onConflict?: ConflictPolicy;
|
|
13
|
+
/** Test seam: answers the conflict questions instead of the terminal. */
|
|
14
|
+
resolver?: ConflictResolver;
|
|
15
|
+
/**
|
|
16
|
+
* Answers remembered across targets and bundles in one run, so installing
|
|
17
|
+
* into three harnesses asks each question once. Created here when absent.
|
|
18
|
+
*/
|
|
19
|
+
decisions?: Map<string, Resolution>;
|
|
20
|
+
refresh?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* What is installed on the machine being written to, which changes where some
|
|
23
|
+
* resources land. Recorded with the installation so `hcm update` does not
|
|
24
|
+
* have to be told again.
|
|
25
|
+
*/
|
|
26
|
+
targetOptions?: TargetOptions;
|
|
27
|
+
/**
|
|
28
|
+
* Install only the bundle's common part plus these flavors, rather than all
|
|
29
|
+
* of it. Empty or absent is the whole bundle. See `core/flavors.ts`.
|
|
30
|
+
*/
|
|
31
|
+
flavors?: string[];
|
|
32
|
+
/**
|
|
33
|
+
* `--param` assignments, as typed: `NAME=value`, `bundle:NAME=value` or
|
|
34
|
+
* `bundle@harness:NAME=value`. See `core/parameters.ts`.
|
|
35
|
+
*/
|
|
36
|
+
params?: string[];
|
|
37
|
+
/** `--params-file`: files of parameter values, later ones winning. */
|
|
38
|
+
paramsFiles?: string[];
|
|
39
|
+
/** Already-parsed overrides, for callers that are not a command line. */
|
|
40
|
+
parameterOverrides?: ParameterOverrides;
|
|
41
|
+
/**
|
|
42
|
+
* Values a previous installation was rendered with, reused unless something
|
|
43
|
+
* overrides them. `hcm update` passes these: it rolls the old installation
|
|
44
|
+
* back before reinstalling, so by then there is no record left to read.
|
|
45
|
+
*/
|
|
46
|
+
recordedParameters?: ParameterValues;
|
|
47
|
+
/**
|
|
48
|
+
* Ask for missing parameter values when there is a terminal. False never
|
|
49
|
+
* asks: defaults are used, and a required value with no default is an error.
|
|
50
|
+
*/
|
|
51
|
+
prompt?: boolean;
|
|
52
|
+
/** Ask again for values a previous install recorded. */
|
|
53
|
+
reconfigure?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Parameter answers remembered across bundles and targets in one run, so
|
|
56
|
+
* installing into three harnesses asks each question once. Created here when
|
|
57
|
+
* absent, like `decisions`.
|
|
58
|
+
*/
|
|
59
|
+
answers?: Map<string, string>;
|
|
60
|
+
/**
|
|
61
|
+
* Test seam: answers the 'which harness?' question instead of the terminal.
|
|
62
|
+
* See `chooseTargets` in core/harnesses.ts.
|
|
63
|
+
*/
|
|
64
|
+
targetChooser?: TargetChooser;
|
|
65
|
+
/** Install only what was named, leaving its `dependencies` to fail later. */
|
|
66
|
+
noDeps?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* The harnesses this folder is used by, so writes into a file another one
|
|
69
|
+
* also reads can be flagged. Worked out once at the start of the run and
|
|
70
|
+
* passed down: detecting again after the first install would find the
|
|
71
|
+
* harnesses this very command just created.
|
|
72
|
+
*/
|
|
73
|
+
presentTargets?: TargetId[];
|
|
74
|
+
cwd: string;
|
|
75
|
+
}
|
|
76
|
+
/** What one bundle in a run records about why it is being installed. */
|
|
77
|
+
export interface BundleRole {
|
|
78
|
+
/** Pulled in to satisfy another bundle rather than asked for by name. */
|
|
79
|
+
auto?: boolean;
|
|
80
|
+
/** The bundles it required, resolved. */
|
|
81
|
+
dependencies?: InstalledDependency[];
|
|
82
|
+
/** Who wanted it, for the log. */
|
|
83
|
+
requiredBy?: string[];
|
|
84
|
+
/**
|
|
85
|
+
* The harnesses to install into, overriding what the options say. A
|
|
86
|
+
* dependency goes wherever the bundles that need it went -- installing it
|
|
87
|
+
* into five harnesses because it happens to support five would leave four
|
|
88
|
+
* copies nobody asked for.
|
|
89
|
+
*/
|
|
90
|
+
targets?: TargetId[];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Install one bundle, or several.
|
|
94
|
+
*
|
|
95
|
+
* Several is not a loop over one. The bundles named in a single command are
|
|
96
|
+
* resolved into a single dependency graph, so a dependency two of them share is
|
|
97
|
+
* installed once, a version clash between them is an error rather than a race,
|
|
98
|
+
* and the conflict questions are asked once for the whole run.
|
|
99
|
+
*/
|
|
100
|
+
export declare function installCommand(references: string | string[], options: InstallOptions): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Install one already-loaded bundle into every requested target.
|
|
103
|
+
*
|
|
104
|
+
* Exported for `hcm update`, which installs a dependency it has already
|
|
105
|
+
* resolved -- going back through a name would only work for bundles that
|
|
106
|
+
* happen to be registered.
|
|
107
|
+
*/
|
|
108
|
+
export declare function installBundle(bundle: LoadedBundle, options: InstallOptions, role?: BundleRole): Promise<void>;
|
|
109
|
+
/** The "Claude Code · project · /path" banner each target's output sits under. */
|
|
110
|
+
export declare function logTargetHeader(targetId: TargetId, options: {
|
|
111
|
+
scope: Scope;
|
|
112
|
+
cwd: string;
|
|
113
|
+
}): void;
|
|
114
|
+
/**
|
|
115
|
+
* Install one bundle into one target. Exported because `hcm update` reinstalls
|
|
116
|
+
* a bundle target by target, following what the ledger says is already there.
|
|
117
|
+
*/
|
|
118
|
+
export declare function installInto(bundle: LoadedBundle, targetId: TargetId, options: InstallOptions, role?: BundleRole): Promise<void>;
|
|
119
|
+
export declare function describeTargetOptions(options: TargetOptions): string;
|