---
phase: 28-clone-rm-mv-clean-config-flags
plan: 01
type: execute
wave: 1
depends_on: []
files_modified:
  - cmd_clone.py
  - cmd_rm.py
  - cmd_mv.py
  - cmd_clean.py
  - cmd_config.py
autonomous: true

must_haves:
  truths:
    - "User can clone with -b/--branch to checkout specific bookmark"
    - "User can clone with -n/--no-checkout to skip checkout"
    - "User can use git rm with -f, --cached warning, -n, -q flags"
    - "User can use git mv with -f, -k warning, -v, -n flags"
    - "User can use git clean -x to remove ignored files too"
    - "User can use git clean -e to exclude patterns"
    - "User can use git config with --get, --unset, scope flags, --show-origin"
    - "User gets helpful warnings for unsupported flags"
  artifacts:
    - path: "cmd_clone.py"
      provides: "Clone flag extraction and translation"
      min_lines: 60
      exports: ["handle"]
    - path: "cmd_rm.py"
      provides: "Rm flag extraction with warnings"
      min_lines: 40
      exports: ["handle"]
    - path: "cmd_mv.py"
      provides: "Mv flag extraction with warnings"
      min_lines: 40
      exports: ["handle"]
    - path: "cmd_clean.py"
      provides: "Clean flag extension for -x, -X, -e"
      min_lines: 70
      exports: ["handle"]
    - path: "cmd_config.py"
      provides: "Config flag extraction and translation"
      min_lines: 70
      exports: ["handle"]
  key_links:
    - from: "cmd_clone.py"
      to: "sl clone"
      via: "run_sl call with translated flags"
      pattern: "run_sl.*clone"
    - from: "cmd_rm.py"
      to: "sl remove"
      via: "run_sl call with warnings"
      pattern: "run_sl.*remove"
    - from: "cmd_mv.py"
      to: "sl rename"
      via: "run_sl call with translated flags"
      pattern: "run_sl.*rename"
    - from: "cmd_clean.py"
      to: "sl purge"
      via: "run_sl call with --ignored translation"
      pattern: "run_sl.*purge"
    - from: "cmd_config.py"
      to: "sl config"
      via: "run_sl call with scope translations"
      pattern: "run_sl.*config"
---

<objective>
Extend cmd_clone.py, cmd_rm.py, cmd_mv.py, cmd_clean.py, and cmd_config.py to support the full range of flags specified in requirements CLON-01 through CLON-09, RM-01 through RM-05, MV-01 through MV-04, CLEN-01 through CLEN-04, and CONF-01 through CONF-08.

Purpose: Enable users to use git clone, rm, mv, clean, and config with standard flags, with proper translation to Sapling equivalents and warnings for unsupported features.

Output: Extended handlers with flag extraction, translation, and warning patterns following established codebase conventions.
</objective>

<execution_context>
@~/.claude/get-shit-done/workflows/execute-plan.md
@~/.claude/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/REQUIREMENTS.md
@.planning/phases/28-clone-rm-mv-clean-config-flags/28-RESEARCH.md
@cmd_grep.py (reference for flag extraction pattern)
@cmd_clone.py (current implementation)
@cmd_rm.py (current implementation)
@cmd_mv.py (current implementation)
@cmd_clean.py (current implementation)
@cmd_config.py (current implementation)
</context>

<tasks>

<task type="auto">
  <name>Task 1: Extend cmd_clone.py with Flag Support</name>
  <files>cmd_clone.py</files>
  <action>
Extend cmd_clone.py to extract and translate clone flags following the pattern in cmd_grep.py:

**Translation flags:**
- CLON-01: `-b <branch>`/`--branch <branch>` -> `-u <branch>` (updaterev)
- CLON-05: `-n`/`--no-checkout` -> `-U`/`--noupdate`

**Pass-through flags:**
- CLON-08: `-q`/`--quiet` -> `-q` (global flag)
- CLON-09: `-v`/`--verbose` -> `-v` (global flag)

**Unsupported flags (print warning to stderr, skip flag):**
- CLON-02: `--depth <n>` - warn: "shallow clone (--depth) has no effect in Sapling (uses lazy fetching by default)"
- CLON-03: `--single-branch` - warn: "not applicable to Sapling (repositories don't have branch isolation)"
- CLON-04: `-o <name>`/`--origin <name>` - warn: "custom remote name not supported. Sapling uses 'default' remote."
- CLON-06: `--recursive`/`--recurse-submodules` - warn: "submodules not supported by Sapling"
- CLON-07: `--no-tags` - warn: "not applicable to Sapling"

