Skip to content

feat(cli): add preset create and delete commands - #317

Open
admin86888 wants to merge 2 commits into
xingkongliang:mainfrom
admin86888:feat/cli-presets-crud
Open

feat(cli): add preset create and delete commands#317
admin86888 wants to merge 2 commits into
xingkongliang:mainfrom
admin86888:feat/cli-presets-crud

Conversation

@admin86888

Copy link
Copy Markdown

Summary

Adds the missing preset CRUD operations to skills-manager-cli:

  • presets create <name> [--description ...] [--icon ...]
  • presets delete <reference>

This resubmission is intentionally limited to CLI preset create/delete and the shared core logic required by the GUI and CLI.

Implementation

  • Extracts preset persistence into the shared scenario_service::create_preset.
  • Moves the complete preset deletion flow into scenario_service::delete_preset.
  • Updates the GUI create/delete commands to use the shared core functions.
  • Adds structured JSON output for CLI deletion results.
  • Trims preset names and rejects blank names.

Behavior

Create

The GUI continues to activate a newly created preset immediately.

CLI creation intentionally leaves the new preset inactive. This allows automation to create a preset, populate it with presets add-skill, and explicitly activate it when ready:

skills-manager-cli presets create Automation
skills-manager-cli presets add-skill Automation skill-a skill-b
skills-manager-cli presets apply Automation

This behavior is documented in presets create --help, and the command output reports "active": false.

### Delete

GUI and CLI now share the same deletion behavior:

- If the deleted preset is inactive, the current active preset is unchanged.
- If it is active, its synced targets are removed first.
- The first remaining preset in persisted order (sort_order, then created_at) becomes active and is synced.
- If no presets remain, the active preset is cleared.

The CLI no longer applies a separate default_scenario replacement preference during deletion.

## Scope

This PR only changes:

- src-tauri/src/bin/skills-manager-cli.rs
- src-tauri/src/commands/presets.rs
- src-tauri/src/core/scenario_service.rs

It does not include UI scrolling changes, build scripts, documentation, README, dependency, or CHANGELOG changes. CHANGELOG updates are left to the existing release:prepare workflow.

## Testing

- cargo test
    - 398 library tests passed
    - 3 CLI tests passed

- npm run lint
- npm run build
- Manual CLI smoke tests covering:
    - create without activation
    - explicit apply
    - active and inactive deletion
    - replacement preset selection
    - name trimming
    - blank-name rejection

The pre-push verification hook also completed successfully.

Share preset persistence and deletion in scenario_service so GUI and CLI use the same delete replacement behavior.

Keep CLI create inactive for headless composition, document the explicit apply step, and reject blank preset names.
Treat a complete empty scenario metadata snapshot as intentional state instead of bootstrapping a new Default preset. Add reopen and reindex regression coverage.
@admin86888
admin86888 force-pushed the feat/cli-presets-crud branch from c2f965c to 062ad69 Compare July 15, 2026 03:44
@quoxientzero

Copy link
Copy Markdown

Glad this feature is coming, will be on the lookout!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants