From 07b0ace8360544ab49d7e29675bf6289830375f9 Mon Sep 17 00:00:00 2001 From: Alvaro Reis <133926455+paureis@users.noreply.github.com> Date: Sat, 24 Oct 2026 22:40:41 -0400 Subject: [PATCH 1/8] Test: Vercel deploy, pull and dev read the link of the folder they are given (#147) Failing on its own: cloudpin reads .vercel/project.json only from --cwd or the folder the command runs in, so `vercel deploy sub` with sub linked to another team passes a pin it should fail. Covers deploy (explicit, bare word, flags before the path, deploy init), --cwd, pull and dev, with controls for known command words, a path Vercel refuses, and the scope staying with the folder the command runs in. Co-Authored-By: Claude Opus 5.5 --- test/vercel-deploy-dir.test.ts | 232 +++++++++++++++++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 test/vercel-deploy-dir.test.ts diff --git a/test/vercel-deploy-dir.test.ts b/test/vercel-deploy-dir.test.ts new file mode 100644 index 0000000..0ed7d3e --- /dev/null +++ b/test/vercel-deploy-dir.test.ts @@ -0,0 +1,232 @@ +import { mkdirSync, writeFileSync } from "node:fs"; +import { join } from "node:path"; +import { describe, expect, it } from "vitest"; +import type { FoundConfig } from "../src/config.js"; +import { guard } from "../src/guard.js"; +import { vercel } from "../src/providers/vercel.js"; +import type { Exec } from "../src/types.js"; +import { tempDir } from "./tmp.js"; + +// #147. Some Vercel commands link the folder named by their path argument, not the folder +// they run in (vercel 50.35): +// - deploy (src/commands/deploy/index.ts handleDefaultDeploy, handleInitDeployment): the paths +// are the positionals after "deploy", resolved against the folder after --cwd; validatePaths +// stops unless paths[0] is a directory; then ensureLink("deploy", client, paths[0]). +// `deploy continue` links the folder itself. +// - a first word that is no Vercel command (src/index.ts) runs an extension vercel- in +// the folder, if one exists, else deploys the word as a path. +// - pull (src/commands/pull/index.ts): `parsedArgs.args[1] || client.cwd`. +// - dev (src/commands/dev/index.ts, dev.ts): the first argument after "dev". +// The scope still comes only from the local config in the folder the command runs in +// (src/index.ts getConfig, read before --cwd). + +const TEAMS = JSON.stringify({ + teams: [ + { id: "team_main", slug: "acme", current: true }, + { id: "team_side", slug: "side", current: false }, + ], + pagination: {}, +}); + +function fakeVercel() { + const exec: Exec = async (_bin, args) => { + if (args[0] === "teams") return { code: 0, stdout: TEAMS, stderr: "" }; + return { code: 1, stdout: "", stderr: "unexpected" }; + }; + return exec; +} + +const loggedIn = { VERCEL_TOKEN: "example-env-token" }; +const split = (cmd: string) => (cmd === "" ? [] : cmd.split(" ")); + +/** Links `dir` (created if missing) to a project of team `org`. */ +function link(dir: string, org: string): string { + mkdirSync(join(dir, ".vercel"), { recursive: true }); + writeFileSync(join(dir, ".vercel", "project.json"), JSON.stringify({ orgId: org, projectId: `prj_${org}` })); + return dir; +} + +/** A folder holding `sub`, linked to `subTeam`; the folder itself is linked to `rootTeam` when given. */ +function tree(subTeam: string, rootTeam?: string): string { + const root = tempDir("cloudpin-vercel-deploy-dir-"); + link(join(root, "sub"), subTeam); + if (rootTeam) link(root, rootTeam); + return root; +} + +const resolve = (args: string[], cwd: string) => vercel.resolve({ args, env: loggedIn, cwd }, fakeVercel()); + +async function check(args: string[], cwd: string, team = "team_main") { + const config: FoundConfig = { path: "/repo/.cloudpin.yml", pins: { vercel: { team } } }; + return guard( + { bin: "vercel", args, env: loggedIn, cwd, mode: "agent" }, + { providers: [vercel], exec: fakeVercel(), findConfig: () => config }, + ); +} + +const ALLOW = { action: "allow", reason: "match" }; + +describe("guard: deploying a folder checks that folder's link (#147)", () => { + it.each([ + "deploy sub", + "sub", + "./sub", + "deploy ./sub --prod", + "deploy --prod sub", + "--prod sub", + "-y sub", + "-dy sub", + "deploy --name app sub", + "deploy -m k=v sub", + "deploy -e A=1 -b B=2 --target preview sub", + "deploy --archive=tgz sub", + "deploy -- sub", + "deploy sub other", + "deploy init sub", + "-d deploy sub", + ])("blocks %s when sub is linked to another team", async (cmd) => { + expect(await check(split(cmd), tree("team_side"))).toMatchObject({ action: "block" }); + }); + + it("blocks an absolute path to a folder linked to another team", async () => { + const elsewhere = tree("team_side"); + expect(await check(["deploy", join(elsewhere, "sub")], tree("team_main"))).toMatchObject({ action: "block" }); + }); + + it.each(["deploy sub", "sub", "-y sub", "deploy init sub"])( + "control: allows %s when sub is linked to the pinned team, and a wrong pin blocks it", + async (cmd) => { + const root = tree("team_main"); + expect(await check(split(cmd), root)).toEqual(ALLOW); + expect(await check(split(cmd), root, "team_side")).toMatchObject({ action: "block" }); + }, + ); + + it("control: deploy with no path still reads the link of the folder it runs in", async () => { + expect(await check(["deploy"], tree("team_side", "team_main"))).toEqual(ALLOW); + expect(await check([], tree("team_side", "team_main"))).toEqual(ALLOW); + expect(await check(["deploy", "--prod"], tree("team_main", "team_side"))).toMatchObject({ action: "block" }); + }); + + it("an explicit deploy of sub reads only sub's link", async () => { + expect(await check(["deploy", "sub"], tree("team_main", "team_side"))).toEqual(ALLOW); + }); + + it("a bare word also counts the folder's own link: Vercel runs vercel- there if it exists", async () => { + expect(await check(["sub"], tree("team_main", "team_side"))).toMatchObject({ action: "block" }); + expect(await check(["sub"], tree("team_main", "team_main"))).toEqual(ALLOW); + }); +}); + +describe("guard: --cwd and the deploy path (#147)", () => { + it("--cwd other deploy sub reads other/sub", async () => { + const root = tree("team_main"); + link(join(root, "other", "sub"), "team_side"); + expect(await check(["--cwd", "other", "deploy", "sub"], root)).toMatchObject({ action: "block" }); + expect(await check(["deploy", "sub", "--cwd=other"], root)).toMatchObject({ action: "block" }); + }); + + it("control: --cwd other deploy sub ignores ./sub", async () => { + const root = tree("team_side"); + link(join(root, "other", "sub"), "team_main"); + expect(await check(["--cwd", "other", "deploy", "sub"], root)).toEqual(ALLOW); + }); +}); + +describe("guard: a known command word is not a path (#147)", () => { + it.each(["env ls", "logs x", "ls", "inspect x", "teams ls x", "switch x"])( + "%s reads the link of the folder it runs in", + async (cmd) => { + const root = tree("team_main", "team_main"); + for (const word of split(cmd)) link(join(root, word), "team_side"); + const res = await check(split(cmd), root); + expect(res.action, JSON.stringify(res)).not.toBe("block"); + }, + ); + + it("deploy continue links the folder it runs in, not a folder named continue", async () => { + const root = tree("team_side", "team_main"); + link(join(root, "continue"), "team_side"); + expect(await check(["deploy", "continue", "--id", "dpl_1"], root)).toEqual(ALLOW); + }); +}); + +describe("guard: a path Vercel would refuse falls back to the folder it runs in (#147)", () => { + it("a missing path, or a file, reads the folder's own link: Vercel stops before linking", async () => { + const root = tree("team_side", "team_main"); + writeFileSync(join(root, "file.txt"), "x"); + expect(await check(["deploy", "missing"], root)).toEqual(ALLOW); + expect(await check(["deploy", "file.txt"], root)).toEqual(ALLOW); + expect(await check(["missing"], root)).toEqual(ALLOW); + const wrong = tree("team_main", "team_side"); + expect(await check(["deploy", "missing"], wrong)).toMatchObject({ action: "block" }); + }); + + it("an unknown deploy flag is a Vercel parse error; the folder's own link is read", async () => { + expect(await check(["deploy", "--bogus", "sub"], tree("team_side", "team_main"))).toEqual(ALLOW); + }); +}); + +describe("guard: pull and dev read the folder they are given (#147)", () => { + it.each([ + "pull sub", + "pull --environment preview sub", + "pull --git-branch main --yes sub", + "dev sub", + "develop sub", + "dev -l 3000 sub", + "dev --listen=3000 -L sub", + ])("blocks %s when sub is linked to another team", async (cmd) => { + expect(await check(split(cmd), tree("team_side", "team_main"))).toMatchObject({ action: "block" }); + }); + + it.each(["pull sub", "dev sub"])("control: allows %s when sub is linked to the pinned team, and a wrong pin blocks it", async (cmd) => { + const root = tree("team_main", "team_side"); + expect(await check(split(cmd), root)).toEqual(ALLOW); + expect(await check(split(cmd), root, "team_side")).toMatchObject({ action: "block" }); + }); + + it.each(["pull", "pull --prod", "dev", "dev dev"])("control: %s reads the folder it runs in", async (cmd) => { + expect(await check(split(cmd), tree("team_side", "team_main"))).toEqual(ALLOW); + }); +}); + +describe("vercel.resolve: the deploy path (#147)", () => { + it("reports the path's linked team", async () => { + expect(await resolve(["deploy", "sub"], tree("team_side", "team_main"))).toMatchObject({ + identity: { team: "team_main", projectTeam: "team_side" }, + }); + }); + + it("uses a repository link's project for the path, not for the folder it runs in", async () => { + const root = tempDir("cloudpin-vercel-deploy-dir-"); + mkdirSync(join(root, ".vercel")); + mkdirSync(join(root, "sub")); + writeFileSync( + join(root, ".vercel", "repo.json"), + JSON.stringify({ + orgId: "team_main", + projects: [ + { id: "prj_root", name: "root", directory: "." }, + { id: "prj_sub", name: "sub", directory: "sub", orgId: "team_side" }, + ], + }), + ); + expect(await resolve(["deploy"], root)).toMatchObject({ identity: { projectTeam: "team_main" } }); + expect(await resolve(["deploy", "sub"], root)).toMatchObject({ identity: { projectTeam: "team_side" } }); + }); + + it("keeps the scope from the folder it runs in: Vercel reads vercel.json before it knows the path", async () => { + const root = tree("team_main"); + writeFileSync(join(root, "sub", "vercel.json"), JSON.stringify({ scope: "side" })); + expect(await resolve(["deploy", "sub"], root)).toMatchObject({ identity: { team: "team_main" } }); + }); + + it("VERCEL_ORG_ID still decides the project team", async () => { + const res = await vercel.resolve( + { args: ["deploy", "sub"], env: { ...loggedIn, VERCEL_ORG_ID: "team_main" }, cwd: tree("team_side") }, + fakeVercel(), + ); + expect(res).toMatchObject({ identity: { projectTeam: "team_main" } }); + }); +}); From 1b6884f332b33cb7d0fa2994e9d8a7b089a282c3 Mon Sep 17 00:00:00 2001 From: Alvaro Reis <133926455+paureis@users.noreply.github.com> Date: Sat, 24 Oct 2026 22:46:53 -0400 Subject: [PATCH 2/8] Vercel: move argument parsing into vercel-args.ts (#147) A pure move, so the #147 fix fits under the file-size cap: the global flag tables, HELP_COMMANDS, mainParse and splitShortGroups, with their comments, move verbatim to src/providers/vercel-args.ts. vercel.ts imports the three names it uses. No behaviour change. Co-Authored-By: Claude Opus 5.5 --- src/providers/vercel-args.ts | 90 ++++++++++++++++++++++++++++++++++++ src/providers/vercel.ts | 89 +---------------------------------- 2 files changed, 91 insertions(+), 88 deletions(-) create mode 100644 src/providers/vercel-args.ts diff --git a/src/providers/vercel-args.ts b/src/providers/vercel-args.ts new file mode 100644 index 0000000..a720d38 --- /dev/null +++ b/src/providers/vercel-args.ts @@ -0,0 +1,90 @@ +// How the Vercel CLI parses its arguments, read by vercel.ts (#147 moved this here). + +// Global options (vercel/vercel packages/cli/src/util/arg-common.ts globalCommandOptions; 50.35). +const GLOBAL_BOOLEAN_FLAGS: Readonly> = { + "--help": "--help", "-h": "--help", "--version": "--version", "-v": "--version", + "--debug": "--debug", "-d": "--debug", "--no-color": "--no-color", "--non-interactive": "--non-interactive", +}; +const GLOBAL_VALUE_FLAGS = new Set([ + "--cwd", "--global-config", "-Q", "--local-config", "-A", "--scope", "-S", "--team", "-T", "--token", "-t", "--api", +]); +// Built-in commands and aliases (src/commands/index.ts; 50.35) that print their help and stop +// on --help or -h. Left out because they can run anyway: `promote ` and `rollback ` +// show help only without a deployment, and `rolling-release`/`rr` look for a literal --help or +// -h word, so `-dh` runs them. Any other word may be an extension (vercel-), which Vercel +// runs without the --help it parsed itself (src/util/extension/exec.ts). +export const HELP_COMMANDS = new Set([ + "activity", "agent", "alerts", "alias", "aliases", "ln", "api", "bisect", "blob", "build", "buy", "cache", + "certs", "cert", "contract", "crons", "cron", "curl", "deploy", "dev", "develop", "dns", "domains", "domain", + "env", "flags", "git", "httpstat", "init", "inspect", "install", "i", "integration", "integration-resource", + "ir", "link", "list", "ls", "logs", "log", "mcp", "microfrontends", "mf", "open", "project", "projects", + "pull", "redeploy", "redirects", "redirect", "remove", "rm", "routes", "skills", "target", "targets", "teams", + "team", "upgrade", "usage", "webhooks", "webhook", +]); + +interface MainParse { + /** Positionals, with the flags Vercel doesn't know globally; the first is the command. */ + positionals: string[]; + /** The global boolean flags seen, by long name. */ + flags: Set; +} + +/** + * The arguments as Vercel's main() parses them (packages/cli/src/index.ts, src/util/get-args.ts): + * arg 5.0.0 with the global options and `{ permissive: true }`. A flag it doesn't know, or an + * unknown letter of a short group, is kept as a positional and the rest of the group is still + * read, so `-dy whoami` has the command `-y`: no command and no extension has that name, so + * Vercel deploys. Every word after "--" is a positional. Undefined when arg would throw (a value + * flag not last in its group, or without a value), which stops Vercel before any command runs. + */ +export function mainParse(args: string[]): MainParse | undefined { + const positionals: string[] = []; + const flags = new Set(); + for (let i = 0; i < args.length; i++) { + const word = args[i]!; + if (word === "--") { + positionals.push(...args.slice(i + 1)); + break; + } + if (word.length < 2 || word[0] !== "-") { + positionals.push(word); + continue; + } + const parts = word[1] === "-" || word.length === 2 ? [word] : word.slice(1).split("").map((c) => `-${c}`); + for (let j = 0; j < parts.length; j++) { + const part = parts[j]!; + const eq = part.startsWith("--") ? part.indexOf("=") : -1; + const name = eq === -1 ? part : part.slice(0, eq); + const boolean = GLOBAL_BOOLEAN_FLAGS[name]; + if (boolean) { + flags.add(boolean); + } else if (!GLOBAL_VALUE_FLAGS.has(name)) { + positionals.push(part); + } else if (eq === -1) { + const value = args[i + 1]; + if (j < parts.length - 1 || value === undefined || (value.length > 1 && value[0] === "-")) return undefined; + i++; + } + } + } + return { positionals, flags }; +} + +/** + * The arguments as Vercel's parser sees them, so a short group's flags and value are read + * (#125). Vercel parses with arg 5.0.0 (vercel/vercel packages/cli/package.json; + * github.com/vercel/arg index.js, tag 5.0.0), which splits a single-dash word longer than two + * characters into one flag per letter (`-dT` is `-d -T`); a last letter that takes a value + * reads the next word, and a value letter anywhere else is an error. A value never starts + * with "-", so splitting every such word before "--" is exact. + */ +export function splitShortGroups(args: string[]): string[] { + const out: string[] = []; + for (let i = 0; i < args.length; i++) { + const arg = args[i]!; + if (arg === "--") return [...out, ...args.slice(i)]; + if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") out.push(...arg.slice(1).split("").map((c) => `-${c}`)); + else out.push(arg); + } + return out; +} diff --git a/src/providers/vercel.ts b/src/providers/vercel.ts index 343041e..2270198 100644 --- a/src/providers/vercel.ts +++ b/src/providers/vercel.ts @@ -4,6 +4,7 @@ import { dirname, join, relative, resolve as resolvePath, sep } from "node:path" import { flagValue } from "../args.js"; import { home } from "../paths.js"; import type { Exec, ProviderDef, Resolution } from "../types.js"; +import { HELP_COMMANDS, mainParse, splitShortGroups } from "./vercel-args.js"; // Behaviour below was observed on vercel 50.35 through `--debug` request URLs, // running read-only commands: @@ -14,94 +15,6 @@ import type { Exec, ProviderDef, Resolution } from "../types.js"; const EXEMPT_COMMANDS = new Set(["login", "logout", "switch", "whoami", "help", "telemetry"]); const EXEMPT_TEAMS_SUBCOMMANDS = new Set(["ls", "list", "switch"]); -// Global options (vercel/vercel packages/cli/src/util/arg-common.ts globalCommandOptions; 50.35). -const GLOBAL_BOOLEAN_FLAGS: Readonly> = { - "--help": "--help", "-h": "--help", "--version": "--version", "-v": "--version", - "--debug": "--debug", "-d": "--debug", "--no-color": "--no-color", "--non-interactive": "--non-interactive", -}; -const GLOBAL_VALUE_FLAGS = new Set([ - "--cwd", "--global-config", "-Q", "--local-config", "-A", "--scope", "-S", "--team", "-T", "--token", "-t", "--api", -]); -// Built-in commands and aliases (src/commands/index.ts; 50.35) that print their help and stop -// on --help or -h. Left out because they can run anyway: `promote ` and `rollback ` -// show help only without a deployment, and `rolling-release`/`rr` look for a literal --help or -// -h word, so `-dh` runs them. Any other word may be an extension (vercel-), which Vercel -// runs without the --help it parsed itself (src/util/extension/exec.ts). -const HELP_COMMANDS = new Set([ - "activity", "agent", "alerts", "alias", "aliases", "ln", "api", "bisect", "blob", "build", "buy", "cache", - "certs", "cert", "contract", "crons", "cron", "curl", "deploy", "dev", "develop", "dns", "domains", "domain", - "env", "flags", "git", "httpstat", "init", "inspect", "install", "i", "integration", "integration-resource", - "ir", "link", "list", "ls", "logs", "log", "mcp", "microfrontends", "mf", "open", "project", "projects", - "pull", "redeploy", "redirects", "redirect", "remove", "rm", "routes", "skills", "target", "targets", "teams", - "team", "upgrade", "usage", "webhooks", "webhook", -]); - -interface MainParse { - /** Positionals, with the flags Vercel doesn't know globally; the first is the command. */ - positionals: string[]; - /** The global boolean flags seen, by long name. */ - flags: Set; -} - -/** - * The arguments as Vercel's main() parses them (packages/cli/src/index.ts, src/util/get-args.ts): - * arg 5.0.0 with the global options and `{ permissive: true }`. A flag it doesn't know, or an - * unknown letter of a short group, is kept as a positional and the rest of the group is still - * read, so `-dy whoami` has the command `-y`: no command and no extension has that name, so - * Vercel deploys. Every word after "--" is a positional. Undefined when arg would throw (a value - * flag not last in its group, or without a value), which stops Vercel before any command runs. - */ -function mainParse(args: string[]): MainParse | undefined { - const positionals: string[] = []; - const flags = new Set(); - for (let i = 0; i < args.length; i++) { - const word = args[i]!; - if (word === "--") { - positionals.push(...args.slice(i + 1)); - break; - } - if (word.length < 2 || word[0] !== "-") { - positionals.push(word); - continue; - } - const parts = word[1] === "-" || word.length === 2 ? [word] : word.slice(1).split("").map((c) => `-${c}`); - for (let j = 0; j < parts.length; j++) { - const part = parts[j]!; - const eq = part.startsWith("--") ? part.indexOf("=") : -1; - const name = eq === -1 ? part : part.slice(0, eq); - const boolean = GLOBAL_BOOLEAN_FLAGS[name]; - if (boolean) { - flags.add(boolean); - } else if (!GLOBAL_VALUE_FLAGS.has(name)) { - positionals.push(part); - } else if (eq === -1) { - const value = args[i + 1]; - if (j < parts.length - 1 || value === undefined || (value.length > 1 && value[0] === "-")) return undefined; - i++; - } - } - } - return { positionals, flags }; -} - -/** - * The arguments as Vercel's parser sees them, so a short group's flags and value are read - * (#125). Vercel parses with arg 5.0.0 (vercel/vercel packages/cli/package.json; - * github.com/vercel/arg index.js, tag 5.0.0), which splits a single-dash word longer than two - * characters into one flag per letter (`-dT` is `-d -T`); a last letter that takes a value - * reads the next word, and a value letter anywhere else is an error. A value never starts - * with "-", so splitting every such word before "--" is exact. - */ -function splitShortGroups(args: string[]): string[] { - const out: string[] = []; - for (let i = 0; i < args.length; i++) { - const arg = args[i]!; - if (arg === "--") return [...out, ...args.slice(i)]; - if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") out.push(...arg.slice(1).split("").map((c) => `-${c}`)); - else out.push(arg); - } - return out; -} interface Team { id: string; From b85a367943499203ac1072386f8102ab02593e83 Mon Sep 17 00:00:00 2001 From: Alvaro Reis <133926455+paureis@users.noreply.github.com> Date: Sat, 24 Oct 2026 22:47:28 -0400 Subject: [PATCH 3/8] Vercel: parse arguments with any command's options, the way arg 5.0.0 does (#147) mainParse becomes argParse(args, spec, permissive) with the global options and permissive mode, as before. Commands parse their own options merged with the globals and not permissively, where an unknown flag is an error; the deploy-path fix needs that. No behaviour change. Co-Authored-By: Claude Opus 5.5 --- src/providers/vercel-args.ts | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/providers/vercel-args.ts b/src/providers/vercel-args.ts index a720d38..2393567 100644 --- a/src/providers/vercel-args.ts +++ b/src/providers/vercel-args.ts @@ -22,10 +22,17 @@ export const HELP_COMMANDS = new Set([ "team", "upgrade", "usage", "webhooks", "webhook", ]); +/** The options a parse knows: the globals, plus a command's own (getFlagsSpecification). */ +interface Spec { + booleans: ReadonlySet; + values: ReadonlySet; +} +const GLOBALS: Spec = { booleans: new Set(Object.keys(GLOBAL_BOOLEAN_FLAGS)), values: GLOBAL_VALUE_FLAGS }; + interface MainParse { - /** Positionals, with the flags Vercel doesn't know globally; the first is the command. */ + /** Positionals, with the flags the spec doesn't know when permissive; the first is the command. */ positionals: string[]; - /** The global boolean flags seen, by long name. */ + /** The boolean flags seen; the global ones by long name. */ flags: Set; } @@ -37,7 +44,13 @@ interface MainParse { * Vercel deploys. Every word after "--" is a positional. Undefined when arg would throw (a value * flag not last in its group, or without a value), which stops Vercel before any command runs. */ -export function mainParse(args: string[]): MainParse | undefined { +export const mainParse = (args: string[]) => argParse(args, GLOBALS, true); + +/** + * The arguments as arg 5.0.0 parses them with `spec` (src/util/get-args.ts parseArguments). + * Not permissive, as commands parse, an unknown flag is an error: undefined. + */ +function argParse(args: string[], spec: Spec, permissive: boolean): MainParse | undefined { const positionals: string[] = []; const flags = new Set(); for (let i = 0; i < args.length; i++) { @@ -55,10 +68,10 @@ export function mainParse(args: string[]): MainParse | undefined { const part = parts[j]!; const eq = part.startsWith("--") ? part.indexOf("=") : -1; const name = eq === -1 ? part : part.slice(0, eq); - const boolean = GLOBAL_BOOLEAN_FLAGS[name]; - if (boolean) { - flags.add(boolean); - } else if (!GLOBAL_VALUE_FLAGS.has(name)) { + if (spec.booleans.has(name)) { + flags.add(GLOBAL_BOOLEAN_FLAGS[name] ?? name); + } else if (!spec.values.has(name)) { + if (!permissive) return undefined; positionals.push(part); } else if (eq === -1) { const value = args[i + 1]; From c8ae82a8dd20ae54c43449772a0086c66c4c19ab Mon Sep 17 00:00:00 2001 From: Alvaro Reis <133926455+paureis@users.noreply.github.com> Date: Sat, 24 Oct 2026 22:48:22 -0400 Subject: [PATCH 4/8] Vercel: deploy, pull and dev check the link of the folder they name (#147) vercel deploy , a bare vercel , deploy init , pull and dev link and act on the project in , but cloudpin read the link only from --cwd or the folder the command runs in, so a folder linked to another team passed a pin it should fail. linkDirs reads each command the way vercel 50.35 does: the path positional after the command's own options, resolved against the folder after --cwd. Deploy falls back to that folder when Vercel would refuse the path (missing, a file, a symlink), since nothing deploys. A first word that is no Vercel command may run an extension vercel- in the folder instead of a deploy, so both folders' links count there. The scope still comes only from the local config in the folder the command runs in. Co-Authored-By: Claude Opus 5.5 --- src/providers/vercel-args.ts | 69 ++++++++++++++++++++++++++++++++++++ src/providers/vercel.ts | 16 +++++---- 2 files changed, 78 insertions(+), 7 deletions(-) diff --git a/src/providers/vercel-args.ts b/src/providers/vercel-args.ts index 2393567..96a8470 100644 --- a/src/providers/vercel-args.ts +++ b/src/providers/vercel-args.ts @@ -1,4 +1,6 @@ // How the Vercel CLI parses its arguments, read by vercel.ts (#147 moved this here). +import { lstatSync } from "node:fs"; +import { resolve as resolvePath } from "node:path"; // Global options (vercel/vercel packages/cli/src/util/arg-common.ts globalCommandOptions; 50.35). const GLOBAL_BOOLEAN_FLAGS: Readonly> = { @@ -21,6 +23,14 @@ export const HELP_COMMANDS = new Set([ "pull", "redeploy", "redirects", "redirect", "remove", "rm", "routes", "skills", "target", "targets", "teams", "team", "upgrade", "usage", "webhooks", "webhook", ]); +// Every built-in command and alias (src/commands/index.ts `commands`; 50.35). Any other first +// word runs an extension vercel- if one is installed, else deploys that word as a path. +// `guidance` and `metrics` join only with FF_GUIDANCE_MODE / FF_METRICS set; read as a deploy +// path they add a folder's link to the check, never remove one. +const COMMANDS = new Set([ + ...HELP_COMMANDS, "help", "login", "logout", "promote", "rollback", "rolling-release", "rr", "switch", + "telemetry", "whoami", +]); /** The options a parse knows: the globals, plus a command's own (getFlagsSpecification). */ interface Spec { @@ -28,6 +38,22 @@ interface Spec { values: ReadonlySet; } const GLOBALS: Spec = { booleans: new Set(Object.keys(GLOBAL_BOOLEAN_FLAGS)), values: GLOBAL_VALUE_FLAGS }; +const commandSpec = (booleans: string, values: string): Spec => ({ + booleans: new Set([...GLOBALS.booleans, ...booleans.split(" ")]), + values: new Set([...GLOBALS.values, ...values.split(" ")]), +}); +// The commands that link a path argument (50.35: src/commands/deploy/command.ts deployCommand +// and initSubcommand, pull/command.ts, dev/command.ts; shared options from arg-common.ts). +const DEPLOY = commandSpec( + "-f --force --with-cache -p --public --prebuilt --prod --no-wait --skip-domain -y --yes -l --logs --guidance --no-logs --no-clipboard --json -c --confirm", + "-e --env -b --build-env -m --meta --regions --archive -n --name --target -F --format", +); +const DEPLOY_INIT = commandSpec( + "-f --force --with-cache -p --public --prod --skip-domain -y --yes --json -c --confirm", + "-e --env -b --build-env -m --meta --regions --archive --target -F --format", +); +const PULL = commandSpec("--prod -y --yes", "--environment --git-branch"); +const DEV = commandSpec("-L --local -y --yes -c --confirm", "-l --listen -p --port"); interface MainParse { /** Positionals, with the flags the spec doesn't know when permissive; the first is the command. */ @@ -101,3 +127,46 @@ export function splitShortGroups(args: string[]): string[] { } return out; } + +const isDirectory = (path: string) => { + try { + return lstatSync(path).isDirectory(); + } catch { + return false; + } +}; + +/** + * The folders whose link a command acts on (#147), given `base`, the folder after --cwd (which + * Vercel chdirs into: Client `set cwd`). Most commands link `base`; these link the folder their + * path argument names (vercel 50.35): + * - deploy (src/commands/deploy/index.ts): deploy_default picks the subcommand from a permissive + * parse; `continue` links `base` (its required --id already fails the default parse); else + * the positionals after "deploy" (and "init") are paths resolved against `base`, + * validatePaths (src/util/validate-paths.ts) stops unless the first is a directory (lstat), + * and ensureLink links it. A path Vercel refuses deploys nothing, so `base` is read. + * - a first word that is no command (src/index.ts main): Vercel runs vercel- in `base` + * if it finds one (src/util/extension/exec.ts), else deploys the word. cloudpin can't tell + * which, so both folders count: a wrong link in either blocks. + * - pull (src/commands/pull/index.ts): `parsedArgs.args[1] || client.cwd`, used unchecked. + * - dev (src/commands/dev/index.ts): the first argument after "dev" (Vercel refuses a second; + * reading the first anyway only adds a check). + */ +export function linkDirs(args: string[], base: string): string[] { + const command = mainParse(args)?.positionals[0]; + const at = (path: string | undefined) => (path ? resolvePath(base, path) : base); + if (command === "pull") return [at(argParse(args, PULL, false)?.positionals[1])]; + if (command === "dev" || command === "develop") { + const words = argParse(args, DEV, false)?.positionals.slice(1) ?? []; + return [at(words[0] === "dev" ? words[1] : words[0])]; + } + if (!command || (command !== "deploy" && COMMANDS.has(command))) return [base]; + + const strip = (words: string[], word: string) => (words[0] === word ? words.slice(1) : words); + const sub = strip(argParse(args, DEPLOY, true)?.positionals ?? [], "deploy")[0]; + let paths: string[] = []; + if (sub === "init") paths = strip(strip(argParse(args, DEPLOY_INIT, false)?.positionals ?? [], "deploy"), "init"); + else if (sub !== "continue") paths = strip(argParse(args, DEPLOY, false)?.positionals ?? [], "deploy"); + const target = paths.length > 0 && isDirectory(at(paths[0])) ? at(paths[0]) : base; + return command === "deploy" || target === base ? [target] : [base, target]; +} diff --git a/src/providers/vercel.ts b/src/providers/vercel.ts index 2270198..e2eb6f5 100644 --- a/src/providers/vercel.ts +++ b/src/providers/vercel.ts @@ -4,7 +4,7 @@ import { dirname, join, relative, resolve as resolvePath, sep } from "node:path" import { flagValue } from "../args.js"; import { home } from "../paths.js"; import type { Exec, ProviderDef, Resolution } from "../types.js"; -import { HELP_COMMANDS, mainParse, splitShortGroups } from "./vercel-args.js"; +import { HELP_COMMANDS, linkDirs, mainParse, splitShortGroups } from "./vercel-args.js"; // Behaviour below was observed on vercel 50.35 through `--debug` request URLs, // running read-only commands: @@ -238,15 +238,17 @@ export const vercel: ProviderDef<"vercel"> = { } const identity: Record = { team, label: slugOf(team) }; - // The team project-level requests use. - const projectDir = resolvePath(cwd, flagValue(args, ["--cwd"]) ?? "."); - let projectTeams: string[]; + // The team project-level requests use, from the folder after --cwd or the one the command + // names (#147); the scope above stays with the folder it runs in. + let projectTeams: string[] = []; if (env.VERCEL_ORG_ID) { projectTeams = [env.VERCEL_ORG_ID]; } else { - const linked = linkedTeams(projectDir, flagValue(args, ["--project"]), home(env)); - if ("error" in linked) return { kind: "error", message: linked.error }; - projectTeams = linked; + for (const dir of linkDirs(typed, resolvePath(cwd, flagValue(args, ["--cwd"]) ?? "."))) { + const linked = linkedTeams(dir, flagValue(args, ["--project"]), home(env)); + if ("error" in linked) return { kind: "error", message: linked.error }; + projectTeams.push(...linked); + } } // Several when a repository link leaves the project open; each must be the pinned team. if (projectTeams.length > 0) identity.projectTeam = [...new Set(projectTeams.map(toId))].join(","); From 61309ccad1384fb7fff60be8e3ebc1adc57883c7 Mon Sep 17 00:00:00 2001 From: Alvaro Reis <133926455+paureis@users.noreply.github.com> Date: Sat, 24 Oct 2026 22:50:06 -0400 Subject: [PATCH 5/8] Test: pin the #147 parses that mutation testing left loose An unknown flag after the deploy path, deploy init's own options, and a folder named dev beside `vercel dev dev`: each case fails if the command's strict parse turns permissive, deploy init parses with the wrong options, or the second "dev" is read as a folder. Co-Authored-By: Claude Opus 5.5 --- test/vercel-deploy-dir.test.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/test/vercel-deploy-dir.test.ts b/test/vercel-deploy-dir.test.ts index 0ed7d3e..d50b40c 100644 --- a/test/vercel-deploy-dir.test.ts +++ b/test/vercel-deploy-dir.test.ts @@ -83,6 +83,7 @@ describe("guard: deploying a folder checks that folder's link (#147)", () => { "deploy -- sub", "deploy sub other", "deploy init sub", + "deploy init --prod -e A=1 sub", "-d deploy sub", ])("blocks %s when sub is linked to another team", async (cmd) => { expect(await check(split(cmd), tree("team_side"))).toMatchObject({ action: "block" }); @@ -162,9 +163,12 @@ describe("guard: a path Vercel would refuse falls back to the folder it runs in expect(await check(["deploy", "missing"], wrong)).toMatchObject({ action: "block" }); }); - it("an unknown deploy flag is a Vercel parse error; the folder's own link is read", async () => { - expect(await check(["deploy", "--bogus", "sub"], tree("team_side", "team_main"))).toEqual(ALLOW); - }); + it.each(["deploy --bogus sub", "deploy sub --bogus", "deploy init --name x sub"])( + "%s is a Vercel parse error; the folder's own link is read", + async (cmd) => { + expect(await check(split(cmd), tree("team_side", "team_main"))).toEqual(ALLOW); + }, + ); }); describe("guard: pull and dev read the folder they are given (#147)", () => { @@ -174,6 +178,7 @@ describe("guard: pull and dev read the folder they are given (#147)", () => { "pull --git-branch main --yes sub", "dev sub", "develop sub", + "dev dev sub", "dev -l 3000 sub", "dev --listen=3000 -L sub", ])("blocks %s when sub is linked to another team", async (cmd) => { @@ -187,7 +192,10 @@ describe("guard: pull and dev read the folder they are given (#147)", () => { }); it.each(["pull", "pull --prod", "dev", "dev dev"])("control: %s reads the folder it runs in", async (cmd) => { - expect(await check(split(cmd), tree("team_side", "team_main"))).toEqual(ALLOW); + // A second "dev" is the command's own name (getSubcommand), not a folder called dev. + const root = tree("team_side", "team_main"); + link(join(root, "dev"), "team_side"); + expect(await check(split(cmd), root)).toEqual(ALLOW); }); }); From da34d2f06a2a2d3554446b5cf2ed15fea16304ae Mon Sep 17 00:00:00 2001 From: Alvaro Reis <133926455+paureis@users.noreply.github.com> Date: Sat, 24 Oct 2026 23:13:41 -0400 Subject: [PATCH 6/8] Test: Vercel -y in a short group, and teams change / team aliases (#148) Fails until the fix: `project inspect -dy` counts as read-only on a protected environment, and `teams change` and `team ls|switch` are checked instead of exempt. The --api, -dv and -dh cases already pass (#146); they are pinned here at guard and resolve level. Co-Authored-By: Claude Opus 5.5 --- test/vercel-yes-group.test.ts | 135 ++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 test/vercel-yes-group.test.ts diff --git a/test/vercel-yes-group.test.ts b/test/vercel-yes-group.test.ts new file mode 100644 index 0000000..523e4e1 --- /dev/null +++ b/test/vercel-yes-group.test.ts @@ -0,0 +1,135 @@ +import { mkdirSync, writeFileSync } from "node:fs"; +import { join } from "node:path"; +import { describe, expect, it } from "vitest"; +import type { FoundConfig } from "../src/config.js"; +import { guard } from "../src/guard.js"; +import { vercel } from "../src/providers/vercel.js"; +import { isReadOnly } from "../src/readonly.js"; +import type { Exec } from "../src/types.js"; +import { tempDir } from "./tmp.js"; + +// #148. `vercel project inspect` with no name links the folder through ensureLink, which with +// --yes can create a project, link the folder and connect Git (vercel 50.35: +// src/commands/project/inspect.ts, util/projects/get-project-by-cwd-or-link.ts). The project +// command parses permissively (src/commands/project/index.ts main), so a group's unknown -y is +// kept as a word, and "--" is dropped; inspect then parses those words with --yes/-y +// (inspectSubcommand options: yesOption). So `-dy`, `-yd` and `-- -dy` all pass --yes. + +const split = (cmd: string) => (cmd === "" ? [] : cmd.split(" ")); +const env = { HOME: tempDir("cloudpin-yes-home-"), USERPROFILE: "" }; +const ro = (cmd: string) => isReadOnly("vercel", split(cmd), env, {}); + +describe("isReadOnly: vercel --yes in a short group (#148)", () => { + it.each([ + "project inspect -dy", + "projects inspect -yd", + "project inspect -dyQ x", + "project inspect -- -y", + "project inspect -- -dy", + "project inspect --yes=false", + "ls -dy", + ])("vercel %s needs confirmation", (cmd) => { + expect(ro(cmd)).toBe(false); + }); + + it.each(["project inspect", "project inspect -dQ dir", "projects inspect -d", "ls -d", "env ls -d"])( + "control: vercel %s stays read-only", + (cmd) => { + expect(ro(cmd)).toBe(true); + }, + ); +}); + +// src/commands/teams/index.ts COMMAND_CONFIG: list = ls|list, switch = switch|change, +// add = create|add, invite. teamsCommand's aliases are "switch" and "team" +// (src/commands/teams/command.ts), and the subcommand is the word after the one typed. +describe("vercel.isExempt: teams subcommand aliases (#148)", () => { + it.each(["teams change", "teams change acme", "team ls", "team list", "team switch", "team change acme", "-d team ls"])( + "allows vercel %s", + (cmd) => { + expect(vercel.isExempt(split(cmd))).toBe(true); + }, + ); + + it.each(["teams add", "teams create", "team add", "team create", "team invite a@example.com", "teams -x ls", "team"])( + "checks vercel %s", + (cmd) => { + expect(vercel.isExempt(split(cmd))).toBe(false); + }, + ); +}); + +const TEAMS = JSON.stringify({ + teams: [ + { id: "team_main", slug: "acme", current: true }, + { id: "team_side", slug: "side", current: false }, + ], + pagination: {}, +}); + +const fakeVercel: Exec = async (_bin, args) => { + if (args[0] === "teams") return { code: 0, stdout: TEAMS, stderr: "" }; + return { code: 1, stdout: "", stderr: "unexpected" }; +}; + +const loggedIn = { VERCEL_TOKEN: "example-env-token" }; +const production = { name: "production", protected: true, source: 'branch "main"' }; + +async function check(cmd: string, team = "team_main", cwd = tempDir("cloudpin-vercel-yes-")) { + const config: FoundConfig = { path: "/repo/.cloudpin.yml", pins: { vercel: { team } }, environment: production }; + return guard( + { bin: "vercel", args: split(cmd), env: loggedIn, cwd, mode: "agent" }, + { providers: [vercel], exec: fakeVercel, findConfig: () => config }, + ); +} + +const CONFIRM = { action: "confirm", provider: "vercel", configPath: "/repo/.cloudpin.yml", environment: production }; + +describe("guard: vercel on a protected environment (#148)", () => { + it.each(["project inspect -dy", "projects inspect -yd", "project inspect -dyQ x"])( + "asks before vercel %s, which may link the folder", + async (cmd) => { + expect(await check(cmd)).toEqual(CONFIRM); + }, + ); + + it("still asks before vercel deploy --prod -dy", async () => { + expect(await check("deploy --prod -dy")).toEqual(CONFIRM); + }); + + it.each(["project inspect", "project inspect -dQ dir"])("control: lets vercel %s through", async (cmd) => { + expect(await check(cmd)).toEqual({ action: "allow", reason: "match" }); + }); + + // #146 fixed these false blocks; a wrong team proves the command is exempt, not matched. + it.each(["-dv", "-dh", "--api https://api.example.com whoami", "teams change", "team switch"])( + "allows vercel %s as exempt", + async (cmd) => { + expect(await check(cmd, "team_side")).toEqual({ action: "allow", reason: "exempt" }); + }, + ); +}); + +/** Links `dir` (created if missing) to a project of team `org`. */ +function link(dir: string, org: string): string { + mkdirSync(join(dir, ".vercel"), { recursive: true }); + writeFileSync(join(dir, ".vercel", "project.json"), JSON.stringify({ orgId: org, projectId: `prj_${org}` })); + return dir; +} + +describe("vercel.resolve: --api takes a value (#146, #148)", () => { + // Read as the command, the value `sub` would be a deploy path and add sub's link. + it("reads the folder's link, not the --api value's", async () => { + const root = link(tempDir("cloudpin-vercel-api-"), "team_main"); + link(join(root, "sub"), "team_side"); + const resolution = await vercel.resolve({ args: split("--api sub ls"), env: loggedIn, cwd: root }, fakeVercel); + expect(resolution).toMatchObject({ kind: "identity", identity: { team: "team_main", projectTeam: "team_main" } }); + }); + + it("control: a deploy of sub reads sub's link", async () => { + const root = link(tempDir("cloudpin-vercel-api-"), "team_main"); + link(join(root, "sub"), "team_side"); + const resolution = await vercel.resolve({ args: split("deploy sub"), env: loggedIn, cwd: root }, fakeVercel); + expect(resolution).toMatchObject({ kind: "identity", identity: { projectTeam: "team_side" } }); + }); +}); From a76cfdddaaf4112d55bead7b311046550d0e53fa Mon Sep 17 00:00:00 2001 From: Alvaro Reis <133926455+paureis@users.noreply.github.com> Date: Sat, 24 Oct 2026 23:14:17 -0400 Subject: [PATCH 7/8] Vercel: read -y inside a short group as --yes on a protected environment (#148) `vercel project inspect -dy` counted as read-only, though inspect with no name goes through ensureLink, which with --yes can create a project, link the folder and connect Git. The project command parses permissively, keeping an unknown -y of a group as a word and dropping a first "--", and inspect parses those words again with --yes/-y (vercel 50.35, src/commands/project/index.ts and inspect.ts). So the check splits every short group, those after "--" included. Co-Authored-By: Claude Opus 5.5 --- src/providers/vercel-args.ts | 11 +++++++++++ src/readonly.ts | 9 ++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/providers/vercel-args.ts b/src/providers/vercel-args.ts index 96a8470..b9fb993 100644 --- a/src/providers/vercel-args.ts +++ b/src/providers/vercel-args.ts @@ -1,6 +1,7 @@ // How the Vercel CLI parses its arguments, read by vercel.ts (#147 moved this here). import { lstatSync } from "node:fs"; import { resolve as resolvePath } from "node:path"; +import { hasAnyFlag } from "../args.js"; // Global options (vercel/vercel packages/cli/src/util/arg-common.ts globalCommandOptions; 50.35). const GLOBAL_BOOLEAN_FLAGS: Readonly> = { @@ -128,6 +129,16 @@ export function splitShortGroups(args: string[]): string[] { return out; } +/** + * Whether the command may get --yes (#148), as `project inspect` reads it (vercel 50.35): + * project's main parses permissively (src/commands/project/index.ts), so a group's -y it + * doesn't know stays a word and a first "--" is dropped; inspect parses those words again with + * --yes/-y (src/commands/project/inspect.ts, yesOption), and arg sets a boolean on `--yes=x` + * too. So every word counts, groups after "--" included; a value never starts with "-". + */ +export const passesYes = (args: string[]) => + hasAnyFlag(splitShortGroups(args.filter((word) => word !== "--")), ["--yes", "-y"]); + const isDirectory = (path: string) => { try { return lstatSync(path).isDirectory(); diff --git a/src/readonly.ts b/src/readonly.ts index 2a57fce..671e016 100644 --- a/src/readonly.ts +++ b/src/readonly.ts @@ -1,11 +1,12 @@ import { existsSync } from "node:fs"; import { dirname, join } from "node:path"; -import { commandWords as argWords, hasAnyFlag, leadingWords } from "./args.js"; +import { commandWords as argWords, leadingWords } from "./args.js"; import type { Provider, ReadOnlyRules } from "./config.js"; import { home } from "./paths.js"; import { commandWords } from "./providers/kubernetes.js"; import { VALUE_FLAGS as SUPABASE_VALUE_FLAGS } from "./providers/supabase.js"; import { VALUE_FLAGS as WRANGLER_VALUE_FLAGS } from "./providers/cloudflare.js"; +import { passesYes } from "./providers/vercel-args.js"; /* * Which commands only read, so they skip the confirmation on a protected @@ -64,9 +65,11 @@ const BUILT_IN: Record< }, // Vercel CLI: bare `vercel ` deploys, `vercel alias` with no subcommand - // creates an alias, and `--yes` can set up a project (vercel.com/docs/cli). + // creates an alias, and `--yes` can set up a project (vercel.com/docs/cli). Of + // this list only `project inspect` with no name uses --yes (ensureLink), read + // also inside a short group (#148); the others never call ensureLink (50.35). vercel: (words, args) => { - if (hasAnyFlag(args, ["--yes", "-y"])) return false; + if (passesYes(args)) return false; const [first, second] = words; if (["ls", "list", "inspect", "logs"].includes(first ?? "")) return true; if (["env", "domains", "dns", "certs", "project", "projects", "teams", "alias"].includes(first ?? "")) { From d78329d5b411f68b72ca38a981edc30fe1d635f3 Mon Sep 17 00:00:00 2001 From: Alvaro Reis <133926455+paureis@users.noreply.github.com> Date: Sat, 24 Oct 2026 23:14:55 -0400 Subject: [PATCH 8/8] Vercel: exempt teams change and the team alias, as Vercel names them (#148) `vercel teams change` is teams switch, and `vercel team ls|switch` is teams (vercel 50.35: src/commands/teams/index.ts COMMAND_CONFIG maps switch to switch|change and list to ls|list; teamsCommand's aliases are switch and team). Both were checked instead of exempt. Co-Authored-By: Claude Opus 5.5 --- src/providers/vercel.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/providers/vercel.ts b/src/providers/vercel.ts index e2eb6f5..327a7a3 100644 --- a/src/providers/vercel.ts +++ b/src/providers/vercel.ts @@ -14,7 +14,11 @@ import { HELP_COMMANDS, linkDirs, mainParse, splitShortGroups } from "./vercel-a // A command may touch both, so both must be the pinned team. const EXEMPT_COMMANDS = new Set(["login", "logout", "switch", "whoami", "help", "telemetry"]); -const EXEMPT_TEAMS_SUBCOMMANDS = new Set(["ls", "list", "switch"]); +// vercel 50.35 src/commands/teams/index.ts COMMAND_CONFIG: list = ls|list, switch = switch|change +// (add = create|add and invite change things). teamsCommand's aliases are switch and team; the +// subcommand is the word after the one typed (`switch` itself runs teams switch). +const TEAMS_COMMANDS = new Set(["teams", "team"]); +const EXEMPT_TEAMS_SUBCOMMANDS = new Set(["ls", "list", "switch", "change"]); interface Team { id: string; @@ -185,7 +189,7 @@ export const vercel: ProviderDef<"vercel"> = { if (!command) return parsed.flags.has("--version") || parsed.flags.has("--help"); // A flag here (`--prod --name whoami`) is a deploy, which is in no list below. if (EXEMPT_COMMANDS.has(command)) return true; - if (command === "teams" && sub !== undefined && EXEMPT_TEAMS_SUBCOMMANDS.has(sub)) return true; + if (TEAMS_COMMANDS.has(command) && sub !== undefined && EXEMPT_TEAMS_SUBCOMMANDS.has(sub)) return true; return parsed.flags.has("--help") && HELP_COMMANDS.has(command); },