barndog 0.2.0 → 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.
Files changed (93) hide show
  1. package/README.md +29 -27
  2. package/dist/commands/add.js +1 -0
  3. package/dist/commands/adopt.js +91 -0
  4. package/dist/commands/asset-install.js +1 -0
  5. package/dist/commands/asset-list.js +7 -2
  6. package/dist/commands/availability.js +25 -8
  7. package/dist/commands/capabilities.js +8 -2
  8. package/dist/commands/collaboration.js +22 -2
  9. package/dist/commands/harnesses.js +74 -0
  10. package/dist/commands/mcp-env.js +78 -0
  11. package/dist/commands/mcp.js +4 -2
  12. package/dist/commands/status.js +2 -1
  13. package/dist/commands/sync.js +2 -1
  14. package/dist/commands/workspace.js +43 -5
  15. package/dist/config/paths.js +19 -0
  16. package/dist/config/settings.js +5 -3
  17. package/dist/config/state.js +18 -6
  18. package/dist/features/adoption/adopt.js +234 -0
  19. package/dist/features/adoption/copies.js +29 -0
  20. package/dist/features/adoption/originals.js +116 -0
  21. package/dist/features/adoption/record.js +120 -0
  22. package/dist/features/adoption/restore.js +28 -0
  23. package/dist/features/adoption/scan.js +482 -0
  24. package/dist/features/adoption/undo.js +42 -0
  25. package/dist/features/asset-kinds/index.js +9 -0
  26. package/dist/features/auth/credentials.js +7 -14
  27. package/dist/features/auth/session.js +4 -5
  28. package/dist/features/auth/transport.js +3 -2
  29. package/dist/features/collaboration/workspace-git.js +13 -7
  30. package/dist/features/collaboration/workspace-github.js +2 -1
  31. package/dist/features/collaboration/workspace-store.js +23 -3
  32. package/dist/features/collaboration/workspace.js +22 -2
  33. package/dist/features/doctor/index.js +24 -2
  34. package/dist/features/environment/harnesses.js +36 -0
  35. package/dist/features/environment/moves.js +171 -0
  36. package/dist/features/environment/names.js +10 -6
  37. package/dist/features/environment/operations.js +7 -7
  38. package/dist/features/environment/stage.js +25 -1
  39. package/dist/features/environment/sync.js +17 -6
  40. package/dist/features/environment/writes.js +55 -8
  41. package/dist/features/hooks/compatibility.js +11 -5
  42. package/dist/features/hooks/divergence.js +30 -9
  43. package/dist/features/hooks/test.js +25 -25
  44. package/dist/features/imports/discover.js +1 -1
  45. package/dist/features/imports/local.js +15 -2
  46. package/dist/features/imports/remote.js +2 -1
  47. package/dist/features/inventory/index.js +13 -2
  48. package/dist/features/inventory/show.js +74 -0
  49. package/dist/features/mcps/import.js +74 -21
  50. package/dist/features/mcps/index.js +12 -7
  51. package/dist/features/mcps/values.js +33 -0
  52. package/dist/features/migration/move.js +72 -17
  53. package/dist/features/migration/promote.js +2 -0
  54. package/dist/features/native/adapters.js +20 -6
  55. package/dist/features/native/configuration.js +8 -4
  56. package/dist/features/native/secret-values.js +74 -0
  57. package/dist/features/secrets/index.js +77 -0
  58. package/dist/features/workspace/format.js +13 -9
  59. package/dist/features/workspace/git.js +11 -4
  60. package/dist/features/workspace/overlay.js +23 -36
  61. package/dist/features/workspace/packages.js +16 -3
  62. package/dist/features/workspace/publish.js +1 -1
  63. package/dist/features/workspace/repo-source.js +4 -3
  64. package/dist/features/workspace/setup.js +12 -3
  65. package/dist/features/workspace/snapshot.js +7 -1
  66. package/dist/harnesses/claude.js +2 -2
  67. package/dist/harnesses/codex.js +19 -9
  68. package/dist/harnesses/cursor.js +2 -2
  69. package/dist/harnesses/formats.js +12 -5
  70. package/dist/harnesses/opencode.js +3 -6
  71. package/dist/platform.js +39 -11
  72. package/dist/program.js +51 -3
  73. package/dist/shared/files.js +35 -0
  74. package/dist/shared/lock.js +87 -23
  75. package/dist/shared/patterns.js +8 -0
  76. package/dist/shared/shell.js +0 -2
  77. package/dist/ui/add-hook.js +8 -2
  78. package/dist/ui/add-mcp.js +69 -6
  79. package/dist/ui/add-skills.js +7 -5
  80. package/dist/ui/adopt.js +197 -0
  81. package/dist/ui/assets.js +5 -3
  82. package/dist/ui/auth.js +2 -1
  83. package/dist/ui/clash.js +2 -3
  84. package/dist/ui/connection.js +7 -2
  85. package/dist/ui/harness-picker.js +18 -0
  86. package/dist/ui/move.js +48 -2
  87. package/dist/ui/onboarding.js +40 -27
  88. package/dist/ui/output.js +3 -1
  89. package/dist/ui/package-details.js +34 -0
  90. package/dist/ui/scope-install.js +4 -1
  91. package/dist/ui/secret-input.js +19 -0
  92. package/dist/ui/selection.js +3 -1
  93. package/package.json +1 -1
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # BarnDog CLI
2
2
 
