codewhale.history 2.2.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codewhale.history",
3
- "version": "2.2.0",
3
+ "version": "2.4.0",
4
4
  "description": "CodeWhale utility commands: session history, tool listing, file snapshot — global install",
5
5
  "bin": {
6
6
  "codewhale-history": "./_list_sessions.js",
@@ -10,12 +10,31 @@ When the user types `//snapshot on`, `//snapshot off`, or `//snapshot status`, m
10
10
  ## Behavior
11
11
 
12
12
  ### `//snapshot on`
13
- 1. Check if `.git` exists in the workspace root via `Test-Path .git`.
14
- 2. **If Git repo exists**: reply "This workspace has a Git repo — snapshotting is not needed. Use `git restore <file>` to undo changes."
15
- 3. **If no Git repo**: create `_snapshots/` directory, write a note to persist `snapshot_enabled=true`, then confirm to the user.
16
- 4. From this point forward, before editing any **existing** file:
17
- - Run `Copy-Item <file> _snapshots/<relative-path>.<N>` (PowerShell)
18
- - Increment N per file (v1, v2, v3...)
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
25
+ $ts = Get-Date -Format 'yyyy-MM-dd_HH-mm-ss'
26
+ $base = [System.IO.Path]::GetFileNameWithoutExtension('<file>')
27
+ $ext = [System.IO.Path]::GetExtension('<file>')
28
+ Copy-Item '<file>' "_snapshots/$base.$ts$ext"
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
+ ```
37
+ - Result example: `foo.py` → `_snapshots/foo.2026-06-20_11-30-00.py`
19
38
  - Do NOT snapshot brand-new files being created for the first time
20
39
 
21
40
  ### `//snapshot off`