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
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { safe, json, renderValue } from "../ui/format.js";
|
|
2
|
+
import { renderMcp } from "../ui/mcp.js";
|
|
3
|
+
import { pickInstalled, resolveOrigin } from "./origin.js";
|
|
4
|
+
/** What every command group prints with and how it finds the asset a command names. */
|
|
5
|
+
export function commandHelpers(context) {
|
|
6
|
+
const write = (value) => context.write(safe(value));
|
|
7
|
+
const print = (result) => {
|
|
8
|
+
if (context.mode.json) {
|
|
9
|
+
context.write(json(result));
|
|
10
|
+
}
|
|
11
|
+
else if (typeof result === "object" && result && "message" in result) {
|
|
12
|
+
write(String(result.message));
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
for (const line of renderValue(result)) {
|
|
16
|
+
context.write(line);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const printMcp = (result) => {
|
|
21
|
+
for (const line of renderMcp(result)) {
|
|
22
|
+
context.write(line);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
/** Adds the owning scope, asking only when several scopes share the name. */
|
|
26
|
+
const locate = async (kind, name, options, usage) => name
|
|
27
|
+
? {
|
|
28
|
+
...options,
|
|
29
|
+
name,
|
|
30
|
+
origin: await resolveOrigin(context, {
|
|
31
|
+
kind,
|
|
32
|
+
name,
|
|
33
|
+
origin: options.origin,
|
|
34
|
+
usage: usage.replace("<name>", name),
|
|
35
|
+
}),
|
|
36
|
+
}
|
|
37
|
+
: { ...options, ...(await pickInstalled(context, kind, usage)) };
|
|
38
|
+
return { write, print, printMcp, locate };
|
|
39
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { bad, dim, json, ok, ORIGIN_HELP } from "../ui/format.js";
|
|
2
|
+
import { Option } from "commander";
|
|
3
|
+
import { renderHookCompatibility } from "../ui/hook-compatibility.js";
|
|
4
|
+
import { hookHarnesses } from "../harnesses/registry.js";
|
|
5
|
+
import { defined } from "../shared/lookup.js";
|
|
6
|
+
import { positiveInteger } from "../ui/options.js";
|
|
7
|
+
import { commandHelpers } from "./helpers.js";
|
|
8
|
+
/** Shell timeout utility convention for a timed-out command. */
|
|
9
|
+
const TIMEOUT_EXIT_CODE = 124;
|
|
10
|
+
function hookTestSummary(timedOut, exitCode) {
|
|
11
|
+
if (timedOut) {
|
|
12
|
+
return `${bad("✖")} Hook test timed out.`;
|
|
13
|
+
}
|
|
14
|
+
if (exitCode) {
|
|
15
|
+
return `${bad("✖")} Hook test exited ${exitCode}.`;
|
|
16
|
+
}
|
|
17
|
+
return `${ok("✔")} Hook test exited 0.`;
|
|
18
|
+
}
|
|
19
|
+
/** `barndog hooks` commands that test a Hook and report or widen its tool coverage. */
|
|
20
|
+
export function registerHooks(program, context) {
|
|
21
|
+
const { write, locate } = commandHelpers(context);
|
|
22
|
+
const hooks = defined(program.commands.find((c) => c.name() === "hooks"), "Command group hooks isn't registered");
|
|
23
|
+
hooks
|
|
24
|
+
.command("test [name]")
|
|
25
|
+
.option("--origin <origin>", ORIGIN_HELP)
|
|
26
|
+
.addOption(new Option("--harness <harness>", "Chosen implementation")
|
|
27
|
+
.choices(hookHarnesses)
|
|
28
|
+
.makeOptionMandatory())
|
|
29
|
+
.requiredOption("--input <file>", "Native JSON test input")
|
|
30
|
+
.option("--event <event>", "Native event name")
|
|
31
|
+
.option("--handler <number>", "One-based command index", positiveInteger)
|
|
32
|
+
.option("--timeout <seconds>", "Maximum test duration", positiveInteger)
|
|
33
|
+
.description("Explicitly run one published command Hook with test input")
|
|
34
|
+
.action(async (name, options) => {
|
|
35
|
+
const located = await locate("hook", name, options, `barndog hooks test <name> --harness ${options.harness} --input ${options.input}`);
|
|
36
|
+
const test = await context.testHook(located.name, located.origin, {
|
|
37
|
+
harness: options.harness,
|
|
38
|
+
input: options.input,
|
|
39
|
+
event: options.event,
|
|
40
|
+
handler: options.handler,
|
|
41
|
+
timeout: options.timeout,
|
|
42
|
+
});
|
|
43
|
+
// The Hook's own result is the command's result, however it is printed.
|
|
44
|
+
if (test.exitCode || test.timedOut) {
|
|
45
|
+
process.exitCode = test.timedOut ? TIMEOUT_EXIT_CODE : test.exitCode;
|
|
46
|
+
}
|
|
47
|
+
if (context.mode.json) {
|
|
48
|
+
return context.write(json(test));
|
|
49
|
+
}
|
|
50
|
+
if (test.stdout) {
|
|
51
|
+
write(test.stdout.trimEnd());
|
|
52
|
+
}
|
|
53
|
+
if (test.stderr) {
|
|
54
|
+
write(test.stderr.trimEnd());
|
|
55
|
+
}
|
|
56
|
+
write(hookTestSummary(test.timedOut, test.exitCode));
|
|
57
|
+
});
|
|
58
|
+
hooks
|
|
59
|
+
.command("compatibility [name]")
|
|
60
|
+
.option("--origin <origin>", ORIGIN_HELP)
|
|
61
|
+
.description("Inspect version-specific declarations and local runtime requirements")
|
|
62
|
+
.action(async (name, options) => {
|
|
63
|
+
const located = await locate("hook", name, options, "barndog hooks compatibility <name>");
|
|
64
|
+
const result = await context.hookCompatibility(located.name, located.origin);
|
|
65
|
+
if (context.mode.json) {
|
|
66
|
+
return context.write(json(result));
|
|
67
|
+
}
|
|
68
|
+
for (const line of renderHookCompatibility(located.name, result)) {
|
|
69
|
+
context.write(line);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
hooks
|
|
73
|
+
.command("adapt [name]")
|
|
74
|
+
.option("--origin <origin>", ORIGIN_HELP)
|
|
75
|
+
.addOption(new Option("--for <tools...>", "Coding tools to adapt it for (default: the ones this machine uses that it doesn't cover)").choices(hookHarnesses))
|
|
76
|
+
.description("Print a prompt for an AI agent to adapt a Hook to coding tools it wasn't written for")
|
|
77
|
+
.action(async (name, options) => {
|
|
78
|
+
const located = await locate("hook", name, options, "barndog hooks adapt <name>");
|
|
79
|
+
const result = await context.adaptHook(located.name, located.origin, options.for);
|
|
80
|
+
if (context.mode.json) {
|
|
81
|
+
return context.write(json(result));
|
|
82
|
+
}
|
|
83
|
+
// Printed bare, so it can be piped to the clipboard or an agent.
|
|
84
|
+
context.write(result.prompt ??
|
|
85
|
+
dim(`${result.name} already has settings for every coding tool this machine uses.`));
|
|
86
|
+
});
|
|
87
|
+
}
|
package/dist/commands/init.js
CHANGED
|
@@ -7,10 +7,12 @@ export function registerInit(program, context) {
|
|
|
7
7
|
.option("--repo <url>", "Share assets through one Git repository")
|
|
8
8
|
.option("--no-browser", "Display the sign-in URL without opening it")
|
|
9
9
|
.action(async (options) => {
|
|
10
|
-
if (options.local && options.server)
|
|
10
|
+
if (options.local && options.server) {
|
|
11
11
|
program.error("--local cannot be combined with --server");
|
|
12
|
-
|
|
12
|
+
}
|
|
13
|
+
if (options.repo && (options.local || options.server)) {
|
|
13
14
|
program.error("--repo cannot be combined with --local or --server");
|
|
15
|
+
}
|
|
14
16
|
await context.setup(true, options.server, {
|
|
15
17
|
local: options.local,
|
|
16
18
|
browser: options.browser,
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { bold, clean, dim, hint, json, ok, table, warn } from "../ui/format.js";
|
|
2
|
+
import { runSelection } from "../ui/selection.js";
|
|
3
|
+
import { commandHelpers } from "./helpers.js";
|
|
4
|
+
/** When coding tools see a knowledge document. */
|
|
5
|
+
function knowledgeListing(listedAtStart, accessMode) {
|
|
6
|
+
if (listedAtStart) {
|
|
7
|
+
return ok("every session");
|
|
8
|
+
}
|
|
9
|
+
return accessMode === "always" ? dim("off") : dim("on demand");
|
|
10
|
+
}
|
|
11
|
+
/** `barndog knowledge`: reading shared knowledge and its session-start listing. */
|
|
12
|
+
export function registerKnowledge(program, context) {
|
|
13
|
+
const { write } = commandHelpers(context);
|
|
14
|
+
const knowledge = program
|
|
15
|
+
.command("knowledge")
|
|
16
|
+
.description("Read your organization's shared knowledge documents");
|
|
17
|
+
knowledge
|
|
18
|
+
.command("list")
|
|
19
|
+
.description("List knowledge documents and when coding tools see them")
|
|
20
|
+
.option("--always", "Only documents listed at every session start")
|
|
21
|
+
.action(async (options) => {
|
|
22
|
+
const docs = await context.knowledgeList(options.always);
|
|
23
|
+
if (context.mode.json) {
|
|
24
|
+
return context.write(json(docs));
|
|
25
|
+
}
|
|
26
|
+
const problems = await context.knowledgeProblems().catch(() => []);
|
|
27
|
+
for (const problem of problems) {
|
|
28
|
+
context.write(`${warn("!")} ${problem.path}: ${problem.reason}`);
|
|
29
|
+
}
|
|
30
|
+
if (!docs.length) {
|
|
31
|
+
return context.write(dim("No knowledge documents yet."));
|
|
32
|
+
}
|
|
33
|
+
for (const line of table(docs.map((doc) => [
|
|
34
|
+
bold(clean(doc.name)),
|
|
35
|
+
knowledgeListing(doc.listedAtStart, doc.accessMode),
|
|
36
|
+
dim(clean(doc.description)),
|
|
37
|
+
]), { header: ["Name", "Listed", "Description"] })) {
|
|
38
|
+
context.write(line);
|
|
39
|
+
}
|
|
40
|
+
context.write("");
|
|
41
|
+
if (docs.some((d) => d.accessMode === "always" && !d.listedAtStart)) {
|
|
42
|
+
context.write(hint("barndog knowledge enable", "Tip") +
|
|
43
|
+
dim(" to list these at session start again"));
|
|
44
|
+
}
|
|
45
|
+
context.write(hint("barndog knowledge get <name>", "Tip") + dim(" to read one"));
|
|
46
|
+
});
|
|
47
|
+
knowledge
|
|
48
|
+
.command("get <name>")
|
|
49
|
+
.description("Print a knowledge document")
|
|
50
|
+
.action(async (name) => {
|
|
51
|
+
const result = await context.knowledgeGet(name);
|
|
52
|
+
if (context.mode.json) {
|
|
53
|
+
return context.write(json(result));
|
|
54
|
+
}
|
|
55
|
+
write(result.version.content.markdown);
|
|
56
|
+
});
|
|
57
|
+
for (const action of ["enable", "disable"]) {
|
|
58
|
+
knowledge
|
|
59
|
+
.command(action)
|
|
60
|
+
.description(action === "enable"
|
|
61
|
+
? "Tell coding tools at session start which knowledge documents exist"
|
|
62
|
+
: "Stop listing knowledge documents at session start")
|
|
63
|
+
.action(async () => {
|
|
64
|
+
await runSelection(context, () => context.setKnowledge(action === "enable"));
|
|
65
|
+
if (context.mode.json) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
context.write(action === "enable"
|
|
69
|
+
? `${ok("✔")} Coding tools now see the list of knowledge documents when a session starts.`
|
|
70
|
+
: `${ok("✔")} Knowledge documents are no longer listed at session start.`);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { json, ok, ORIGIN_HELP } from "../ui/format.js";
|
|
2
|
+
import { Option } from "commander";
|
|
3
|
+
import { harnesses } from "../harnesses/registry.js";
|
|
4
|
+
import { defined } from "../shared/lookup.js";
|
|
5
|
+
import { commandHelpers } from "./helpers.js";
|
|
6
|
+
/** `barndog mcp` commands that publish, inspect and authenticate MCP configurations. */
|
|
7
|
+
export function registerMcp(program, context) {
|
|
8
|
+
const { write, print, printMcp, locate } = commandHelpers(context);
|
|
9
|
+
const mcp = defined(program.commands.find((c) => c.name() === "mcp"), "Command group mcp isn't registered");
|
|
10
|
+
for (const action of ["create", "update"]) {
|
|
11
|
+
const command = mcp
|
|
12
|
+
.command(`${action} <name>`)
|
|
13
|
+
.description(`${action === "create" ? "Create" : "Publish a new revision of"} an MCP configuration directly`)
|
|
14
|
+
.requiredOption("--origin <origin>", ORIGIN_HELP)
|
|
15
|
+
.requiredOption("--file <file>", "JSON connection definition with secret references")
|
|
16
|
+
.option("--key <key>", "Stable key for exact retries");
|
|
17
|
+
if (action === "update") {
|
|
18
|
+
command.requiredOption("--expected-version <id>", "Inspected configuration version ID");
|
|
19
|
+
}
|
|
20
|
+
command.action(async (name, options) => {
|
|
21
|
+
const result = action === "create"
|
|
22
|
+
? await context.createMcp({ ...options, name })
|
|
23
|
+
: await context.updateMcp({ ...options, name });
|
|
24
|
+
if (context.mode.json) {
|
|
25
|
+
return context.write(json(result));
|
|
26
|
+
}
|
|
27
|
+
write(`${ok("✔")} Published ${name}.`);
|
|
28
|
+
printMcp(result);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
mcp
|
|
32
|
+
.command("show <name>")
|
|
33
|
+
.option("--origin <origin>", ORIGIN_HELP)
|
|
34
|
+
.description("Inspect a connection definition")
|
|
35
|
+
.action(async (name, options) => {
|
|
36
|
+
const located = await locate("mcp", name, options, `barndog mcp show ${name}`);
|
|
37
|
+
const result = await context.showMcp(located.name, located.origin);
|
|
38
|
+
if (context.mode.json) {
|
|
39
|
+
return context.write(json(result));
|
|
40
|
+
}
|
|
41
|
+
printMcp(result);
|
|
42
|
+
});
|
|
43
|
+
mcp
|
|
44
|
+
.command("versions <name>")
|
|
45
|
+
.option("--origin <origin>", ORIGIN_HELP)
|
|
46
|
+
.description("Inspect immutable configuration history")
|
|
47
|
+
.action(async (name, options) => {
|
|
48
|
+
const located = await locate("mcp", name, options, `barndog mcp versions ${name}`);
|
|
49
|
+
print(await context.mcpVersions(located.name, located.origin));
|
|
50
|
+
});
|
|
51
|
+
mcp
|
|
52
|
+
.command("auth <name>")
|
|
53
|
+
.option("--origin <origin>", ORIGIN_HELP)
|
|
54
|
+
.addOption(new Option("--harness <harness>", "Native login owner")
|
|
55
|
+
.choices(harnesses)
|
|
56
|
+
.makeOptionMandatory())
|
|
57
|
+
.description("Enter native authentication without sharing credentials")
|
|
58
|
+
.action(async (name, options) => {
|
|
59
|
+
const located = await locate("mcp", name, options, `barndog mcp auth ${name} --harness ${options.harness}`);
|
|
60
|
+
print(await context.authenticateMcp(located.name, located.origin, options.harness));
|
|
61
|
+
});
|
|
62
|
+
}
|
package/dist/commands/origin.js
CHANGED
|
@@ -1,48 +1,46 @@
|
|
|
1
|
+
import { assetKinds } from "../features/asset-kinds/index.js";
|
|
1
2
|
import { CliError } from "../errors.js";
|
|
2
3
|
import { pickOne } from "../ui/pick.js";
|
|
3
4
|
import { clean, originLabel } from "../ui/format.js";
|
|
4
|
-
|
|
5
|
-
skill: "Skill",
|
|
6
|
-
hook: "Hook",
|
|
7
|
-
mcp: "MCP server",
|
|
8
|
-
};
|
|
9
|
-
const groups = {
|
|
10
|
-
skill: "skills",
|
|
11
|
-
hook: "hooks",
|
|
12
|
-
mcp: "mcp",
|
|
13
|
-
};
|
|
5
|
+
import { only } from "../shared/lookup.js";
|
|
14
6
|
/**
|
|
15
7
|
* Names are unique only within a scope, so `--origin` picks between scopes
|
|
16
8
|
* that share one. When only one scope has the name, as in a local folder
|
|
17
9
|
* with its single scope, the name alone identifies the asset.
|
|
18
10
|
*/
|
|
19
|
-
export async function resolveOrigin(context, kind, name, origin, usage) {
|
|
20
|
-
if (origin)
|
|
11
|
+
export async function resolveOrigin(context, { kind, name, origin, usage, }) {
|
|
12
|
+
if (origin) {
|
|
21
13
|
return origin;
|
|
14
|
+
}
|
|
22
15
|
const rows = (await context.searchCatalog(kind)).filter((row) => row.name === name || row.id === name);
|
|
23
|
-
if (!rows.length)
|
|
24
|
-
throw new CliError(`No ${
|
|
16
|
+
if (!rows.length) {
|
|
17
|
+
throw new CliError(`No ${assetKinds[kind].one} named ${name} is available to you.`, `barndog ${assetKinds[kind].command} search ${name}`);
|
|
18
|
+
}
|
|
25
19
|
const labels = [...new Set(rows.map((row) => originLabel(row.origin)))];
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
const single = only(labels);
|
|
21
|
+
if (single) {
|
|
22
|
+
return single;
|
|
23
|
+
}
|
|
24
|
+
if (!context.mode.interactive) {
|
|
29
25
|
throw new CliError(`${name} exists in several scopes: ${labels.join(", ")}. Choose one with --origin.`, `${usage} --origin ${labels[0]}`);
|
|
26
|
+
}
|
|
30
27
|
return pickOne(`${name} exists in several scopes. Which one?`, labels.map((label) => ({
|
|
31
28
|
value: label,
|
|
32
29
|
name: label,
|
|
33
|
-
hint: clean(rows.find((row) => originLabel(row.origin) === label)
|
|
34
|
-
.description),
|
|
30
|
+
hint: clean(rows.find((row) => originLabel(row.origin) === label)?.version
|
|
31
|
+
.description ?? ""),
|
|
35
32
|
})));
|
|
36
33
|
}
|
|
37
34
|
/** Lets the person choose an installed asset when the command was given no name. */
|
|
38
35
|
export async function pickInstalled(context, kind, usage) {
|
|
39
|
-
if (!context.mode.interactive)
|
|
40
|
-
throw new CliError(`Name the ${
|
|
36
|
+
if (!context.mode.interactive) {
|
|
37
|
+
throw new CliError(`Name the ${assetKinds[kind].one} to use, or run this in a terminal to choose from a list.`, usage);
|
|
38
|
+
}
|
|
41
39
|
const items = (await context.inventory()).items.filter((item) => item.kind === kind && item.origin !== "—");
|
|
42
|
-
const item = await pickOne(`Choose a ${
|
|
40
|
+
const item = await pickOne(`Choose a ${assetKinds[kind].one}`, items.map((item) => ({
|
|
43
41
|
value: item,
|
|
44
42
|
name: item.installedName,
|
|
45
43
|
hint: `${item.origin} · ${item.state}`,
|
|
46
|
-
})), { empty: `No ${
|
|
44
|
+
})), { empty: `No ${assetKinds[kind].one}s are installed on this machine.` });
|
|
47
45
|
return { name: item.name, origin: item.origin };
|
|
48
46
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { bold, clean, dim, hint, json, originLabel, table, } from "../ui/format.js";
|
|
2
|
+
/** `barndog people`: coworkers and the personal assets they share. */
|
|
3
|
+
export function registerPeople(program, context) {
|
|
4
|
+
const people = program
|
|
5
|
+
.command("people")
|
|
6
|
+
.description("Find coworkers and the personal assets they share");
|
|
7
|
+
people
|
|
8
|
+
.command("list")
|
|
9
|
+
.description("List people in your organization")
|
|
10
|
+
.option("--search <query>", "Search names or handles")
|
|
11
|
+
.action(async (options) => {
|
|
12
|
+
const rows = await context.developers(options.search);
|
|
13
|
+
if (context.mode.json) {
|
|
14
|
+
return context.write(json(rows));
|
|
15
|
+
}
|
|
16
|
+
if (!rows.length) {
|
|
17
|
+
return context.write(dim("No matching people."));
|
|
18
|
+
}
|
|
19
|
+
for (const line of table(rows.map((person) => [
|
|
20
|
+
bold(clean(person.name)),
|
|
21
|
+
dim(`@${clean(person.slug)}`),
|
|
22
|
+
]), { header: ["Name", "Handle"] })) {
|
|
23
|
+
context.write(line);
|
|
24
|
+
}
|
|
25
|
+
context.write("");
|
|
26
|
+
context.write(hint("barndog people show <handle>", "Tip") +
|
|
27
|
+
dim(" to see what someone shares"));
|
|
28
|
+
});
|
|
29
|
+
people
|
|
30
|
+
.command("show <handle>")
|
|
31
|
+
.description("List a person's shared assets")
|
|
32
|
+
.option("--search <query>", "Filter asset names")
|
|
33
|
+
.action(async (handle, options) => {
|
|
34
|
+
const result = await context.developerAssets(handle, options.search);
|
|
35
|
+
if (context.mode.json) {
|
|
36
|
+
return context.write(json(result));
|
|
37
|
+
}
|
|
38
|
+
context.write(`${bold(clean(result.developer.name))} ${dim(`@${result.developer.slug}`)}`);
|
|
39
|
+
context.write("");
|
|
40
|
+
if (!result.assets.length) {
|
|
41
|
+
return context.write(dim(" Nothing shared yet."));
|
|
42
|
+
}
|
|
43
|
+
for (const line of table(result.assets.map((asset) => [
|
|
44
|
+
dim(asset.kind),
|
|
45
|
+
bold(clean(asset.name)),
|
|
46
|
+
originLabel(asset.origin),
|
|
47
|
+
]), { header: ["Kind", "Name", "Origin"] })) {
|
|
48
|
+
context.write(line);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { Option } from "commander";
|
|
2
|
+
import { assetListOptions } from "../ui/asset-list.js";
|
|
3
|
+
import { runSetInstall } from "../ui/scope-install.js";
|
|
4
|
+
import { runSelection } from "../ui/selection.js";
|
|
5
|
+
import { pickOne } from "../ui/pick.js";
|
|
6
|
+
import { bold, dim, hint, json, ok, originLabel, section, table, } from "../ui/format.js";
|
|
7
|
+
import { requireArguments } from "./arguments.js";
|
|
8
|
+
const setDescriptions = {
|
|
9
|
+
install: "Subscribe to a scope's shared assets",
|
|
10
|
+
remove: "Unsubscribe from a scope",
|
|
11
|
+
enable: "Turn a paused subscription back on",
|
|
12
|
+
disable: "Pause a subscription without removing it",
|
|
13
|
+
};
|
|
14
|
+
/** What the picker offers when a `sets` command is run without a scope. */
|
|
15
|
+
const setPickers = {
|
|
16
|
+
install: {
|
|
17
|
+
message: "Choose a scope to subscribe to",
|
|
18
|
+
offers: (subscription) => !subscription,
|
|
19
|
+
empty: "You're already subscribed to every scope.",
|
|
20
|
+
},
|
|
21
|
+
remove: {
|
|
22
|
+
message: "Choose a subscription to remove",
|
|
23
|
+
offers: (subscription) => Boolean(subscription),
|
|
24
|
+
empty: "You have no subscriptions yet.",
|
|
25
|
+
},
|
|
26
|
+
enable: {
|
|
27
|
+
message: "Choose a paused subscription to turn back on",
|
|
28
|
+
offers: (subscription) => subscription?.enabled === false,
|
|
29
|
+
empty: "None of your subscriptions are paused.",
|
|
30
|
+
},
|
|
31
|
+
disable: {
|
|
32
|
+
message: "Choose a subscription to pause",
|
|
33
|
+
offers: (subscription) => subscription?.enabled === true,
|
|
34
|
+
empty: "None of your subscriptions are active.",
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
export function registerSets(program, context) {
|
|
38
|
+
const sets = program
|
|
39
|
+
.command("sets")
|
|
40
|
+
.description("Subscribe to everything a team, repository or the organization shares");
|
|
41
|
+
const load = () => context.listSets();
|
|
42
|
+
const label = (scope) => originLabel(scope);
|
|
43
|
+
assetListOptions(sets
|
|
44
|
+
.command("list")
|
|
45
|
+
.description("Show your subscriptions and the scopes you can subscribe to")).action(async (options) => {
|
|
46
|
+
const result = await load();
|
|
47
|
+
if (context.mode.json) {
|
|
48
|
+
return context.write(json(result));
|
|
49
|
+
}
|
|
50
|
+
const subscribed = result.subscriptions.map((subscription) => ({
|
|
51
|
+
subscription,
|
|
52
|
+
scope: result.available.find((s) => s.id === subscription.scope.id && s.type === subscription.scope.type),
|
|
53
|
+
}));
|
|
54
|
+
context.write(`${section("Subscribed")} ${dim(`(${subscribed.length})`)}`);
|
|
55
|
+
context.write(subscribed.length
|
|
56
|
+
? table(subscribed.map(({ subscription, scope }) => [
|
|
57
|
+
bold(scope
|
|
58
|
+
? label(scope)
|
|
59
|
+
: `${subscription.scope.type}/${subscription.scope.id}`),
|
|
60
|
+
scope?.name ?? dim("unavailable"),
|
|
61
|
+
subscription.mode,
|
|
62
|
+
subscription.enabled ? ok("enabled") : dim("disabled"),
|
|
63
|
+
]), { header: ["Scope", "Name", "Mode", "State"] }).join("\n")
|
|
64
|
+
: dim(" None yet."));
|
|
65
|
+
const terms = options.search?.toLowerCase().split(/\s+/).filter(Boolean) ?? [];
|
|
66
|
+
const available = result.available
|
|
67
|
+
.filter((scope) => !result.subscriptions.some((s) => s.scope.id === scope.id && s.scope.type === scope.type))
|
|
68
|
+
.filter((scope) => (!options.origin ||
|
|
69
|
+
scope.type === options.origin ||
|
|
70
|
+
label(scope) === options.origin.replace(":", "/")) &&
|
|
71
|
+
terms.every((term) => `${label(scope)} ${scope.name ?? ""}`.toLowerCase().includes(term)))
|
|
72
|
+
.sort((a, b) => label(a).localeCompare(label(b)));
|
|
73
|
+
const start = (options.page - 1) * options.limit;
|
|
74
|
+
const page = available.slice(start, start + options.limit);
|
|
75
|
+
context.write("");
|
|
76
|
+
context.write(`${section("Available")} ${dim(`(${available.length})`)}`);
|
|
77
|
+
context.write(page.length
|
|
78
|
+
? table(page.map((scope) => [bold(label(scope)), scope.name ?? ""]), { header: ["Scope", "Name"] }).join("\n")
|
|
79
|
+
: dim(" Nothing else to subscribe to."));
|
|
80
|
+
if (start + options.limit < available.length) {
|
|
81
|
+
context.write(hint(`barndog sets list --page ${options.page + 1}`));
|
|
82
|
+
}
|
|
83
|
+
context.write("");
|
|
84
|
+
context.write(hint("barndog sets install", "Tip") + dim(" to subscribe"));
|
|
85
|
+
});
|
|
86
|
+
const chooseScope = async (message, filter, empty) => {
|
|
87
|
+
const result = await load();
|
|
88
|
+
return pickOne(message, result.available
|
|
89
|
+
.filter((scope) => filter(scope, result.subscriptions.find((s) => s.scope.id === scope.id && s.scope.type === scope.type)))
|
|
90
|
+
.sort((a, b) => label(a).localeCompare(label(b)))
|
|
91
|
+
.map((scope) => ({
|
|
92
|
+
value: label(scope),
|
|
93
|
+
name: label(scope),
|
|
94
|
+
hint: scope.name,
|
|
95
|
+
})), { empty });
|
|
96
|
+
};
|
|
97
|
+
for (const action of ["install", "remove", "enable", "disable"]) {
|
|
98
|
+
const command = sets
|
|
99
|
+
.command(`${action} [scope]`)
|
|
100
|
+
.description(setDescriptions[action])
|
|
101
|
+
.option("--origin <origin>", "Scope, such as org, team/engineering or repo/web-app");
|
|
102
|
+
if (action === "install") {
|
|
103
|
+
command
|
|
104
|
+
.addOption(new Option("--mode <mode>", "Which assets to include; asks when omitted").choices(["recommended", "optional", "all"]))
|
|
105
|
+
.addOption(new Option("--overrides <choice>", "Keep or clear your existing exclusions").choices(["preserve", "clear"]))
|
|
106
|
+
.option("--decisions <file>", "JSON per-asset override choices");
|
|
107
|
+
}
|
|
108
|
+
command.action(async (scope, options) => {
|
|
109
|
+
let origin = scope ?? options.origin;
|
|
110
|
+
if (!origin) {
|
|
111
|
+
requireArguments(context, `barndog sets ${action} <scope>`);
|
|
112
|
+
const { message, offers, empty } = setPickers[action];
|
|
113
|
+
origin = await chooseScope(message, (_, s) => offers(s), empty);
|
|
114
|
+
}
|
|
115
|
+
return action === "install"
|
|
116
|
+
? runSetInstall(context, { ...options, origin })
|
|
117
|
+
: runSelection(context, (resolution) => context.changeSet(action, { ...options, origin, resolution }));
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
const switchCommand = (name, hidden) => sets
|
|
121
|
+
.command(`${name} [scope]`, { hidden })
|
|
122
|
+
.description("Switch to another team or repository, replacing your current one of that type")
|
|
123
|
+
.addOption(new Option("--mode <mode>", "Which assets to include")
|
|
124
|
+
.choices(["recommended", "optional", "all"])
|
|
125
|
+
.default("recommended"))
|
|
126
|
+
.addOption(new Option("--overrides <choice>", "Keep or clear your existing exclusions").choices(["preserve", "clear"]))
|
|
127
|
+
.option("--decisions <file>", "JSON per-asset override choices")
|
|
128
|
+
.action(async (scope, options) => {
|
|
129
|
+
let origin = scope && name === "switch-team" && !scope.includes("/")
|
|
130
|
+
? `team/${scope}`
|
|
131
|
+
: scope;
|
|
132
|
+
if (!origin) {
|
|
133
|
+
requireArguments(context, "barndog sets switch <team/slug|repo/slug>");
|
|
134
|
+
origin = await chooseScope("Switch to", (candidate, subscription) => !subscription &&
|
|
135
|
+
(candidate.type === "team" || candidate.type === "repo"), "There is no other team or repository to switch to.");
|
|
136
|
+
}
|
|
137
|
+
await runSelection(context, (resolution) => context.switchSet({ ...options, origin, resolution }));
|
|
138
|
+
});
|
|
139
|
+
switchCommand("switch", false);
|
|
140
|
+
switchCommand("switch-team", true);
|
|
141
|
+
}
|
package/dist/commands/status.js
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
|
-
import { harnessNames, inventoryHints,
|
|
1
|
+
import { harnessNames, inventoryHints, renderInventory } from "../ui/assets.js";
|
|
2
2
|
import { renderCollaboration } from "../ui/collaboration.js";
|
|
3
3
|
import { dim, fields, heading, hint, json, ok, plural } from "../ui/format.js";
|
|
4
|
+
import { assetKindList, assetKinds } from "../features/asset-kinds/index.js";
|
|
5
|
+
function knowledgeState(enabled) {
|
|
6
|
+
return enabled ? ok("listed at session start") : dim("off");
|
|
7
|
+
}
|
|
4
8
|
export function registerStatus(program, context) {
|
|
5
9
|
program
|
|
6
10
|
.command("status")
|
|
7
11
|
.description("Show what's installed on this machine and where (inside a working copy, its edits first)")
|
|
8
12
|
.option("--paths", "Show installed folders and configuration files")
|
|
9
13
|
.action(async (options) => {
|
|
10
|
-
const working =
|
|
14
|
+
const working = await context.workingStatus();
|
|
11
15
|
const inventory = await context.inventory();
|
|
12
|
-
if (context.mode.json)
|
|
13
|
-
return context.write(json(
|
|
14
|
-
? inventory
|
|
15
|
-
:
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
if (context.mode.json) {
|
|
17
|
+
return context.write(json("changes" in working
|
|
18
|
+
? { workingCopy: working, ...inventory }
|
|
19
|
+
: inventory));
|
|
20
|
+
}
|
|
21
|
+
if ("changes" in working) {
|
|
22
|
+
for (const line of renderCollaboration(working)) {
|
|
18
23
|
context.write(line);
|
|
24
|
+
}
|
|
19
25
|
context.write("");
|
|
20
26
|
}
|
|
21
27
|
context.write(`${heading("status")}\n`);
|
|
@@ -27,40 +33,44 @@ export function registerStatus(program, context) {
|
|
|
27
33
|
],
|
|
28
34
|
[
|
|
29
35
|
"Knowledge",
|
|
30
|
-
inventory.server
|
|
31
|
-
? inventory.knowledge
|
|
32
|
-
? ok("listed at session start")
|
|
33
|
-
: dim("off")
|
|
34
|
-
: undefined,
|
|
36
|
+
inventory.server ? knowledgeState(inventory.knowledge) : undefined,
|
|
35
37
|
],
|
|
36
|
-
]))
|
|
38
|
+
])) {
|
|
37
39
|
context.write(line);
|
|
38
|
-
|
|
40
|
+
}
|
|
41
|
+
if (inventory.offline) {
|
|
39
42
|
context.write(dim(`\nShowing local state only: ${inventory.offline}`));
|
|
40
|
-
|
|
43
|
+
}
|
|
44
|
+
for (const kind of assetKindList) {
|
|
41
45
|
const items = inventory.items.filter((item) => item.kind === kind);
|
|
42
46
|
context.write("");
|
|
43
47
|
if (!items.length) {
|
|
44
|
-
context.write(`${
|
|
45
|
-
context.write(dim(` None. ${`barndog ${
|
|
48
|
+
context.write(`${assetKinds[kind].many} ${dim("(0)")}`);
|
|
49
|
+
context.write(dim(` None. ${`barndog ${assetKinds[kind].command} install`} to add some.`));
|
|
46
50
|
continue;
|
|
47
51
|
}
|
|
48
52
|
for (const line of renderInventory(items, {
|
|
49
|
-
heading:
|
|
53
|
+
heading: assetKinds[kind].many,
|
|
50
54
|
paths: options.paths,
|
|
51
|
-
|
|
55
|
+
runtime: context.runtime,
|
|
56
|
+
})) {
|
|
52
57
|
context.write(line);
|
|
58
|
+
}
|
|
53
59
|
}
|
|
54
60
|
const hints = inventoryHints(inventory.items);
|
|
55
61
|
context.write("");
|
|
56
|
-
if (hints.length)
|
|
57
|
-
for (const line of hints)
|
|
62
|
+
if (hints.length) {
|
|
63
|
+
for (const line of hints) {
|
|
58
64
|
context.write(line);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
59
67
|
// Without the workspace, BarnDog only knows what is installed, not whether it's current.
|
|
60
|
-
else if (inventory.offline)
|
|
68
|
+
else if (inventory.offline) {
|
|
61
69
|
context.write(`${plural(inventory.items.length, "asset")} installed. ${dim("Couldn't check for updates; run barndog sync once the workspace is reachable.")}`);
|
|
62
|
-
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
63
72
|
context.write(`${ok("✔")} ${plural(inventory.items.length, "asset")} up to date.` +
|
|
64
73
|
(options.paths ? "" : ` ${hint("barndog status --paths", "Tip")}`));
|
|
74
|
+
}
|
|
65
75
|
});
|
|
66
76
|
}
|