barndog 0.2.2 → 0.2.3
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 +2 -0
- package/dist/cli.js +2 -2
- package/dist/commands/add.js +4 -2
- package/dist/commands/asset-install.js +7 -3
- package/dist/commands/asset-share.js +15 -3
- package/dist/commands/capabilities.js +23 -5
- package/dist/commands/collaboration.js +9 -3
- package/dist/commands/harnesses.js +1 -1
- package/dist/commands/hooks.js +16 -1
- package/dist/commands/mcp-env.js +39 -12
- package/dist/commands/mcp.js +13 -3
- package/dist/commands/origin.js +7 -4
- package/dist/commands/sets.js +3 -3
- package/dist/commands/status.js +3 -1
- package/dist/commands/sync.js +1 -1
- package/dist/commands/uninstall.js +4 -2
- package/dist/commands/workspace.js +19 -0
- package/dist/config/state.js +19 -0
- package/dist/errors.js +4 -0
- package/dist/features/adoption/adopt.js +18 -1
- package/dist/features/adoption/scan.js +5 -0
- package/dist/features/asset-kinds/url-query.js +26 -0
- package/dist/features/doctor/check.js +1 -0
- package/dist/features/doctor/grouped.js +127 -0
- package/dist/features/doctor/index.js +18 -33
- package/dist/features/environment/events.js +10 -0
- package/dist/features/environment/kept-value-events.js +40 -0
- package/dist/features/environment/mcp-records.js +57 -0
- package/dist/features/environment/stage.js +12 -8
- package/dist/features/environment/sync.js +11 -1
- package/dist/features/environment/writes.js +25 -27
- package/dist/features/hooks/compatibility.js +37 -17
- package/dist/features/hooks/test.js +2 -2
- package/dist/features/inventory/hook-matrix.js +14 -0
- package/dist/features/inventory/hook-readiness.js +47 -0
- package/dist/features/inventory/index.js +9 -1
- package/dist/features/inventory/show.js +10 -2
- package/dist/features/mcps/import.js +40 -8
- package/dist/features/mcps/index.js +23 -10
- package/dist/features/mcps/values.js +71 -21
- package/dist/features/migration/move.js +4 -0
- package/dist/features/migration/promote.js +1 -0
- package/dist/features/native/adapters.js +4 -44
- package/dist/features/native/requirements.js +98 -0
- package/dist/features/secrets/index.js +4 -3
- package/dist/features/uninstall/index.js +1 -1
- package/dist/features/workspace/cloud-source.js +38 -4
- package/dist/program.js +4 -1
- package/dist/ui/add-hook.js +2 -2
- package/dist/ui/add-mcp.js +37 -5
- package/dist/ui/add-skills.js +2 -2
- package/dist/ui/adopt.js +80 -14
- package/dist/ui/assets.js +15 -2
- package/dist/ui/collaboration.js +5 -3
- package/dist/ui/format.js +81 -2
- package/dist/ui/hook-compatibility.js +176 -22
- package/dist/ui/mcp.js +98 -19
- package/dist/ui/move.js +1 -1
- package/dist/ui/onboarding.js +11 -2
- package/dist/ui/output.js +96 -42
- package/dist/ui/package-details.js +7 -2
- package/dist/ui/pick.js +20 -6
- package/dist/ui/selection.js +1 -1
- package/dist/ui/uninstall.js +14 -2
- package/dist/ui/variable-problems.js +23 -0
- package/package.json +2 -2
package/dist/ui/format.js
CHANGED
|
@@ -27,6 +27,8 @@ export const dim = (text) => paint("dim", text);
|
|
|
27
27
|
export const warn = (text) => paint("yellow", text);
|
|
28
28
|
export const ok = (text) => selected(text);
|
|
29
29
|
export const bad = (text) => danger(text);
|
|
30
|
+
/** Dimmed danger, for things the user has turned off. */
|
|
31
|
+
export const off = (text) => dim(danger(text));
|
|
30
32
|
/** Removes terminal control sequences and folds whitespace in remote text. */
|
|
31
33
|
export function clean(value) {
|
|
32
34
|
return safe(value).replace(/\s+/g, " ").trim();
|
|
@@ -39,13 +41,15 @@ export function clean(value) {
|
|
|
39
41
|
export function visibleWidth(text) {
|
|
40
42
|
return [...stripVTControlCharacters(text)].length;
|
|
41
43
|
}
|
|
42
|
-
|
|
44
|
+
/** `text` followed by spaces to `width` visible columns. */
|
|
45
|
+
export function pad(text, width) {
|
|
43
46
|
return text + " ".repeat(Math.max(0, width - visibleWidth(text)));
|
|
44
47
|
}
|
|
45
48
|
/** One SGR style code, such as `\u001b[1m` (bold) or `\u001b[38;2;197;72;54m`; captured so `split` keeps it. */
|
|
46
49
|
// eslint-disable-next-line no-control-regex -- matches terminal style codes
|
|
47
50
|
const STYLE_CODE = /(\u001b\[[\d;]*m)/;
|
|
48
|
-
|
|
51
|
+
/** `text` cut to `width` visible columns with `…`, keeping its style codes. */
|
|
52
|
+
export function truncate(text, width) {
|
|
49
53
|
const plain = stripVTControlCharacters(text);
|
|
50
54
|
if ([...plain].length <= width) {
|
|
51
55
|
return text;
|
|
@@ -96,6 +100,79 @@ export function fields(rows, indent = 0) {
|
|
|
96
100
|
const width = Math.max(0, ...visible.map(([label]) => label.length));
|
|
97
101
|
return visible.map(([label, value]) => `${" ".repeat(indent)}${dim(pad(label, width))} ${value}`);
|
|
98
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Lines a choice's description always takes, so a checklist keeps its height
|
|
105
|
+
* as the cursor moves between short and long descriptions.
|
|
106
|
+
*/
|
|
107
|
+
const DESCRIPTION_LINES = 5;
|
|
108
|
+
/** Columns assumed when the output has no terminal dimensions. */
|
|
109
|
+
const FALLBACK_COLUMNS = 80;
|
|
110
|
+
/** Inquirer's checklist lines besides choices and description: question, blank line, key help. */
|
|
111
|
+
const CHECKLIST_FIXED_LINES = 3;
|
|
112
|
+
/** Lines a checklist takes besides its choices, with one spare. */
|
|
113
|
+
const CHECKLIST_CHROME_LINES = CHECKLIST_FIXED_LINES + DESCRIPTION_LINES + 1;
|
|
114
|
+
/** Inquirer's own page size, the fewest choices a checklist shows. */
|
|
115
|
+
const MIN_CHECKLIST_PAGE = 7;
|
|
116
|
+
/** How many of `count` choices a checklist shows at once: as many as the terminal's height fits. */
|
|
117
|
+
export function checklistPageSize(count) {
|
|
118
|
+
const rows = process.stdout.rows || 0;
|
|
119
|
+
return Math.max(MIN_CHECKLIST_PAGE, Math.min(count, rows - CHECKLIST_CHROME_LINES));
|
|
120
|
+
}
|
|
121
|
+
/** Words wrapped to lines of at most `width` columns; a longer word is cut. */
|
|
122
|
+
function wrapWords(text, width) {
|
|
123
|
+
const lines = [];
|
|
124
|
+
for (const paragraph of text.split("\n")) {
|
|
125
|
+
let line = "";
|
|
126
|
+
for (const word of paragraph.split(" ").filter(Boolean)) {
|
|
127
|
+
if (!line) {
|
|
128
|
+
line = word;
|
|
129
|
+
}
|
|
130
|
+
else if (visibleWidth(line) + 1 + visibleWidth(word) <= width) {
|
|
131
|
+
line += ` ${word}`;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
lines.push(line);
|
|
135
|
+
line = word;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
lines.push(line);
|
|
139
|
+
}
|
|
140
|
+
return lines.map((line) => truncate(line, width));
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* A bold label before each comma-separated list, the lists aligned and
|
|
144
|
+
* wrapped under themselves rather than under the label:
|
|
145
|
+
*
|
|
146
|
+
* node_repl NODE_REPL_INSTRUCTIONS_USE_CASE_CHROME,
|
|
147
|
+
* BROWSER_USE_ACCESS_PIPE_PATH
|
|
148
|
+
*/
|
|
149
|
+
export function labelledLists(rows, options) {
|
|
150
|
+
const width = options.width ?? (process.stdout.columns || FALLBACK_COLUMNS);
|
|
151
|
+
const labelWidth = Math.max(0, ...rows.map((row) => visibleWidth(row.label)));
|
|
152
|
+
const lead = options.indent + labelWidth + 2;
|
|
153
|
+
// A spare column keeps the terminal from wrapping a full line itself.
|
|
154
|
+
const room = Math.max(MIN_FLEX_COLUMN_WIDTH, width - lead - 1);
|
|
155
|
+
return rows.flatMap((row) => wrapWords(row.items.map(clean).join(", "), room).map((line, index) => `${" ".repeat(options.indent)}${index ? " ".repeat(labelWidth) : bold(pad(clean(row.label), labelWidth))} ${line}`));
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* A choice's description as exactly five lines: wrapped to the terminal,
|
|
159
|
+
* padded when shorter and cut with `…` when longer.
|
|
160
|
+
*/
|
|
161
|
+
export function choiceDescription(text, width = process.stdout.columns || FALLBACK_COLUMNS) {
|
|
162
|
+
// A spare column keeps the terminal from wrapping a full line itself.
|
|
163
|
+
const room = width - 1;
|
|
164
|
+
const lines = wrapWords(text.trim(), room);
|
|
165
|
+
const shown = lines.length > DESCRIPTION_LINES
|
|
166
|
+
? [
|
|
167
|
+
...lines.slice(0, DESCRIPTION_LINES - 1),
|
|
168
|
+
truncate(`${lines[DESCRIPTION_LINES - 1]} ${lines[DESCRIPTION_LINES]}`, room),
|
|
169
|
+
]
|
|
170
|
+
: lines;
|
|
171
|
+
return [
|
|
172
|
+
...shown,
|
|
173
|
+
...Array(DESCRIPTION_LINES - shown.length).fill(""),
|
|
174
|
+
].join("\n");
|
|
175
|
+
}
|
|
99
176
|
/** Aligned columns with ANSI-aware widths that fit the terminal. */
|
|
100
177
|
export function table(rows, options = {}) {
|
|
101
178
|
const indent = " ".repeat(options.indent ?? 2);
|
|
@@ -138,6 +215,8 @@ export function badge(state, label = state) {
|
|
|
138
215
|
case "missing":
|
|
139
216
|
case "unavailable":
|
|
140
217
|
return bad(label);
|
|
218
|
+
case "disabled":
|
|
219
|
+
return off(label);
|
|
141
220
|
default:
|
|
142
221
|
return dim(label);
|
|
143
222
|
}
|
|
@@ -1,21 +1,157 @@
|
|
|
1
1
|
import { SHORT_COMMIT_LENGTH } from "../shared/constants.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { adapters, hookHarnesses } from "../harnesses/registry.js";
|
|
3
|
+
import { requirementFix, } from "../features/native/requirements.js";
|
|
4
|
+
import { bold, dim, fields, hint, ok, table, warn } from "./format.js";
|
|
5
|
+
/** What the author declares for a tool: `—` when the Hook isn't written for it. */
|
|
6
|
+
function authorSays(row) {
|
|
7
|
+
switch (row.status) {
|
|
8
|
+
case "supported":
|
|
9
|
+
return ok("supported");
|
|
10
|
+
case "partial":
|
|
11
|
+
return warn("partial");
|
|
12
|
+
case "unsupported":
|
|
13
|
+
return dim("—");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function onThisMachine(row) {
|
|
17
|
+
if (row.status === "unsupported") {
|
|
18
|
+
return dim("—");
|
|
19
|
+
}
|
|
20
|
+
return row.missingRequirements.length
|
|
21
|
+
? warn("! missing requirement")
|
|
22
|
+
: ok("✔ ready");
|
|
23
|
+
}
|
|
24
|
+
/** One cell of `hooks compatibility --all`. */
|
|
25
|
+
function matrixCell(row) {
|
|
26
|
+
if (!row || row.status === "unsupported") {
|
|
7
27
|
return dim("—");
|
|
8
28
|
}
|
|
9
|
-
|
|
29
|
+
if (row.missingRequirements.length) {
|
|
30
|
+
return warn("! can't run");
|
|
31
|
+
}
|
|
32
|
+
return row.status === "partial" ? warn("◐ partial") : ok("✔ supported");
|
|
33
|
+
}
|
|
34
|
+
/** How a missing requirement reads beside the requirement it belongs to. */
|
|
35
|
+
function shortStatus(harness, missing) {
|
|
36
|
+
const tool = adapters[harness].name;
|
|
37
|
+
switch (missing.type) {
|
|
38
|
+
case "command":
|
|
39
|
+
return "not installed or not on your PATH";
|
|
40
|
+
case "invalid-range":
|
|
41
|
+
return "not a valid version range";
|
|
42
|
+
case "tool-missing":
|
|
43
|
+
return `can't find ${tool}`;
|
|
44
|
+
case "version-unknown":
|
|
45
|
+
return `couldn't read ${tool}'s version`;
|
|
46
|
+
case "version":
|
|
47
|
+
return `this machine has ${missing.installed}`;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/** Each declared requirement with whether this machine meets it, and the fixes for those it doesn't. */
|
|
51
|
+
function requirementLines(rows) {
|
|
52
|
+
const lines = [];
|
|
53
|
+
const fixes = new Set();
|
|
54
|
+
for (const row of rows) {
|
|
55
|
+
const requirements = row.implementation?.requirements;
|
|
56
|
+
if (!requirements) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const tool = adapters[row.harness].name;
|
|
60
|
+
const status = (missing) => {
|
|
61
|
+
if (!missing) {
|
|
62
|
+
return ok("✔");
|
|
63
|
+
}
|
|
64
|
+
fixes.add(requirementFix(row.harness, missing));
|
|
65
|
+
return warn(`! ${shortStatus(row.harness, missing)}`);
|
|
66
|
+
};
|
|
67
|
+
for (const command of requirements.commands) {
|
|
68
|
+
lines.push([
|
|
69
|
+
tool,
|
|
70
|
+
`${bold(command)} command`,
|
|
71
|
+
status(row.missingRequirements.find((missing) => missing.type === "command" && missing.command === command)),
|
|
72
|
+
]);
|
|
73
|
+
}
|
|
74
|
+
if (requirements.harnessVersion) {
|
|
75
|
+
lines.push([
|
|
76
|
+
tool,
|
|
77
|
+
`${tool} ${requirements.harnessVersion}`,
|
|
78
|
+
status(row.missingRequirements.find((missing) => missing.type !== "command")),
|
|
79
|
+
]);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (!lines.length) {
|
|
83
|
+
return [];
|
|
84
|
+
}
|
|
85
|
+
return [
|
|
86
|
+
"",
|
|
87
|
+
dim("Requirements"),
|
|
88
|
+
...table(lines),
|
|
89
|
+
...[...fixes].map((fix) => ` ${dim("Fix:")} ${fix}, then run ${bold("barndog sync")}`),
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
/** What the author wrote about partial support, or that they wrote nothing. */
|
|
93
|
+
function noteLines(rows) {
|
|
94
|
+
const notes = rows.flatMap((row) => {
|
|
95
|
+
const text = row.implementation?.notes?.trim();
|
|
96
|
+
if (text) {
|
|
97
|
+
return [[adapters[row.harness].name, text]];
|
|
98
|
+
}
|
|
99
|
+
return row.status === "partial"
|
|
100
|
+
? [
|
|
101
|
+
[
|
|
102
|
+
adapters[row.harness].name,
|
|
103
|
+
dim("The author marked this partial but didn't say what's missing."),
|
|
104
|
+
],
|
|
105
|
+
]
|
|
106
|
+
: [];
|
|
107
|
+
});
|
|
108
|
+
if (!notes.length) {
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
return [
|
|
112
|
+
"",
|
|
113
|
+
dim("Author's notes"),
|
|
114
|
+
...table(notes.map(([tool = "", text = ""]) => [bold(tool), text])),
|
|
115
|
+
];
|
|
10
116
|
}
|
|
11
117
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
118
|
+
* A Hook in each tool BarnDog manages: what the author declares, whether this
|
|
119
|
+
* machine can run it, its events, requirements and the author's notes.
|
|
120
|
+
*/
|
|
121
|
+
export function renderHookTools(name, rows) {
|
|
122
|
+
const missing = rows.filter((row) => row.status === "unsupported");
|
|
123
|
+
const partial = rows.some((row) => row.status === "partial");
|
|
124
|
+
return [
|
|
125
|
+
dim("Tools"),
|
|
126
|
+
...table(rows.map((row) => [
|
|
127
|
+
adapters[row.harness].name,
|
|
128
|
+
authorSays(row),
|
|
129
|
+
onThisMachine(row),
|
|
130
|
+
row.implementation
|
|
131
|
+
? Object.keys(row.implementation.events).join(", ")
|
|
132
|
+
: dim("—"),
|
|
133
|
+
]), { header: ["Tool", "Author says", "On this machine", "Events"] }),
|
|
134
|
+
...requirementLines(rows),
|
|
135
|
+
...noteLines(rows),
|
|
136
|
+
...(partial
|
|
137
|
+
? [
|
|
138
|
+
"",
|
|
139
|
+
dim("partial: the author says only part of this Hook works in that tool."),
|
|
140
|
+
]
|
|
141
|
+
: []),
|
|
142
|
+
...(missing.length
|
|
143
|
+
? [
|
|
144
|
+
"",
|
|
145
|
+
`${dim(`No ${missing.map((row) => adapters[row.harness].name).join(" or ")} version yet.`)} ${hint(`barndog hooks adapt ${name} --for ${missing.map((row) => row.harness).join(" ")}`, "Tip")}`,
|
|
146
|
+
]
|
|
147
|
+
: []),
|
|
148
|
+
];
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Returns a Hook's version, then its support and readiness per tool,
|
|
152
|
+
* abbreviating content hashes to seven characters.
|
|
14
153
|
*/
|
|
15
154
|
export function renderHookCompatibility(name, result) {
|
|
16
|
-
const missing = result.compatibility
|
|
17
|
-
.filter((row) => row.status === "unsupported")
|
|
18
|
-
.map((row) => row.harness);
|
|
19
155
|
return [
|
|
20
156
|
// A content hash is long; its first 7 characters identify it, as Git shows them.
|
|
21
157
|
...fields([
|
|
@@ -26,16 +162,34 @@ export function renderHookCompatibility(name, result) {
|
|
|
26
162
|
: result.version.slice(0, SHORT_COMMIT_LENGTH),
|
|
27
163
|
],
|
|
28
164
|
]),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
165
|
+
"",
|
|
166
|
+
...renderHookTools(name, result.compatibility),
|
|
167
|
+
];
|
|
168
|
+
}
|
|
169
|
+
/** Every selected Hook against every tool BarnDog manages, with what each mark means. */
|
|
170
|
+
export function renderHookMatrix(rows) {
|
|
171
|
+
if (!rows.length) {
|
|
172
|
+
return [dim("No Hooks are selected on this machine.")];
|
|
173
|
+
}
|
|
174
|
+
const tools = hookHarnesses.filter((harness) => rows.some((row) => row.compatibility.some((c) => c.harness === harness)));
|
|
175
|
+
return [
|
|
176
|
+
...table(rows.map((row) => [
|
|
177
|
+
bold(row.name),
|
|
178
|
+
...tools.map((harness) => matrixCell(row.compatibility.find((c) => c.harness === harness))),
|
|
179
|
+
]), { header: ["Hook", ...tools.map((harness) => adapters[harness].name)] }),
|
|
180
|
+
"",
|
|
181
|
+
...table([
|
|
182
|
+
[
|
|
183
|
+
dim("—"),
|
|
184
|
+
dim("not written for that tool, so BarnDog doesn't install it there"),
|
|
185
|
+
],
|
|
186
|
+
[
|
|
187
|
+
dim("partial"),
|
|
188
|
+
dim("the author says only part of it works in that tool"),
|
|
189
|
+
],
|
|
190
|
+
[dim("can't run"), dim("this machine is missing something it needs")],
|
|
191
|
+
]),
|
|
192
|
+
"",
|
|
193
|
+
` ${hint("barndog hooks show <name>", "Tip")}${dim(" for requirements and the author's notes")}`,
|
|
40
194
|
];
|
|
41
195
|
}
|
package/dist/ui/mcp.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { SHORT_COMMIT_LENGTH } from "../shared/constants.js";
|
|
2
|
+
import { only } from "../shared/lookup.js";
|
|
3
|
+
import confirm from "@inquirer/confirm";
|
|
2
4
|
import { mcpDefinitionSchema } from "@barndog-ai/api-contract";
|
|
3
5
|
import { z } from "zod";
|
|
4
|
-
import {
|
|
6
|
+
import { CliError } from "../errors.js";
|
|
7
|
+
import { bold, clean, dim, fields, hint, originLabel, renderValue, table, warn, } from "./format.js";
|
|
8
|
+
import { promptTheme } from "./theme.js";
|
|
9
|
+
import { LOCAL_ORIGIN } from "../features/workspace/overlay.js";
|
|
5
10
|
const shownMcpSchema = z.looseObject({
|
|
6
11
|
name: z.string(),
|
|
7
12
|
origin: z.union([
|
|
@@ -18,6 +23,10 @@ const shownMcpSchema = z.looseObject({
|
|
|
18
23
|
z.looseObject({ number: z.number(), definition: mcpDefinitionSchema }),
|
|
19
24
|
]),
|
|
20
25
|
definition: mcpDefinitionSchema.optional(),
|
|
26
|
+
/** Variables BarnDog keeps a value for, or reads from another variable. */
|
|
27
|
+
keptVariables: z
|
|
28
|
+
.array(z.object({ variable: z.string(), from: z.string().optional() }))
|
|
29
|
+
.optional(),
|
|
21
30
|
/** Variables it refers to that have no value on this machine. */
|
|
22
31
|
unsetVariables: z.array(z.string()).optional(),
|
|
23
32
|
});
|
|
@@ -26,6 +35,16 @@ const signIn = {
|
|
|
26
35
|
environment: "environment variables",
|
|
27
36
|
"native-oauth": "OAuth, through each coding tool",
|
|
28
37
|
};
|
|
38
|
+
/** How to sign in to each local server that signs in through its coding tools: one `mcp auth` per tool. */
|
|
39
|
+
export function renderSignIn(signIns) {
|
|
40
|
+
return signIns.flatMap(({ server, harnesses }) => {
|
|
41
|
+
const tools = harnesses.length ? harnesses : ["<tool>"];
|
|
42
|
+
return [
|
|
43
|
+
`${warn("!")} ${bold(clean(server))} signs in through each coding tool. Sign in once in each:`,
|
|
44
|
+
...tools.map((tool) => ` ${bold(`barndog mcp auth ${clean(server)} --origin ${LOCAL_ORIGIN} --harness ${tool}`)}`),
|
|
45
|
+
];
|
|
46
|
+
});
|
|
47
|
+
}
|
|
29
48
|
/**
|
|
30
49
|
* Where each literal MCP value went: one sentence for the values BarnDog keeps
|
|
31
50
|
* and one for those the developer has to set, each over a column of variables
|
|
@@ -55,20 +74,42 @@ export function renderMcpValues(values) {
|
|
|
55
74
|
}
|
|
56
75
|
return output;
|
|
57
76
|
}
|
|
77
|
+
/** A variable whose value BarnDog keeps, as `mcp show` lists it. */
|
|
78
|
+
const KEPT_BY_BARNDOG = "kept by BarnDog";
|
|
79
|
+
/** What "kept by BarnDog" means, under the variables when any is. */
|
|
80
|
+
const KEPT_NOTE = "BarnDog keeps these values in ~/.barndog/secrets.json, on this machine only and never uploaded, and writes them into each coding tool's settings.";
|
|
81
|
+
/**
|
|
82
|
+
* One warning for all of a server's variables with no value here (the
|
|
83
|
+
* variables table above it marks which), and the
|
|
84
|
+
* `mcp env set` that fixes them: naming the variable when there's one, else
|
|
85
|
+
* letting the person pick each from a list.
|
|
86
|
+
*/
|
|
87
|
+
function unsetProblem(server, variables) {
|
|
88
|
+
if (!variables.length) {
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
const single = only(variables);
|
|
92
|
+
const warning = single
|
|
93
|
+
? `${bold(single)} has no value here, so ${server} can't use it.`
|
|
94
|
+
: `${variables.length} variables have no value here, so ${server} can't use them.`;
|
|
95
|
+
const fix = single
|
|
96
|
+
? `barndog mcp env set ${server} ${single}`
|
|
97
|
+
: `barndog mcp env set ${server}`;
|
|
98
|
+
return ["", `${warn("!")} ${warning}`, ` ${hint(fix, "Fix")}`];
|
|
99
|
+
}
|
|
58
100
|
/**
|
|
59
|
-
* A note per listed MCP server with variables that have no value here
|
|
60
|
-
*
|
|
61
|
-
* gives one for each.
|
|
101
|
+
* A note per listed MCP server with variables that have no value here, with
|
|
102
|
+
* the `mcp env set` that fixes them.
|
|
62
103
|
*/
|
|
63
104
|
export function unsetVariableNotes(items) {
|
|
64
105
|
return items.flatMap(({ installedName: name, unsetVariables: variables }) => {
|
|
65
106
|
if (!variables?.length) {
|
|
66
107
|
return [];
|
|
67
108
|
}
|
|
68
|
-
const
|
|
69
|
-
const fix =
|
|
70
|
-
? `barndog mcp env set ${clean(name)} ${clean(
|
|
71
|
-
: `barndog mcp
|
|
109
|
+
const single = only(variables);
|
|
110
|
+
const fix = single
|
|
111
|
+
? `barndog mcp env set ${clean(name)} ${clean(single)}`
|
|
112
|
+
: `barndog mcp env set ${clean(name)}`;
|
|
72
113
|
return [
|
|
73
114
|
"",
|
|
74
115
|
`${warn("!")} ${bold(clean(name))} can't use ${variables.map((variable) => bold(clean(variable))).join(", ")}: no value here.`,
|
|
@@ -92,17 +133,27 @@ export function renderMcp(value) {
|
|
|
92
133
|
? definition.environment
|
|
93
134
|
: definition.headers;
|
|
94
135
|
const unset = mcp.unsetVariables ?? [];
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
136
|
+
const kept = new Map((mcp.keptVariables ?? []).map((row) => [row.variable, row.from]));
|
|
137
|
+
// A kept `from` is a variable to read; only a kept value is BarnDog's own.
|
|
138
|
+
const keptValue = (secretRef) => kept.has(secretRef) && !kept.get(secretRef);
|
|
139
|
+
const valueSources = Object.entries(references).map(([key, { secretRef }]) => {
|
|
140
|
+
const source = keptValue(secretRef)
|
|
141
|
+
? KEPT_BY_BARNDOG
|
|
142
|
+
: `from $${clean(kept.get(secretRef) ?? secretRef)}`;
|
|
143
|
+
return [
|
|
144
|
+
clean(key),
|
|
145
|
+
unset.includes(secretRef) ? `${source} ${warn("(not set)")}` : source,
|
|
146
|
+
];
|
|
100
147
|
});
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
148
|
+
const keepsAny = Object.values(references).some(({ secretRef }) => keptValue(secretRef));
|
|
149
|
+
const variableTable = valueSources.length
|
|
150
|
+
? [
|
|
151
|
+
"",
|
|
152
|
+
...table(valueSources, { header: ["Variable", "Value"], indent: 0 }),
|
|
153
|
+
...(keepsAny ? ["", dim(KEPT_NOTE)] : []),
|
|
154
|
+
]
|
|
155
|
+
: [];
|
|
156
|
+
const problems = unsetProblem(clean(mcp.name), unset.map(clean));
|
|
106
157
|
return [
|
|
107
158
|
...fields([
|
|
108
159
|
["Name", clean(mcp.name)],
|
|
@@ -124,8 +175,36 @@ export function renderMcp(value) {
|
|
|
124
175
|
: clean([definition.command, ...definition.args].join(" ")),
|
|
125
176
|
],
|
|
126
177
|
["Sign-in", signIn[definition.authentication]],
|
|
127
|
-
["Variables", variables.join(", ")],
|
|
128
178
|
]),
|
|
179
|
+
...variableTable,
|
|
129
180
|
...problems,
|
|
130
181
|
];
|
|
131
182
|
}
|
|
183
|
+
/** One warning per MCP server whose URL has query parameters, naming them but never their values. */
|
|
184
|
+
export function renderUrlQueries(servers) {
|
|
185
|
+
return servers.map((server) => `${warn("!")} ${bold(server.name)}'s URL has query parameters: ${server.parameters.join(", ")}.`);
|
|
186
|
+
}
|
|
187
|
+
/** Said before adding servers with a query string to the local folder. */
|
|
188
|
+
export const LOCAL_URL_QUERY = "A query string can hold sensitive data, such as an API key. BarnDog keeps the URL as written: it stays on this machine and works as is.";
|
|
189
|
+
const askToShare = (message) => confirm({ message, default: false, theme: promptTheme });
|
|
190
|
+
/**
|
|
191
|
+
* How a command that shares assets beyond this machine asks about MCP servers
|
|
192
|
+
* whose URL has a query string: `--allow-url-query` shares them, a terminal
|
|
193
|
+
* asks (no by default), and anything else is refused with that flag as the fix.
|
|
194
|
+
*/
|
|
195
|
+
export function confirmSharingUrlQuery(options) {
|
|
196
|
+
return async (servers) => {
|
|
197
|
+
if (options.allowed) {
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
const one = servers.length === 1;
|
|
201
|
+
if (!options.interactive) {
|
|
202
|
+
throw new CliError(`${servers.map((server) => server.name).join(", ")} ${one ? "has a URL" : "have URLs"} with query parameters, which can hold sensitive data such as an API key, and sharing shows ${one ? "it" : "them"} to everyone who can see the destination.`, options.fix);
|
|
203
|
+
}
|
|
204
|
+
for (const line of renderUrlQueries(servers)) {
|
|
205
|
+
options.write(line);
|
|
206
|
+
}
|
|
207
|
+
options.write(dim("A query string can hold sensitive data, such as an API key. Sharing keeps the URL as written, so everyone who can see the destination can read it."));
|
|
208
|
+
return (options.ask ?? askToShare)(`Share ${one ? "it" : "them"} anyway?`);
|
|
209
|
+
};
|
|
210
|
+
}
|
package/dist/ui/move.js
CHANGED
|
@@ -9,7 +9,7 @@ export function pickLocalAssets(local) {
|
|
|
9
9
|
.map((asset) => ({
|
|
10
10
|
value: asset.name,
|
|
11
11
|
name: asset.name,
|
|
12
|
-
|
|
12
|
+
columns: [dim(asset.kind)],
|
|
13
13
|
})), { empty: "No local assets can be moved." });
|
|
14
14
|
}
|
|
15
15
|
/** True keeps separate local copies; false makes the shared copies the only ones. */
|
package/dist/ui/onboarding.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { confirmSharingUrlQuery } from "./mcp.js";
|
|
1
2
|
import { environmentChooser } from "./environment-onboarding.js";
|
|
2
3
|
import { authStatus, configuredServer } from "../features/auth/session.js";
|
|
3
4
|
import { chooseConnection, chooseLocalAssets, chooseMoveTarget, } from "./connection.js";
|
|
@@ -293,7 +294,7 @@ export async function runSetup(options) {
|
|
|
293
294
|
},
|
|
294
295
|
apply: connected
|
|
295
296
|
? async (settings) => {
|
|
296
|
-
for (const line of renderSyncOutput(await synchronize(undefined, options.runtime, settings))) {
|
|
297
|
+
for (const line of renderSyncOutput(await synchronize(undefined, options.runtime, settings), options.runtime)) {
|
|
297
298
|
write(line);
|
|
298
299
|
}
|
|
299
300
|
}
|
|
@@ -315,7 +316,15 @@ export async function runSetup(options) {
|
|
|
315
316
|
? await (options.chooseMoveTarget ?? chooseMoveTarget)(await cloudMoveTargets(options.runtime))
|
|
316
317
|
: undefined;
|
|
317
318
|
write("");
|
|
318
|
-
for (const line of renderMove(await moveLocalAssets({
|
|
319
|
+
for (const line of renderMove(await moveLocalAssets({
|
|
320
|
+
to,
|
|
321
|
+
keepLocal: localChoice === "copy",
|
|
322
|
+
confirmUrlQuery: confirmSharingUrlQuery({
|
|
323
|
+
interactive: true,
|
|
324
|
+
write,
|
|
325
|
+
fix: "barndog local move --all --allow-url-query",
|
|
326
|
+
}),
|
|
327
|
+
}, options.runtime))) {
|
|
319
328
|
write(line);
|
|
320
329
|
}
|
|
321
330
|
}
|