**Implementation pattern:**
```python
import sys
from common import ParsedCommand, run_sl

def handle(parsed: ParsedCommand) -> int:
    """
    Handle 'git clone' command.

    Translations:
    - git clone -b <branch> -> sl clone -u <bookmark>
    - git clone -n/--no-checkout -> sl clone -U
    - git clone -q/--quiet -> sl clone -q
    - git clone -v/--verbose -> sl clone -v

    Warnings (unsupported):
    - --depth (no effect in Sapling)
    - --single-branch (not applicable)
    - -o/--origin (Sapling uses 'default')
    - --recursive/--recurse-submodules (no submodules)
    - --no-tags (not applicable)
    """
    sl_args = []
    remaining_args = []

    i = 0
    while i < len(parsed.args):
        arg = parsed.args[i]

        # Translation: -b/--branch <value> -> -u <value>
        if arg in ('-b', '--branch'):
            if i + 1 < len(parsed.args):
                i += 1
                sl_args.extend(['-u', parsed.args[i]])
        elif arg.startswith('--branch='):
            sl_args.extend(['-u', arg.split('=', 1)[1]])

        # Translation: -n/--no-checkout -> -U
        elif arg in ('-n', '--no-checkout'):
            sl_args.append('-U')

        # Pass-through: -q/--quiet, -v/--verbose
        elif arg in ('-q', '--quiet'):
            sl_args.append('-q')
        elif arg in ('-v', '--verbose'):
            sl_args.append('-v')

        # Unsupported: --depth
        elif arg == '--depth':
            if i + 1 < len(parsed.args):
                i += 1  # Skip the value
            print("Warning: --depth has no effect in Sapling (uses lazy fetching by default)",
                  file=sys.stderr)
        elif arg.startswith('--depth='):
            print("Warning: --depth has no effect in Sapling (uses lazy fetching by default)",
                  file=sys.stderr)

        # Unsupported: --single-branch
        elif arg == '--single-branch':
            print("Warning: --single-branch not applicable to Sapling", file=sys.stderr)

        # Unsupported: -o/--origin
        elif arg in ('-o', '--origin'):
            if i + 1 < len(parsed.args):
                i += 1  # Skip the value
            print("Warning: custom remote name not supported. Sapling uses 'default' remote.",
                  file=sys.stderr)
        elif arg.startswith('--origin='):
            print("Warning: custom remote name not supported. Sapling uses 'default' remote.",
                  file=sys.stderr)

        # Unsupported: --recursive/--recurse-submodules
        elif arg in ('--recursive', '--recurse-submodules'):
            print("Warning: submodules not supported by Sapling", file=sys.stderr)

        # Unsupported: --no-tags
        elif arg == '--no-tags':
            print("Warning: --no-tags not applicable to Sapling", file=sys.stderr)

        else:
            remaining_args.append(arg)

        i += 1

    return run_sl(["clone"] + sl_args + remaining_args)
```
  </action>
  <verify>
Run: `python -c "import cmd_clone; print('Import OK')"`
Verify cmd_clone.py has flag extraction loop handling all 9 CLON requirements.
  </verify>
  <done>
cmd_clone.py extracts and translates all clone flags per requirements:
- Translation: -b -> -u, -n -> -U
- Pass-through: -q, -v
- Warnings: --depth, --single-branch, -o/--origin, --recursive, --no-tags
  </done>
</task>

<task type="auto">
  <name>Task 2: Extend cmd_rm.py and cmd_mv.py with Flag Support</name>
  <files>cmd_rm.py, cmd_mv.py</files>
  <action>
**Extend cmd_rm.py:**

Keep existing `-r/--recursive` filtering. Add:

- RM-01: `-f`/`--force` -> pass through (already works)
- RM-02: `--cached` -> warn: "not supported. Sapling has no staging area. Use 'sl forget' to untrack files."
- RM-03: `-n`/`--dry-run` -> warn: "not supported by Sapling remove. Use 'sl status' to see what would be removed."
- RM-04: `-q`/`--quiet` -> pass through (global flag)
- RM-05: `-r`/`--recursive` -> filter out (already done, sl remove is recursive by default)

