barndog 0.2.0 → 0.2.2
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 +45 -24
- package/dist/cli.js +27 -1
- package/dist/commands/add.js +1 -0
- package/dist/commands/adopt.js +91 -0
- package/dist/commands/asset-install.js +1 -0
- package/dist/commands/asset-list.js +12 -3
- package/dist/commands/availability.js +25 -8
- package/dist/commands/capabilities.js +8 -2
- package/dist/commands/collaboration.js +22 -2
- package/dist/commands/harnesses.js +104 -0
- package/dist/commands/mcp-env.js +167 -0
- package/dist/commands/mcp.js +4 -2
- package/dist/commands/sets.js +13 -2
- package/dist/commands/status.js +2 -1
- package/dist/commands/sync.js +2 -1
- package/dist/commands/uninstall.js +62 -0
- package/dist/commands/workspace.js +43 -5
- package/dist/config/paths.js +21 -0
- package/dist/config/settings.js +5 -3
- package/dist/config/state.js +18 -6
- package/dist/entry/update-check.js +15 -0
- package/dist/features/adoption/adopt.js +235 -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 +9 -0
- package/dist/features/auth/credentials.js +7 -14
- package/dist/features/auth/session.js +26 -5
- package/dist/features/auth/transport.js +3 -2
- package/dist/features/collaboration/workspace-git.js +13 -7
- package/dist/features/collaboration/workspace-github.js +2 -1
- package/dist/features/collaboration/workspace-store.js +25 -4
- package/dist/features/collaboration/workspace.js +22 -2
- package/dist/features/doctor/index.js +46 -7
- package/dist/features/environment/events.js +8 -1
- package/dist/features/environment/harnesses.js +36 -0
- package/dist/features/environment/kept-values.js +68 -0
- package/dist/features/environment/moves.js +187 -0
- package/dist/features/environment/names.js +10 -6
- package/dist/features/environment/operations.js +7 -7
- package/dist/features/environment/stage.js +25 -1
- package/dist/features/environment/sync.js +17 -6
- package/dist/features/environment/writes.js +55 -8
- package/dist/features/hooks/compatibility.js +11 -5
- package/dist/features/hooks/divergence.js +30 -9
- package/dist/features/hooks/test.js +25 -25
- package/dist/features/imports/discover.js +1 -1
- package/dist/features/imports/local.js +15 -2
- package/dist/features/imports/remote.js +2 -1
- package/dist/features/inventory/index.js +57 -3
- package/dist/features/inventory/show.js +74 -0
- package/dist/features/mcps/import.js +95 -21
- package/dist/features/mcps/index.js +24 -9
- package/dist/features/mcps/values.js +121 -0
- package/dist/features/migration/migrate.js +15 -0
- package/dist/features/migration/move.js +105 -25
- package/dist/features/migration/promote.js +2 -0
- package/dist/features/native/adapters.js +20 -7
- package/dist/features/native/configuration.js +8 -4
- package/dist/features/native/hook-shell.js +11 -0
- package/dist/features/native/secret-values.js +74 -0
- package/dist/features/secrets/index.js +142 -0
- package/dist/features/uninstall/index.js +126 -0
- package/dist/features/uninstall/leave.js +152 -0
- package/dist/features/uninstall/survey.js +103 -0
- package/dist/features/update-check/index.js +108 -0
- package/dist/features/workspace/format.js +19 -10
- package/dist/features/workspace/git.js +11 -4
- package/dist/features/workspace/overlay.js +23 -36
- package/dist/features/workspace/packages.js +16 -3
- package/dist/features/workspace/publish.js +1 -1
- package/dist/features/workspace/repo-source.js +4 -3
- package/dist/features/workspace/setup.js +12 -3
- package/dist/features/workspace/snapshot.js +7 -1
- package/dist/harnesses/claude.js +2 -2
- package/dist/harnesses/codex.js +54 -20
- package/dist/harnesses/cursor.js +2 -2
- package/dist/harnesses/formats.js +12 -5
- package/dist/harnesses/opencode.js +3 -6
- package/dist/harnesses/read-renamed-variables.js +141 -0
- package/dist/harnesses/renamed-variables.js +99 -0
- package/dist/platform.js +51 -12
- package/dist/program.js +68 -8
- package/dist/shared/files.js +35 -0
- package/dist/shared/lock.js +87 -23
- package/dist/shared/patterns.js +8 -0
- package/dist/shared/shell.js +0 -2
- package/dist/ui/add-hook.js +8 -2
- package/dist/ui/add-mcp.js +82 -13
- package/dist/ui/add-skills.js +7 -5
- package/dist/ui/adopt.js +202 -0
- package/dist/ui/assets.js +5 -3
- package/dist/ui/auth.js +2 -1
- package/dist/ui/clash.js +2 -3
- package/dist/ui/connection.js +9 -2
- package/dist/ui/harness-picker.js +23 -0
- package/dist/ui/mcp.js +89 -23
- package/dist/ui/move.js +49 -2
- package/dist/ui/onboarding.js +40 -27
- package/dist/ui/output.js +35 -8
- package/dist/ui/package-details.js +34 -0
- package/dist/ui/scope-install.js +4 -1
- package/dist/ui/secret-input.js +28 -0
- package/dist/ui/selection.js +3 -1
- package/dist/ui/uninstall.js +174 -0
- package/dist/ui/update.js +10 -0
- package/dist/version.js +2 -2
- package/package.json +1 -1
- package/dist/entry/mcp-launch.js +0 -71
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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
|
|
|
@@ -13,24 +13,36 @@ Currently supported harnesses:
|
|
|
13
13
|
|
|
14
14
|
## Why
|
|
15
15
|
|
|
16
|
-
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.
|
|
17
17
|
|
|
18
|
-
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>`.
|
|
19
31
|
|
|
20
32
|
## How it works
|
|
21
33
|
|
|
22
34
|
```mermaid
|
|
23
35
|
flowchart LR
|
|
24
|
-
W["Your workspace<br/>
|
|
36
|
+
W["Your workspace<br/>a local folder, a Git repo,<br/>or BarnDog Cloud"] -->|barndog sync| C["barndog CLI"]
|
|
25
37
|
C --> CC[Claude Code]
|
|
26
38
|
C --> CX[Codex]
|
|
27
39
|
C --> CU[Other harnesses]
|
|
28
40
|
```
|
|
29
41
|
|
|
30
|
-
1. **Connect to a workspace.** `barndog init`
|
|
31
|
-
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.
|
|
32
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.
|
|
33
|
-
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.
|
|
34
46
|
|
|
35
47
|
## What it manages
|
|
36
48
|
|
|
@@ -39,7 +51,7 @@ flowchart LR
|
|
|
39
51
|
| **Skill** | A folder with a `SKILL.md` and supporting files that agents load when relevant. |
|
|
40
52
|
| **MCP server** | A connection to an MCP server. It names the secrets it needs but never stores their values. |
|
|
41
53
|
| **Hook** | A command that runs on an agent lifecycle event, such as after a file edit. |
|
|
42
|
-
| **Knowledge** |
|
|
54
|
+
| **Knowledge** | Policies and context that agents can look up when a task needs it (Git and Cloud). |
|
|
43
55
|
|
|
44
56
|
## Install
|
|
45
57
|
|
|
@@ -49,30 +61,30 @@ Runs on **macOS, Linux, and Windows** with [Node.js](https://nodejs.org) 24 or n
|
|
|
49
61
|
npm install -g barndog
|
|
50
62
|
```
|
|
51
63
|
|
|
52
|
-
|
|
64
|
+
### Update
|
|
53
65
|
|
|
54
66
|
```sh
|
|
55
|
-
|
|
56
|
-
barndog
|
|
57
|
-
barndog
|
|
58
|
-
barndog skills install code-review # add one asset on top of your sets
|
|
59
|
-
barndog sync # apply changes now
|
|
60
|
-
barndog doctor # check everything and print a fix for each problem
|
|
67
|
+
npm install -g barndog@latest
|
|
68
|
+
barndog sync
|
|
69
|
+
barndog --version
|
|
61
70
|
```
|
|
62
71
|
|
|
63
|
-
Run `barndog`
|
|
64
|
-
|
|
65
|
-
### No BarnDog server? Use Git
|
|
72
|
+
Run `barndog sync` after every update: it brings the session-start and Hook registrations in your coding tools in line with the new version.
|
|
66
73
|
|
|
67
|
-
|
|
74
|
+
## Quick start
|
|
68
75
|
|
|
69
76
|
```sh
|
|
70
|
-
barndog init
|
|
77
|
+
barndog init # choose a workspace and your coding tools
|
|
78
|
+
barndog status # what's installed on this machine, and where
|
|
79
|
+
barndog skills add https://github.com/... # add a Skill from a repository
|
|
80
|
+
barndog skills search review # browse what the workspace offers
|
|
81
|
+
barndog sync # apply changes now
|
|
82
|
+
barndog doctor # check everything and print a fix for each problem
|
|
71
83
|
```
|
|
72
84
|
|
|
73
|
-
|
|
85
|
+
Run `barndog` on its own to see every command, or `barndog <command> --help` for its options.
|
|
74
86
|
|
|
75
|
-
### Suggest a change
|
|
87
|
+
### Suggest a change (Git and Cloud)
|
|
76
88
|
|
|
77
89
|
```sh
|
|
78
90
|
barndog skills pull code-review --origin team/engineering
|
|
@@ -82,7 +94,7 @@ barndog diff
|
|
|
82
94
|
barndog push --title "Add a security checklist"
|
|
83
95
|
```
|
|
84
96
|
|
|
85
|
-
|
|
97
|
+
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.
|
|
86
98
|
|
|
87
99
|
## What it changes on your machine
|
|
88
100
|
|
|
@@ -94,6 +106,15 @@ BarnDog is careful with your existing setup:
|
|
|
94
106
|
- Changes are journaled before they're applied, so an interrupted sync is finished safely on the next run.
|
|
95
107
|
- Hook scripts run only inside your coding tools, after their own trust checks. Installing or syncing never runs them.
|
|
96
108
|
|
|
109
|
+
## Uninstall
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
barndog uninstall
|
|
113
|
+
npm uninstall -g barndog
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Run `barndog uninstall` first. It asks whether to leave your Skills, MCP servers, and Hooks in your coding tools or remove them.
|
|
117
|
+
|
|
97
118
|
## Documentation
|
|
98
119
|
|
|
99
120
|
- [What is BarnDog?](https://barndog.dev/docs)
|
package/dist/cli.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
2
4
|
import { CommanderError, InvalidArgumentError } from "commander";
|
|
3
5
|
import { assertCommandAvailable, currentSetupMode, } from "./commands/availability.js";
|
|
4
6
|
import { captureRuntime, createProgram } from "./program.js";
|
|
5
7
|
import { renderError, renderJsonError } from "./ui/output.js";
|
|
6
8
|
import { json } from "./ui/format.js";
|
|
7
9
|
import { CliError, NothingToDoError } from "./errors.js";
|
|
10
|
+
import { updateCheck } from "./features/update-check/index.js";
|
|
11
|
+
import { renderUpdateNotice } from "./ui/update.js";
|
|
12
|
+
import { cliVersion } from "./version.js";
|
|
8
13
|
// Parsing errors happen before any action runs, so read the flag directly.
|
|
9
14
|
const words = process.argv.slice(2);
|
|
10
15
|
const end = words.indexOf("--");
|
|
11
16
|
const asJson = (end < 0 ? words : words.slice(0, end)).includes("--json");
|
|
17
|
+
const runtime = captureRuntime();
|
|
12
18
|
try {
|
|
13
|
-
const runtime = captureRuntime();
|
|
14
19
|
await createProgram({
|
|
15
20
|
runtime,
|
|
16
21
|
guard: (path, options) => assertCommandAvailable(path, options, runtime),
|
|
@@ -42,3 +47,24 @@ catch (error) {
|
|
|
42
47
|
process.exitCode = 1;
|
|
43
48
|
}
|
|
44
49
|
}
|
|
50
|
+
// After the command, on stderr, so it never changes what a script reads; and
|
|
51
|
+
// it can never fail the command.
|
|
52
|
+
if (!asJson && process.stderr.isTTY) {
|
|
53
|
+
try {
|
|
54
|
+
const check = await updateCheck(cliVersion, runtime);
|
|
55
|
+
if (check?.update) {
|
|
56
|
+
console.error(renderUpdateNotice(check.update).join("\n"));
|
|
57
|
+
}
|
|
58
|
+
if (check?.due) {
|
|
59
|
+
spawn(process.execPath, [
|
|
60
|
+
fileURLToPath(new URL("entry/update-check.js", import.meta.url)),
|
|
61
|
+
runtime.home,
|
|
62
|
+
], { detached: true, windowsHide: true, stdio: "ignore" })
|
|
63
|
+
.on("error", () => { })
|
|
64
|
+
.unref();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// The next command checks again.
|
|
69
|
+
}
|
|
70
|
+
}
|
package/dist/commands/add.js
CHANGED
|
@@ -63,6 +63,7 @@ export function registerAdd(program, context) {
|
|
|
63
63
|
.option("--config <json>", "Server configuration as JSON text")
|
|
64
64
|
.option("--file <path>", "Read the configuration from a file")
|
|
65
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")
|
|
66
67
|
.option("--replace", "Replace an existing entry in your coding tools")
|
|
67
68
|
.option("--oauth", "The server signs in through your coding tool (OAuth)")
|
|
68
69
|
.option("--description <text>", "What the server does")
|
|
@@ -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
|
+
}
|
|
@@ -4,6 +4,7 @@ import { assetListing, inventoryHints, renderCatalog, renderInventory, } from ".
|
|
|
4
4
|
import { dim, hint, json } from "../ui/format.js";
|
|
5
5
|
import { assetKinds } from "../features/asset-kinds/index.js";
|
|
6
6
|
import { addArguments } from "./arguments.js";
|
|
7
|
+
import { unsetVariableNotes } from "../ui/mcp.js";
|
|
7
8
|
/** `list`: installed, disabled and available assets of one kind. */
|
|
8
9
|
export function registerList(command, kind, context) {
|
|
9
10
|
const labels = assetKinds[kind];
|
|
@@ -22,10 +23,12 @@ export function registerList(command, kind, context) {
|
|
|
22
23
|
const onlyAvailable = options.available && !narrowed;
|
|
23
24
|
let catalogProblem;
|
|
24
25
|
const [inventory, rows] = await Promise.all([
|
|
25
|
-
context.inventory(),
|
|
26
|
+
context.inventory({ checkVariables: kind === "mcp" }),
|
|
26
27
|
options.available || !narrowed
|
|
27
28
|
? context.searchCatalog(kind).catch((error) => {
|
|
28
|
-
|
|
29
|
+
// JSON has nowhere to say the list is partial, so it fails;
|
|
30
|
+
// --installed and --disabled don't need the catalog.
|
|
31
|
+
if (onlyAvailable || context.mode.json) {
|
|
29
32
|
throw error;
|
|
30
33
|
}
|
|
31
34
|
catalogProblem = friendlyMessage(error);
|
|
@@ -81,6 +84,9 @@ export function registerList(command, kind, context) {
|
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
const onThisMachine = page.filter((item) => item.state !== "available");
|
|
87
|
+
for (const line of unsetVariableNotes(onThisMachine)) {
|
|
88
|
+
context.write(line);
|
|
89
|
+
}
|
|
84
90
|
const hints = inventoryHints(onThisMachine);
|
|
85
91
|
if (hints.length) {
|
|
86
92
|
context.write(["", ...hints].join("\n"));
|
|
@@ -111,7 +117,10 @@ export function registerSearch(command, kind, context) {
|
|
|
111
117
|
selected: selected.has(row.id),
|
|
112
118
|
}))));
|
|
113
119
|
}
|
|
114
|
-
for (const line of renderCatalog(rows, { ...options, search: query },
|
|
120
|
+
for (const line of renderCatalog(rows, { ...options, search: query }, {
|
|
121
|
+
command: `barndog ${group} search`,
|
|
122
|
+
platform: context.runtime.platform,
|
|
123
|
+
}, selected)) {
|
|
115
124
|
context.write(line);
|
|
116
125
|
}
|
|
117
126
|
};
|
|
@@ -22,16 +22,21 @@ export const cloudOnlyCommands = [
|
|
|
22
22
|
/^(?:skills|mcp|hooks) (?:fork|promote)$/,
|
|
23
23
|
/^mcp (?:create|update)$/,
|
|
24
24
|
];
|
|
25
|
+
/** Commands that need published versions and reviews, which a local folder lacks. */
|
|
26
|
+
const reviewCommands = [
|
|
27
|
+
/^(?:pull|push|resolve)$/,
|
|
28
|
+
/^(?:skills|hooks) (?:pull|push|create|versions|diff)$/,
|
|
29
|
+
/^mcp versions$/,
|
|
30
|
+
];
|
|
31
|
+
/** Every `knowledge …` command. */
|
|
32
|
+
const KNOWLEDGE_COMMANDS = /^knowledge(?: |$)/;
|
|
25
33
|
/**
|
|
26
|
-
* Commands
|
|
34
|
+
* Commands a local folder can't serve yet: nothing adds knowledge documents to
|
|
35
|
+
* it, so they need a Git repo or Cloud Workspace.
|
|
27
36
|
*
|
|
28
37
|
* @internal Exported for its table test in `src/tests/patterns.test.ts`.
|
|
29
38
|
*/
|
|
30
|
-
export const
|
|
31
|
-
/^(?:pull|push|resolve)$/,
|
|
32
|
-
/^(?:skills|hooks) (?:pull|push|create|versions|show|diff)$/,
|
|
33
|
-
/^mcp versions$/,
|
|
34
|
-
];
|
|
39
|
+
export const sharedSourceCommands = [...reviewCommands, KNOWLEDGE_COMMANDS];
|
|
35
40
|
/** The setup this machine runs on, when that setup limits what commands can do. */
|
|
36
41
|
export async function currentSetupMode(runtime) {
|
|
37
42
|
const { home } = runtime;
|
|
@@ -50,11 +55,20 @@ export function commandNeeds(command, mode) {
|
|
|
50
55
|
return "cloud";
|
|
51
56
|
}
|
|
52
57
|
if (mode === "local" &&
|
|
53
|
-
|
|
58
|
+
sharedSourceCommands.some((pattern) => pattern.test(command))) {
|
|
54
59
|
return "shared";
|
|
55
60
|
}
|
|
56
61
|
return undefined;
|
|
57
62
|
}
|
|
63
|
+
/** Like `commandNeeds()`, for a command line whose options can change what it needs. */
|
|
64
|
+
function setupNeeds(command, options, mode) {
|
|
65
|
+
// `show` describes any asset; only a published version's files need shared versions.
|
|
66
|
+
const showsFiles = ["skills show", "hooks show"].includes(command) &&
|
|
67
|
+
(options.files === true || options.version !== undefined);
|
|
68
|
+
return mode === "local" && showsFiles
|
|
69
|
+
? "shared"
|
|
70
|
+
: commandNeeds(command, mode);
|
|
71
|
+
}
|
|
58
72
|
export const needText = (need) => need === "cloud" ? "a Cloud Workspace" : "a Git repo or Cloud Workspace";
|
|
59
73
|
export const modeName = (mode) => mode === "local" ? "local" : "Git";
|
|
60
74
|
/** Help's note beside a command this setup can't run. */
|
|
@@ -104,11 +118,14 @@ export async function assertCommandAvailable(path, options, runtime) {
|
|
|
104
118
|
if (command.endsWith(" promote") && options.origin === LOCAL_ORIGIN) {
|
|
105
119
|
return;
|
|
106
120
|
}
|
|
107
|
-
const needs =
|
|
121
|
+
const needs = setupNeeds(command, options, git ? "git" : "local");
|
|
108
122
|
if (needs === "cloud") {
|
|
109
123
|
const action = why[command] ?? "needs a BarnDog Cloud Workspace";
|
|
110
124
|
throw new CliError(`\`barndog ${command}\` ${action}, but this machine keeps its assets in ${where}.${git ? "" : " Your local assets stay active if you switch."}`, "barndog init --server <url>");
|
|
111
125
|
}
|
|
126
|
+
if (needs === "shared" && KNOWLEDGE_COMMANDS.test(command)) {
|
|
127
|
+
throw new CliError(`\`barndog ${command}\` reads shared knowledge documents, which a local folder can't hold yet.`, "barndog init");
|
|
128
|
+
}
|
|
112
129
|
if (needs === "shared") {
|
|
113
130
|
throw new CliError(`\`barndog ${command}\` works with shared versions and reviews, which assets in a local folder don't have. Edit them directly in ${folder}, then sync.`, "barndog sync");
|
|
114
131
|
}
|
|
@@ -71,7 +71,7 @@ function registerGeneral(program, context) {
|
|
|
71
71
|
}
|
|
72
72
|
if (!result.root) {
|
|
73
73
|
context.write("Not inside a Git repository.");
|
|
74
|
-
context.write(
|
|
74
|
+
context.write(`${dim("Tip:")} run ${bold("barndog repo status")} from inside your repository.`);
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
77
|
const repositoryId = result.repository?.id;
|
|
@@ -118,7 +118,13 @@ function registerGeneral(program, context) {
|
|
|
118
118
|
const mark = checkMarks[check.status];
|
|
119
119
|
context.write(`${mark} ${check.name.padEnd(width)} ${check.status === "ok" ? dim(check.detail) : check.detail}`);
|
|
120
120
|
if (check.fix) {
|
|
121
|
-
|
|
121
|
+
// A fix in words reads as plain text when a command follows it.
|
|
122
|
+
context.write(check.command
|
|
123
|
+
? ` ${" ".repeat(width)} ${dim("Fix:")} ${check.fix}`
|
|
124
|
+
: ` ${" ".repeat(width)} ${hint(check.fix, "Fix")}`);
|
|
125
|
+
}
|
|
126
|
+
if (check.command) {
|
|
127
|
+
context.write(` ${" ".repeat(width)} ${dim("Command:")} ${bold(check.command)}`);
|
|
122
128
|
}
|
|
123
129
|
}
|
|
124
130
|
const failed = checks.filter((c) => c.status === "fail").length;
|
|
@@ -9,6 +9,7 @@ import { ApiError } from "@barndog-ai/api-contract";
|
|
|
9
9
|
import { assetKinds } from "../features/asset-kinds/index.js";
|
|
10
10
|
import { packageKindList } from "../config/selection.js";
|
|
11
11
|
import { pickOne } from "../ui/pick.js";
|
|
12
|
+
import { renderPackageDetails } from "../ui/package-details.js";
|
|
12
13
|
import { resolveOrigin } from "./origin.js";
|
|
13
14
|
import { clean, json, ORIGIN_HELP, originLabel, warn } from "../ui/format.js";
|
|
14
15
|
import { defined } from "../shared/lookup.js";
|
|
@@ -108,6 +109,15 @@ export function registerCollaboration(program, context, kind) {
|
|
|
108
109
|
const noun = assetKinds[kind].one;
|
|
109
110
|
const group = assetKinds[kind].command;
|
|
110
111
|
const kindCommand = defined(program.commands.find((c) => c.name() === group), `Command group ${group} isn't registered`);
|
|
112
|
+
const describe = async (name, origin) => {
|
|
113
|
+
const details = await context.showPackage(kind, name, origin);
|
|
114
|
+
if (context.mode.json) {
|
|
115
|
+
return context.write(json(details));
|
|
116
|
+
}
|
|
117
|
+
for (const line of renderPackageDetails(details)) {
|
|
118
|
+
context.write(line);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
111
121
|
/** Fills a missing name and origin from a searchable catalog list. */
|
|
112
122
|
const choose = async (name, origin, usage) => {
|
|
113
123
|
if (name) {
|
|
@@ -152,7 +162,10 @@ export function registerCollaboration(program, context, kind) {
|
|
|
152
162
|
"versions",
|
|
153
163
|
`List ${noun === "Skill" ? "a Skill's" : "a Hook's"} published versions`,
|
|
154
164
|
],
|
|
155
|
-
[
|
|
165
|
+
[
|
|
166
|
+
"show",
|
|
167
|
+
`Describe ${noun === "Skill" ? "a Skill" : "a Hook"}: origin, version, where it's installed`,
|
|
168
|
+
],
|
|
156
169
|
["diff", "Compare two published versions"],
|
|
157
170
|
]) {
|
|
158
171
|
const command = kindCommand
|
|
@@ -160,7 +173,9 @@ export function registerCollaboration(program, context, kind) {
|
|
|
160
173
|
.description(description)
|
|
161
174
|
.option("--origin <origin>", ORIGIN_HELP);
|
|
162
175
|
if (name === "show") {
|
|
163
|
-
command
|
|
176
|
+
command
|
|
177
|
+
.option("--files", "Print the files of the published version")
|
|
178
|
+
.option("--version <number>", "Print the files of this published version", positiveInteger);
|
|
164
179
|
}
|
|
165
180
|
if (name === "diff") {
|
|
166
181
|
command
|
|
@@ -175,6 +190,11 @@ export function registerCollaboration(program, context, kind) {
|
|
|
175
190
|
if (name === "versions") {
|
|
176
191
|
await run(context.packageVersions(target));
|
|
177
192
|
}
|
|
193
|
+
else if (name === "show" &&
|
|
194
|
+
!options.files &&
|
|
195
|
+
options.version === undefined) {
|
|
196
|
+
await describe(target.name, target.origin);
|
|
197
|
+
}
|
|
178
198
|
else if (name === "show") {
|
|
179
199
|
await run(context.versionFiles(target));
|
|
180
200
|
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Argument } from "commander";
|
|
2
|
+
import { styleText } from "node:util";
|
|
3
|
+
import { CliError } from "../errors.js";
|
|
4
|
+
import { harnesses } from "../harnesses/registry.js";
|
|
5
|
+
import { toolNames } from "../features/hooks/adapt.js";
|
|
6
|
+
import { bold, dim, json, ok, table } from "../ui/format.js";
|
|
7
|
+
import { chooseHarnesses } from "../ui/harness-picker.js";
|
|
8
|
+
import { renderSyncOutput } from "../ui/output.js";
|
|
9
|
+
function managedLine(managed) {
|
|
10
|
+
return managed.length
|
|
11
|
+
? `${ok("✔")} BarnDog now manages ${toolNames(managed)}.`
|
|
12
|
+
: `${ok("✔")} BarnDog no longer manages any coding tool. Add one with ${styleText("bold", "barndog harnesses enable <harness>")}.`;
|
|
13
|
+
}
|
|
14
|
+
const pickMessage = {
|
|
15
|
+
enable: "Which coding tools should BarnDog start managing?",
|
|
16
|
+
disable: "Which coding tools should BarnDog stop managing?",
|
|
17
|
+
};
|
|
18
|
+
const nothingTo = {
|
|
19
|
+
enable: "BarnDog already manages every coding tool it supports.",
|
|
20
|
+
disable: "BarnDog doesn't manage any coding tool.",
|
|
21
|
+
};
|
|
22
|
+
const nothingToHint = {
|
|
23
|
+
enable: "barndog harnesses list",
|
|
24
|
+
disable: "barndog harnesses enable <harness>",
|
|
25
|
+
};
|
|
26
|
+
function harnessTable(rows) {
|
|
27
|
+
return table(rows.map((row) => [
|
|
28
|
+
bold(row.id),
|
|
29
|
+
row.name,
|
|
30
|
+
row.enabled ? ok("managed") : dim("off"),
|
|
31
|
+
row.evidence ? dim(row.evidence) : dim("not found"),
|
|
32
|
+
]), { header: ["Harness", "Tool", "State", "Detected"] });
|
|
33
|
+
}
|
|
34
|
+
export function registerHarnesses(program, context) {
|
|
35
|
+
const group = program
|
|
36
|
+
.command("harnesses")
|
|
37
|
+
.description("Choose which coding tools BarnDog manages; a tool turned off loses everything BarnDog installed there");
|
|
38
|
+
group
|
|
39
|
+
.command("list", { isDefault: true })
|
|
40
|
+
.description("List supported coding tools and whether BarnDog manages them")
|
|
41
|
+
.action(async () => {
|
|
42
|
+
const rows = await context.listHarnesses();
|
|
43
|
+
if (context.mode.json) {
|
|
44
|
+
return context.write(json(rows));
|
|
45
|
+
}
|
|
46
|
+
for (const line of harnessTable(rows)) {
|
|
47
|
+
context.write(line);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
const report = (result) => {
|
|
51
|
+
if (context.mode.json) {
|
|
52
|
+
return context.write(json(result));
|
|
53
|
+
}
|
|
54
|
+
for (const line of renderSyncOutput(result.events)) {
|
|
55
|
+
context.write(line);
|
|
56
|
+
}
|
|
57
|
+
context.write(managedLine(result.harnesses));
|
|
58
|
+
};
|
|
59
|
+
// With no tools named, a terminal picks from the ones the change applies to.
|
|
60
|
+
const pickTargets = async (change) => {
|
|
61
|
+
const usage = `barndog harnesses ${change} <harness>`;
|
|
62
|
+
if (!context.mode.interactive) {
|
|
63
|
+
throw new CliError(`Name the coding tools to ${change}.`, usage);
|
|
64
|
+
}
|
|
65
|
+
const offered = (await context.listHarnesses()).filter((row) => row.enabled === (change === "disable"));
|
|
66
|
+
if (offered.length === 0) {
|
|
67
|
+
throw new CliError(nothingTo[change], nothingToHint[change]);
|
|
68
|
+
}
|
|
69
|
+
return chooseHarnesses(offered.map((row) => ({
|
|
70
|
+
value: row.id,
|
|
71
|
+
name: row.name,
|
|
72
|
+
evidence: row.evidence,
|
|
73
|
+
checked: false,
|
|
74
|
+
})), { message: pickMessage[change], required: true });
|
|
75
|
+
};
|
|
76
|
+
for (const change of ["enable", "disable"]) {
|
|
77
|
+
group
|
|
78
|
+
.command(change)
|
|
79
|
+
.description(change === "enable"
|
|
80
|
+
? "Start installing your selection into these coding tools"
|
|
81
|
+
: "Remove everything BarnDog installed in these coding tools and stop installing there")
|
|
82
|
+
.addArgument(new Argument("[harnesses...]", "Coding tools").choices(harnesses))
|
|
83
|
+
.action(async (named) => {
|
|
84
|
+
const targets = named.length ? named : await pickTargets(change);
|
|
85
|
+
report(await context.changeHarnesses(change, targets));
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
group
|
|
89
|
+
.command("select")
|
|
90
|
+
.description("Choose from a list exactly which coding tools BarnDog manages")
|
|
91
|
+
.action(async () => {
|
|
92
|
+
if (!context.mode.interactive) {
|
|
93
|
+
throw new CliError("Choosing coding tools from a list needs a terminal.", "barndog harnesses enable <harness>");
|
|
94
|
+
}
|
|
95
|
+
const rows = await context.listHarnesses();
|
|
96
|
+
const chosen = await chooseHarnesses(rows.map((row) => ({
|
|
97
|
+
value: row.id,
|
|
98
|
+
name: row.name,
|
|
99
|
+
evidence: row.evidence,
|
|
100
|
+
checked: row.enabled,
|
|
101
|
+
})));
|
|
102
|
+
report(await context.selectHarnesses(chosen));
|
|
103
|
+
});
|
|
104
|
+
}
|