3
- Set up your and your team's AI coding environment once, and have it show up in every developer's Claude Code, Codex, or any other coding harness.
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 your organization's shared Skills, MCP servers, Hooks, and knowledge into the coding agents your developers already use, keeps them up to date, and lets the team improve them together with review, like code.
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 a team's setup consistent across them usually means copying files around and hoping nobody's copy is stale.
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 shared setup and writes it into each tool in that tool's own format. Developers keep working in the agent they prefer.
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/>BarnDog Cloud, a Git repo,<br/>or a local folder"] -->|barndog sync| C["barndog CLI"]
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` signs you in to a BarnDog server, or points at a Git repository or local folder that holds your or your team's assets.
31
- 2. **Choose what you want.** Pick your coding tools, then the sets you need: the whole organization, your team, the repositories you work in, plus any individual assets.
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 together.** Pull an asset into a folder, edit it, and `barndog push` a Suggested Change. Teammates review it line by line, and once it's merged everyone gets the new version on their next sync.
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** | Company policies and context that agents can look up when a task needs it. |
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
 
@@ -52,27 +64,17 @@ npm install -g barndog
52
64
  ## Quick start
53
65
 
54
66
  ```sh
55
- barndog init # connect, optionally sign in, choose tools and sets
56
- barndog status # what's installed on this machine, and where
57
- barndog skills search review # browse the shared catalog
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
+ 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
61
73
  ```
62
74
 
63
75
  Run `barndog` on its own to see every command, or `barndog <command> --help` for its options.
64
76
 
65
- ### No BarnDog server? Use Git
66
-
67
- 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:
68
-
69
- ```sh
70
- barndog init --repo git@github.com:acme/ai-setup.git
71
- ```
72
-
73
- Or keep them in a folder on your machine with `barndog init --local`. See [Git workspaces](https://barndog.dev/docs/cli/git-workspaces#local-workspaces) for the layout.
74
-
75
- ### Suggest a change
77
+ ### Suggest a change (Git and Cloud)
76
78
 
77
79
  ```sh
78
80
  barndog skills pull code-review --origin team/engineering
@@ -82,7 +84,7 @@ barndog diff
82
84
  barndog push --title "Add a security checklist"
