codewhale.history 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/skills/snapshot/SKILL.md +19 -6
package/package.json
CHANGED
package/skills/snapshot/SKILL.md
CHANGED
|
@@ -10,17 +10,30 @@ When the user types `//snapshot on`, `//snapshot off`, or `//snapshot status`, m
|
|
|
10
10
|
## Behavior
|
|
11
11
|
|
|
12
12
|
### `//snapshot on`
|
|
13
|
-
1.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
-
|
|
18
|
-
|
|
13
|
+
1. Detect the platform from the shell environment:
|
|
14
|
+
- **Windows**: `$env:OS` contains `Windows_NT`, shell is `powershell.exe`
|
|
15
|
+
- **macOS/Linux**: detect by the absence of `$env:OS`, shell is typically `bash` or `zsh`
|
|
16
|
+
2. Check if `.git` exists in the workspace root:
|
|
17
|
+
- **Windows**: `if (Test-Path .git) { ... }`
|
|
18
|
+
- **macOS/Linux**: `if [ -d .git ]; then ...`
|
|
19
|
+
3. **If Git repo exists**: reply "This workspace has a Git repo — snapshotting is not needed. Use `git restore <file>` to undo changes."
|
|
20
|
+
4. **If no Git repo**: create `_snapshots/` directory, write a note to persist `snapshot_enabled=true`, then confirm to the user.
|
|
21
|
+
5. From this point forward, before editing any **existing** file:
|
|
22
|
+
- Snapshot the file using the appropriate command for the detected platform:
|
|
23
|
+
**Windows (PowerShell):**
|
|
24
|
+
```powershell
|
|
19
25
|
$ts = Get-Date -Format 'yyyy-MM-dd_HH-mm-ss'
|
|
20
26
|
$base = [System.IO.Path]::GetFileNameWithoutExtension('<file>')
|
|
21
27
|
$ext = [System.IO.Path]::GetExtension('<file>')
|
|
22
28
|
Copy-Item '<file>' "_snapshots/$base.$ts$ext"
|
|
23
29
|
```
|
|
30
|
+
**macOS/Linux (Bash):**
|
|
31
|
+
```bash
|
|
32
|
+
ts=$(date +%Y-%m-%d_%H-%M-%S)
|
|
33
|
+
base=$(basename "<file>" | sed 's/\.[^.]*$//')
|
|
34
|
+
ext=$(echo "<file>" | sed 's/.*\.//')
|
|
35
|
+
cp "<file>" "_snapshots/${base}.${ts}.${ext}"
|
|
36
|
+
```
|
|
24
37
|
- Result example: `foo.py` → `_snapshots/foo.2026-06-20_11-30-00.py`
|
|
25
38
|
- Do NOT snapshot brand-new files being created for the first time
|
|
26
39
|
|