(deps commandDeps)
| 533 | } |
| 534 | |
| 535 | func newMemoryPromoteCommand(deps commandDeps) *cobra.Command { |
| 536 | var flags memorySelectorFlags |
| 537 | var fromRaw string |
| 538 | var toRaw string |
| 539 | var dryRun bool |
| 540 | |
| 541 | cmd := &cobra.Command{ |
| 542 | Use: "promote <filename> --from <scope[:tier]> --to <scope[:tier]>", |
| 543 | Short: "Promote a memory entry across Memory v2 scopes", |
| 544 | Args: exactOneNonBlankArg(), |
| 545 | RunE: func(cmd *cobra.Command, args []string) error { |
| 546 | client, err := clientFromDeps(deps) |
| 547 | if err != nil { |
| 548 | return err |
| 549 | } |
| 550 | from, err := parseMemoryPromotionSelector(deps, flags, fromRaw) |
| 551 | if err != nil { |
| 552 | return err |
| 553 | } |
| 554 | to, err := parseMemoryPromotionSelector(deps, flags, toRaw) |
| 555 | if err != nil { |
| 556 | return err |
| 557 | } |
| 558 | response, err := client.PromoteMemory(cmd.Context(), MemoryPromoteRequest{ |
| 559 | Filename: strings.TrimSpace(args[0]), |
| 560 | From: from, |
| 561 | To: to, |
| 562 | DryRun: dryRun, |
| 563 | }) |
| 564 | if err != nil { |
| 565 | return err |
| 566 | } |
| 567 | return writeCommandOutput(cmd, memoryPromoteBundle(response)) |
| 568 | }, |
| 569 | } |
| 570 | addMemorySelectorFlags(cmd, &flags) |
| 571 | cmd.Flags().StringVar(&fromRaw, "from", "", "Source scope: global, workspace, agent:workspace, or agent:global") |
| 572 | cmd.Flags().StringVar(&toRaw, "to", "", "Destination scope: global, workspace, agent:workspace, or agent:global") |
| 573 | cmd.Flags().BoolVar(&dryRun, "dry-run", false, "Ask for a promotion decision without applying it") |
| 574 | mustMarkFlagRequired(cmd, "from") |
| 575 | mustMarkFlagRequired(cmd, "to") |
| 576 | return cmd |
| 577 | } |
| 578 | |
| 579 | func newMemoryResetCommand(deps commandDeps) *cobra.Command { |
| 580 | var flags memorySelectorFlags |
no test coverage detected