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
|
@@ -1,65 +1,139 @@
|
|
|
1
|
+
import { HTTP_STATUS } from "../shared/constants.js";
|
|
1
2
|
import { InvalidArgumentError } from "commander";
|
|
2
3
|
import { styleText } from "node:util";
|
|
3
4
|
import { renderCollaboration } from "../ui/collaboration.js";
|
|
4
5
|
import { folderDivergence, nearestHookFolder, } from "../features/hooks/divergence.js";
|
|
5
6
|
import { resolve } from "node:path";
|
|
6
|
-
import { CliError, friendlyHint, friendlyMessage } from "../errors.js";
|
|
7
|
+
import { CHANGES_LIST_FIX, CliError, friendlyHint, friendlyMessage, } from "../errors.js";
|
|
7
8
|
import { ApiError } from "@barndog-ai/api-contract";
|
|
9
|
+
import { assetKinds } from "../features/asset-kinds/index.js";
|
|
10
|
+
import { packageKindList } from "../config/selection.js";
|
|
8
11
|
import { pickOne } from "../ui/pick.js";
|
|
12
|
+
import { renderPackageDetails } from "../ui/package-details.js";
|
|
9
13
|
import { resolveOrigin } from "./origin.js";
|
|
10
14
|
import { clean, json, ORIGIN_HELP, originLabel, warn } from "../ui/format.js";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
import { defined } from "../shared/lookup.js";
|
|
16
|
+
import { positiveInteger } from "../ui/options.js";
|
|
17
|
+
function side(value) {
|
|
18
|
+
if (value !== "old" && value !== "new") {
|
|
19
|
+
throw new InvalidArgumentError("Expected old or new");
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
15
22
|
}
|
|
16
|
-
/**
|
|
17
|
-
function
|
|
18
|
-
|
|
23
|
+
/** Prints a working-copy or review result, as JSON with `--json`. */
|
|
24
|
+
function printer(context) {
|
|
25
|
+
return (result, options = {}) => {
|
|
26
|
+
if (context.mode.json) {
|
|
27
|
+
context.write(json(result));
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
for (const line of renderCollaboration(result, options)) {
|
|
31
|
+
context.write(line);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** Warns when a Hook's coding tools run different scripts; editing is when that matters. */
|
|
37
|
+
async function warnDivergence(context, folder) {
|
|
38
|
+
const warning = !context.mode.json && folder && (await folderDivergence(folder));
|
|
39
|
+
if (warning) {
|
|
40
|
+
context.write(`${warn("!")} ${warning}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** Each package kind has its own list of changes; point at the others when an ID isn't here. */
|
|
44
|
+
function reviewError(error, kind, { changeId, thread }) {
|
|
45
|
+
if (!(error instanceof ApiError)) {
|
|
19
46
|
return error;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
47
|
+
}
|
|
48
|
+
if (error.status === HTTP_STATUS.notFound && changeId && !thread) {
|
|
49
|
+
return new CliError(`No ${assetKinds[kind].one} Suggested Change has that ID.`, packageKindList
|
|
50
|
+
.filter((other) => other !== kind)
|
|
51
|
+
.map((other) => `barndog ${assetKinds[other].command} changes show ${changeId}`)
|
|
52
|
+
.join(" or "), { cause: error });
|
|
53
|
+
}
|
|
54
|
+
// A server refusal doesn't say which kind's change it is about; this command knows.
|
|
55
|
+
return friendlyHint(error) === CHANGES_LIST_FIX
|
|
56
|
+
? new CliError(friendlyMessage(error), `barndog ${assetKinds[kind].command} changes list`, { cause: error })
|
|
25
57
|
: error;
|
|
26
58
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
59
|
+
/**
|
|
60
|
+
* The working-copy commands at the root: `pull`, `diff`, `push` and `resolve`.
|
|
61
|
+
* They act on whatever the working copy holds, so they name no kind; a new
|
|
62
|
+
* folder's kind comes from its manifest file.
|
|
63
|
+
*/
|
|
64
|
+
export function registerWorkingCopy(program, context) {
|
|
65
|
+
const print = printer(context);
|
|
66
|
+
program
|
|
67
|
+
.command("pull")
|
|
68
|
+
.description("Bring the latest published version into this working copy, keeping your edits")
|
|
69
|
+
.action(async () => print(await context.updateWorkingCopy()));
|
|
70
|
+
program
|
|
71
|
+
.command("diff")
|
|
72
|
+
.description("Show your edits in this working copy (elsewhere: preview what sync would change)")
|
|
73
|
+
.action(async () => print(await context.workingDiff()));
|
|
74
|
+
program
|
|
75
|
+
.command("push")
|
|
76
|
+
.description("Propose this working copy's edits as a Suggested Change")
|
|
77
|
+
.option("--origin <origin>", "Origin for a folder that isn't a working copy yet")
|
|
78
|
+
.option("--publish", "Publish directly with admin or personal-owner authority")
|
|
79
|
+
.option("--new", "Start a new proposal instead of updating the linked proposal")
|
|
80
|
+
.option("--title <title>", "Suggested Change title")
|
|
81
|
+
.action(async (options) => {
|
|
82
|
+
print(await context.pushWorkingCopy(options));
|
|
83
|
+
await warnDivergence(context, nearestHookFolder(context.runtime.cwd));
|
|
84
|
+
});
|
|
85
|
+
program
|
|
86
|
+
.command("resolve <path>")
|
|
87
|
+
.description("Mark a conflicted file in this working copy as resolved")
|
|
88
|
+
.action(async (path) => print(await context.resolveFile(path)));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Registers working-copy and review commands; handlers use the supplied
|
|
92
|
+
* services and output mode.
|
|
93
|
+
*/
|
|
94
|
+
export function registerCollaboration(program, context, kind) {
|
|
95
|
+
const withKind = (options) => ({ ...options, kind });
|
|
96
|
+
const print = printer(context);
|
|
97
|
+
const run = async (operation, options = {}) => {
|
|
98
|
+
const result = await operation.catch((error) => {
|
|
32
99
|
throw reviewError(error, kind, options);
|
|
33
100
|
});
|
|
101
|
+
print(result, options);
|
|
102
|
+
};
|
|
103
|
+
/** Editing is when tools drifting apart matters, so Hooks say it at both ends. */
|
|
104
|
+
const divergence = async (folder) => {
|
|
105
|
+
if (kind === "hook") {
|
|
106
|
+
await warnDivergence(context, folder);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const noun = assetKinds[kind].one;
|
|
110
|
+
const group = assetKinds[kind].command;
|
|
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);
|
|
34
114
|
if (context.mode.json) {
|
|
35
|
-
context.write(json(
|
|
36
|
-
return;
|
|
115
|
+
return context.write(json(details));
|
|
37
116
|
}
|
|
38
|
-
for (const line of
|
|
117
|
+
for (const line of renderPackageDetails(details)) {
|
|
39
118
|
context.write(line);
|
|
40
|
-
|
|
41
|
-
return;
|
|
42
|
-
// Editing is when tools drifting apart matters, so say it at both ends.
|
|
43
|
-
const pulled = action === "pull-skill"
|
|
44
|
-
? (result?.root ??
|
|
45
|
-
resolve(options.directory ?? options.name ?? "."))
|
|
46
|
-
: nearestHookFolder(process.cwd());
|
|
47
|
-
const warning = pulled && (await folderDivergence(pulled));
|
|
48
|
-
if (warning)
|
|
49
|
-
context.write(`${warn("!")} ${warning}`);
|
|
119
|
+
}
|
|
50
120
|
};
|
|
51
|
-
const skills = program.commands.find((c) => c.name() === (kind === "hook" ? "hooks" : "skills"));
|
|
52
|
-
const noun = kind === "skill" ? "Skill" : "Hook";
|
|
53
|
-
const group = kind === "skill" ? "skills" : "hooks";
|
|
54
121
|
/** Fills a missing name and origin from a searchable catalog list. */
|
|
55
122
|
const choose = async (name, origin, usage) => {
|
|
56
|
-
if (name)
|
|
123
|
+
if (name) {
|
|
57
124
|
return {
|
|
58
125
|
name,
|
|
59
|
-
origin: await resolveOrigin(context,
|
|
126
|
+
origin: await resolveOrigin(context, {
|
|
127
|
+
kind,
|
|
128
|
+
name,
|
|
129
|
+
origin,
|
|
130
|
+
usage: usage.replace("<name>", name),
|
|
131
|
+
}),
|
|
60
132
|
};
|
|
61
|
-
|
|
133
|
+
}
|
|
134
|
+
if (!context.mode.interactive) {
|
|
62
135
|
throw new CliError(`Name the ${noun} to use.`, usage);
|
|
136
|
+
}
|
|
63
137
|
const rows = await context.searchCatalog(kind);
|
|
64
138
|
const row = await pickOne(`Choose a ${noun}`, rows.map((row) => ({
|
|
65
139
|
value: row,
|
|
@@ -68,136 +142,166 @@ export function registerCollaboration(program, context, kind = "skill") {
|
|
|
68
142
|
})), { empty: `No ${noun}s are published yet.` });
|
|
69
143
|
return { name: row.name, origin: originLabel(row.origin) };
|
|
70
144
|
};
|
|
71
|
-
|
|
145
|
+
kindCommand
|
|
72
146
|
.command("pull [name]")
|
|
73
147
|
.option("--origin <origin>", ORIGIN_HELP)
|
|
74
148
|
.option("--directory <path>", "Folder for the editable copy")
|
|
75
149
|
.description(`Download a ${noun} into an editable folder to change and propose edits`)
|
|
76
|
-
.action(async (name, options) =>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
"diff",
|
|
88
|
-
"Show your edits in this working copy (elsewhere: preview what sync would change)",
|
|
89
|
-
],
|
|
90
|
-
])
|
|
91
|
-
program
|
|
92
|
-
.command(command)
|
|
93
|
-
.description(description)
|
|
94
|
-
.action(() => run(command));
|
|
95
|
-
program
|
|
96
|
-
.command("push")
|
|
97
|
-
.description("Propose this working copy's edits as a Suggested Change")
|
|
98
|
-
.option("--origin <origin>", "Origin for a new local Skill")
|
|
99
|
-
.option("--publish", "Publish directly with admin or personal-owner authority")
|
|
100
|
-
.option("--new", "Start a new proposal instead of updating the linked proposal")
|
|
101
|
-
.option("--title <title>", "Suggested Change title")
|
|
102
|
-
.action((options) => run("push", options));
|
|
103
|
-
program
|
|
104
|
-
.command("resolve <path>")
|
|
105
|
-
.description("Mark a conflicted file in this working copy as resolved")
|
|
106
|
-
.action((path) => run("resolve", { path }));
|
|
107
|
-
}
|
|
108
|
-
for (const [name, action, description] of [
|
|
150
|
+
.action(async (name, options) => {
|
|
151
|
+
const target = {
|
|
152
|
+
...options,
|
|
153
|
+
...(await choose(name, options.origin, `barndog ${group} pull <name>`)),
|
|
154
|
+
};
|
|
155
|
+
const pulled = context.pullPackage(withKind(target));
|
|
156
|
+
await run(pulled);
|
|
157
|
+
await divergence((await pulled)?.root ??
|
|
158
|
+
resolve(context.runtime.cwd, target.directory ?? target.name));
|
|
159
|
+
});
|
|
160
|
+
for (const [name, description] of [
|
|
109
161
|
[
|
|
110
|
-
"versions",
|
|
111
162
|
"versions",
|
|
112
163
|
`List ${noun === "Skill" ? "a Skill's" : "a Hook's"} published versions`,
|
|
113
164
|
],
|
|
114
|
-
[
|
|
115
|
-
|
|
165
|
+
[
|
|
166
|
+
"show",
|
|
167
|
+
`Describe ${noun === "Skill" ? "a Skill" : "a Hook"}: origin, version, where it's installed`,
|
|
168
|
+
],
|
|
169
|
+
["diff", "Compare two published versions"],
|
|
116
170
|
]) {
|
|
117
|
-
const command =
|
|
171
|
+
const command = kindCommand
|
|
118
172
|
.command(`${name} [name]`)
|
|
119
173
|
.description(description)
|
|
120
174
|
.option("--origin <origin>", ORIGIN_HELP);
|
|
121
|
-
if (name === "show")
|
|
122
|
-
command.option("--version <number>", "Published version", positive);
|
|
123
|
-
if (name === "diff")
|
|
175
|
+
if (name === "show") {
|
|
124
176
|
command
|
|
125
|
-
.
|
|
126
|
-
.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
177
|
+
.option("--files", "Print the files of the published version")
|
|
178
|
+
.option("--version <number>", "Print the files of this published version", positiveInteger);
|
|
179
|
+
}
|
|
180
|
+
if (name === "diff") {
|
|
181
|
+
command
|
|
182
|
+
.requiredOption("--from <number>", "Old version", positiveInteger)
|
|
183
|
+
.requiredOption("--to <number>", "New version", positiveInteger);
|
|
184
|
+
}
|
|
185
|
+
command.action(async (asset, options) => {
|
|
186
|
+
const target = withKind({
|
|
187
|
+
...options,
|
|
188
|
+
...(await choose(asset, options.origin, `barndog ${group} ${name} <name>`)),
|
|
189
|
+
});
|
|
190
|
+
if (name === "versions") {
|
|
191
|
+
await run(context.packageVersions(target));
|
|
192
|
+
}
|
|
193
|
+
else if (name === "show" &&
|
|
194
|
+
!options.files &&
|
|
195
|
+
options.version === undefined) {
|
|
196
|
+
await describe(target.name, target.origin);
|
|
197
|
+
}
|
|
198
|
+
else if (name === "show") {
|
|
199
|
+
await run(context.versionFiles(target));
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
await run(context.diffVersions(target));
|
|
203
|
+
}
|
|
204
|
+
});
|
|
131
205
|
}
|
|
132
|
-
|
|
206
|
+
kindCommand
|
|
133
207
|
.command("push [name]")
|
|
134
208
|
.description("Propose this working copy's edits as a Suggested Change")
|
|
135
209
|
.option("--origin <origin>", "Scope for a new package, such as team/engineering")
|
|
136
210
|
.option("--publish", "Publish with direct authority")
|
|
137
211
|
.option("--new", "Start a new proposal")
|
|
138
212
|
.option("--title <title>", "Proposal title")
|
|
139
|
-
.action((name, options) =>
|
|
140
|
-
|
|
213
|
+
.action(async (name, options) => {
|
|
214
|
+
await run(context.pushWorkingCopy(withKind({ ...options, name })));
|
|
215
|
+
await divergence(nearestHookFolder(context.runtime.cwd));
|
|
216
|
+
});
|
|
217
|
+
kindCommand
|
|
141
218
|
.command("create <name>")
|
|
142
219
|
.requiredOption("--origin <origin>", ORIGIN_HELP)
|
|
143
220
|
.option("--directory <path>", "New editable folder")
|
|
144
221
|
.description(`Start a new ${noun} in an editable folder (not installed until published)`)
|
|
145
|
-
.action((name, options) => run(
|
|
146
|
-
|
|
147
|
-
registerChanges(parent, run);
|
|
222
|
+
.action((name, options) => run(context.createPackage(withKind({ ...options, name }))));
|
|
223
|
+
registerChanges(kindCommand, context, withKind, run);
|
|
148
224
|
}
|
|
149
|
-
function registerChanges(parent, run) {
|
|
225
|
+
function registerChanges(parent, context, withKind, run) {
|
|
150
226
|
const changes = parent
|
|
151
227
|
.command("changes")
|
|
152
228
|
.description("Review, discuss and merge Suggested Changes");
|
|
153
229
|
changes
|
|
154
230
|
.command("list")
|
|
155
231
|
.description("List accessible Suggested Changes")
|
|
156
|
-
.action(() => run(
|
|
232
|
+
.action(() => run(context.listChanges(withKind({}))));
|
|
157
233
|
changes
|
|
158
234
|
.command("show <id>")
|
|
159
235
|
.description("Read proposal content, reviews, and discussion history")
|
|
160
|
-
.action((id) => run(
|
|
236
|
+
.action((id) => run(context.showChange(withKind({ id })), {
|
|
237
|
+
changeId: id,
|
|
238
|
+
details: true,
|
|
239
|
+
}));
|
|
161
240
|
changes
|
|
162
241
|
.command("diff <id>")
|
|
163
242
|
.description("Inspect a proposal diff")
|
|
164
|
-
.option("--revision <number>", "Proposal revision",
|
|
165
|
-
.option("--from-revision <number>", "Compare to another proposal revision",
|
|
166
|
-
.action((id, options) => run(
|
|
243
|
+
.option("--revision <number>", "Proposal revision", positiveInteger)
|
|
244
|
+
.option("--from-revision <number>", "Compare to another proposal revision", positiveInteger)
|
|
245
|
+
.action((id, options) => run(context.changeDiff(withKind({ ...options, id })), {
|
|
246
|
+
changeId: id,
|
|
247
|
+
}));
|
|
167
248
|
for (const [name, description] of [
|
|
168
249
|
["approve", "Approve a reviewed revision"],
|
|
169
250
|
["request-changes", "Request further changes"],
|
|
170
251
|
["reject", "Close a proposal as its author or admin"],
|
|
171
252
|
["merge", "Publish a proposal under its scope's merge rules"],
|
|
172
|
-
])
|
|
253
|
+
]) {
|
|
173
254
|
changes
|
|
174
255
|
.command(`${name} <id>`)
|
|
175
256
|
.description(description)
|
|
176
|
-
.requiredOption("--revision <number>", "Revision you reviewed",
|
|
177
|
-
.action((id, options) =>
|
|
257
|
+
.requiredOption("--revision <number>", "Revision you reviewed", positiveInteger)
|
|
258
|
+
.action((id, options) => {
|
|
259
|
+
const target = withKind({ ...options, id });
|
|
260
|
+
const labels = { changeId: id };
|
|
261
|
+
if (name === "reject") {
|
|
262
|
+
return run(context.rejectChange(target), labels);
|
|
263
|
+
}
|
|
264
|
+
if (name === "merge") {
|
|
265
|
+
return run(context.mergeChange(target), labels);
|
|
266
|
+
}
|
|
267
|
+
return run(context.reviewChange(name, target), labels);
|
|
268
|
+
});
|
|
269
|
+
}
|
|
178
270
|
changes
|
|
179
271
|
.command("comment <id>")
|
|
180
272
|
.description("Comment, reply, or suggest an inline replacement")
|
|
181
|
-
.requiredOption("--revision <number>", "Proposal revision",
|
|
273
|
+
.requiredOption("--revision <number>", "Proposal revision", positiveInteger)
|
|
182
274
|
.option("--body <text>", "Comment text")
|
|
183
275
|
.option("--body-file <path>", "Read comment text from a file")
|
|
184
276
|
.option("--thread <id>", "Reply to a discussion")
|
|
185
277
|
.option("--path <path>", "Package file for an inline discussion")
|
|
186
|
-
.option("--side <side>", "old or new")
|
|
187
|
-
.option("--start-line <number>", "First line",
|
|
188
|
-
.option("--end-line <number>", "Last line",
|
|
278
|
+
.option("--side <side>", "old or new", side)
|
|
279
|
+
.option("--start-line <number>", "First line", positiveInteger)
|
|
280
|
+
.option("--end-line <number>", "Last line", positiveInteger)
|
|
189
281
|
.option("--replacement-file <path>", "Replacement text file")
|
|
190
282
|
.option("--expected-file <path>", "Exact original text file")
|
|
191
|
-
.action((id, options) => run(
|
|
283
|
+
.action((id, options) => run(context.commentOnChange(withKind({ ...options, id })), {
|
|
284
|
+
changeId: id,
|
|
285
|
+
thread: options.thread,
|
|
286
|
+
}));
|
|
192
287
|
for (const [name, description] of [
|
|
193
288
|
["apply", "Apply a current reviewer suggestion"],
|
|
194
289
|
["resolve-discussion", "Resolve a discussion"],
|
|
195
290
|
["reopen-discussion", "Reopen a discussion"],
|
|
196
|
-
])
|
|
291
|
+
]) {
|
|
197
292
|
changes
|
|
198
293
|
.command(`${name} <id> <thread>`)
|
|
199
294
|
.description(description)
|
|
200
|
-
.requiredOption("--revision <number>", "Current proposal revision",
|
|
201
|
-
.action((id, thread, options) =>
|
|
202
|
-
|
|
295
|
+
.requiredOption("--revision <number>", "Current proposal revision", positiveInteger)
|
|
296
|
+
.action((id, thread, options) => {
|
|
297
|
+
const target = withKind({ ...options, id, thread });
|
|
298
|
+
return run(name === "apply"
|
|
299
|
+
? context.applySuggestion(target)
|
|
300
|
+
: context.setDiscussionResolved({
|
|
301
|
+
...target,
|
|
302
|
+
resolved: name === "resolve-discussion",
|
|
303
|
+
}), { changeId: id, thread });
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
changes.addHelpText("after", `\nReview ${styleText("bold", `barndog ${parent.name()} changes diff <id>`)} before approving a revision. Approval does not publish; use ${styleText("bold", `barndog ${parent.name()} changes merge <id> --revision <number>`)}.`);
|
|
203
307
|
}
|