**Implementation pattern for cmd_rm.py:**
```python
import sys
from common import ParsedCommand, run_sl

def handle(parsed: ParsedCommand) -> int:
    """
    Handle 'git rm' command.

    Translations:
    - git rm -f -> sl remove -f
    - git rm -q -> sl remove -q
    - git rm -r -> sl remove (recursive by default)

    Warnings:
    - --cached (no staging area)
    - -n/--dry-run (not supported)
    """
    sl_args = []
    remaining_args = []

    i = 0
    while i < len(parsed.args):
        arg = parsed.args[i]

        # Pass-through: -f/--force
        if arg in ('-f', '--force'):
            sl_args.append('-f')

        # Pass-through: -q/--quiet
        elif arg in ('-q', '--quiet'):
            sl_args.append('-q')

        # Filter out: -r/--recursive (sl remove is recursive by default)
        elif arg in ('-r', '--recursive'):
            pass  # Skip

        # Unsupported: --cached
        elif arg == '--cached':
            print("Warning: --cached not supported. Sapling has no staging area. "
                  "Use 'sl forget' to untrack files.", file=sys.stderr)

        # Unsupported: -n/--dry-run
        elif arg in ('-n', '--dry-run'):
            print("Warning: -n/--dry-run not supported by Sapling remove. "
                  "Use 'sl status' to see tracked files.", file=sys.stderr)

        else:
            remaining_args.append(arg)

        i += 1

    return run_sl(["remove"] + sl_args + remaining_args)
```

**Extend cmd_mv.py:**

- MV-01: `-f`/`--force` -> pass through
- MV-02: `-k` -> warn: "skip errors flag not supported by Sapling rename"
- MV-03: `-v`/`--verbose` -> pass through (global flag)
- MV-04: `-n`/`--dry-run` -> pass through

**Implementation pattern for cmd_mv.py:**
```python
import sys
from common import ParsedCommand, run_sl

def handle(parsed: ParsedCommand) -> int:
    """
    Handle 'git mv' command.

    Translations:
    - git mv -f -> sl rename -f
    - git mv -n -> sl rename -n
    - git mv -v -> sl rename -v

    Warnings:
    - -k (skip errors not supported)
    """
    sl_args = []
    remaining_args = []

    i = 0
    while i < len(parsed.args):
        arg = parsed.args[i]

        # Pass-through: -f/--force
        if arg in ('-f', '--force'):
            sl_args.append('-f')

        # Pass-through: -n/--dry-run
        elif arg in ('-n', '--dry-run'):
            sl_args.append('-n')

        # Pass-through: -v/--verbose
        elif arg in ('-v', '--verbose'):
            sl_args.append('-v')

        # Unsupported: -k (skip errors)
        elif arg == '-k':
            print("Warning: -k (skip errors) not supported by Sapling rename", file=sys.stderr)

        else:
            remaining_args.append(arg)

        i += 1

    return run_sl(["rename"] + sl_args + remaining_args)
```
  </action>
  <verify>
Run: `python -c "import cmd_rm; import cmd_mv; print('Import OK')"`
Verify both handlers have flag extraction loops.
  </verify>
  <done>
cmd_rm.py and cmd_mv.py handle all requirements:
- cmd_rm.py: -f pass-through, --cached warning, -n warning, -q pass-through, -r filtered
- cmd_mv.py: -f, -v, -n pass-through, -k warning
  </done>
</task>

<task type="auto">
  <name>Task 3: Extend cmd_clean.py and cmd_config.py with Flag Support</name>
  <files>cmd_clean.py, cmd_config.py</files>
  <action>
**Extend cmd_clean.py:**

Keep existing -f, -d, -n handling. Add:

- CLEN-01: `-x` -> `--ignored` (remove ignored files too)
- CLEN-02: `-X` -> warn: "removing ONLY ignored files not directly supported. Using --ignored which removes all untracked and ignored."
- CLEN-03: `-e <pattern>` -> `-X <pattern>` (exclude pattern - NOTE: git -e and sl -X both mean exclude)
- CLEN-04: Verify existing -f, -d, -n work correctly (already done)

Update the flag parsing loop to handle -x, -X, -e in addition to existing flags:

```python
# In the flag processing section, add:

# -x: remove ignored files too
if 'x' in arg and arg.startswith('-') and not arg.startswith('--'):
    sl_args.append('--ignored')
    # Remove 'x' from combined flags
    arg = arg.replace('x', '')

# -X: ONLY ignored files (warn - not directly supported)
if 'X' in arg and arg.startswith('-') and not arg.startswith('--'):
    print("Warning: -X (only ignored files) not directly supported. "
          "Using --ignored which removes untracked and ignored files.", file=sys.stderr)
    sl_args.append('--ignored')
    arg = arg.replace('X', '')

# Also handle -e <pattern>
elif arg == '-e':
    if i + 1 < len(parsed.args):
        i += 1
        sl_args.extend(['-X', parsed.args[i]])  # sl -X = exclude pattern
```

**Extend cmd_config.py:**

Current implementation handles --list/-l. Add:

- CONF-01: `--get` -> no special handling needed (sl config key returns value)
- CONF-02: `--unset` -> `--delete`
- CONF-03: `--list`/`-l` -> already implemented (sl config with no args)
- CONF-04: `--global` -> `--user`
- CONF-05: `--local` -> `--local` (pass through, already works)
- CONF-06: `--system` -> `--system` (pass through)
- CONF-07: `--show-origin` -> `--debug` (shows source file:line)
- CONF-08: `--all` -> warn: "multi-valued key retrieval not supported by Sapling config"

