codewhale.history 2.1.0 → 2.3.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/README.md +5 -3
- package/instructions.md +3 -0
- package/package.json +2 -2
- package/skills/snapshot/SKILL.md +40 -0
- package/tools-install.js +6 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# CodeWhale Tools Pack
|
|
2
2
|
|
|
3
|
-
A portable pack of global CodeWhale commands: `//tools
|
|
3
|
+
A portable pack of global CodeWhale commands: `//tools`, `//history`, and `//snapshot`.
|
|
4
4
|
|
|
5
5
|
Cross-platform — works on Windows, Mac, Linux.
|
|
6
6
|
|
|
@@ -12,7 +12,8 @@ tools_for_codewhale/
|
|
|
12
12
|
├── package.json # npm package config
|
|
13
13
|
├── tools-install.js # Cross-platform installer (skills + instructions)
|
|
14
14
|
├── skills/
|
|
15
|
-
│ ├── history/SKILL.md
|
|
15
|
+
│ ├── history/SKILL.md # //history — calls codewhale-history
|
|
16
|
+
│ ├── snapshot/SKILL.md # //snapshot — pre-edit file backups
|
|
16
17
|
│ └── tools/tools-skill/SKILL.md # //tools — lists all available tools
|
|
17
18
|
├── instructions.md # Trigger config (drop into any .codewhale/)
|
|
18
19
|
└── README.md # This file
|
|
@@ -26,7 +27,7 @@ One command:
|
|
|
26
27
|
npm install -g codewhale.history && codewhale-tools-install
|
|
27
28
|
```
|
|
28
29
|
|
|
29
|
-
Then in any CodeWhale workspace, `//tools
|
|
30
|
+
Then in any CodeWhale workspace, `//tools`, `//history`, and `//snapshot` work immediately.
|
|
30
31
|
|
|
31
32
|
### Manual per-workspace install (if already globally installed)
|
|
32
33
|
|
|
@@ -38,6 +39,7 @@ codewhale-tools-install -p <target-path> # specific workspace
|
|
|
38
39
|
## After install
|
|
39
40
|
- **`//tools`** — lists every tool available in the current session
|
|
40
41
|
- **`//history`** — lists all chat sessions for the current workspace with cost totals
|
|
42
|
+
- **`//snapshot`** — toggle pre-edit file backups (`on`, `off`, `status`)
|
|
41
43
|
|
|
42
44
|
## Requirements
|
|
43
45
|
- Node.js (for the `codewhale-history` command)
|
package/instructions.md
CHANGED
|
@@ -5,3 +5,6 @@ When the user types `//tools`, immediately load the `tools` skill (from `tools-s
|
|
|
5
5
|
|
|
6
6
|
## //history Command
|
|
7
7
|
When the user types `//history`, immediately load the `history` skill (from `history/SKILL.md`) and list all CodeWhale chat sessions for the current workspace with message count, tokens, cost, and totals. This works in all sessions once the skill is installed globally.
|
|
8
|
+
|
|
9
|
+
## //snapshot Command
|
|
10
|
+
When the user types `//snapshot`, immediately load the `snapshot` skill (from `snapshot/SKILL.md`) and follow its instructions. `//snapshot on` enables automatic pre-edit file backups to `_snapshots/` when no Git repo is present. `//snapshot off` disables it. `//snapshot status` reports the current state. This works in all sessions once the skill is installed globally.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codewhale.history",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "CodeWhale utility commands: session history, tool listing — global install",
|
|
3
|
+
"version": "2.3.0",
|
|
4
|
+
"description": "CodeWhale utility commands: session history, tool listing, file snapshot — global install",
|
|
5
5
|
"bin": {
|
|
6
6
|
"codewhale-history": "./_list_sessions.js",
|
|
7
7
|
"codewhale-tools-install": "./tools-install.js"
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: snapshot
|
|
3
|
+
description: Toggle automatic pre-edit file snapshotting on or off. Triggered by //snapshot on and //snapshot off.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `//snapshot` Command
|
|
7
|
+
|
|
8
|
+
When the user types `//snapshot on`, `//snapshot off`, or `//snapshot status`, manage automatic file backup before edits.
|
|
9
|
+
|
|
10
|
+
## Behavior
|
|
11
|
+
|
|
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 the following PowerShell command to snapshot with a timestamp:
|
|
18
|
+
```
|
|
19
|
+
$ts = Get-Date -Format 'yyyy-MM-dd_HH-mm-ss'
|
|
20
|
+
$base = [System.IO.Path]::GetFileNameWithoutExtension('<file>')
|
|
21
|
+
$ext = [System.IO.Path]::GetExtension('<file>')
|
|
22
|
+
Copy-Item '<file>' "_snapshots/$base.$ts$ext"
|
|
23
|
+
```
|
|
24
|
+
- Result example: `foo.py` → `_snapshots/foo.2026-06-20_11-30-00.py`
|
|
25
|
+
- Do NOT snapshot brand-new files being created for the first time
|
|
26
|
+
|
|
27
|
+
### `//snapshot off`
|
|
28
|
+
1. Write a note to persist `snapshot_enabled=false`.
|
|
29
|
+
2. Reply "Snapshotting is now off. Existing snapshots in `_snapshots/` have been preserved."
|
|
30
|
+
3. Stop snapshotting before future edits.
|
|
31
|
+
|
|
32
|
+
### `//snapshot status`
|
|
33
|
+
1. Read the snapshot-enabled note.
|
|
34
|
+
2. Count files in `_snapshots/` (if directory exists).
|
|
35
|
+
3. Report: whether snapshotting is on/off, the snapshot directory exists, and file count.
|
|
36
|
+
|
|
37
|
+
## Notes
|
|
38
|
+
- The skill is installed globally — works in any workspace
|
|
39
|
+
- Snapshot state is session-scoped — does not persist across different CodeWhale sessions
|
|
40
|
+
- Use `//snapshot off` before switching to a Git-tracked project to avoid redundant copies
|
package/tools-install.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* CodeWhale Tools Installer
|
|
4
4
|
*
|
|
5
|
-
* Installs global skills and workspace triggers for //tools and //
|
|
5
|
+
* Installs global skills and workspace triggers for //tools, //history, and //snapshot.
|
|
6
6
|
*
|
|
7
7
|
* Usage:
|
|
8
8
|
* node tools-install.js # current directory
|
|
@@ -55,12 +55,12 @@ if (fs.existsSync(instructionsSource)) {
|
|
|
55
55
|
if (fs.existsSync(instructionsDest)) {
|
|
56
56
|
const existingContent = fs.readFileSync(instructionsDest, 'utf-8');
|
|
57
57
|
// Only append if it's not already there (idempotent)
|
|
58
|
-
if (!existingContent.includes('## //tools Command') && !existingContent.includes('## //history Command')) {
|
|
58
|
+
if (!existingContent.includes('## //tools Command') && !existingContent.includes('## //history Command') && !existingContent.includes('## //snapshot Command')) {
|
|
59
59
|
const separator = `\n\n---\n\n`;
|
|
60
60
|
fs.writeFileSync(instructionsDest, existingContent + separator + newContent, 'utf-8');
|
|
61
|
-
console.log(' Appended //tools and //
|
|
61
|
+
console.log(' Appended //tools, //history, and //snapshot instructions to existing instructions.md');
|
|
62
62
|
} else {
|
|
63
|
-
console.log(' //tools and //
|
|
63
|
+
console.log(' //tools, //history, and //snapshot already present in instructions.md — skipped.');
|
|
64
64
|
}
|
|
65
65
|
} else {
|
|
66
66
|
fs.writeFileSync(instructionsDest, newContent, 'utf-8');
|
|
@@ -77,6 +77,7 @@ let errors = 0;
|
|
|
77
77
|
const checklist = {
|
|
78
78
|
'history skill': path.join(skillsDest, 'history', 'SKILL.md'),
|
|
79
79
|
'tools skill': path.join(skillsDest, 'tools', 'tools-skill', 'SKILL.md'),
|
|
80
|
+
'snapshot skill': path.join(skillsDest, 'snapshot', 'SKILL.md'),
|
|
80
81
|
'workspace instructions': instructionsDest
|
|
81
82
|
};
|
|
82
83
|
|
|
@@ -93,7 +94,7 @@ console.log('');
|
|
|
93
94
|
if (errors === 0) {
|
|
94
95
|
console.log('=== Installation complete! ===');
|
|
95
96
|
console.log('Make sure codewhale-history is installed globally: npm install -g <path-to-tools_for_codewhale>');
|
|
96
|
-
console.log('Then type //tools or //
|
|
97
|
+
console.log('Then type //tools, //history, or //snapshot in any CodeWhale session.');
|
|
97
98
|
} else {
|
|
98
99
|
console.log(`=== Installation finished with ${errors} error(s). ===`);
|
|
99
100
|
}
|