version-history-widget 0.1.1 → 0.1.3
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 +14 -0
- package/package.json +3 -2
- package/skill/SKILL.md +57 -0
- package/vh.js +8 -1
- package/widget.js +2 -2
package/README.md
CHANGED
|
@@ -64,6 +64,20 @@ npx vh-singlefile list page.html [query]
|
|
|
64
64
|
Restoring is handled entirely in the browser by the injected widget — no
|
|
65
65
|
server needed.
|
|
66
66
|
|
|
67
|
+
## Claude Code skill
|
|
68
|
+
|
|
69
|
+
If you use Claude Code, this installs a skill so you can drive it with
|
|
70
|
+
`/version-history-widget` (or by just describing what you want) instead
|
|
71
|
+
of typing the CLI commands yourself:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npx version-history-widget skill
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
This copies a `SKILL.md` into `~/.claude/skills/version-history-widget/`
|
|
78
|
+
on your machine. It's per-machine — anyone else who wants the slash
|
|
79
|
+
command needs to run this once on their own machine too.
|
|
80
|
+
|
|
67
81
|
## How it works
|
|
68
82
|
|
|
69
83
|
- No runtime dependencies — only Node's built-in `fs`, `path`, `http`, and
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "version-history-widget",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Zero-dependency version history for web projects: snapshots every change and adds a floating widget to browse, search, and restore any version.",
|
|
5
5
|
"keywords": ["version history", "undo", "snapshot", "restore", "dev-tool", "widget"],
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"widget.js",
|
|
18
18
|
"middleware.js",
|
|
19
19
|
"serve.js",
|
|
20
|
-
"singlefile.js"
|
|
20
|
+
"singlefile.js",
|
|
21
|
+
"skill/SKILL.md"
|
|
21
22
|
],
|
|
22
23
|
"repository": {
|
|
23
24
|
"type": "git",
|
package/skill/SKILL.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: version-history-widget
|
|
3
|
+
description: Zero-dependency version history for web projects (the `vh` / version-history-widget CLI). Use when the user wants to save a checkpoint or snapshot of their site, record a titled version of recent changes, list past versions, or restore/roll back to an earlier version. Covers both project mode (multi-file sites, snapshots in .versions/) and single-file mode (one HTML file, snapshots embedded in the file).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Version History Widget
|
|
7
|
+
|
|
8
|
+
CLI for saving titled, restorable snapshots of a web project, plus a
|
|
9
|
+
floating "Versions" widget injected into the live site so anyone can
|
|
10
|
+
browse, search, and restore with one click. No runtime dependencies.
|
|
11
|
+
|
|
12
|
+
Two modes — pick based on what the user is working on:
|
|
13
|
+
|
|
14
|
+
- **Project mode**: a normal multi-file site/app. History lives in `.versions/`.
|
|
15
|
+
- **Single-file mode**: one standalone `.html` file. History lives inside that file.
|
|
16
|
+
|
|
17
|
+
## Project mode
|
|
18
|
+
|
|
19
|
+
Run these with Bash from the project root (`npx` needs no local install):
|
|
20
|
+
|
|
21
|
+
- First time only — sets up `.versions/`, injects the widget into the
|
|
22
|
+
site's entry HTML, saves version 1:
|
|
23
|
+
`npx version-history-widget init`
|
|
24
|
+
- After the user has made changes and wants a checkpoint:
|
|
25
|
+
`npx version-history-widget record "Title" -d "what changed and why"`
|
|
26
|
+
- List versions, optionally filtered by title/details text:
|
|
27
|
+
`npx version-history-widget list [query]`
|
|
28
|
+
- Restore an earlier version (this automatically snapshots the
|
|
29
|
+
current state first, so it's safe):
|
|
30
|
+
`npx version-history-widget restore <id>`
|
|
31
|
+
- To serve the site so the widget's in-browser restore button works:
|
|
32
|
+
`node .versions/serve.js` (or mount `.versions/middleware.js` in
|
|
33
|
+
their existing dev server — see `.versions/middleware.js`'s header
|
|
34
|
+
comment for Express/Vite examples).
|
|
35
|
+
|
|
36
|
+
If `.versions/` doesn't exist yet in the project, run `init` first.
|
|
37
|
+
|
|
38
|
+
## Single-file mode
|
|
39
|
+
|
|
40
|
+
Use when the user names one `.html` file rather than a project:
|
|
41
|
+
|
|
42
|
+
- Init: `npx -p version-history-widget vh-singlefile init page.html`
|
|
43
|
+
- Record: `npx -p version-history-widget vh-singlefile record page.html "Title" -d "details"`
|
|
44
|
+
- List: `npx -p version-history-widget vh-singlefile list page.html [query]`
|
|
45
|
+
|
|
46
|
+
Restoring in single-file mode happens entirely in the browser via the
|
|
47
|
+
widget embedded in the file — no server or CLI restore command needed.
|
|
48
|
+
|
|
49
|
+
## Notes
|
|
50
|
+
|
|
51
|
+
- If the user has it installed as a devDependency already
|
|
52
|
+
(`npm install --save-dev version-history-widget`), use `npx vh ...`
|
|
53
|
+
and `npx vh-singlefile ...` directly instead of the longer `-p` form.
|
|
54
|
+
- Always ask for or infer a short, human title when recording — it's
|
|
55
|
+
what shows up in the widget's list and search.
|
|
56
|
+
- Don't run `restore` without the user confirming which version id
|
|
57
|
+
they want — list versions first if it's ambiguous.
|
package/vh.js
CHANGED
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
node vh.js record "Title" [-d "details" | -f details.txt] — snapshot changed files as a new version
|
|
5
5
|
node vh.js restore <id> — snapshot current state, then restore version <id>
|
|
6
6
|
node vh.js list [query] — list versions (optionally filtered by title/details)
|
|
7
|
+
node vh.js skill — install the Claude Code skill (~/.claude/skills) so
|
|
8
|
+
/version-history-widget works in Claude Code sessions
|
|
7
9
|
Env: VH_ROOT (project root, default cwd) */
|
|
8
|
-
const fs = require('fs'), path = require('path');
|
|
10
|
+
const fs = require('fs'), path = require('path'), os = require('os');
|
|
9
11
|
const ROOT = path.resolve(process.env.VH_ROOT || process.cwd());
|
|
10
12
|
const VDIR = path.join(ROOT, '.versions'), SNAP = path.join(VDIR, 'snapshots'), MAN = path.join(VDIR, 'manifest.json');
|
|
11
13
|
const IGNORE = new Set(['node_modules', '.git', '.versions', 'dist', 'build', '.next', '.nuxt', 'coverage', '.cache']);
|
|
@@ -115,5 +117,10 @@ if (cmd === 'init') {
|
|
|
115
117
|
} else if (cmd === 'list') {
|
|
116
118
|
const q = (args[0] || '').toLowerCase();
|
|
117
119
|
for (const v of readMan()) if (!q || v.title.toLowerCase().includes(q) || (v.details || '').toLowerCase().includes(q)) console.log(String(v.id).padStart(3) + ' ' + v.time.slice(0, 16).replace('T', ' ') + ' ' + v.title);
|
|
120
|
+
} else if (cmd === 'skill') {
|
|
121
|
+
const dest = path.join(os.homedir(), '.claude', 'skills', 'version-history-widget');
|
|
122
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
123
|
+
fs.copyFileSync(path.join(__dirname, 'skill', 'SKILL.md'), path.join(dest, 'SKILL.md'));
|
|
124
|
+
console.log('Installed Claude Code skill to ' + dest + '. Restart Claude Code (or start a new session) and try /version-history-widget.');
|
|
118
125
|
} else { console.log(fs.readFileSync(__filename, 'utf8').split('*/')[0].split('\n').slice(1).join('\n')); }
|
|
119
126
|
module.exports = { restore: id => { const { execFileSync } = require('child_process'); return execFileSync(process.execPath, [__filename, 'restore', String(id)], { cwd: ROOT, env: process.env }).toString(); } };
|
package/widget.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
if (window.__vhLoaded) return; window.__vhLoaded = true;
|
|
4
4
|
var Z = 2147483647, MODE = document.getElementById('vh-store') ? 'single' : 'project';
|
|
5
5
|
var css = '\
|
|
6
|
-
.vh-pill{position:fixed;right:16px;
|
|
7
|
-
.vh-panel{position:fixed;right:16px;
|
|
6
|
+
.vh-pill{position:fixed;right:16px;top:16px;z-index:' + Z + ';font:13px/1 system-ui,sans-serif;background:#111;color:#fff;border:0;border-radius:999px;padding:10px 14px;cursor:pointer;box-shadow:0 6px 20px rgba(0,0,0,.35)}\
|
|
7
|
+
.vh-panel{position:fixed;right:16px;top:56px;width:440px;max-width:calc(100vw - 32px);max-height:70vh;z-index:' + Z + ';background:#fff;color:#111;border:1px solid #ddd;border-radius:12px;box-shadow:0 12px 40px rgba(0,0,0,.35);font:13px/1.4 system-ui,sans-serif;display:flex;flex-direction:column;overflow:hidden}\
|
|
8
8
|
.vh-head{display:flex;gap:8px;padding:10px;border-bottom:1px solid #eee;align-items:center}\
|
|
9
9
|
.vh-search{flex:1;padding:8px 10px;border:1px solid #ccc;border-radius:8px;font:inherit;outline:none}.vh-search:focus{border-color:#111}\
|
|
10
10
|
.vh-clear{border:0;background:#eee;border-radius:6px;padding:6px 8px;cursor:pointer}\
|