**Implementation pattern for cmd_config.py:**
```python
import sys
from common import ParsedCommand, run_sl

def handle(parsed: ParsedCommand) -> int:
    """
    Handle 'git config' command.

    Translations:
    - git config --global -> sl config --user
    - git config --unset -> sl config --delete
    - git config --show-origin -> sl config --debug
    - git config --list -> sl config (no args)

    Pass-through:
    - git config --local -> sl config --local
    - git config --system -> sl config --system

    Warnings:
    - --all (multi-valued keys not supported)
    """
    sl_args = []
    remaining_args = []
    is_list = False

    i = 0
    while i < len(parsed.args):
        arg = parsed.args[i]

        # --list/-l: sl config with no args shows all
        if arg in ('--list', '-l'):
            is_list = True

        # --get: no special handling, just pass key through
        elif arg == '--get':
            pass  # Skip the flag, key will be in remaining_args

        # --unset -> --delete
        elif arg == '--unset':
            sl_args.append('--delete')

        # --global -> --user
        elif arg == '--global':
            sl_args.append('--user')

        # --local: pass through
        elif arg == '--local':
            sl_args.append('--local')

        # --system: pass through
        elif arg == '--system':
            sl_args.append('--system')

        # --show-origin -> --debug
        elif arg == '--show-origin':
            sl_args.append('--debug')

        # --all: warn (multi-valued not supported)
        elif arg == '--all':
            print("Warning: --all (multi-valued key retrieval) not supported by Sapling config",
                  file=sys.stderr)

        else:
            remaining_args.append(arg)

        i += 1

    # Handle list mode
    if is_list:
        return run_sl(["config"] + sl_args)

    # Count positional args (non-flag args)
    positional = [a for a in remaining_args if not a.startswith('-')]

    # If setting a value (key and value present) and no scope specified
    if len(positional) >= 2:
        has_scope = any(a in sl_args for a in ('--user', '--local', '--system'))
        if not has_scope:
            sl_args.append('--local')

    return run_sl(["config"] + sl_args + remaining_args)
```
  </action>
  <verify>
Run: `python -c "import cmd_clean; import cmd_config; print('Import OK')"`
Verify both handlers have extended flag handling.
  </verify>
  <done>
cmd_clean.py and cmd_config.py handle all requirements:
- cmd_clean.py: -x -> --ignored, -X warning, -e -> -X exclude pattern
- cmd_config.py: --get no-op, --unset -> --delete, --global -> --user, --show-origin -> --debug, --all warning
  </done>
</task>

</tasks>

<verification>
1. cmd_clone.py handles all 9 CLON requirements (CLON-01 through CLON-09)
2. cmd_rm.py handles all 5 RM requirements (RM-01 through RM-05)
3. cmd_mv.py handles all 4 MV requirements (MV-01 through MV-04)
4. cmd_clean.py handles all 4 CLEN requirements (CLEN-01 through CLEN-04)
5. cmd_config.py handles all 8 CONF requirements (CONF-01 through CONF-08)
6. All handlers follow established flag extraction pattern from cmd_grep.py
7. Critical translations implemented:
   - git clone -b -> sl clone -u
   - git clone -n -> sl clone -U
   - git config --global -> sl config --user
   - git config --unset -> sl config --delete
   - git clean -x -> sl purge --ignored
8. Unsupported flags print helpful warnings to stderr
9. All handlers import correctly: `python -c "import cmd_clone, cmd_rm, cmd_mv, cmd_clean, cmd_config"`
</verification>

<success_criteria>
- [ ] cmd_clone.py extended with flag extraction loop (~60+ lines)
- [ ] cmd_rm.py extended with flag extraction loop (~40+ lines)
- [ ] cmd_mv.py extended with flag extraction loop (~40+ lines)
- [ ] cmd_clean.py extended with -x, -X, -e handling (~70+ lines)
- [ ] cmd_config.py extended with scope and action flags (~70+ lines)
- [ ] git clone -b correctly translates to sl clone -u
- [ ] git clone -n correctly translates to sl clone -U
- [ ] git config --global correctly translates to sl config --user
- [ ] git config --unset correctly translates to sl config --delete
- [ ] Unsupported flags print warnings (--depth, --cached, -k, -X, --all)
- [ ] All handlers import without errors
</success_criteria>

<output>
After completion, create `.planning/phases/28-clone-rm-mv-clean-config-flags/28-01-SUMMARY.md`
</output>
