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
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
1
|
+
import { slugify } from "../../shared/patterns.js";
|
|
2
|
+
import { assetKinds } from "../asset-kinds/index.js";
|
|
3
|
+
/** Eight ID characters distinguish hooks with the same display name. */
|
|
4
|
+
const HOOK_ID_SUFFIX_LENGTH = 8;
|
|
5
|
+
/** Unknown origins sort after all explicitly ranked origins. */
|
|
6
|
+
const UNKNOWN_ORIGIN_RANK = 9;
|
|
7
|
+
/** Allow repeated scope and ID disambiguation before declaring a collision. */
|
|
8
|
+
const NAME_RESOLUTION_PASSES_PER_ASSET = 4;
|
|
10
9
|
const rank = {
|
|
11
10
|
local: 0,
|
|
12
11
|
dev: 1,
|
|
@@ -16,20 +15,28 @@ const rank = {
|
|
|
16
15
|
};
|
|
17
16
|
/** `<origin-type>-<origin-slug>-<name>` with single hyphens, e.g. team-super-team-review. */
|
|
18
17
|
export function prefixedName(asset) {
|
|
19
|
-
|
|
18
|
+
const prefix = [
|
|
20
19
|
asset.origin.type,
|
|
21
20
|
asset.origin.slug ?? asset.origin.id ?? "",
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
.
|
|
27
|
-
.replace(/^-+|-+$/g, "");
|
|
28
|
-
}
|
|
29
|
-
export function validInstalledName(name) {
|
|
30
|
-
return skillName.test(name) && name.length <= 64;
|
|
21
|
+
].join("-");
|
|
22
|
+
// An MCP server keeps its own spelling, such as my_server; only the prefix is a slug.
|
|
23
|
+
return asset.kind === "mcp"
|
|
24
|
+
? `${slugify(prefix)}-${asset.name}`
|
|
25
|
+
: slugify(`${prefix}-${asset.name}`);
|
|
31
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* The name an asset installs under: its saved rename from `localNames`, else
|
|
29
|
+
* its published name.
|
|
30
|
+
*/
|
|
32
31
|
export const installedName = (asset, localNames) => localNames[asset.id] ?? asset.name;
|
|
32
|
+
/** A folder name with a trailing copy number, `review-1a2b-2`; group 1 is the rest. */
|
|
33
|
+
const COPY_NUMBER = /^(.*)-\d+$/;
|
|
34
|
+
/**
|
|
35
|
+
* `review-1a2b-2` → `review-1a2b`; undefined when there is no copy number.
|
|
36
|
+
*
|
|
37
|
+
* @internal Exported for its table test in `src/tests/patterns.test.ts`.
|
|
38
|
+
*/
|
|
39
|
+
export const withoutCopyNumber = (folder) => COPY_NUMBER.exec(folder)?.[1];
|
|
33
40
|
/**
|
|
34
41
|
* Origin prefixes are ambiguous: team a's b-c and team a-b's c read the same. Each
|
|
35
42
|
* Hook gets its own folder: kept and already-installed folders stay put, a name only
|
|
@@ -42,66 +49,77 @@ export function hookFolders(hooks, localNames) {
|
|
|
42
49
|
folders.set(hook.id, folder);
|
|
43
50
|
used.add(folder);
|
|
44
51
|
};
|
|
45
|
-
const plain = (hook) => localNames[hook.id] ?? prefixedName(hook);
|
|
52
|
+
const plain = (hook) => localNames[hook.id] ?? prefixedName({ ...hook, kind: "hook" });
|
|
46
53
|
const idText = (hook) => hook.id.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
47
|
-
const suffixed = (hook) => `${plain(hook)}-${idText(hook).slice(0,
|
|
54
|
+
const suffixed = (hook) => `${plain(hook)}-${idText(hook).slice(0, HOOK_ID_SUFFIX_LENGTH)}`;
|
|
48
55
|
const whole = (hook) => `${plain(hook)}-${idText(hook)}`;
|
|
49
56
|
const ordered = [...hooks].sort((a, b) => a.id.localeCompare(b.id));
|
|
50
57
|
const open = () => ordered.filter((hook) => !folders.has(hook.id));
|
|
51
|
-
for (const hook of ordered)
|
|
52
|
-
if (hook.kept)
|
|
58
|
+
for (const hook of ordered) {
|
|
59
|
+
if (hook.kept) {
|
|
53
60
|
claim(hook, hook.kept);
|
|
54
|
-
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
for (const hook of open()) {
|
|
55
64
|
if (hook.current &&
|
|
56
65
|
!used.has(hook.current) &&
|
|
57
66
|
(hook.current === plain(hook) ||
|
|
58
67
|
hook.current === suffixed(hook) ||
|
|
59
68
|
hook.current === whole(hook) ||
|
|
60
|
-
hook.current
|
|
69
|
+
withoutCopyNumber(hook.current) === whole(hook))) {
|
|
61
70
|
claim(hook, hook.current);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
62
73
|
const wanting = open().map(plain);
|
|
63
|
-
for (const hook of open())
|
|
74
|
+
for (const hook of open()) {
|
|
64
75
|
if (!used.has(plain(hook)) &&
|
|
65
|
-
wanting.filter((folder) => folder === plain(hook)).length === 1)
|
|
76
|
+
wanting.filter((folder) => folder === plain(hook)).length === 1) {
|
|
66
77
|
claim(hook, plain(hook));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
67
80
|
for (const hook of open()) {
|
|
68
81
|
let folder = used.has(suffixed(hook)) ? whole(hook) : suffixed(hook);
|
|
69
|
-
for (let n = 2; used.has(folder); n++)
|
|
82
|
+
for (let n = 2; used.has(folder); n++) {
|
|
70
83
|
folder = `${whole(hook)}-${n}`;
|
|
84
|
+
}
|
|
71
85
|
claim(hook, folder);
|
|
72
86
|
}
|
|
73
87
|
return folders;
|
|
74
88
|
}
|
|
75
89
|
/** Drops automatic renames whose plain name is free again; explicit names stay. */
|
|
76
|
-
|
|
90
|
+
function restoreNames(assets, localNames) {
|
|
77
91
|
const next = { ...localNames };
|
|
78
92
|
for (const asset of assets) {
|
|
79
|
-
if (asset.renamable === false || next[asset.id] !== prefixedName(asset))
|
|
93
|
+
if (asset.renamable === false || next[asset.id] !== prefixedName(asset)) {
|
|
80
94
|
continue;
|
|
95
|
+
}
|
|
81
96
|
const taken = assets.some((other) => other.id !== asset.id &&
|
|
82
97
|
other.kind === asset.kind &&
|
|
83
98
|
installedName(other, next) === asset.name);
|
|
84
|
-
if (!taken)
|
|
99
|
+
if (!taken) {
|
|
85
100
|
delete next[asset.id];
|
|
101
|
+
}
|
|
86
102
|
}
|
|
87
103
|
return next;
|
|
88
104
|
}
|
|
89
105
|
/** The first clash in a stable order; the asset already installed (or most specific scope) keeps the name. */
|
|
90
|
-
|
|
106
|
+
function findClash(assets, localNames) {
|
|
91
107
|
const groups = new Map();
|
|
92
108
|
for (const asset of assets) {
|
|
93
109
|
const key = `${asset.kind}\0${installedName(asset, localNames)}`;
|
|
94
110
|
groups.set(key, [...(groups.get(key) ?? []), asset]);
|
|
95
111
|
}
|
|
96
|
-
for (const [
|
|
97
|
-
if (group.length < 2)
|
|
98
|
-
continue;
|
|
112
|
+
for (const [, group] of [...groups].sort(([a], [b]) => a.localeCompare(b))) {
|
|
99
113
|
const [installed, incoming] = [...group].sort((a, b) => Number(b.installed) - Number(a.installed) ||
|
|
100
|
-
(rank[a.origin.type] ??
|
|
114
|
+
(rank[a.origin.type] ?? UNKNOWN_ORIGIN_RANK) -
|
|
115
|
+
(rank[b.origin.type] ?? UNKNOWN_ORIGIN_RANK) ||
|
|
101
116
|
a.id.localeCompare(b.id));
|
|
117
|
+
if (!installed || !incoming) {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
102
120
|
return {
|
|
103
121
|
kind: installed.kind,
|
|
104
|
-
name:
|
|
122
|
+
name: installedName(installed, localNames),
|
|
105
123
|
installed,
|
|
106
124
|
incoming,
|
|
107
125
|
installedRename: prefixedName(installed),
|
|
@@ -119,24 +137,28 @@ export async function resolveClashes(assets, localNames, resolver) {
|
|
|
119
137
|
let active = [...assets];
|
|
120
138
|
const disabled = [];
|
|
121
139
|
const skipped = [];
|
|
122
|
-
for (let guard = 0; guard <
|
|
140
|
+
for (let guard = 0; guard <
|
|
141
|
+
assets.length * NAME_RESOLUTION_PASSES_PER_ASSET +
|
|
142
|
+
NAME_RESOLUTION_PASSES_PER_ASSET; guard++) {
|
|
123
143
|
const clash = findClash(active, names);
|
|
124
|
-
if (!clash)
|
|
144
|
+
if (!clash) {
|
|
125
145
|
return { localNames: names, disabledAssetIds: disabled, skipped };
|
|
146
|
+
}
|
|
126
147
|
let choice = resolver ? await resolver(clash) : "skip-incoming";
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
148
|
+
const renames = {
|
|
149
|
+
"rename-incoming": clash.incoming,
|
|
150
|
+
"rename-installed": clash.installed,
|
|
151
|
+
};
|
|
152
|
+
const rename = renames[choice];
|
|
132
153
|
if (rename) {
|
|
133
154
|
const name = prefixedName(rename);
|
|
134
155
|
if (rename.renamable === false ||
|
|
135
|
-
!
|
|
156
|
+
!assetKinds[rename.kind].validName(name) ||
|
|
136
157
|
active.some((other) => other.id !== rename.id &&
|
|
137
158
|
other.kind === rename.kind &&
|
|
138
|
-
installedName(other, names) === name))
|
|
159
|
+
installedName(other, names) === name)) {
|
|
139
160
|
choice = "skip-incoming";
|
|
161
|
+
}
|
|
140
162
|
else {
|
|
141
163
|
names = { ...names, [rename.id]: name };
|
|
142
164
|
continue;
|
|
@@ -144,10 +166,12 @@ export async function resolveClashes(assets, localNames, resolver) {
|
|
|
144
166
|
}
|
|
145
167
|
const removed = choice === "replace-installed" ? clash.installed : clash.incoming;
|
|
146
168
|
active = active.filter((asset) => asset.id !== removed.id);
|
|
147
|
-
if (resolver)
|
|
169
|
+
if (resolver) {
|
|
148
170
|
disabled.push(removed.id);
|
|
149
|
-
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
150
173
|
skipped.push(clash);
|
|
174
|
+
}
|
|
151
175
|
}
|
|
152
|
-
throw new Error("
|
|
176
|
+
throw new Error("Installed names still clash after renaming");
|
|
153
177
|
}
|