83
85
  ```
84
86
 
85
- Reviewers use `barndog skills changes list`, `changes diff`, and `changes approve` (or the same under `barndog hooks`) from the terminal, or GitHub repo, or the BarnDog web workspace.
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.
86
88
 
87
89
  ## What it changes on your machine
88
90
 
@@ -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
+ }
@@ -127,6 +127,7 @@ export function registerRename(command, kind, context) {
127
127
  target = item.id;
128
128
  const [type = "", slug = ""] = item.origin.split("/");
129
129
  suggestion = prefixedName({
130
+ kind: item.kind,
130
131
  name: item.name,
131
132
  origin: { type, slug },
132
133
  });
@@ -25,7 +25,9 @@ export function registerList(command, kind, context) {
25
25
  context.inventory(),
26
26
  options.available || !narrowed
27
27
  ? context.searchCatalog(kind).catch((error) => {
28
- if (onlyAvailable) {
28
+ // JSON has nowhere to say the list is partial, so it fails;
29
+ // --installed and --disabled don't need the catalog.
30
+ if (onlyAvailable || context.mode.json) {
29
31
  throw error;
30
32
  }
31
33
  catalogProblem = friendlyMessage(error);
@@ -111,7 +113,10 @@ export function registerSearch(command, kind, context) {
111
113
  selected: selected.has(row.id),
112
114
  }))));
113
115
  }
114
- for (const line of renderCatalog(rows, { ...options, search: query }, `barndog ${group} search`, selected)) {
116
+ for (const line of renderCatalog(rows, { ...options, search: query }, {
117
+ command: `barndog ${group} search`,
118
+ platform: context.runtime.platform,
119
+ }, selected)) {
115
120
  context.write(line);
116
121
  }
117
122
  };
@@ -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 that need published versions and reviews, which a local folder lacks.
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 reviewCommands = [
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
- reviewCommands.some((pattern) => pattern.test(command))) {
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 = commandNeeds(command, git ? "git" : "local");
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(hint("cd <your-repository> && barndog repo status", "Tip"));
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
- context.write(` ${" ".repeat(width)} ${hint(check.fix, "Fix")}`);
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
- ["show", "Print the files of a published version"],
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.option("--version <number>", "Published version", positiveInteger);
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,74 @@
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
+ function harnessTable(rows) {
15
+ return table(rows.map((row) => [
16
+ bold(row.id),
17
+ row.name,
18
+ row.enabled ? ok("managed") : dim("off"),
19
+ row.evidence ? dim(row.evidence) : dim("not found"),
20
+ ]), { header: ["Harness", "Tool", "State", "Detected"] });
21
+ }
22
+ export function registerHarnesses(program, context) {
23
+ const group = program
24
+ .command("harnesses")
25
+ .description("Choose which coding tools BarnDog manages; a tool turned off loses everything BarnDog installed there");
26
+ group
27
+ .command("list", { isDefault: true })
28
+ .description("List supported coding tools and whether BarnDog manages them")
29
+ .action(async () => {
30
+ const rows = await context.listHarnesses();
31
+ if (context.mode.json) {
32
+ return context.write(json(rows));
33
+ }
34
+ for (const line of harnessTable(rows)) {
35
+ context.write(line);
36
+ }
37
+ });
38
+ const report = (result) => {
39
+ if (context.mode.json) {
40
+ return context.write(json(result));
41
+ }
42
+ for (const line of renderSyncOutput(result.events)) {
43
+ context.write(line);
44
+ }
45
+ context.write(managedLine(result.harnesses));
46
+ };
47
+ for (const change of ["enable", "disable"]) {
48
+ group
49
+ .command(change)
50
+ .description(change === "enable"
51
+ ? "Start installing your selection into these coding tools"
52
+ : "Remove everything BarnDog installed in these coding tools and stop installing there")
53
+ .addArgument(new Argument("<harnesses...>", "Coding tools").choices(harnesses))
54
+ .action(async (targets) => {
55
+ report(await context.changeHarnesses(change, targets));
56
+ });
57
+ }
58
+ group
59
+ .command("select")
60
+ .description("Choose from a list exactly which coding tools BarnDog manages")
61
+ .action(async () => {
62
+ if (!context.mode.interactive) {
63
+ throw new CliError("Choosing coding tools from a list needs a terminal.", "barndog harnesses enable <harness>");
64
+ }
65
+ const rows = await context.listHarnesses();
66
+ const chosen = await chooseHarnesses(rows.map((row) => ({
67
+ value: row.id,
68
+ name: row.name,
69
+ evidence: row.evidence,
70
+ checked: row.enabled,
71
+ })));
72
+ report(await context.selectHarnesses(chosen));
73
+ });
74
+ }
@@ -0,0 +1,78 @@
1
+ import { CliError } from "../errors.js";
2
+ import { bold, dim, json, ok, table } from "../ui/format.js";
3
+ import { displayPath, renderSyncOutput } from "../ui/output.js";
4
+ import { askSecret, readStdin } from "../ui/secret-input.js";
5
+ /**
6
+ * `barndog mcp env`: MCP variable values BarnDog keeps on this machine. Every
7
+ * command says where a value is kept and where it was written; none prints one.
8
+ */
9
+ export function registerMcpEnv(mcp, context) {
10
+ const env = mcp
11
+ .command("env")
12
+ .description("Keep MCP variable values on this machine, never uploaded, and write them into your coding tools");
13
+ const where = (file) => displayPath(file, context.runtime);
14
+ env
15
+ .command("set <variable>")
16
+ .description("Keep a value for a variable MCP servers refer to")
17
+ .option("--stdin", "Read the value from standard input")
18
+ .addHelpText("after", `
19
+ The value is saved in ~/.barndog/secrets.json, which only you can read, and never leaves this machine.
20
+ Sync then writes it into the settings of each coding tool whose MCP servers use the variable, as the
21
+ tools store values they're given; shared definitions keep only the variable's name.`)
22
+ .action(async (variable, options) => {
23
+ const value = await readValue(variable, options.stdin);
24
+ const result = await context.keepMcpValue(variable, value);
25
+ if (context.mode.json) {
26
+ return context.write(json({ variable, file: result.file }));
27
+ }
28
+ context.write(`${ok("✔")} Saved ${bold(variable)} in ${where(result.file)}, readable only by you. It stays on this machine and is never uploaded.`);
29
+ for (const line of renderSyncOutput(result.events)) {
30
+ context.write(line);
31
+ }
32
+ });
33
+ env
34
+ .command("unset <variable>")
35
+ .description("Forget a kept value; the tools read the variable again")
36
+ .action(async (variable) => {
37
+ const result = await context.forgetMcpValue(variable);
38
+ if (context.mode.json) {
39
+ return context.write(json({ variable, file: result.file }));
40
+ }
41
+ context.write(`${ok("✔")} Removed ${bold(variable)} from ${where(result.file)}.`);
42
+ for (const line of renderSyncOutput(result.events)) {
43
+ context.write(line);
44
+ }
45
+ });
46
+ env
47
+ .command("list")
48
+ .description("List kept variables and where their values are written")
49
+ .action(async () => {
50
+ const kept = await context.listKeptValues();
51
+ if (context.mode.json) {
52
+ return context.write(json(kept));
53
+ }
54
+ if (!kept.length) {
55
+ return context.write(`${dim("BarnDog keeps no MCP values. Add one with")} ${bold("barndog mcp env set <variable>")}${dim(".")}`);
56
+ }
57
+ context.write(dim("Kept in ~/.barndog/secrets.json on this machine only. Values aren't shown."));
58
+ for (const line of table(kept.map((item) => [
59
+ bold(item.variable),
60
+ item.writtenTo.length
61
+ ? item.writtenTo
62
+ .map((place) => `${where(place.file)} (${place.server})`)
63
+ .join(", ")
64
+ : dim("not written anywhere yet"),
65
+ ]), { header: ["Variable", "Written into"] })) {
66
+ context.write(line);
67
+ }
68
+ });
69
+ async function readValue(variable, stdin) {
70
+ if (stdin) {
71
+ return readStdin();
72
+ }
73
+ if (!context.mode.interactive) {
74
+ throw new CliError("Pass the value on standard input, so it stays out of your shell history.", `barndog mcp env set ${variable} --stdin`);
75
+ }
76
+ return askSecret(variable);
77
+ }
78
+ }
@@ -3,6 +3,7 @@ import { Option } from "commander";
3
3
  import { harnesses } from "../harnesses/registry.js";
4
4
  import { defined } from "../shared/lookup.js";
5
5
  import { commandHelpers } from "./helpers.js";
6
+ import { registerMcpEnv } from "./mcp-env.js";
6
7
  /** `barndog mcp` commands that publish, inspect and authenticate MCP configurations. */
7
8
  export function registerMcp(program, context) {
8
9
  const { write, print, printMcp, locate } = commandHelpers(context);
@@ -29,11 +30,11 @@ export function registerMcp(program, context) {
29
30
  });
30
31
  }
31
32
  mcp
32
- .command("show <name>")
33
+ .command("show [name]")
33
34
  .option("--origin <origin>", ORIGIN_HELP)
34
35
  .description("Inspect a connection definition")
35
36
  .action(async (name, options) => {
36
- const located = await locate("mcp", name, options, `barndog mcp show ${name}`);
37
+ const located = await locate("mcp", name, options, "barndog mcp show <name>");
37
38
  const result = await context.showMcp(located.name, located.origin);
38
39
  if (context.mode.json) {
39
40
  return context.write(json(result));
@@ -59,4 +60,5 @@ export function registerMcp(program, context) {
59
60
  const located = await locate("mcp", name, options, `barndog mcp auth ${name} --harness ${options.harness}`);
60
61
  print(await context.authenticateMcp(located.name, located.origin, options.harness));
61
62
  });
63
+ registerMcpEnv(mcp, context);
62
64
  }
@@ -1,6 +1,6 @@
1
1
  import { harnessNames, inventoryHints, renderInventory } from "../ui/assets.js";
2
2
  import { renderCollaboration } from "../ui/collaboration.js";
3
- import { dim, fields, heading, hint, json, ok, plural } from "../ui/format.js";
3
+ import { dim, fields, heading, hint, json, ok, plural, warn, } from "../ui/format.js";
4
4
  import { assetKindList, assetKinds } from "../features/asset-kinds/index.js";
5
5
  function knowledgeState(enabled) {
6
6
  return enabled ? ok("listed at session start") : dim("off");
@@ -41,6 +41,7 @@ export function registerStatus(program, context) {
41
41
  if (inventory.offline) {
42
42
  context.write(dim(`\nShowing local state only: ${inventory.offline}`));
43
43
  }
44
+ inventory.moving.forEach((move) => context.write(`\n${warn("!")} ${move.name} is moving to ${move.to}. Your local copy stays in use until that merges.`));
44
45
  for (const kind of assetKindList) {
45
46
  const items = inventory.items.filter((item) => item.kind === kind);
46
47
  context.write("");
@@ -1,3 +1,4 @@
1
+ import { Option } from "commander";
1
2
  import { resolve } from "node:path";
2
3
  import { renderSyncOutput } from "../ui/output.js";
3
4
  import { json } from "../ui/format.js";
@@ -9,7 +10,7 @@ export function registerSync(program, context) {
9
10
  .option("--dry-run", "Show what would change without changing anything")
10
11
  .option("-v, --verbose", "Also list what is already up to date, including BarnDog's own entries")
11
12
  .option("--config <path>", "Use an explicit configuration file once")
12
- .option("--auto", "Quiet background sync used at session start")
13
+ .addOption(new Option("--auto", "Quiet background sync used at session start").conflicts(["dryRun", "verbose", "config"]))
13
14
  .action(async (options) => {
14
15
  // Runs detached at session start: nobody is watching, so it never reports.
15
16
  if (options.auto) {