barndog 0.1.1 → 0.2.1
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/README.md +31 -28
- package/dist/cli.js +11 -7
- package/dist/commands/add.js +34 -21
- package/dist/commands/adopt.js +91 -0
- package/dist/commands/arguments.js +12 -0
- package/dist/commands/asset-install.js +161 -0
- package/dist/commands/asset-list.js +126 -0
- package/dist/commands/asset-share.js +94 -0
- package/dist/commands/auth.js +4 -0
- package/dist/commands/availability.js +72 -27
- package/dist/commands/capabilities.js +79 -417
- package/dist/commands/collaboration.js +212 -108
- package/dist/commands/environment.js +18 -411
- package/dist/commands/github.js +200 -0
- package/dist/commands/harnesses.js +74 -0
- package/dist/commands/helpers.js +39 -0
- package/dist/commands/hooks.js +87 -0
- package/dist/commands/init.js +4 -2
- package/dist/commands/knowledge.js +73 -0
- package/dist/commands/mcp-env.js +78 -0
- package/dist/commands/mcp.js +64 -0
- package/dist/commands/origin.js +21 -23
- package/dist/commands/people.js +51 -0
- package/dist/commands/sets.js +141 -0
- package/dist/commands/status.js +36 -25
- package/dist/commands/sync.js +13 -5
- package/dist/commands/workspace.js +75 -23
- package/dist/config/environment.js +13 -27
- package/dist/config/paths.js +81 -0
- package/dist/config/selection.js +30 -0
- package/dist/config/settings.js +99 -108
- package/dist/config/state.js +67 -55
- package/dist/entry/knowledge-startup.js +32 -0
- package/dist/entry/mcp-launch.js +71 -0
- package/dist/entry/opencode-plugin.js +62 -0
- package/dist/{features/git-workspace/startup.js → entry/workspace-startup.js} +7 -2
- package/dist/errors.js +198 -55
- package/dist/features/adoption/adopt.js +234 -0
- package/dist/features/adoption/copies.js +29 -0
- package/dist/features/adoption/originals.js +116 -0
- package/dist/features/adoption/record.js +120 -0
- package/dist/features/adoption/restore.js +28 -0
- package/dist/features/adoption/scan.js +482 -0
- package/dist/features/adoption/undo.js +42 -0
- package/dist/features/asset-kinds/index.js +129 -0
- package/dist/features/asset-selection/index.js +51 -19
- package/dist/features/auth/credentials.js +80 -54
- package/dist/features/auth/session.js +83 -49
- package/dist/features/auth/transport.js +69 -17
- package/dist/features/catalog/index.js +32 -61
- package/dist/features/collaboration/api.js +160 -0
- package/dist/features/collaboration/index.js +321 -233
- package/dist/features/collaboration/remote.js +35 -115
- package/dist/features/collaboration/results.js +2 -0
- package/dist/features/collaboration/workspace-git.js +242 -152
- package/dist/features/collaboration/workspace-github.js +118 -54
- package/dist/features/collaboration/workspace-store.js +157 -97
- package/dist/features/collaboration/workspace.js +278 -173
- package/dist/features/discovery/index.js +68 -57
- package/dist/features/doctor/index.js +56 -26
- package/dist/features/environment/auto-sync.js +28 -27
- package/dist/features/environment/harnesses.js +36 -0
- package/dist/features/environment/moves.js +171 -0
- package/dist/features/environment/names.js +73 -49
- package/dist/features/environment/operations.js +322 -229
- package/dist/features/environment/own-entries.js +89 -0
- package/dist/features/environment/settle-names.js +91 -0
- package/dist/features/environment/stage.js +202 -0
- package/dist/features/environment/sync.js +127 -487
- package/dist/features/environment/transaction.js +179 -147
- package/dist/features/environment/writes.js +243 -0
- package/dist/features/github/account.js +25 -0
- package/dist/features/github/connections.js +119 -0
- package/dist/features/github/pulls.js +118 -0
- package/dist/features/hooks/adapt.js +32 -25
- package/dist/features/hooks/catalog.js +28 -0
- package/dist/features/hooks/compatibility.js +55 -0
- package/dist/features/hooks/divergence.js +36 -12
- package/dist/features/hooks/test.js +91 -66
- package/dist/features/hooks/types.js +1 -0
- package/dist/features/imports/discover.js +133 -60
- package/dist/features/imports/folder.js +48 -14
- package/dist/features/imports/local.js +127 -135
- package/dist/features/imports/remote.js +46 -26
- package/dist/features/inspection/index.js +17 -17
- package/dist/features/inventory/index.js +111 -111
- package/dist/features/inventory/show.js +74 -0
- package/dist/features/knowledge/index.js +69 -49
- package/dist/features/mcps/catalog.js +31 -0
- package/dist/features/mcps/import.js +369 -0
- package/dist/features/mcps/index.js +104 -50
- package/dist/features/mcps/values.js +33 -0
- package/dist/features/migration/migrate.js +263 -0
- package/dist/features/migration/move.js +448 -0
- package/dist/features/migration/promote.js +26 -0
- package/dist/features/native/adapters.js +69 -96
- package/dist/features/native/configuration.js +134 -84
- package/dist/features/native/hook-shell.js +55 -0
- package/dist/features/native/plugin-module.js +56 -0
- package/dist/features/native/secret-values.js +74 -0
- package/dist/features/onboarding/environment.js +67 -34
- package/dist/features/onboarding/setup.js +43 -40
- package/dist/features/repositories/context.js +30 -13
- package/dist/features/secrets/index.js +77 -0
- package/dist/features/server/catalog.js +58 -0
- package/dist/features/server/client.js +13 -0
- package/dist/features/server/connection.js +37 -0
- package/dist/features/server/origin.js +74 -0
- package/dist/features/server/pages.js +24 -0
- package/dist/features/skills/catalog.js +42 -0
- package/dist/features/workspace/assets.js +57 -0
- package/dist/features/workspace/cloud-source.js +34 -0
- package/dist/features/workspace/directory.js +38 -0
- package/dist/features/{git-workspace → workspace}/format.js +121 -54
- package/dist/features/workspace/git.js +221 -0
- package/dist/features/workspace/installed.js +92 -0
- package/dist/features/{git-workspace → workspace}/overlay.js +53 -46
- package/dist/features/workspace/packages.js +173 -0
- package/dist/features/{git-workspace → workspace}/publish.js +120 -64
- package/dist/features/workspace/repo-source.js +193 -0
- package/dist/features/{git-workspace → workspace}/setup.js +72 -45
- package/dist/features/{git-workspace → workspace}/snapshot.js +60 -19
- package/dist/features/workspace/source.js +1 -0
- package/dist/features/workspace/tree.js +52 -0
- package/dist/features/workspace/workspace-source.js +27 -0
- package/dist/harnesses/claude.js +23 -1
- package/dist/harnesses/codex.js +67 -1
- package/dist/harnesses/cursor.js +22 -1
- package/dist/harnesses/detect.js +6 -50
- package/dist/harnesses/formats.js +52 -0
- package/dist/harnesses/opencode.js +108 -0
- package/dist/harnesses/registry.js +35 -2
- package/dist/platform.js +403 -0
- package/dist/program.js +275 -56
- package/dist/runtime.js +1 -0
- package/dist/shared/cli-error.js +22 -0
- package/dist/shared/constants.js +32 -0
- package/dist/shared/files.js +107 -0
- package/dist/shared/lock.js +113 -0
- package/dist/shared/lookup.js +11 -0
- package/dist/shared/patterns.js +102 -0
- package/dist/shared/shell.js +20 -0
- package/dist/shared/values.js +26 -0
- package/dist/ui/add-asset.js +41 -400
- package/dist/ui/add-hook.js +219 -0
- package/dist/ui/add-mcp.js +170 -0
- package/dist/ui/add-prompts.js +47 -0
- package/dist/ui/add-skills.js +117 -0
- package/dist/ui/adopt.js +197 -0
- package/dist/ui/asset-list.js +31 -13
- package/dist/ui/assets.js +38 -47
- package/dist/ui/auth.js +45 -34
- package/dist/ui/clash.js +10 -6
- package/dist/ui/collaboration.js +116 -44
- package/dist/ui/connection.js +17 -6
- package/dist/ui/decision-error.js +24 -0
- package/dist/ui/environment-onboarding.js +35 -13
- package/dist/ui/format.js +66 -18
- package/dist/ui/harness-picker.js +18 -0
- package/dist/ui/hook-compatibility.js +14 -6
- package/dist/ui/mcp.js +28 -3
- package/dist/ui/move.js +57 -6
- package/dist/ui/onboarding.js +148 -95
- package/dist/ui/options.js +9 -0
- package/dist/ui/output.js +108 -43
- package/dist/ui/package-details.js +34 -0
- package/dist/ui/pick.js +45 -33
- package/dist/ui/scope-install.js +18 -7
- package/dist/ui/secret-input.js +19 -0
- package/dist/ui/selection.js +17 -11
- package/dist/ui/theme.js +37 -14
- package/dist/version.js +6 -3
- package/package.json +13 -3
- package/dist/features/capabilities/index.js +0 -106
- package/dist/features/collaboration/domain.js +0 -90
- package/dist/features/environment/cloud-source.js +0 -27
- package/dist/features/environment/installed.js +0 -124
- package/dist/features/environment/packages.js +0 -120
- package/dist/features/environment/remote.js +0 -71
- package/dist/features/environment/workspace-source.js +0 -19
- package/dist/features/git-hosts/index.js +0 -148
- package/dist/features/git-workspace/assets.js +0 -71
- package/dist/features/git-workspace/git.js +0 -135
- package/dist/features/git-workspace/migrate.js +0 -188
- package/dist/features/git-workspace/move.js +0 -337
- package/dist/features/git-workspace/source.js +0 -159
- package/dist/features/imports/mcp.js +0 -219
- package/dist/features/knowledge/startup.js +0 -25
- package/dist/features/native/mcp-launch.js +0 -57
- package/dist/features/skills/install.js +0 -25
- package/dist/features/skills/remote.js +0 -177
- package/dist/features/skills/sync.js +0 -121
- package/dist/features/skills/validation.js +0 -34
- /package/dist/features/environment/{source.js → events.js} +0 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Taking an asset out of its coding tool and putting it back. Each step checks
|
|
3
|
+
* the disk first, so running it again after a crash does only what is left.
|
|
4
|
+
*/
|
|
5
|
+
import { cp, lstat, mkdir, readlink, rename, rm, symlink, unlink, } from "node:fs/promises";
|
|
6
|
+
import { dirname } from "node:path";
|
|
7
|
+
import { isDeepStrictEqual } from "node:util";
|
|
8
|
+
import { parse as parseJsonc } from "jsonc-parser";
|
|
9
|
+
import { parse as parseToml } from "smol-toml";
|
|
10
|
+
import { CliError } from "../../errors.js";
|
|
11
|
+
import { adapters } from "../../harnesses/registry.js";
|
|
12
|
+
import { directoryLinkType } from "../../platform.js";
|
|
13
|
+
import { ifExists, readIfExists, writeAtomic } from "../../shared/files.js";
|
|
14
|
+
import { asRecord } from "../../shared/values.js";
|
|
15
|
+
import { errorCode } from "../../shared/values.js";
|
|
16
|
+
import { patchNative } from "../native/configuration.js";
|
|
17
|
+
/** A rename can't cross disks, so a folder on another one is copied, then removed. */
|
|
18
|
+
async function moveFolder(from, to) {
|
|
19
|
+
await mkdir(dirname(to), { recursive: true });
|
|
20
|
+
try {
|
|
21
|
+
await rename(from, to);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
if (errorCode(error) !== "EXDEV") {
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
await cp(from, to, { recursive: true, verbatimSymlinks: true });
|
|
28
|
+
await rm(from, { recursive: true, force: true });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const nativeEntry = (harness, original) => ({
|
|
32
|
+
id: "adoption",
|
|
33
|
+
kind: original.kind,
|
|
34
|
+
harness,
|
|
35
|
+
file: original.file,
|
|
36
|
+
key: original.key,
|
|
37
|
+
value: original.value,
|
|
38
|
+
});
|
|
39
|
+
/** Whether the tool's settings file holds this entry exactly as it was adopted. */
|
|
40
|
+
function holds(text, harness, original) {
|
|
41
|
+
if (text === null) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
const data = asRecord(original.file.endsWith(".toml") ? parseToml(text) : parseJsonc(text));
|
|
45
|
+
if (original.kind === "mcp") {
|
|
46
|
+
const servers = adapters[harness].mcp.path.reduce((value, key) => asRecord(value)[key], data);
|
|
47
|
+
return isDeepStrictEqual(asRecord(servers)[original.key], original.value);
|
|
48
|
+
}
|
|
49
|
+
const list = asRecord(data.hooks)[original.key];
|
|
50
|
+
return (Array.isArray(list) &&
|
|
51
|
+
list.some((entry) => isDeepStrictEqual(entry, original.value)));
|
|
52
|
+
}
|
|
53
|
+
/** Takes an asset out of its tool; a Skill folder moves to `backup`. */
|
|
54
|
+
export async function takeOut(harness, original, backup) {
|
|
55
|
+
switch (original.type) {
|
|
56
|
+
case "folder": {
|
|
57
|
+
if (!backup) {
|
|
58
|
+
throw new Error("A Skill folder is adopted without a backup path");
|
|
59
|
+
}
|
|
60
|
+
if ((await ifExists(lstat(original.path))) !== null) {
|
|
61
|
+
await moveFolder(original.path, backup);
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
case "link": {
|
|
66
|
+
if ((await ifExists(lstat(original.path))) !== null) {
|
|
67
|
+
await unlink(original.path);
|
|
68
|
+
}
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
case "entry": {
|
|
72
|
+
const text = await readIfExists(original.file);
|
|
73
|
+
if (holds(text, harness, original)) {
|
|
74
|
+
await writeAtomic(original.file, patchNative(text, [nativeEntry(harness, original)], []));
|
|
75
|
+
}
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** Puts an asset back where it was, refusing to replace anything that took its place. */
|
|
81
|
+
export async function putBack(harness, original, backup, runtime) {
|
|
82
|
+
const occupied = (path) => new CliError(`${path} exists again, so BarnDog can't put the adopted copy back there.`, "Move it aside, then run barndog adopt undo again");
|
|
83
|
+
switch (original.type) {
|
|
84
|
+
case "folder": {
|
|
85
|
+
const saved = backup && (await ifExists(lstat(backup)));
|
|
86
|
+
if (!backup || !saved) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if ((await ifExists(lstat(original.path))) !== null) {
|
|
90
|
+
throw occupied(original.path);
|
|
91
|
+
}
|
|
92
|
+
await moveFolder(backup, original.path);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
case "link": {
|
|
96
|
+
const existing = await ifExists(lstat(original.path));
|
|
97
|
+
if (existing) {
|
|
98
|
+
if (existing.isSymbolicLink() &&
|
|
99
|
+
(await readlink(original.path)) === original.target) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
throw occupied(original.path);
|
|
103
|
+
}
|
|
104
|
+
await mkdir(dirname(original.path), { recursive: true });
|
|
105
|
+
await symlink(original.target, original.path, directoryLinkType(runtime.platform));
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
case "entry": {
|
|
109
|
+
const text = await readIfExists(original.file);
|
|
110
|
+
if (!holds(text, harness, original)) {
|
|
111
|
+
await writeAtomic(original.file, patchNative(text, [], [nativeEntry(harness, original)]));
|
|
112
|
+
}
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The record of one `barndog adopt`, kept at
|
|
3
|
+
* `~/.barndog/adoptions/<id>/record.json` with the originals it moved aside.
|
|
4
|
+
* Undo reads it to put everything back, and checks each step against the disk
|
|
5
|
+
* so it can finish an adoption that stopped halfway.
|
|
6
|
+
*/
|
|
7
|
+
import { readdir } from "node:fs/promises";
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { barndogPaths } from "../../config/paths.js";
|
|
10
|
+
import { CliError } from "../../errors.js";
|
|
11
|
+
import { harnesses } from "../../harnesses/registry.js";
|
|
12
|
+
import { ifExists, readIfExists, writeAtomic } from "../../shared/files.js";
|
|
13
|
+
import { UUID_V4 } from "../../shared/patterns.js";
|
|
14
|
+
/** The kinds of asset a coding tool keeps that BarnDog can adopt. */
|
|
15
|
+
const nativeAssetKinds = ["skill", "mcp", "hook"];
|
|
16
|
+
const originalSchema = z.discriminatedUnion("type", [
|
|
17
|
+
/** A Skill folder of the tool's own, moved into the adoption's folder. */
|
|
18
|
+
z.strictObject({ type: z.literal("folder"), path: z.string() }),
|
|
19
|
+
/** A link the user made to a Skill kept elsewhere; its target is never touched. */
|
|
20
|
+
z.strictObject({
|
|
21
|
+
type: z.literal("link"),
|
|
22
|
+
path: z.string(),
|
|
23
|
+
target: z.string(),
|
|
24
|
+
}),
|
|
25
|
+
/** An MCP server or one hook event entry in a tool's settings file, as it was written there. */
|
|
26
|
+
z.strictObject({
|
|
27
|
+
type: z.literal("entry"),
|
|
28
|
+
kind: z.enum(["mcp", "hook"]),
|
|
29
|
+
file: z.string(),
|
|
30
|
+
/** The MCP server's name, or the hook's event. */
|
|
31
|
+
key: z.string(),
|
|
32
|
+
value: z.record(z.string(), z.unknown()),
|
|
33
|
+
}),
|
|
34
|
+
]);
|
|
35
|
+
const itemSchema = z.strictObject({
|
|
36
|
+
/** `claude/mcp/github`, as `--only` names it. */
|
|
37
|
+
key: z.string(),
|
|
38
|
+
harness: z.enum(harnesses),
|
|
39
|
+
kind: z.enum(nativeAssetKinds),
|
|
40
|
+
name: z.string(),
|
|
41
|
+
description: z.string(),
|
|
42
|
+
/** BarnDog's copy in the local folder; tools that had the same name share it. */
|
|
43
|
+
copy: z.string(),
|
|
44
|
+
assetId: z.string(),
|
|
45
|
+
/** The copy as adopted, so undo can tell whether it was edited since. */
|
|
46
|
+
fingerprint: z.string(),
|
|
47
|
+
original: originalSchema,
|
|
48
|
+
/** Where a moved Skill folder waits until undo puts it back. */
|
|
49
|
+
backup: z.string().optional(),
|
|
50
|
+
undone: z.boolean(),
|
|
51
|
+
});
|
|
52
|
+
const recordSchema = z.looseObject({
|
|
53
|
+
id: z.string().regex(UUID_V4),
|
|
54
|
+
createdAt: z.string(),
|
|
55
|
+
/** `pending` until every step finished; undo can finish or reverse one. */
|
|
56
|
+
status: z.enum(["pending", "applied", "undone"]),
|
|
57
|
+
/** Copies of each settings file taken before BarnDog first changed it. */
|
|
58
|
+
files: z.array(z.strictObject({ file: z.string(), backup: z.string() })),
|
|
59
|
+
items: z.array(itemSchema),
|
|
60
|
+
});
|
|
61
|
+
const recordFile = (id, home) => barndogPaths(home).adoption(id).record;
|
|
62
|
+
export async function writeAdoption(record, home) {
|
|
63
|
+
await writeAtomic(recordFile(record.id, home), JSON.stringify(record, null, 2) + "\n");
|
|
64
|
+
}
|
|
65
|
+
async function readAdoption(id, home) {
|
|
66
|
+
// Only an ID BarnDog made names a folder, so `../x` can't reach elsewhere.
|
|
67
|
+
const file = UUID_V4.test(id) ? recordFile(id, home) : null;
|
|
68
|
+
const text = file === null ? null : await readIfExists(file);
|
|
69
|
+
if (file === null || text === null) {
|
|
70
|
+
throw new CliError(`There's no adoption ${id}.`, "barndog adopt list");
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
return recordSchema.parse(JSON.parse(text));
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
throw new CliError(`${file} is damaged, so BarnDog can't tell what that adoption moved.`, "Undo any edit to that file, then try again", { cause: error });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/** Every adoption on this machine, newest first. */
|
|
80
|
+
export async function readAdoptions(home) {
|
|
81
|
+
const folders = (await ifExists(readdir(barndogPaths(home).adoptions))) ?? [];
|
|
82
|
+
const records = await Promise.all(folders
|
|
83
|
+
.filter((name) => UUID_V4.test(name))
|
|
84
|
+
.map((id) => readAdoption(id, home)));
|
|
85
|
+
return records.sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
|
86
|
+
}
|
|
87
|
+
/** The adoption `id` names, or the newest one that still has something to undo. */
|
|
88
|
+
export async function findAdoption(id, home) {
|
|
89
|
+
if (id) {
|
|
90
|
+
return readAdoption(id, home);
|
|
91
|
+
}
|
|
92
|
+
const open = (await readAdoptions(home)).find((record) => record.status !== "undone");
|
|
93
|
+
if (!open) {
|
|
94
|
+
throw new CliError("There's nothing to undo.", "barndog adopt list");
|
|
95
|
+
}
|
|
96
|
+
return open;
|
|
97
|
+
}
|
|
98
|
+
export function summary(record) {
|
|
99
|
+
return {
|
|
100
|
+
id: record.id,
|
|
101
|
+
createdAt: record.createdAt,
|
|
102
|
+
status: record.status,
|
|
103
|
+
items: record.items.map((item) => ({
|
|
104
|
+
key: item.key,
|
|
105
|
+
harness: item.harness,
|
|
106
|
+
kind: item.kind,
|
|
107
|
+
name: item.name,
|
|
108
|
+
description: item.description,
|
|
109
|
+
location: item.original.type === "entry"
|
|
110
|
+
? item.original.file
|
|
111
|
+
: item.original.path,
|
|
112
|
+
copy: item.copy,
|
|
113
|
+
undone: item.undone,
|
|
114
|
+
})),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/** The adoptions on this machine, newest first, as `adopt list` shows them. */
|
|
118
|
+
export async function listAdoptions(home) {
|
|
119
|
+
return (await readAdoptions(home)).map(summary);
|
|
120
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { rm } from "node:fs/promises";
|
|
2
|
+
import { readState } from "../../config/state.js";
|
|
3
|
+
import { synchronize } from "../environment/sync.js";
|
|
4
|
+
import { installed } from "./copies.js";
|
|
5
|
+
import { putBack } from "./originals.js";
|
|
6
|
+
import { writeAdoption } from "./record.js";
|
|
7
|
+
/**
|
|
8
|
+
* Removes BarnDog's copies of `items`, syncs so its installations go, and puts
|
|
9
|
+
* the originals back. Safe to run again: each step checks what is still to do.
|
|
10
|
+
*/
|
|
11
|
+
export async function restore(record, items, runtime) {
|
|
12
|
+
const { home } = runtime;
|
|
13
|
+
for (const copy of new Set(items.map((item) => item.copy))) {
|
|
14
|
+
await rm(copy, { recursive: true, force: true });
|
|
15
|
+
}
|
|
16
|
+
const state = await readState(home);
|
|
17
|
+
if (items.some((item) => installed(item, state))) {
|
|
18
|
+
await synchronize(undefined, runtime, undefined, { prompt: false });
|
|
19
|
+
}
|
|
20
|
+
for (const item of items) {
|
|
21
|
+
await putBack(item.harness, item.original, item.backup, runtime);
|
|
22
|
+
item.undone = true;
|
|
23
|
+
}
|
|
24
|
+
record.status = record.items.every((item) => item.undone)
|
|
25
|
+
? "undone"
|
|
26
|
+
: "applied";
|
|
27
|
+
await writeAdoption(record, home);
|
|
28
|
+
}
|