import { Command, Option } from "commander"; import { describe, expect, it } from "vitest"; import { collectShellCompletionCommandTree } from "./completion-command-tree.js"; describe("shell completion command tree", () => { it("collects root command aliases and parsed short and long option flags", () => { const program = new Command() .name("openclaw") .option("-p, --profile ", "Profile") .option("-v, --verbose", "Verbose output"); program.command("infer").alias("capability"); const tree = collectShellCompletionCommandTree(program); expect(tree.root.pathVariants).toEqual([[]]); expect(tree.root.completions).toEqual([ "infer", "capability", "-p", "--profile", "-v", "--verbose", ]); expect(tree.root.valueOptions).toEqual(["-p", "--profile"]); }); it("expands aliases across every ancestor and inherits value-taking options", () => { const program = new Command().name("openclaw").option("-p, --profile ", "Profile"); const cron = program.command("cron").alias("schedule").option("-z, --timezone "); cron.command("add").alias("create").option("--at