| 559 | } |
| 560 | |
| 561 | export function registerWorksetCommand(program: Command): void { |
| 562 | const worksetCommand = new WorksetCommand(); |
| 563 | const groupDescription = |
| 564 | COMMAND_REGISTRY.find((entry) => entry.name === 'workset')?.description ?? |
| 565 | 'Compose, keep, and open personal working views (purely local)'; |
| 566 | const workset = program.command('workset').description(groupDescription); |
| 567 | // Parsed at the group level so `openspec workset --json` keeps the |
| 568 | // one-JSON-document contract instead of a raw Commander error. The |
| 569 | // parent option matches anywhere; actions read optsWithGlobals(). |
| 570 | workset.addOption(new Option('--json', 'Output as JSON').hideHelp()); |
| 571 | |
| 572 | workset |
| 573 | .command('create [name]') |
| 574 | .description('Compose and save a named working view of folders you choose') |
| 575 | .option( |
| 576 | '--member <member>', |
| 577 | 'Member folder as <path> or <name>=<path>; repeatable, first is the primary', |
| 578 | collectMember, |
| 579 | [] as string[] |
| 580 | ) |
| 581 | .option('--tool <id>', 'Preferred tool to open this workset with') |
| 582 | .option('--json', 'Output as JSON') |
| 583 | .action(async (name: string | undefined, _options: WorksetCreateOptions, command: Command) => { |
| 584 | await worksetCommand.create(name, command.optsWithGlobals()); |
| 585 | }); |
| 586 | |
| 587 | workset |
| 588 | .command('list') |
| 589 | .alias('ls') |
| 590 | .description('Show saved worksets with their members') |
| 591 | .option('--json', 'Output as JSON') |
| 592 | .action(async (_options: { json?: boolean }, command: Command) => { |
| 593 | await worksetCommand.list(command.optsWithGlobals()); |
| 594 | }); |
| 595 | |
| 596 | workset |
| 597 | .command('open <name>') |
| 598 | .description('Open a saved workset in your tool (editor window or agent session)') |
| 599 | .option('--tool <id>', 'Open with this tool just this once') |
| 600 | .addOption( |
| 601 | // Parsed so Commander never owns the error; rejected in the |
| 602 | // action with one JSON document. Hidden because help should not |
| 603 | // advertise a mode that only rejects. |
| 604 | new Option('--json', 'Not supported for open').hideHelp() |
| 605 | ) |
| 606 | .action(async (name: string, _options: WorksetOpenOptions, command: Command) => { |
| 607 | await worksetCommand.open(name, command.optsWithGlobals()); |
| 608 | }); |
| 609 | |
| 610 | workset |
| 611 | .command('remove <name>') |
| 612 | .description('Delete a saved workset (member folders are never touched)') |
| 613 | .option('--yes', 'Confirm removal non-interactively') |
| 614 | .option('--json', 'Output as JSON') |
| 615 | .action(async (name: string, _options: WorksetRemoveOptions, command: Command) => { |
| 616 | await worksetCommand.remove(name, command.optsWithGlobals()); |
| 617 | }); |
| 618 | |