@mesh-tech/mesh-cli
Version:
CLI for Mesh platform development utilities
64 lines (63 loc) • 4.02 kB
JavaScript
import { cloneCommand } from "./clone.js";
import { getCommand } from "./get.js";
import { draftsCreateCommand, draftsDiscardCommand, draftsListCommand, draftsShowCommand, draftsSubmitCommand, } from "./drafts.js";
import { proposeCommand } from "./propose.js";
import { rmCommand } from "./rm.js";
import { approveCommand, commentCommand, diffCommand, proposalsCommand, rejectCommand, requestChangesCommand, showCommand, } from "./review.js";
function withCommon(cmd) {
return cmd
.option("--url <url>", "vcs service URL (or VCS_URL, or derived from origin remote)")
.option("--token <token>", "bearer token (or VCS_TOKEN)")
.option("--context <context>", "mesh login context to mint a token from");
}
export function registerVcsCommands(program) {
const vcs = program
.command("vcs")
.description("Versioned content repos (mesh.vcs): clone, get, propose, rm, review");
withCommon(vcs.command("clone <repo> [dest]").description("Clone a repo (read-only remote)")).action(cloneCommand);
withCommon(vcs
.command("get <repo> <path>")
.description("Read a specific path (file or subtree) from a repo — one doc, not the whole repo")
.option("--target <name>", "agent target (agent-targets registry) to derive the vcs URL + auth")
.option("-o, --output <dir>", "write file(s) here instead of stdout")).action(getCommand);
withCommon(vcs
.command("propose")
.description("Propose the working tree's changes (run inside a clone)")
.option("-m, --message <message>", "proposal message")
.option("--proposal-id <id>", "explicit proposal id")
.option("--revise <id>", "add a revision to an existing proposal")
.option("--merge-parent <sha>", "conflict resolution: main sha incorporated")).action(proposeCommand);
withCommon(vcs
.command("rm <repo> <paths...>")
.description("Propose deleting files or folders (no clone needed)")
.option("-m, --message <message>", "proposal message")
.option("--dry-run", "list what would be deleted, propose nothing")).action(rmCommand);
withCommon(vcs.command("proposals <repo>").description("List open proposals")).action(proposalsCommand);
withCommon(vcs.command("show <repo> <id>").description("Show proposal state")).action(showCommand);
withCommon(vcs.command("diff <repo> <id>").description("Show proposal diff")).action(diffCommand);
withCommon(vcs
.command("approve <repo> <id>")
.description("Approve at the current head (payload-bound)")
.option("--sha <sha>", "approve a specific head sha")).action(approveCommand);
withCommon(vcs
.command("reject <repo> <id>")
.description("Reject a proposal")
.option("--reason <reason>", "rejection reason")).action(rejectCommand);
withCommon(vcs.command("comment <repo> <id> <text>").description("Comment on a proposal")).action(commentCommand);
withCommon(vcs
.command("request-changes <repo> <id>")
.description("Ask the author for changes (review stays open)")
.option("--note <note>", "what needs to change")).action(requestChangesCommand);
const drafts = vcs.command("drafts").description("Work-in-progress drafts");
withCommon(drafts.command("list <repo>").description("List open drafts").option("--all", "include closed drafts")).action(draftsListCommand);
withCommon(drafts.command("show <repo> <id>").description("Show draft status")).action(draftsShowCommand);
withCommon(drafts
.command("create <repo>")
.description("Create a draft")
.option("--title <title>", "draft title")).action(draftsCreateCommand);
withCommon(drafts
.command("submit <repo> <id>")
.description("Submit a draft for review")
.option("--note <note>", "note to reviewers")).action(draftsSubmitCommand);
withCommon(drafts.command("discard <repo> <id>").description("Discard a draft")).action(draftsDiscardCommand);
}