Skip to content

Make install command non-destructive with merge support#2

Closed
ibrahimkteish wants to merge 3 commits intopointfreeco:mainfrom
ibrahimkteish:non-destructive-install
Closed

Make install command non-destructive with merge support#2
ibrahimkteish wants to merge 3 commits intopointfreeco:mainfrom
ibrahimkteish:non-destructive-install

Conversation

@ibrahimkteish
Copy link
Copy Markdown
Contributor

@ibrahimkteish ibrahimkteish commented Jan 25, 2026

Summary

  • Remove destructive file deletion from install command
  • Add support for installing to current directory with --path .
  • Add path validation for ALL custom paths to ensure they contain /skills
  • Add helpful error messages with usage examples when validation fails
  • Add user confirmation prompt for custom path installs
  • Fix extraction to place skills directly in target path (not in nested skills/skills/ folder)
  • All install operations now merge files instead of replacing

Motivation

Previously, pfw install would delete everything in the target directory before installing, which could cause loss of custom or work-in-progress skills. Additionally, users could accidentally install to arbitrary locations like /tmp or project root directories. Finally, the zip extraction was creating a nested skills/skills/ structure instead of placing skills directly in the target path.

This change makes the install command always merge new files with existing ones, validates that installations only happen in appropriate skills directories, and correctly extracts skills to the target location.

Changes

  1. Non-destructive by default: Removed FileManager.default.removeItem() call for the install directory - installations now preserve existing files (individual skills are still updated to latest versions)
  2. Current directory support: Users can now use --path . to install into their current working directory
  3. Flexible path validation: Any --path argument is validated to ensure it contains /skills (supports various naming conventions like .copilot, .claude, .github, .config, etc.)
  4. Improved error messages: Clear, helpful error messages with examples when path validation fails
  5. User confirmation: Prompts for confirmation before installing to any custom path
  6. Correct extraction: Skills are extracted directly to the target path, not into a nested skills/ subfolder
  7. Updated help text: Documents the new current directory option

Examples

Valid usage:

# Default install to ~/.claude/skills/the-point-free-way
pfw install --tool claude

# Install to custom project path (any directory structure containing /skills)
pfw install --tool claude --path /Users/me/MyProject/.claude/skills
pfw install --tool claude --path /Users/me/MyProject/.github/skills
pfw install --tool claude --path /Users/me/MyProject/.config/skills

# Install to current directory (must contain /skills in path)
cd ~/.claude/skills/my-custom-skills
pfw install --tool claude --path .

Invalid usage (now properly rejected):

# Will show helpful error message
pfw install --tool claude --path /tmp
pfw install --tool claude --path /Users/me/MyProject

Test plan

  • Test default install: pfw install - should merge into default location
  • Test valid custom path: pfw install --path /project/.claude/skills - should prompt and merge, skills directly in path
  • Test invalid custom path: pfw install --path /tmp - should error with helpful message
  • Test current directory in valid location: cd ~/.claude/skills/test && pfw install --path . - should prompt and merge
  • Test current directory in invalid location: cd /tmp && pfw install --path . - should error with helpful message
  • Verify existing files are preserved and skills are placed directly in target (not in nested skills/ folder)
  • All 20 unit tests pass

- Remove destructive file deletion - all installs now merge files
- Add support for --path . or --path current to install into current directory
- Add path validation for ALL custom paths to ensure they're in .codex/skills or .claude/skills
- Add helpful error messages with usage examples when validation fails
- Add user confirmation prompt when installing to custom paths
- Fix extraction to place skills directly in target path, not in nested skills/skills folder
- Update help text to document current directory option

This change ensures users never lose existing work when installing skills, and prevents installations to arbitrary directories outside the expected skills folders.
@ibrahimkteish ibrahimkteish force-pushed the non-destructive-install branch from 234b059 to 3af0178 Compare January 25, 2026 10:43
- Add test target to Package.swift
- Refactor Install.swift to extract testable helper functions:
  - isCurrentDirectoryPath: Detects if path is current directory
  - validateInstallPath: Validates path contains expected tool pattern
  - resolveInstallURL: Resolves final install URL based on inputs
- Create comprehensive test suite with 21 tests using @test syntax:
  - Path validation tests (valid/invalid paths, tool matching)
  - Current directory detection tests
  - Install URL resolution tests
  - Tool default path tests
  - Edge cases (whitespace, case sensitivity, trailing slashes)
- All tests passing with Swift Testing framework (macOS 15+)
Copy link
Copy Markdown

@johankool johankool left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions. Not saying it's up to you to fix them, just sharing what I found when trying to use pfw with copilot-cli.

Comment thread Sources/pfw/Install.swift Outdated
Comment thread Sources/pfw/Install.swift Outdated
Comment thread Sources/pfw/Install.swift
Comment thread Sources/pfw/Install.swift Outdated
- Remove 'current' keyword support to avoid conflicts with actual directory names
- Make path validation flexible to support different naming conventions (.github, .copilot, .claude)
- Update validation to only require '/skills' in path instead of tool-specific pattern
- Update tests to reflect new validation logic
@ibrahimkteish
Copy link
Copy Markdown
Contributor Author

closing in favor of a better implementation here #3

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.

2 participants