barndog 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -28
- package/dist/cli.js +11 -7
- package/dist/commands/add.js +34 -21
- package/dist/commands/adopt.js +91 -0
- package/dist/commands/arguments.js +12 -0
- package/dist/commands/asset-install.js +161 -0
- package/dist/commands/asset-list.js +126 -0
- package/dist/commands/asset-share.js +94 -0
- package/dist/commands/auth.js +4 -0
- package/dist/commands/availability.js +72 -27
- package/dist/commands/capabilities.js +79 -417
- package/dist/commands/collaboration.js +212 -108
- package/dist/commands/environment.js +18 -411
- package/dist/commands/github.js +200 -0
- package/dist/commands/harnesses.js +74 -0
- package/dist/commands/helpers.js +39 -0
- package/dist/commands/hooks.js +87 -0
- package/dist/commands/init.js +4 -2
- package/dist/commands/knowledge.js +73 -0
- package/dist/commands/mcp-env.js +78 -0
- package/dist/commands/mcp.js +64 -0
- package/dist/commands/origin.js +21 -23
- package/dist/commands/people.js +51 -0
- package/dist/commands/sets.js +141 -0
- package/dist/commands/status.js +36 -25
- package/dist/commands/sync.js +13 -5
- package/dist/commands/workspace.js +75 -23
- package/dist/config/environment.js +13 -27
- package/dist/config/paths.js +81 -0
- package/dist/config/selection.js +30 -0
- package/dist/config/settings.js +99 -108
- package/dist/config/state.js +67 -55
- package/dist/entry/knowledge-startup.js +32 -0
- package/dist/entry/mcp-launch.js +71 -0
- package/dist/entry/opencode-plugin.js +62 -0
- package/dist/{features/git-workspace/startup.js → entry/workspace-startup.js} +7 -2
- package/dist/errors.js +198 -55
- package/dist/features/adoption/adopt.js +234 -0
- package/dist/features/adoption/copies.js +29 -0
- package/dist/features/adoption/originals.js +116 -0
- package/dist/features/adoption/record.js +120 -0
- package/dist/features/adoption/restore.js +28 -0
- package/dist/features/adoption/scan.js +482 -0
- package/dist/features/adoption/undo.js +42 -0
- package/dist/features/asset-kinds/index.js +129 -0
- package/dist/features/asset-selection/index.js +51 -19
- package/dist/features/auth/credentials.js +80 -54
- package/dist/features/auth/session.js +83 -49
- package/dist/features/auth/transport.js +69 -17
- package/dist/features/catalog/index.js +32 -61
- package/dist/features/collaboration/api.js +160 -0
- package/dist/features/collaboration/index.js +321 -233
- package/dist/features/collaboration/remote.js +35 -115
- package/dist/features/collaboration/results.js +2 -0
- package/dist/features/collaboration/workspace-git.js +242 -152
- package/dist/features/collaboration/workspace-github.js +118 -54
- package/dist/features/collaboration/workspace-store.js +157 -97
- package/dist/features/collaboration/workspace.js +278 -173
- package/dist/features/discovery/index.js +68 -57
- package/dist/features/doctor/index.js +56 -26
- package/dist/features/environment/auto-sync.js +28 -27
- package/dist/features/environment/harnesses.js +36 -0
- package/dist/features/environment/moves.js +171 -0
- package/dist/features/environment/names.js +73 -49
- package/dist/features/environment/operations.js +322 -229
- package/dist/features/environment/own-entries.js +89 -0
- package/dist/features/environment/settle-names.js +91 -0
- package/dist/features/environment/stage.js +202 -0
- package/dist/features/environment/sync.js +127 -487
- package/dist/features/environment/transaction.js +179 -147
- package/dist/features/environment/writes.js +243 -0
- package/dist/features/github/account.js +25 -0
- package/dist/features/github/connections.js +119 -0
- package/dist/features/github/pulls.js +118 -0
- package/dist/features/hooks/adapt.js +32 -25
- package/dist/features/hooks/catalog.js +28 -0
- package/dist/features/hooks/compatibility.js +55 -0
- package/dist/features/hooks/divergence.js +36 -12
- package/dist/features/hooks/test.js +91 -66
- package/dist/features/hooks/types.js +1 -0
- package/dist/features/imports/discover.js +133 -60
- package/dist/features/imports/folder.js +48 -14
- package/dist/features/imports/local.js +127 -135
- package/dist/features/imports/remote.js +46 -26
- package/dist/features/inspection/index.js +17 -17
- package/dist/features/inventory/index.js +111 -111
- package/dist/features/inventory/show.js +74 -0
- package/dist/features/knowledge/index.js +69 -49
- package/dist/features/mcps/catalog.js +31 -0
- package/dist/features/mcps/import.js +369 -0
- package/dist/features/mcps/index.js +104 -50
- package/dist/features/mcps/values.js +33 -0
- package/dist/features/migration/migrate.js +263 -0
- package/dist/features/migration/move.js +448 -0
- package/dist/features/migration/promote.js +26 -0
- package/dist/features/native/adapters.js +69 -96
- package/dist/features/native/configuration.js +134 -84
- package/dist/features/native/hook-shell.js +55 -0
- package/dist/features/native/plugin-module.js +56 -0
- package/dist/features/native/secret-values.js +74 -0
- package/dist/features/onboarding/environment.js +67 -34
- package/dist/features/onboarding/setup.js +43 -40
- package/dist/features/repositories/context.js +30 -13
- package/dist/features/secrets/index.js +77 -0
- package/dist/features/server/catalog.js +58 -0
- package/dist/features/server/client.js +13 -0
- package/dist/features/server/connection.js +37 -0
- package/dist/features/server/origin.js +74 -0
- package/dist/features/server/pages.js +24 -0
- package/dist/features/skills/catalog.js +42 -0
- package/dist/features/workspace/assets.js +57 -0
- package/dist/features/workspace/cloud-source.js +34 -0
- package/dist/features/workspace/directory.js +38 -0
- package/dist/features/{git-workspace → workspace}/format.js +121 -54
- package/dist/features/workspace/git.js +221 -0
- package/dist/features/workspace/installed.js +92 -0
- package/dist/features/{git-workspace → workspace}/overlay.js +53 -46
- package/dist/features/workspace/packages.js +173 -0
- package/dist/features/{git-workspace → workspace}/publish.js +120 -64
- package/dist/features/workspace/repo-source.js +193 -0
- package/dist/features/{git-workspace → workspace}/setup.js +72 -45
- package/dist/features/{git-workspace → workspace}/snapshot.js +60 -19
- package/dist/features/workspace/source.js +1 -0
- package/dist/features/workspace/tree.js +52 -0
- package/dist/features/workspace/workspace-source.js +27 -0
- package/dist/harnesses/claude.js +23 -1
- package/dist/harnesses/codex.js +67 -1
- package/dist/harnesses/cursor.js +22 -1
- package/dist/harnesses/detect.js +6 -50
- package/dist/harnesses/formats.js +52 -0
- package/dist/harnesses/opencode.js +108 -0
- package/dist/harnesses/registry.js +35 -2
- package/dist/platform.js +403 -0
- package/dist/program.js +275 -56
- package/dist/runtime.js +1 -0
- package/dist/shared/cli-error.js +22 -0
- package/dist/shared/constants.js +32 -0
- package/dist/shared/files.js +107 -0
- package/dist/shared/lock.js +113 -0
- package/dist/shared/lookup.js +11 -0
- package/dist/shared/patterns.js +102 -0
- package/dist/shared/shell.js +20 -0
- package/dist/shared/values.js +26 -0
- package/dist/ui/add-asset.js +41 -400
- package/dist/ui/add-hook.js +219 -0
- package/dist/ui/add-mcp.js +170 -0
- package/dist/ui/add-prompts.js +47 -0
- package/dist/ui/add-skills.js +117 -0
- package/dist/ui/adopt.js +197 -0
- package/dist/ui/asset-list.js +31 -13
- package/dist/ui/assets.js +38 -47
- package/dist/ui/auth.js +45 -34
- package/dist/ui/clash.js +10 -6
- package/dist/ui/collaboration.js +116 -44
- package/dist/ui/connection.js +17 -6
- package/dist/ui/decision-error.js +24 -0
- package/dist/ui/environment-onboarding.js +35 -13
- package/dist/ui/format.js +66 -18
- package/dist/ui/harness-picker.js +18 -0
- package/dist/ui/hook-compatibility.js +14 -6
- package/dist/ui/mcp.js +28 -3
- package/dist/ui/move.js +57 -6
- package/dist/ui/onboarding.js +148 -95
- package/dist/ui/options.js +9 -0
- package/dist/ui/output.js +108 -43
- package/dist/ui/package-details.js +34 -0
- package/dist/ui/pick.js +45 -33
- package/dist/ui/scope-install.js +18 -7
- package/dist/ui/secret-input.js +19 -0
- package/dist/ui/selection.js +17 -11
- package/dist/ui/theme.js +37 -14
- package/dist/version.js +6 -3
- package/package.json +13 -3
- package/dist/features/capabilities/index.js +0 -106
- package/dist/features/collaboration/domain.js +0 -90
- package/dist/features/environment/cloud-source.js +0 -27
- package/dist/features/environment/installed.js +0 -124
- package/dist/features/environment/packages.js +0 -120
- package/dist/features/environment/remote.js +0 -71
- package/dist/features/environment/workspace-source.js +0 -19
- package/dist/features/git-hosts/index.js +0 -148
- package/dist/features/git-workspace/assets.js +0 -71
- package/dist/features/git-workspace/git.js +0 -135
- package/dist/features/git-workspace/migrate.js +0 -188
- package/dist/features/git-workspace/move.js +0 -337
- package/dist/features/git-workspace/source.js +0 -159
- package/dist/features/imports/mcp.js +0 -219
- package/dist/features/knowledge/startup.js +0 -25
- package/dist/features/native/mcp-launch.js +0 -57
- package/dist/features/skills/install.js +0 -25
- package/dist/features/skills/remote.js +0 -177
- package/dist/features/skills/sync.js +0 -121
- package/dist/features/skills/validation.js +0 -34
- /package/dist/features/environment/{source.js → events.js} +0 -0
package/README.md
CHANGED
|
@@ -1,35 +1,48 @@
|
|
|
1
1
|
# BarnDog CLI
|
|
2
2
|
|
|
3
|
-
Set up your
|
|
3
|
+
Set up your AI coding environment once, and have it show up in Claude Code, Codex, or any other harness you love.
|
|
4
4
|
|
|
5
|
-
`barndog` is the command-line tool for [BarnDog](https://barndog.dev). It installs
|
|
5
|
+
`barndog` is the command-line tool for [BarnDog](https://barndog.dev). It installs Skills, MCP servers, Hooks, and knowledge into the coding agents you already use, keeps them up to date, and lets you improve them like code. It works the same whether it's just you, a small team, or a whole organization; only where the assets live changes.
|
|
6
6
|
|
|
7
7
|
Currently supported harnesses:
|
|
8
8
|
|
|
9
9
|
- Claude Code
|
|
10
10
|
- Codex
|
|
11
11
|
- Cursor
|
|
12
|
+
- OpenCode (Skills, MCP servers and knowledge; it has no command hooks, so Hooks don't apply)
|
|
12
13
|
|
|
13
14
|
## Why
|
|
14
15
|
|
|
15
|
-
Every coding agent has its own place for skills, its own MCP config format, and its own hook settings. Keeping
|
|
16
|
+
Every coding agent has its own place for skills, its own MCP config format, and its own hook settings. Keeping one setup consistent across them, or across a team, usually means copying files around and hoping nobody's copy is stale.
|
|
16
17
|
|
|
17
|
-
BarnDog keeps one
|
|
18
|
+
BarnDog keeps one setup and writes it into each tool in that tool's own format. You keep working in the agent you prefer.
|
|
19
|
+
|
|
20
|
+
## Pick your setup
|
|
21
|
+
|
|
22
|
+
| Workspace | Run | Best for | What you get |
|
|
23
|
+
| ------------------ | --------------------------- | -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
24
|
+
| **Local folder** | `barndog init --local` | Just you | One copy of your assets in every tool. No account, nothing shared. |
|
|
25
|
+
| **Git repository** | `barndog init --repo <url>` | Teams that want full control over their data | BarnDog stores nothing. You edit `barndog.yaml` and the folders by hand, and the repository's permissions decide who can change what. |
|
|
26
|
+
| **BarnDog Cloud** | `barndog init` | Teams of any size | A web catalog to manage, distribute, and discover assets, teams and people; per-team approval rules, and review in the terminal or the browser. |
|
|
27
|
+
|
|
28
|
+
Git trades discoverability for governance: there are no per-team approval rules, people management or web catalog, and a growing setup can get heavy to maintain by hand. BarnDog Cloud is free during the beta, and will stay free for teams of up to 5 people.
|
|
29
|
+
|
|
30
|
+
Installing and syncing work the same everywhere. Knowledge needs Git or Cloud. Switch later with `barndog local move` or `barndog migrate --to <server>`.
|
|
18
31
|
|
|
19
32
|
## How it works
|
|
20
33
|
|
|
21
34
|
```mermaid
|
|
22
35
|
flowchart LR
|
|
23
|
-
W["Your workspace<br/>
|
|
36
|
+
W["Your workspace<br/>a local folder, a Git repo,<br/>or BarnDog Cloud"] -->|barndog sync| C["barndog CLI"]
|
|
24
37
|
C --> CC[Claude Code]
|
|
25
38
|
C --> CX[Codex]
|
|
26
39
|
C --> CU[Other harnesses]
|
|
27
40
|
```
|
|
28
41
|
|
|
29
|
-
1. **Connect to a workspace.** `barndog init`
|
|
30
|
-
2. **Choose what you want.** Pick your coding tools, then
|
|
42
|
+
1. **Connect to a workspace.** `barndog init` points at a local folder, a Git repository, or a BarnDog server.
|
|
43
|
+
2. **Choose what you want.** Pick your coding tools, then what to install. On BarnDog Cloud that means sets (the organization, your team, the repositories you work in) plus any individual assets.
|
|
31
44
|
3. **Sync.** `barndog sync` writes everything into each tool's native location. It runs again automatically when a coding session starts, so updates arrive without anyone thinking about it.
|
|
32
|
-
4. **Improve
|
|
45
|
+
4. **Improve.** Edit a local asset directly, or, in a Git or Cloud workspace, pull it into a folder, edit it, and `barndog push` it for review. Once merged, everyone gets the new version on their next sync.
|
|
33
46
|
|
|
34
47
|
## What it manages
|
|
35
48
|
|
|
@@ -38,11 +51,11 @@ flowchart LR
|
|
|
38
51
|
| **Skill** | A folder with a `SKILL.md` and supporting files that agents load when relevant. |
|
|
39
52
|
| **MCP server** | A connection to an MCP server. It names the secrets it needs but never stores their values. |
|
|
40
53
|
| **Hook** | A command that runs on an agent lifecycle event, such as after a file edit. |
|
|
41
|
-
| **Knowledge** |
|
|
54
|
+
| **Knowledge** | Policies and context that agents can look up when a task needs it (Git and Cloud). |
|
|
42
55
|
|
|
43
56
|
## Install
|
|
44
57
|
|
|
45
|
-
|
|
58
|
+
Runs on **macOS, Linux, and Windows** with [Node.js](https://nodejs.org) 24 or newer.
|
|
46
59
|
|
|
47
60
|
```sh
|
|
48
61
|
npm install -g barndog
|
|
@@ -51,27 +64,17 @@ npm install -g barndog
|
|
|
51
64
|
## Quick start
|
|
52
65
|
|
|
53
66
|
```sh
|
|
54
|
-
barndog init
|
|
55
|
-
barndog status
|
|
56
|
-
barndog skills
|
|
57
|
-
barndog skills
|
|
58
|
-
barndog sync
|
|
59
|
-
barndog doctor
|
|
67
|
+
barndog init # choose a workspace and your coding tools
|
|
68
|
+
barndog status # what's installed on this machine, and where
|
|
69
|
+
barndog skills add https://github.com/... # add a Skill from a repository
|
|
70
|
+
barndog skills search review # browse what the workspace offers
|
|
71
|
+
barndog sync # apply changes now
|
|
72
|
+
barndog doctor # check everything and print a fix for each problem
|
|
60
73
|
```
|
|
61
74
|
|
|
62
75
|
Run `barndog` on its own to see every command, or `barndog <command> --help` for its options.
|
|
63
76
|
|
|
64
|
-
###
|
|
65
|
-
|
|
66
|
-
You can share assets through any Git repository, using your own Git credentials. This requires the [GitHub CLI](https://cli.github.com) (`gh`) to be installed:
|
|
67
|
-
|
|
68
|
-
```sh
|
|
69
|
-
barndog init --repo git@github.com:acme/ai-setup.git
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
Or keep them in a folder on your machine with `barndog init --local`. See [Git workspaces](https://barndog.dev/docs/cli/git-workspaces) for the layout.
|
|
73
|
-
|
|
74
|
-
### Suggest a change
|
|
77
|
+
### Suggest a change (Git and Cloud)
|
|
75
78
|
|
|
76
79
|
```sh
|
|
77
80
|
barndog skills pull code-review --origin team/engineering
|
|
@@ -81,7 +84,7 @@ barndog diff
|
|
|
81
84
|
barndog push --title "Add a security checklist"
|
|
82
85
|
```
|
|
83
86
|
|
|
84
|
-
|
|
87
|
+
In a Git workspace this opens a pull request on your Git host. In BarnDog Cloud it creates a Suggested Change that reviewers handle with `barndog skills changes list`, `changes diff`, and `changes approve` (or the same under `barndog hooks`), or in the web workspace.
|
|
85
88
|
|
|
86
89
|
## What it changes on your machine
|
|
87
90
|
|
package/dist/cli.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { CommanderError, InvalidArgumentError } from "commander";
|
|
3
3
|
import { assertCommandAvailable, currentSetupMode, } from "./commands/availability.js";
|
|
4
|
-
import { createProgram } from "./program.js";
|
|
4
|
+
import { captureRuntime, createProgram } from "./program.js";
|
|
5
5
|
import { renderError, renderJsonError } from "./ui/output.js";
|
|
6
6
|
import { json } from "./ui/format.js";
|
|
7
|
-
import { NothingToDoError } from "./errors.js";
|
|
7
|
+
import { CliError, NothingToDoError } from "./errors.js";
|
|
8
8
|
// Parsing errors happen before any action runs, so read the flag directly.
|
|
9
9
|
const words = process.argv.slice(2);
|
|
10
10
|
const end = words.indexOf("--");
|
|
11
11
|
const asJson = (end < 0 ? words : words.slice(0, end)).includes("--json");
|
|
12
12
|
try {
|
|
13
|
+
const runtime = captureRuntime();
|
|
13
14
|
await createProgram({
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
runtime,
|
|
16
|
+
guard: (path, options) => assertCommandAvailable(path, options, runtime),
|
|
17
|
+
setupMode: await currentSetupMode(runtime),
|
|
16
18
|
...(asJson ? { writeError: () => undefined } : {}),
|
|
17
19
|
}).parseAsync(process.argv);
|
|
18
20
|
}
|
|
@@ -21,13 +23,15 @@ catch (error) {
|
|
|
21
23
|
!(error instanceof InvalidArgumentError)) {
|
|
22
24
|
// Commander already printed help or the parsing error, unless it was silenced for --json.
|
|
23
25
|
process.exitCode = error.exitCode;
|
|
24
|
-
if (asJson && error.exitCode)
|
|
25
|
-
console.error(renderJsonError(new
|
|
26
|
+
if (asJson && error.exitCode) {
|
|
27
|
+
console.error(renderJsonError(new CliError(error.code === "commander.help"
|
|
26
28
|
? "Choose a subcommand. Add --help to see them."
|
|
27
29
|
: error.message.replace(/^error: /, ""))));
|
|
30
|
+
}
|
|
28
31
|
}
|
|
29
32
|
else if (error instanceof Error && error.name === "ExitPromptError") {
|
|
30
|
-
|
|
33
|
+
const message = "Cancelled. Nothing was changed.";
|
|
34
|
+
console.log(asJson ? json({ message }) : message);
|
|
31
35
|
process.exitCode = 130;
|
|
32
36
|
}
|
|
33
37
|
else if (error instanceof NothingToDoError) {
|
package/dist/commands/add.js
CHANGED
|
@@ -1,25 +1,36 @@
|
|
|
1
1
|
import { Option } from "commander";
|
|
2
|
+
import { harnesses } from "../harnesses/registry.js";
|
|
2
3
|
import { stripVTControlCharacters } from "node:util";
|
|
3
|
-
import { addHook
|
|
4
|
+
import { addHook } from "../ui/add-hook.js";
|
|
5
|
+
import { addMcp } from "../ui/add-mcp.js";
|
|
6
|
+
import { addSkills } from "../ui/add-skills.js";
|
|
7
|
+
import { terminalPrompts } from "../ui/add-prompts.js";
|
|
4
8
|
import { renderCollaboration } from "../ui/collaboration.js";
|
|
5
9
|
import { dim, json, ok } from "../ui/format.js";
|
|
6
10
|
import { renderSyncOutput } from "../ui/output.js";
|
|
11
|
+
import { defined } from "../shared/lookup.js";
|
|
7
12
|
const updates = () => new Option("--updates <mode>", "Stay current: fork, manual or auto").choices([
|
|
8
13
|
"fork",
|
|
9
14
|
"manual",
|
|
10
15
|
"auto",
|
|
11
16
|
]);
|
|
17
|
+
/**
|
|
18
|
+
* Adds import and update commands to existing asset groups using the supplied
|
|
19
|
+
* command services.
|
|
20
|
+
*/
|
|
12
21
|
export function registerAdd(program, context) {
|
|
13
|
-
const group = (name) => program.commands.find((c) => c.name() === name);
|
|
22
|
+
const group = (name) => defined(program.commands.find((c) => c.name() === name), `Command group ${name} isn't registered`);
|
|
14
23
|
const add = () => ({
|
|
24
|
+
runtime: context.runtime,
|
|
15
25
|
interactive: context.mode.interactive,
|
|
16
26
|
write: context.write,
|
|
17
27
|
prompts: terminalPrompts(context.write),
|
|
18
28
|
});
|
|
19
29
|
/** Adding narrates as it goes; `--json` callers get those lines as one object. */
|
|
20
30
|
const reporting = async (run) => {
|
|
21
|
-
if (!context.mode.json)
|
|
31
|
+
if (!context.mode.json) {
|
|
22
32
|
return run(add());
|
|
33
|
+
}
|
|
23
34
|
const messages = [];
|
|
24
35
|
await run({
|
|
25
36
|
...add(),
|
|
@@ -39,10 +50,11 @@ export function registerAdd(program, context) {
|
|
|
39
50
|
.action((url, options) => reporting((context) => addSkills(url, options, context)));
|
|
40
51
|
group("hooks")
|
|
41
52
|
.command("add <url>")
|
|
42
|
-
.description("Add
|
|
53
|
+
.description("Add Hooks from a repository, for the coding tools they were written for")
|
|
43
54
|
.addOption(updates())
|
|
44
|
-
.option("--as <name>", "Add
|
|
45
|
-
.option("--only <names...>", "Choose
|
|
55
|
+
.option("--as <name>", "Add one Hook under a different name")
|
|
56
|
+
.option("--only <names...>", "Choose Hooks by name or folder")
|
|
57
|
+
.option("--all", "Add every Hook in the repository")
|
|
46
58
|
.option("--description <text>", "What the Hook does")
|
|
47
59
|
.action((url, options) => reporting((context) => addHook(url, options, context)));
|
|
48
60
|
group("mcp")
|
|
@@ -50,11 +62,8 @@ export function registerAdd(program, context) {
|
|
|
50
62
|
.description("Add an MCP server from JSON or from one of your coding tools")
|
|
51
63
|
.option("--config <json>", "Server configuration as JSON text")
|
|
52
64
|
.option("--file <path>", "Read the configuration from a file")
|
|
53
|
-
.addOption(new Option("--from <harness>", "Import from a coding tool").choices(
|
|
54
|
-
"
|
|
55
|
-
"codex",
|
|
56
|
-
"cursor",
|
|
57
|
-
]))
|
|
65
|
+
.addOption(new Option("--from <harness>", "Import from a coding tool").choices(harnesses))
|
|
66
|
+
.option("--as <name>", "Add one MCP server under a different name")
|
|
58
67
|
.option("--replace", "Replace an existing entry in your coding tools")
|
|
59
68
|
.option("--oauth", "The server signs in through your coding tool (OAuth)")
|
|
60
69
|
.option("--description <text>", "What the server does")
|
|
@@ -62,38 +71,42 @@ export function registerAdd(program, context) {
|
|
|
62
71
|
for (const [name, kind] of [
|
|
63
72
|
["skills", "skill"],
|
|
64
73
|
["hooks", "hook"],
|
|
65
|
-
])
|
|
74
|
+
]) {
|
|
66
75
|
group(name)
|
|
67
76
|
.command("update [name]")
|
|
68
77
|
.description("Bring assets added from a repository up to date, showing what changed")
|
|
69
78
|
.option("--force", "Overwrite local edits")
|
|
70
79
|
.option("--dry-run", "Show what would change without changing anything")
|
|
71
80
|
.action(async (asset, options) => {
|
|
72
|
-
const results =
|
|
73
|
-
kind,
|
|
74
|
-
name: asset,
|
|
81
|
+
const results = await context.updateImported(kind, asset, {
|
|
75
82
|
force: options.force,
|
|
76
83
|
dryRun: options.dryRun,
|
|
77
|
-
})
|
|
84
|
+
});
|
|
78
85
|
// New files only reach coding tools through the installed copies.
|
|
79
86
|
const applied = !options.dryRun && results.some((r) => r.changes.length > 0);
|
|
80
87
|
const events = applied
|
|
81
88
|
? await context.synchronize(undefined, { prompt: false })
|
|
82
89
|
: [];
|
|
83
|
-
if (context.mode.json)
|
|
90
|
+
if (context.mode.json) {
|
|
84
91
|
return context.write(json(results));
|
|
85
|
-
|
|
92
|
+
}
|
|
93
|
+
if (!results.length) {
|
|
86
94
|
return context.write(dim("Nothing was added from a repository."));
|
|
95
|
+
}
|
|
87
96
|
for (const result of results) {
|
|
88
97
|
context.write(`${result.name}: ${result.changes.length ? `${result.changes.length} file${result.changes.length === 1 ? "" : "s"} changed` : "up to date"}`);
|
|
89
|
-
if (result.changes.length)
|
|
90
|
-
for (const line of renderCollaboration(
|
|
98
|
+
if (result.changes.length) {
|
|
99
|
+
for (const line of renderCollaboration(result.changes)) {
|
|
91
100
|
context.write(line);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
92
103
|
}
|
|
93
104
|
if (applied) {
|
|
94
|
-
for (const line of renderSyncOutput(events))
|
|
105
|
+
for (const line of renderSyncOutput(events)) {
|
|
95
106
|
context.write(line);
|
|
107
|
+
}
|
|
96
108
|
context.write(`${ok("✔")} Update installed.`);
|
|
97
109
|
}
|
|
98
110
|
});
|
|
111
|
+
}
|
|
99
112
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { CliError } from "../errors.js";
|
|
2
|
+
import { offerAdoption, renderAdoption, renderAdoptions, renderScan, renderUndo, } from "../ui/adopt.js";
|
|
3
|
+
import { dim, json } from "../ui/format.js";
|
|
4
|
+
/** Registers `adopt`, `adopt list` and `adopt undo`. */
|
|
5
|
+
export function registerAdopt(program, context) {
|
|
6
|
+
const adopt = program
|
|
7
|
+
.command("adopt")
|
|
8
|
+
.description("Let BarnDog manage the Skills, MCP servers and Hooks your coding tools already have")
|
|
9
|
+
.option("--dry-run", "Show what can be adopted without changing anything")
|
|
10
|
+
.option("--all", "Adopt everything that can be adopted")
|
|
11
|
+
.option("--only <assets...>", "Adopt these, named tool/kind/name as --dry-run lists them")
|
|
12
|
+
.action(async (options) => {
|
|
13
|
+
if (options.all && options.only) {
|
|
14
|
+
throw new CliError("--all and --only can't be combined. Choose one.", "barndog adopt --help");
|
|
15
|
+
}
|
|
16
|
+
const scan = await context.scanNative();
|
|
17
|
+
if (options.dryRun) {
|
|
18
|
+
if (context.mode.json) {
|
|
19
|
+
return context.write(json(scan));
|
|
20
|
+
}
|
|
21
|
+
for (const line of renderScan(scan, context.runtime)) {
|
|
22
|
+
context.write(line);
|
|
23
|
+
}
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const keys = options.all
|
|
27
|
+
? scan.assets.map((asset) => asset.key)
|
|
28
|
+
: options.only;
|
|
29
|
+
if (!keys) {
|
|
30
|
+
if (!context.mode.interactive) {
|
|
31
|
+
throw new CliError("Choose what to adopt with --only <tool/kind/name...> or --all; --dry-run lists the names.", "barndog adopt --dry-run");
|
|
32
|
+
}
|
|
33
|
+
if (!scan.assets.length) {
|
|
34
|
+
for (const line of renderScan(scan, context.runtime)) {
|
|
35
|
+
context.write(line);
|
|
36
|
+
}
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
await offerAdoption(scan, {
|
|
40
|
+
adoptNative: context.adoptNative,
|
|
41
|
+
write: context.write,
|
|
42
|
+
runtime: context.runtime,
|
|
43
|
+
});
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (!keys.length) {
|
|
47
|
+
return context.write(context.mode.json ? json({ adopted: [] }) : dim("Nothing to adopt."));
|
|
48
|
+
}
|
|
49
|
+
// Without a terminal nothing is kept; the notes say which variables to set.
|
|
50
|
+
const result = await context.adoptNative(keys, []);
|
|
51
|
+
if (context.mode.json) {
|
|
52
|
+
return context.write(json(result));
|
|
53
|
+
}
|
|
54
|
+
for (const line of renderAdoption(result, context.runtime)) {
|
|
55
|
+
context.write(line);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
adopt
|
|
59
|
+
.command("list")
|
|
60
|
+
.description("List adoptions on this machine and what each took over")
|
|
61
|
+
.action(async () => {
|
|
62
|
+
const list = await context.listAdoptions();
|
|
63
|
+
if (context.mode.json) {
|
|
64
|
+
return context.write(json(list));
|
|
65
|
+
}
|
|
66
|
+
for (const line of renderAdoptions(list)) {
|
|
67
|
+
context.write(line);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
adopt
|
|
71
|
+
.command("undo [id]")
|
|
72
|
+
.description("Put adopted assets back in their coding tools (the newest adoption by default)")
|
|
73
|
+
.option("--only <assets...>", "Put back only these, named tool/kind/name as adopt list shows them")
|
|
74
|
+
.option("--force", "Undo even if BarnDog's copy was edited since")
|
|
75
|
+
.action(async (id, _, command) => {
|
|
76
|
+
// Commander gives `--only` to `adopt`, which declares it too, wherever
|
|
77
|
+
// it appears; positional options would change how every command parses.
|
|
78
|
+
const options = command.optsWithGlobals();
|
|
79
|
+
const result = await context.undoAdoption({
|
|
80
|
+
id,
|
|
81
|
+
only: options.only,
|
|
82
|
+
force: options.force,
|
|
83
|
+
});
|
|
84
|
+
if (context.mode.json) {
|
|
85
|
+
return context.write(json(result));
|
|
86
|
+
}
|
|
87
|
+
for (const line of renderUndo(result, context.runtime)) {
|
|
88
|
+
context.write(line);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CliError } from "../errors.js";
|
|
2
|
+
export function requireArguments(context, usage) {
|
|
3
|
+
if (!context.mode.interactive) {
|
|
4
|
+
throw new CliError("Name the asset to act on, or run this in a terminal to choose from a list.", usage);
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
/** What `add` copies from, as its usage shows it. */
|
|
8
|
+
export const addArguments = {
|
|
9
|
+
skill: " <source>",
|
|
10
|
+
mcp: "",
|
|
11
|
+
hook: " <url>",
|
|
12
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { Option } from "commander";
|
|
2
|
+
import { prefixedName } from "../features/environment/names.js";
|
|
3
|
+
import { runSelection } from "../ui/selection.js";
|
|
4
|
+
import { pickMany, pickOne } from "../ui/pick.js";
|
|
5
|
+
import { bold, clean, ok, ORIGIN_HELP, originLabel } from "../ui/format.js";
|
|
6
|
+
import { assetKinds } from "../features/asset-kinds/index.js";
|
|
7
|
+
import { addArguments, requireArguments } from "./arguments.js";
|
|
8
|
+
import { ask } from "./asset-share.js";
|
|
9
|
+
/** Installed assets eligible for an action on this machine. */
|
|
10
|
+
function localCandidates(items, kind, action, origin) {
|
|
11
|
+
return items.filter((item) => item.kind === kind &&
|
|
12
|
+
!item.via.includes("config") &&
|
|
13
|
+
item.origin !== "—" &&
|
|
14
|
+
(!origin || item.origin === origin.replace(":", "/")) &&
|
|
15
|
+
(action !== "enable" || item.state === "disabled") &&
|
|
16
|
+
(action !== "disable" || item.state !== "disabled"));
|
|
17
|
+
}
|
|
18
|
+
const localChoice = (item) => ({
|
|
19
|
+
value: item,
|
|
20
|
+
name: item.installedName,
|
|
21
|
+
hint: `${item.origin} · ${item.state}`,
|
|
22
|
+
});
|
|
23
|
+
/** `install`: adds assets of one kind to the selection and syncs. */
|
|
24
|
+
export function registerInstall(command, kind, context) {
|
|
25
|
+
const labels = assetKinds[kind];
|
|
26
|
+
const group = assetKinds[kind].command;
|
|
27
|
+
const addCommand = `barndog ${assetKinds[kind].command} add${addArguments[kind]}`;
|
|
28
|
+
command
|
|
29
|
+
.command("install [name]")
|
|
30
|
+
.description(`Install ${labels.many} on this machine; choose from a list when no name is given`)
|
|
31
|
+
.option("--origin <origin>", ORIGIN_HELP)
|
|
32
|
+
.addOption(new Option("--overrides <choice>", "Keep or clear your existing exclusions").choices(["preserve", "clear"]))
|
|
33
|
+
.option("--decisions <file>", "JSON per-asset override choices")
|
|
34
|
+
.action(async (name, options) => {
|
|
35
|
+
if (name) {
|
|
36
|
+
return runSelection(context, (resolution) => context.changeAsset("install", {
|
|
37
|
+
...options,
|
|
38
|
+
name,
|
|
39
|
+
kind,
|
|
40
|
+
resolution,
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
requireArguments(context, `barndog ${group} install <name> --origin <origin>`);
|
|
44
|
+
const [rows, inventory] = await Promise.all([
|
|
45
|
+
context.searchCatalog(kind),
|
|
46
|
+
context.inventory(),
|
|
47
|
+
]);
|
|
48
|
+
const selected = new Set(inventory.items
|
|
49
|
+
.filter((item) => item.state !== "removing")
|
|
50
|
+
.map((item) => item.id));
|
|
51
|
+
const inOrigin = rows.filter((row) => !options.origin ||
|
|
52
|
+
originLabel(row.origin) === options.origin.replace(":", "/"));
|
|
53
|
+
const ids = await pickMany(`Choose ${labels.many} to install`, inOrigin
|
|
54
|
+
.filter((row) => !selected.has(row.id))
|
|
55
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
56
|
+
.map((row) => ({
|
|
57
|
+
value: row.id,
|
|
58
|
+
name: row.name,
|
|
59
|
+
hint: `${originLabel(row.origin)} · ${clean(row.version.description)}`,
|
|
60
|
+
})), {
|
|
61
|
+
empty: inOrigin.length
|
|
62
|
+
? `Every available ${labels.one} is already on this machine.`
|
|
63
|
+
: `No ${labels.many} available to install. Add one with ${addCommand}.`,
|
|
64
|
+
});
|
|
65
|
+
await runSelection(context, (resolution) => context.changeAssets("install", {
|
|
66
|
+
kind,
|
|
67
|
+
ids,
|
|
68
|
+
overrides: options.overrides,
|
|
69
|
+
decisions: options.decisions,
|
|
70
|
+
resolution,
|
|
71
|
+
}));
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/** `remove`, `enable` and `disable` for assets installed on this machine. */
|
|
75
|
+
export function registerToggles(command, kind, context) {
|
|
76
|
+
const labels = assetKinds[kind];
|
|
77
|
+
const group = assetKinds[kind].command;
|
|
78
|
+
for (const action of ["remove", "enable", "disable"]) {
|
|
79
|
+
command
|
|
80
|
+
.command(`${action} [name]`)
|
|
81
|
+
.description({
|
|
82
|
+
remove: `Remove ${labels.many} from this machine, even when a set includes them`,
|
|
83
|
+
enable: `Turn disabled ${labels.many} back on`,
|
|
84
|
+
disable: `Turn ${labels.many} off without removing them from your selection`,
|
|
85
|
+
}[action])
|
|
86
|
+
.option("--origin <origin>", ORIGIN_HELP)
|
|
87
|
+
.action(async (name, options) => {
|
|
88
|
+
if (name) {
|
|
89
|
+
return runSelection(context, (resolution) => context.changeAsset(action, {
|
|
90
|
+
...options,
|
|
91
|
+
name,
|
|
92
|
+
kind,
|
|
93
|
+
resolution,
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
requireArguments(context, `barndog ${group} ${action} <name>`);
|
|
97
|
+
const items = localCandidates((await context.inventory()).items, kind, action, options.origin);
|
|
98
|
+
const chosen = await pickMany(`Choose ${labels.many} to ${action}`, items.map(localChoice), {
|
|
99
|
+
empty: action === "enable"
|
|
100
|
+
? `No ${labels.many} are disabled.`
|
|
101
|
+
: `No ${labels.many} to ${action} on this machine.`,
|
|
102
|
+
});
|
|
103
|
+
await runSelection(context, (resolution) => context.changeAssets(action, {
|
|
104
|
+
kind,
|
|
105
|
+
ids: chosen.map((item) => item.id),
|
|
106
|
+
resolution,
|
|
107
|
+
}));
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/** `rename`: installs an asset under another local name. */
|
|
112
|
+
export function registerRename(command, kind, context) {
|
|
113
|
+
const labels = assetKinds[kind];
|
|
114
|
+
const group = assetKinds[kind].command;
|
|
115
|
+
command
|
|
116
|
+
.command("rename [name]")
|
|
117
|
+
.description(`Install ${labels.a} under a different local name`)
|
|
118
|
+
.option("--origin <origin>", ORIGIN_HELP)
|
|
119
|
+
.option("--as <name>", "New local name: lowercase letters, numbers and hyphens")
|
|
120
|
+
.option("--reset", "Go back to the published name")
|
|
121
|
+
.action(async (name, options) => {
|
|
122
|
+
let target = name;
|
|
123
|
+
let suggestion;
|
|
124
|
+
if (!target) {
|
|
125
|
+
requireArguments(context, `barndog ${group} rename <name> --as <new-name>`);
|
|
126
|
+
const item = await pickOne(`Choose ${labels.a} to rename`, localCandidates((await context.inventory()).items, kind, "rename", options.origin).map(localChoice), { empty: `No ${labels.many} to rename on this machine.` });
|
|
127
|
+
target = item.id;
|
|
128
|
+
const [type = "", slug = ""] = item.origin.split("/");
|
|
129
|
+
suggestion = prefixedName({
|
|
130
|
+
kind: item.kind,
|
|
131
|
+
name: item.name,
|
|
132
|
+
origin: { type, slug },
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
const as = options.reset
|
|
136
|
+
? undefined
|
|
137
|
+
: await ask(context, options.as, {
|
|
138
|
+
message: "New local name",
|
|
139
|
+
flag: "--as",
|
|
140
|
+
fallback: suggestion,
|
|
141
|
+
});
|
|
142
|
+
await runSelection(context, () => context.renameAsset({
|
|
143
|
+
kind,
|
|
144
|
+
name: target,
|
|
145
|
+
origin: options.origin,
|
|
146
|
+
as,
|
|
147
|
+
reset: options.reset,
|
|
148
|
+
}));
|
|
149
|
+
// A clash prompt during the sync may have chosen a different name.
|
|
150
|
+
const renamed = target;
|
|
151
|
+
const item = (await context.inventory()).items.find((entry) => entry.kind === kind &&
|
|
152
|
+
[entry.id, entry.name, entry.installedName].includes(renamed) &&
|
|
153
|
+
(!options.origin ||
|
|
154
|
+
entry.origin === options.origin.replace(":", "/")));
|
|
155
|
+
if (item && !context.mode.json) {
|
|
156
|
+
context.write(item.installedName === item.name
|
|
157
|
+
? `${ok("✔")} ${bold(item.name)} uses its published name.`
|
|
158
|
+
: `${ok("✔")} ${bold(item.name)} from ${item.origin} is installed as ${bold(item.installedName)}.`);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|