barndog 0.1.0 → 0.2.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/README.md +11 -10
- package/dist/cli.js +11 -7
- package/dist/commands/add.js +33 -21
- package/dist/commands/arguments.js +12 -0
- package/dist/commands/asset-install.js +160 -0
- package/dist/commands/asset-list.js +121 -0
- package/dist/commands/asset-share.js +94 -0
- package/dist/commands/auth.js +4 -0
- package/dist/commands/availability.js +54 -26
- package/dist/commands/capabilities.js +71 -415
- package/dist/commands/collaboration.js +194 -110
- package/dist/commands/environment.js +18 -411
- package/dist/commands/github.js +200 -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.js +62 -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 +34 -24
- package/dist/commands/sync.js +11 -4
- package/dist/commands/workspace.js +33 -19
- package/dist/config/environment.js +13 -27
- package/dist/config/paths.js +62 -0
- package/dist/config/selection.js +30 -0
- package/dist/config/settings.js +97 -108
- package/dist/config/state.js +57 -57
- 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/asset-kinds/index.js +120 -0
- package/dist/features/asset-selection/index.js +51 -19
- package/dist/features/auth/credentials.js +80 -47
- package/dist/features/auth/session.js +80 -45
- package/dist/features/auth/transport.js +66 -15
- 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 +233 -149
- package/dist/features/collaboration/workspace-github.js +117 -54
- package/dist/features/collaboration/workspace-store.js +140 -100
- package/dist/features/collaboration/workspace.js +257 -172
- package/dist/features/discovery/index.js +68 -57
- package/dist/features/doctor/index.js +32 -24
- package/dist/features/environment/auto-sync.js +28 -27
- package/dist/features/environment/names.js +67 -47
- package/dist/features/environment/operations.js +321 -228
- package/dist/features/environment/own-entries.js +89 -0
- package/dist/features/environment/settle-names.js +91 -0
- package/dist/features/environment/stage.js +178 -0
- package/dist/features/environment/sync.js +113 -484
- package/dist/features/environment/transaction.js +179 -147
- package/dist/features/environment/writes.js +196 -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 +49 -0
- package/dist/features/hooks/divergence.js +9 -6
- package/dist/features/hooks/test.js +74 -49
- package/dist/features/hooks/types.js +1 -0
- package/dist/features/imports/discover.js +134 -61
- package/dist/features/imports/folder.js +48 -14
- package/dist/features/imports/local.js +113 -134
- package/dist/features/imports/remote.js +44 -25
- package/dist/features/inspection/index.js +17 -17
- package/dist/features/inventory/index.js +99 -110
- package/dist/features/knowledge/index.js +69 -49
- package/dist/features/mcps/catalog.js +31 -0
- package/dist/features/mcps/import.js +316 -0
- package/dist/features/mcps/index.js +98 -49
- package/dist/features/migration/migrate.js +263 -0
- package/dist/features/{git-workspace → migration}/move.js +165 -109
- package/dist/features/migration/promote.js +24 -0
- package/dist/features/native/adapters.js +53 -94
- package/dist/features/native/configuration.js +128 -82
- package/dist/features/native/hook-shell.js +55 -0
- package/dist/features/native/plugin-module.js +56 -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/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 +114 -51
- package/dist/features/workspace/git.js +214 -0
- package/dist/features/workspace/installed.js +92 -0
- package/dist/features/{git-workspace → workspace}/overlay.js +43 -23
- package/dist/features/workspace/packages.js +160 -0
- package/dist/features/{git-workspace → workspace}/publish.js +120 -64
- package/dist/features/workspace/repo-source.js +192 -0
- package/dist/features/{git-workspace → workspace}/setup.js +60 -42
- package/dist/features/{git-workspace → workspace}/snapshot.js +53 -18
- 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 +57 -1
- package/dist/harnesses/cursor.js +22 -1
- package/dist/harnesses/detect.js +6 -50
- package/dist/harnesses/formats.js +45 -0
- package/dist/harnesses/opencode.js +111 -0
- package/dist/harnesses/registry.js +35 -2
- package/dist/platform.js +375 -0
- package/dist/program.js +225 -54
- 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 +72 -0
- package/dist/shared/lock.js +49 -0
- package/dist/shared/lookup.js +11 -0
- package/dist/shared/patterns.js +94 -0
- package/dist/shared/shell.js +22 -0
- package/dist/shared/values.js +26 -0
- package/dist/ui/add-asset.js +41 -400
- package/dist/ui/add-hook.js +213 -0
- package/dist/ui/add-mcp.js +107 -0
- package/dist/ui/add-prompts.js +47 -0
- package/dist/ui/add-skills.js +115 -0
- package/dist/ui/asset-list.js +31 -13
- package/dist/ui/assets.js +33 -44
- package/dist/ui/auth.js +43 -33
- package/dist/ui/clash.js +11 -6
- package/dist/ui/collaboration.js +116 -44
- package/dist/ui/connection.js +10 -4
- 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/hook-compatibility.js +14 -6
- package/dist/ui/mcp.js +28 -3
- package/dist/ui/move.js +10 -5
- package/dist/ui/onboarding.js +113 -73
- package/dist/ui/options.js +9 -0
- package/dist/ui/output.js +106 -43
- package/dist/ui/pick.js +45 -33
- package/dist/ui/scope-install.js +15 -7
- package/dist/ui/selection.js +15 -11
- package/dist/ui/theme.js +37 -14
- package/dist/version.js +6 -3
- package/package.json +24 -11
- 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/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
package/dist/ui/auth.js
CHANGED
|
@@ -1,38 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { login, logout, authStatus } from "../features/auth/session.js";
|
|
4
|
-
import { configuredServer } from "../features/auth/session.js";
|
|
1
|
+
import open from "open";
|
|
2
|
+
import { login, logout, authStatus, configuredServer, } from "../features/auth/session.js";
|
|
5
3
|
import { readCredentials } from "../features/auth/credentials.js";
|
|
6
4
|
import { LoginRequiredError } from "../features/auth/transport.js";
|
|
7
5
|
import { CliError } from "../errors.js";
|
|
8
6
|
import { promptServer } from "./connection.js";
|
|
9
7
|
import { bad, bold, dim, fields, heading, hint, humanize, json, ok, warn, } from "./format.js";
|
|
8
|
+
/** Opens `url` in the default browser; rejects when no browser could be started. */
|
|
10
9
|
export async function openBrowser(url) {
|
|
11
|
-
|
|
12
|
-
? "open"
|
|
13
|
-
: process.platform === "win32"
|
|
14
|
-
? "rundll32"
|
|
15
|
-
: "xdg-open";
|
|
16
|
-
const args = process.platform === "win32" ? ["url.dll,FileProtocolHandler", url] : [url];
|
|
17
|
-
await new Promise((resolve, reject) => {
|
|
18
|
-
const child = spawn(command, args, { stdio: "ignore" });
|
|
19
|
-
child.once("error", reject);
|
|
20
|
-
child.once("exit", (code) => code === 0 ? resolve() : reject(new Error("Unable to open browser")));
|
|
21
|
-
});
|
|
10
|
+
await open(url);
|
|
22
11
|
}
|
|
23
12
|
function describeIdentity(context) {
|
|
24
13
|
return `${bold(context.developer.name)} ${dim(`@${context.developer.slug}`)} · ${context.organization.name}`;
|
|
25
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Runs interactive device login, optionally opens a browser and saves
|
|
17
|
+
* credentials; reports an existing session unless forced.
|
|
18
|
+
*/
|
|
26
19
|
export async function runLogin(options, write) {
|
|
27
20
|
const server = options.server ??
|
|
28
|
-
(await configuredServer(options.
|
|
21
|
+
(await configuredServer(options.runtime)) ??
|
|
29
22
|
(process.stdin.isTTY && process.stdout.isTTY
|
|
30
23
|
? await promptServer()
|
|
31
24
|
: undefined);
|
|
32
25
|
if (server && !options.force) {
|
|
33
|
-
const current = await authStatus(options.
|
|
34
|
-
if (error instanceof LoginRequiredError)
|
|
26
|
+
const current = await authStatus(options.runtime, server).catch((error) => {
|
|
27
|
+
if (error instanceof LoginRequiredError) {
|
|
35
28
|
return undefined;
|
|
29
|
+
}
|
|
36
30
|
throw error;
|
|
37
31
|
});
|
|
38
32
|
if (current) {
|
|
@@ -50,14 +44,15 @@ export async function runLogin(options, write) {
|
|
|
50
44
|
try {
|
|
51
45
|
const result = await login({
|
|
52
46
|
server,
|
|
53
|
-
|
|
47
|
+
runtime: options.runtime,
|
|
54
48
|
signal: controller.signal,
|
|
55
49
|
verification: async (details) => {
|
|
56
50
|
write(`\n${heading("sign-in")}\n`);
|
|
57
51
|
write(`Verification code: ${bold(details.userCode)}`);
|
|
58
52
|
write(`Open ${details.url} and confirm this code.`);
|
|
59
|
-
if (options.browser)
|
|
53
|
+
if (options.browser) {
|
|
60
54
|
await openBrowser(details.browserUrl).catch(() => write("Open the verification URL above to continue."));
|
|
55
|
+
}
|
|
61
56
|
},
|
|
62
57
|
});
|
|
63
58
|
write("");
|
|
@@ -65,37 +60,51 @@ export async function runLogin(options, write) {
|
|
|
65
60
|
write(hint("barndog init"));
|
|
66
61
|
}
|
|
67
62
|
catch (error) {
|
|
68
|
-
if (controller.signal.aborted)
|
|
69
|
-
throw new
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
if (controller.signal.aborted) {
|
|
64
|
+
throw new CliError("Sign-in cancelled.", "barndog login", {
|
|
65
|
+
cause: error,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
if (error instanceof Error &&
|
|
69
|
+
(error.name === "AbortError" || error.name === "TimeoutError")) {
|
|
72
70
|
throw new CliError("Sign-in expired before it was confirmed.", "barndog login", {
|
|
73
71
|
cause: error,
|
|
74
72
|
});
|
|
73
|
+
}
|
|
75
74
|
throw error;
|
|
76
75
|
}
|
|
77
76
|
finally {
|
|
78
77
|
process.removeListener("SIGINT", cancel);
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Revokes the current session and removes local credentials, reporting whether
|
|
82
|
+
* remote revocation was confirmed.
|
|
83
|
+
*/
|
|
84
|
+
export async function runLogout(write, runtime) {
|
|
85
|
+
const result = await logout(runtime);
|
|
83
86
|
write(result.revoked
|
|
84
87
|
? `${ok("✔")} Signed out of ${result.server}.`
|
|
85
88
|
: `${warn("!")} Removed the local credential, but ${result.server} did not confirm the session was revoked.`);
|
|
86
89
|
}
|
|
87
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Fetches and writes authentication status in JSON or terminal form; signed-out
|
|
92
|
+
* status sets process.exitCode to 1.
|
|
93
|
+
*/
|
|
94
|
+
export async function showAuthStatus(output, runtime) {
|
|
88
95
|
const { write } = output;
|
|
89
96
|
let result;
|
|
90
97
|
try {
|
|
91
|
-
result = await authStatus(
|
|
98
|
+
result = await authStatus(runtime);
|
|
92
99
|
}
|
|
93
100
|
catch (error) {
|
|
94
|
-
if (!(error instanceof LoginRequiredError))
|
|
101
|
+
if (!(error instanceof LoginRequiredError)) {
|
|
95
102
|
throw error;
|
|
96
|
-
|
|
97
|
-
|
|
103
|
+
}
|
|
104
|
+
const server = await configuredServer(runtime).catch(() => undefined);
|
|
105
|
+
if (output.json) {
|
|
98
106
|
write(json({ signedIn: false, server: server ?? null }));
|
|
107
|
+
}
|
|
99
108
|
else {
|
|
100
109
|
write(`${bad("✖")} Not signed in${server ? ` to ${server}` : ""}.`);
|
|
101
110
|
write(` ${hint(server ? "barndog login" : "barndog init", "Fix")}`);
|
|
@@ -103,7 +112,7 @@ export async function showAuthStatus(output, home = homedir()) {
|
|
|
103
112
|
process.exitCode = 1;
|
|
104
113
|
return;
|
|
105
114
|
}
|
|
106
|
-
const credential = (await readCredentials(
|
|
115
|
+
const credential = (await readCredentials(runtime)).servers[result.server];
|
|
107
116
|
if (output.json) {
|
|
108
117
|
write(json({
|
|
109
118
|
signedIn: true,
|
|
@@ -133,6 +142,7 @@ export async function showAuthStatus(output, home = homedir()) {
|
|
|
133
142
|
? `expires ${new Date(credential.expiresAt).toLocaleString()}`
|
|
134
143
|
: undefined,
|
|
135
144
|
],
|
|
136
|
-
]))
|
|
145
|
+
])) {
|
|
137
146
|
write(line);
|
|
147
|
+
}
|
|
138
148
|
}
|
package/dist/ui/clash.js
CHANGED
|
@@ -1,31 +1,36 @@
|
|
|
1
1
|
import select from "@inquirer/select";
|
|
2
|
-
import {
|
|
2
|
+
import { validAssetName } from "../shared/patterns.js";
|
|
3
|
+
import { originLabel } from "../features/server/origin.js";
|
|
3
4
|
import { bold, dim, fields, warn } from "./format.js";
|
|
4
5
|
import { promptTheme } from "./theme.js";
|
|
6
|
+
import { assetKinds } from "../features/asset-kinds/index.js";
|
|
5
7
|
/** Asks once per clash; the sync persists the answer. */
|
|
6
8
|
export async function promptClash(clash) {
|
|
7
|
-
const noun = clash.kind
|
|
9
|
+
const noun = assetKinds[clash.kind].many;
|
|
8
10
|
console.log("");
|
|
9
11
|
console.log(`${warn("!")} Two ${noun} want the name ${bold(clash.name)}`);
|
|
10
12
|
for (const line of fields([
|
|
11
13
|
["Installed", originLabel(clash.installed.origin)],
|
|
12
14
|
["New", originLabel(clash.incoming.origin)],
|
|
13
|
-
], 2))
|
|
15
|
+
], 2)) {
|
|
14
16
|
console.log(line);
|
|
17
|
+
}
|
|
15
18
|
console.log("");
|
|
16
19
|
const choices = [];
|
|
17
20
|
if (clash.incoming.renamable !== false &&
|
|
18
|
-
|
|
21
|
+
validAssetName(clash.incomingRename)) {
|
|
19
22
|
choices.push({
|
|
20
23
|
name: `Rename the new one to ${clash.incomingRename}`,
|
|
21
24
|
value: "rename-incoming",
|
|
22
25
|
});
|
|
26
|
+
}
|
|
23
27
|
if (clash.installed.renamable !== false &&
|
|
24
|
-
|
|
28
|
+
validAssetName(clash.installedRename)) {
|
|
25
29
|
choices.push({
|
|
26
30
|
name: `Rename the installed one to ${clash.installedRename}`,
|
|
27
31
|
value: "rename-installed",
|
|
28
32
|
});
|
|
33
|
+
}
|
|
29
34
|
choices.push({ name: "Don't install the new one", value: "skip-incoming" }, {
|
|
30
35
|
name: "Replace the installed one with the new one",
|
|
31
36
|
value: "replace-installed",
|
|
@@ -37,7 +42,7 @@ export async function promptClash(clash) {
|
|
|
37
42
|
theme: promptTheme,
|
|
38
43
|
});
|
|
39
44
|
console.log(dim(" Saved. Change it later with barndog " +
|
|
40
|
-
|
|
45
|
+
assetKinds[clash.kind].command +
|
|
41
46
|
" rename, enable or disable."));
|
|
42
47
|
return choice;
|
|
43
48
|
}
|
package/dist/ui/collaboration.js
CHANGED
|
@@ -1,17 +1,69 @@
|
|
|
1
|
+
import { SHORT_COMMIT_LENGTH } from "../shared/constants.js";
|
|
1
2
|
import { primary } from "./theme.js";
|
|
2
3
|
import { renderSyncOutput } from "./output.js";
|
|
4
|
+
import { safe } from "./format.js";
|
|
3
5
|
import { changeSchema } from "@barndog-ai/api-contract";
|
|
4
6
|
import { textContent } from "@barndog-ai/api-contract/collaboration";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import { isRecord } from "../shared/values.js";
|
|
9
|
+
// The shapes below list only what this module prints; other fields pass through.
|
|
10
|
+
const filesSchema = z.array(z.looseObject({
|
|
11
|
+
path: z.string(),
|
|
12
|
+
content: z.string(),
|
|
13
|
+
executable: z.boolean().optional(),
|
|
14
|
+
}));
|
|
15
|
+
const detailsSchema = z.looseObject({
|
|
16
|
+
names: z.record(z.string(), z.string()).optional(),
|
|
17
|
+
baseVersionNumber: z.number().optional(),
|
|
18
|
+
});
|
|
19
|
+
const pushedSchema = z.looseObject({
|
|
20
|
+
branch: z.string(),
|
|
21
|
+
commit: z.string(),
|
|
22
|
+
published: z.boolean().optional(),
|
|
23
|
+
url: z.string().nullish(),
|
|
24
|
+
opened: z.boolean().optional(),
|
|
25
|
+
});
|
|
26
|
+
const statusSchema = z.looseObject({
|
|
27
|
+
root: z.string(),
|
|
28
|
+
name: z.string(),
|
|
29
|
+
baseVersion: z.number().nullable(),
|
|
30
|
+
baseCommit: z.string().optional(),
|
|
31
|
+
review: z
|
|
32
|
+
.looseObject({ branch: z.string(), url: z.string().nullable() })
|
|
33
|
+
.nullish(),
|
|
34
|
+
proposal: z.looseObject({ id: z.string(), revision: z.number() }).nullable(),
|
|
35
|
+
external: z
|
|
36
|
+
.looseObject({
|
|
37
|
+
pull: z.looseObject({ number: z.number(), head: z.string() }).nullable(),
|
|
38
|
+
})
|
|
39
|
+
.nullish(),
|
|
40
|
+
conflicts: z.array(z.string()),
|
|
41
|
+
pending: z.boolean(),
|
|
42
|
+
changes: z.array(z.unknown()),
|
|
43
|
+
});
|
|
44
|
+
const workingCopySchema = z.looseObject({
|
|
45
|
+
root: z.string(),
|
|
46
|
+
version: z.number().optional(),
|
|
47
|
+
baseVersion: z.number().nullish(),
|
|
48
|
+
commit: z.string().optional(),
|
|
49
|
+
conflicts: z.array(z.string()).optional(),
|
|
50
|
+
});
|
|
51
|
+
const isEnvironmentPreview = (value) => isRecord(value) &&
|
|
52
|
+
value.mode === "environment-preview" &&
|
|
53
|
+
Array.isArray(value.events);
|
|
54
|
+
/** A short commit hash, else `v<version>`, else nothing. */
|
|
55
|
+
function baseLabel(commit, version) {
|
|
56
|
+
if (commit) {
|
|
57
|
+
return commit.slice(0, SHORT_COMMIT_LENGTH);
|
|
58
|
+
}
|
|
59
|
+
return version ? `v${version}` : undefined;
|
|
10
60
|
}
|
|
11
61
|
function files(value) {
|
|
12
|
-
|
|
62
|
+
const parsed = filesSchema.safeParse(value);
|
|
63
|
+
if (!parsed.success) {
|
|
13
64
|
return [];
|
|
14
|
-
|
|
65
|
+
}
|
|
66
|
+
return parsed.data.flatMap((file) => {
|
|
15
67
|
const text = textContent(Buffer.from(file.content, "base64"));
|
|
16
68
|
return [
|
|
17
69
|
primary(`${safe(file.path)}${file.executable ? " (executable)" : ""}`),
|
|
@@ -21,30 +73,40 @@ function files(value) {
|
|
|
21
73
|
}
|
|
22
74
|
/** Mode changes are worth a mention; a new file having no old mode isn't. */
|
|
23
75
|
function executableNote(previous, next) {
|
|
24
|
-
if (previous === next || next === null || next === undefined)
|
|
76
|
+
if (previous === next || next === null || next === undefined) {
|
|
25
77
|
return "";
|
|
26
|
-
|
|
78
|
+
}
|
|
79
|
+
if (previous === null || previous === undefined) {
|
|
27
80
|
return next ? " executable" : "";
|
|
28
|
-
|
|
81
|
+
}
|
|
82
|
+
return ` executable: ${safe(previous)} → ${safe(next)}`;
|
|
29
83
|
}
|
|
30
|
-
|
|
84
|
+
/** Results are told apart by their shape, not by the command that produced them. */
|
|
85
|
+
export function renderCollaboration(value, options = {}) {
|
|
31
86
|
if (Array.isArray(value)) {
|
|
32
|
-
if (!value.length)
|
|
87
|
+
if (!value.length) {
|
|
33
88
|
return ["No changes."];
|
|
89
|
+
}
|
|
34
90
|
return value.flatMap((row) => {
|
|
35
|
-
if (row
|
|
91
|
+
if (!isRecord(row)) {
|
|
92
|
+
return [safe(JSON.stringify(row, null, 2))];
|
|
93
|
+
}
|
|
94
|
+
if ("patch" in row) {
|
|
36
95
|
return [
|
|
37
96
|
`${safe(row.kind)} ${safe(row.path)}${row.binary ? " (binary)" : ""}${executableNote(row.oldExecutable, row.newExecutable)}`,
|
|
38
97
|
safe(row.patch),
|
|
39
98
|
].filter(Boolean);
|
|
40
|
-
|
|
99
|
+
}
|
|
100
|
+
if ("status" in row) {
|
|
41
101
|
return [
|
|
42
|
-
`${safe(row.name)} ${safe(row.status)} revision ${row.revision}\n ${safe(row.id)} ${safe(row.title)}`,
|
|
102
|
+
`${safe(row.name)} ${safe(row.status)} revision ${safe(row.revision)}\n ${safe(row.id)} ${safe(row.title)}`,
|
|
43
103
|
];
|
|
44
|
-
|
|
104
|
+
}
|
|
105
|
+
if ("number" in row) {
|
|
45
106
|
return [
|
|
46
|
-
`v${row.number} ${row.commit}\n ${safe(row.description)} published by ${safe(row.publisherName ?? row.publishedBy)}`,
|
|
107
|
+
`v${safe(row.number)} ${safe(row.commit)}\n ${safe(row.description)} published by ${safe(row.publisherName ?? row.publishedBy)}`,
|
|
47
108
|
];
|
|
109
|
+
}
|
|
48
110
|
return [safe(JSON.stringify(row, null, 2))];
|
|
49
111
|
});
|
|
50
112
|
}
|
|
@@ -55,38 +117,48 @@ export function renderCollaboration(action, value) {
|
|
|
55
117
|
primary(`${change.status === "merged" ? "Published" : "Suggested Change"} ${change.id}`),
|
|
56
118
|
safe(`${change.title} · ${change.status} · revision ${change.revision}`),
|
|
57
119
|
];
|
|
58
|
-
if (
|
|
59
|
-
const
|
|
120
|
+
if (options.details) {
|
|
121
|
+
const shown = detailsSchema.safeParse(value);
|
|
122
|
+
const details = shown.success ? shown.data : {};
|
|
60
123
|
const person = (id) => safe(details.names?.[id] ?? id);
|
|
61
124
|
rows.push(`Author: ${person(change.authorId)}`, `Base: ${details.baseVersionNumber ? `v${details.baseVersionNumber}` : (change.baseVersionId ?? "new package")}`);
|
|
62
|
-
for (const review of change.reviews)
|
|
125
|
+
for (const review of change.reviews) {
|
|
63
126
|
rows.push(`Review: ${review.decision} revision ${review.revision} ${person(review.developerId)}`);
|
|
127
|
+
}
|
|
64
128
|
for (const thread of change.threads) {
|
|
65
129
|
rows.push(`\nDiscussion ${thread.id} revision ${thread.revision}${thread.outdated ? " (outdated)" : ""}${thread.resolved ? " (resolved)" : ""}${thread.path ? ` ${safe(thread.path)}:${thread.startLine}-${thread.endLine} (${thread.side})` : ""}`);
|
|
66
|
-
for (const comment of thread.comments)
|
|
130
|
+
for (const comment of thread.comments) {
|
|
67
131
|
rows.push(` ${person(comment.authorId)}: ${safe(comment.body)}`);
|
|
68
|
-
|
|
132
|
+
}
|
|
133
|
+
if (thread.replacement !== null) {
|
|
69
134
|
rows.push(" Suggested replacement:", safe(thread.replacement));
|
|
135
|
+
}
|
|
70
136
|
}
|
|
71
|
-
if (value && typeof value === "object" && "files" in value)
|
|
137
|
+
if (value && typeof value === "object" && "files" in value) {
|
|
72
138
|
rows.push("", ...files(value.files));
|
|
139
|
+
}
|
|
73
140
|
}
|
|
74
141
|
return rows;
|
|
75
142
|
}
|
|
76
143
|
if (value && typeof value === "object") {
|
|
77
|
-
if (
|
|
78
|
-
value.
|
|
79
|
-
|
|
80
|
-
|
|
144
|
+
if (isEnvironmentPreview(value)) {
|
|
145
|
+
return renderSyncOutput(value.events, {
|
|
146
|
+
title: "preview",
|
|
147
|
+
preview: true,
|
|
148
|
+
});
|
|
81
149
|
}
|
|
82
|
-
if ("files" in value)
|
|
150
|
+
if ("files" in value) {
|
|
83
151
|
return files(value.files);
|
|
84
|
-
|
|
152
|
+
}
|
|
153
|
+
if ("unchanged" in value) {
|
|
85
154
|
return ["Package unchanged."];
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
155
|
+
}
|
|
156
|
+
const pushedResult = pushedSchema.safeParse(value);
|
|
157
|
+
if (pushedResult.success) {
|
|
158
|
+
const pushed = pushedResult.data;
|
|
159
|
+
if (pushed.published) {
|
|
89
160
|
return [primary(`Pushed to ${safe(pushed.branch)}`), pushed.commit];
|
|
161
|
+
}
|
|
90
162
|
return [
|
|
91
163
|
primary(`Pushed ${safe(pushed.branch)}`),
|
|
92
164
|
pushed.url
|
|
@@ -94,11 +166,12 @@ export function renderCollaboration(action, value) {
|
|
|
94
166
|
: "Open a pull request from this branch on your Git host.",
|
|
95
167
|
];
|
|
96
168
|
}
|
|
97
|
-
|
|
98
|
-
|
|
169
|
+
const statusResult = statusSchema.safeParse(value);
|
|
170
|
+
if (statusResult.success) {
|
|
171
|
+
const status = statusResult.data;
|
|
99
172
|
return [
|
|
100
173
|
primary(`${safe(status.name)} ${safe(status.root)}`),
|
|
101
|
-
`Base: ${status.baseCommit
|
|
174
|
+
`Base: ${baseLabel(status.baseCommit, status.baseVersion) ?? "new package"}`,
|
|
102
175
|
...(status.review
|
|
103
176
|
? [
|
|
104
177
|
`Review branch: ${safe(status.review.branch)}${status.review.url ? ` ${safe(status.review.url)}` : ""}`,
|
|
@@ -118,25 +191,24 @@ export function renderCollaboration(action, value) {
|
|
|
118
191
|
? ["Submission awaiting confirmation; retry barndog push."]
|
|
119
192
|
: []),
|
|
120
193
|
...status.conflicts.map((path) => `Conflict: ${safe(path)}`),
|
|
121
|
-
...renderCollaboration(
|
|
194
|
+
...renderCollaboration(status.changes).filter((line) => !line.startsWith("@@") && !line.startsWith("+")),
|
|
122
195
|
];
|
|
123
196
|
}
|
|
124
|
-
|
|
125
|
-
|
|
197
|
+
const workingCopy = workingCopySchema.safeParse(value);
|
|
198
|
+
if (workingCopy.success) {
|
|
199
|
+
const result = workingCopy.data;
|
|
200
|
+
const base = baseLabel(result.commit, result.version || result.baseVersion);
|
|
126
201
|
return [
|
|
127
202
|
`Working copy: ${safe(result.root)}`,
|
|
128
|
-
...(
|
|
129
|
-
? [`Base: ${result.commit.slice(0, 7)}`]
|
|
130
|
-
: result.version || result.baseVersion
|
|
131
|
-
? [`Base: v${result.version ?? result.baseVersion}`]
|
|
132
|
-
: []),
|
|
203
|
+
...(base ? [`Base: ${base}`] : []),
|
|
133
204
|
...(result.conflicts?.length
|
|
134
205
|
? result.conflicts.map((path) => `Conflict: ${safe(path)}; edit and run barndog resolve <path>.`)
|
|
135
206
|
: []),
|
|
136
207
|
];
|
|
137
208
|
}
|
|
138
|
-
if ("resolved" in value)
|
|
209
|
+
if ("resolved" in value) {
|
|
139
210
|
return [`Resolved: ${safe(value.resolved)}`];
|
|
211
|
+
}
|
|
140
212
|
}
|
|
141
213
|
return [safe(JSON.stringify(value, null, 2))];
|
|
142
214
|
}
|
package/dist/ui/connection.js
CHANGED
|
@@ -2,8 +2,11 @@ import input from "@inquirer/input";
|
|
|
2
2
|
import select from "@inquirer/select";
|
|
3
3
|
import { defaultServer } from "../config/build.js";
|
|
4
4
|
import { normalizeServer } from "../features/auth/transport.js";
|
|
5
|
-
import { checkRepositoryUrl } from "../features/
|
|
5
|
+
import { checkRepositoryUrl } from "../features/workspace/git.js";
|
|
6
6
|
import { promptTheme } from "./theme.js";
|
|
7
|
+
/**
|
|
8
|
+
* Asks for the workspace URL, offering `current` or the build's default server.
|
|
9
|
+
*/
|
|
7
10
|
export async function promptServer(current) {
|
|
8
11
|
return normalizeServer(await input({
|
|
9
12
|
message: "BarnDog workspace URL (cloud or self-hosted)",
|
|
@@ -21,6 +24,7 @@ export async function promptServer(current) {
|
|
|
21
24
|
theme: promptTheme,
|
|
22
25
|
}).then((value) => value.trim()));
|
|
23
26
|
}
|
|
27
|
+
/** Asks where to keep assets, defaulting to `current`. */
|
|
24
28
|
export async function chooseConnection(current) {
|
|
25
29
|
const kind = await select({
|
|
26
30
|
loop: false,
|
|
@@ -45,13 +49,15 @@ export async function chooseConnection(current) {
|
|
|
45
49
|
],
|
|
46
50
|
theme: promptTheme,
|
|
47
51
|
});
|
|
48
|
-
if (kind === "local")
|
|
52
|
+
if (kind === "local") {
|
|
49
53
|
return { kind };
|
|
50
|
-
|
|
54
|
+
}
|
|
55
|
+
if (kind === "cloud") {
|
|
51
56
|
return {
|
|
52
57
|
kind,
|
|
53
58
|
server: await promptServer(current?.kind === "cloud" ? current.server : undefined),
|
|
54
59
|
};
|
|
60
|
+
}
|
|
55
61
|
return {
|
|
56
62
|
kind,
|
|
57
63
|
url: (await input({
|
|
@@ -63,7 +69,7 @@ export async function chooseConnection(current) {
|
|
|
63
69
|
return true;
|
|
64
70
|
}
|
|
65
71
|
catch (error) {
|
|
66
|
-
return error.message;
|
|
72
|
+
return error instanceof Error ? error.message : String(error);
|
|
67
73
|
}
|
|
68
74
|
},
|
|
69
75
|
theme: promptTheme,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CliError } from "../errors.js";
|
|
2
|
+
import { assetKinds } from "../features/asset-kinds/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* A change that would undo exclusions or disables, run where nobody can be
|
|
5
|
+
* asked. It names every asset, so a `--decisions` file can be written for it;
|
|
6
|
+
* `--json` lists them under `decisions`.
|
|
7
|
+
*/
|
|
8
|
+
export class DecisionRequiredError extends CliError {
|
|
9
|
+
decisions;
|
|
10
|
+
constructor(conflicts) {
|
|
11
|
+
const decisions = conflicts.map(({ asset }) => ({
|
|
12
|
+
assetId: asset.id,
|
|
13
|
+
kind: asset.kind,
|
|
14
|
+
name: asset.name,
|
|
15
|
+
}));
|
|
16
|
+
super([
|
|
17
|
+
"Existing exclusions or disabled assets need a decision:",
|
|
18
|
+
...conflicts.map(({ asset }) => ` ${asset.name} (${assetKinds[asset.kind].one}) ${asset.id}`),
|
|
19
|
+
'A --decisions file lists each one as {"assetId": "<id>", "choice": "preserve"} or "clear".',
|
|
20
|
+
].join("\n"), "add --overrides preserve, --overrides clear or --decisions <file>");
|
|
21
|
+
this.name = "DecisionRequiredError";
|
|
22
|
+
this.decisions = decisions;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -14,8 +14,15 @@ function sourceLabels(sources, describe) {
|
|
|
14
14
|
const rows = sources.map(describe);
|
|
15
15
|
const width = Math.max(...rows.map((row) => visibleWidth(row.name)));
|
|
16
16
|
const detailWidth = Math.max(...rows.map((row) => visibleWidth(row.detail)));
|
|
17
|
-
return sources.map((source
|
|
17
|
+
return sources.map((source) => {
|
|
18
|
+
const row = describe(source);
|
|
19
|
+
return `${row.name.padEnd(width)} ${dim(row.detail.padEnd(detailWidth))} ${dim(`${source.assets.length} ${source.assets.length === 1 ? "asset" : "assets"}`)}${source.scope.type === "org" ? ` ${dim("· suggested")}` : ""}`;
|
|
20
|
+
});
|
|
18
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates the interactive environment picker using the supplied output sink;
|
|
24
|
+
* returns selections without persisting them.
|
|
25
|
+
*/
|
|
19
26
|
export function environmentChooser(write) {
|
|
20
27
|
return async (choices) => {
|
|
21
28
|
const sources = onboardingSources(choices);
|
|
@@ -31,28 +38,40 @@ export function environmentChooser(write) {
|
|
|
31
38
|
}
|
|
32
39
|
const repoName = sources.find((s) => s.scope.type === "org")?.label ?? "";
|
|
33
40
|
const folder = (source) => {
|
|
34
|
-
if (source.scope.type === "org")
|
|
41
|
+
if (source.scope.type === "org") {
|
|
35
42
|
return "org/";
|
|
43
|
+
}
|
|
36
44
|
const slug = choices.scopes.find((s) => s.id === source.scope.id)?.slug;
|
|
37
45
|
return `${source.scope.type === "team" ? "teams" : "repos"}/${slug}/`;
|
|
38
46
|
};
|
|
39
47
|
// A Git repo with only shared assets has nothing to choose between.
|
|
40
48
|
const single = git && sources.length === 1;
|
|
41
|
-
const titled = (source) =>
|
|
42
|
-
|
|
49
|
+
const titled = (source) => {
|
|
50
|
+
if (!git) {
|
|
51
|
+
return source.label;
|
|
52
|
+
}
|
|
53
|
+
return single ? repoName : folder(source);
|
|
54
|
+
};
|
|
55
|
+
if (!git && !choices.catalog.assets.length) {
|
|
43
56
|
write("No published assets are available yet. Add assets in the web workspace when you're ready.");
|
|
44
|
-
|
|
57
|
+
}
|
|
58
|
+
if (!single) {
|
|
45
59
|
write("Choose where this machine's Skills, MCP servers and Hooks come from. Anything you leave unchecked is removed.");
|
|
60
|
+
}
|
|
46
61
|
if (choices.developerId !== null &&
|
|
47
62
|
choices.firstSetup &&
|
|
48
|
-
choices.memberTeamIds.length === 1)
|
|
63
|
+
choices.memberTeamIds.length === 1) {
|
|
49
64
|
write(dim("Your team is preselected."));
|
|
50
|
-
|
|
65
|
+
}
|
|
66
|
+
if (choices.developerId !== null && choices.memberTeamIds.length > 1) {
|
|
51
67
|
write(dim("You belong to several teams; choose the ones you work with."));
|
|
52
|
-
|
|
68
|
+
}
|
|
69
|
+
if (!single) {
|
|
53
70
|
write(dim(`Later: barndog sets switch team/<slug> or repo/<slug>, barndog sets install repo/<slug>.`));
|
|
54
|
-
|
|
71
|
+
}
|
|
72
|
+
if (!single) {
|
|
55
73
|
write("");
|
|
74
|
+
}
|
|
56
75
|
const labels = sourceLabels(sources, (source) => git
|
|
57
76
|
? {
|
|
58
77
|
name: source.scope.type === "org" ? "Everyone" : source.label,
|
|
@@ -67,7 +86,7 @@ export function environmentChooser(write) {
|
|
|
67
86
|
? `What should this machine install from ${repoName}?`
|
|
68
87
|
: "Which sources would you like to include?",
|
|
69
88
|
choices: sources.map((source, index) => ({
|
|
70
|
-
name: labels[index],
|
|
89
|
+
name: labels[index] ?? titled(source),
|
|
71
90
|
short: titled(source),
|
|
72
91
|
value: source,
|
|
73
92
|
checked: source.checked,
|
|
@@ -95,8 +114,9 @@ export function environmentChooser(write) {
|
|
|
95
114
|
let assetIds;
|
|
96
115
|
if (mode === "custom") {
|
|
97
116
|
const width = Math.max(0, ...source.assets.map((a) => a.name.length));
|
|
98
|
-
if (source.assets.length)
|
|
117
|
+
if (source.assets.length) {
|
|
99
118
|
write("");
|
|
119
|
+
}
|
|
100
120
|
assetIds = source.assets.length
|
|
101
121
|
? await checkbox({
|
|
102
122
|
loop: false,
|
|
@@ -112,12 +132,14 @@ export function environmentChooser(write) {
|
|
|
112
132
|
})
|
|
113
133
|
: [];
|
|
114
134
|
}
|
|
115
|
-
if (!source.assets.length)
|
|
135
|
+
if (!source.assets.length) {
|
|
116
136
|
write(dim(`No published assets in ${titled(source)} yet.`));
|
|
137
|
+
}
|
|
117
138
|
if (source.scope.type === "dev" &&
|
|
118
139
|
mode === "recommended" &&
|
|
119
|
-
!source.recommendedIds.length)
|
|
140
|
+
!source.recommendedIds.length) {
|
|
120
141
|
write(dim("None of your personal assets are marked recommended in an organization or team set."));
|
|
142
|
+
}
|
|
121
143
|
selections.push({ source, mode, assetIds });
|
|
122
144
|
}
|
|
123
145
|
return selectOnboardingSources(selections);
|