afterimage-cli 0.1.0 → 0.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0
4
+
5
+ - **The pill.** Afterimage now sits on the prototype itself. Save keeps the current state as the next version, and History opens every version over the page, in the same tab; Esc or the close button returns to the prototype. On a deployed site the same pill shows everyone the versions, without Save. It draws in a shadow root, so the app's CSS can't reach it, and it stays out of saved versions.
6
+ - **`init` adds the pill and wires `npm run dev`.** A plain HTML page gets one script tag, and a Vite app's `index.html` one import. For Next.js, Astro and SvelteKit it prints the one import to add. The `dev` script now starts Afterimage beside the app (`vite` becomes `afterimage dev -- vite`), and a plain HTML folder gets a `dev` script that serves it. Run `npx afterimage init` again on a project set up with 0.1.
7
+ - **`afterimage dev -- <your dev command>`** runs the app's own dev server with Afterimage beside it and stops when it stops. With no dev command, a plain HTML prototype is served at `/`. dev now starts before the first save, answers the pill's save on this machine only, and keeps its served copy outside the project, so a dev server watching the project can't stop it updating after a save on Windows.
8
+ - **The viewer closes itself when it is opened in the pill's layer**: Esc with nothing else open returns to the prototype.
9
+ - **The agent instructions** cover "add Afterimage so I can track my versions" from start to finish, and tell the agent to answer in a line instead of handing back commands.
10
+
11
+ ## 0.1.1
12
+
13
+ - **`init` keeps Next.js's long cache on the live app.** For a project that depends on `next`, `vercel.json` gets a header rule and a new `netlify.toml` a `[[headers]]` block that serve `/_next/static/` with `public, max-age=31536000, immutable`. The host settings Afterimage needs for Next.js turn off each host's own Next.js handling, which set that header, and real deploys of 0.1.0 showed those files served with `max-age=0`. Run `npx afterimage init` again to add it to a project set up with 0.1.0; for an existing `netlify.toml` it prints the lines to add.
14
+ - **`afterimage dev` passes over a port Windows refuses.** Windows reserves port ranges for Hyper-V, WSL and Docker and refuses them with a permission error, which stopped `dev` instead of moving it to the next port, as a taken port does.
15
+
3
16
  ## 0.1.0
4
17
 
5
18
  The first release.
package/README.md CHANGED
@@ -17,7 +17,7 @@ npx afterimage init
17
17
 
18
18
  A plain HTML folder with no `package.json` needs `npm init -y` first.
19
19
 
20
- `init` works out what your prototype is: a plain HTML folder, a Vite app, a Next.js static export, an Astro site, or SvelteKit with `@sveltejs/adapter-static`. It writes `afterimage.config.json`, three scripts in `package.json`, lines in `.gitattributes` and `.gitignore`, and host config for Vercel and Netlify, then lists every file it changed. When it can't tell which folder holds the prototype, it asks. You can also tell it:
20
+ `init` works out what your prototype is: a plain HTML folder, a Vite app, a Next.js static export, an Astro site, or SvelteKit with `@sveltejs/adapter-static`. It puts the Afterimage pill on your prototype and makes `npm run dev` start Afterimage beside your app. It also writes `afterimage.config.json`, lines in `.gitattributes` and `.gitignore`, and host config for Vercel and Netlify, then lists every file it changed. For Next.js, Astro and SvelteKit it prints the one import that adds the pill. When it can't tell which folder holds the prototype, it asks. You can also tell it:
21
21
 
22
22
  ```bash
23
23
  npx afterimage init --source dist --build "npm run build"
@@ -25,26 +25,28 @@ npx afterimage init --source dist --build "npm run build"
25
25
 
26
26
  ## Setup prompt
27
27
 
28
- Working with Claude Code, Cursor or another coding agent? Paste the setup prompt from [docs/agents.md](docs/agents.md) instead. It installs Afterimage and runs `init` with `--agent claude` or `--agent cursor`, which copies Afterimage's instructions into the project, where your agent reads them. It also passes `--no-input`, so init never waits on a question. Then it saves a first version and gives you the viewer's link. After that, "save a version called Remember me" works in plain words.
28
+ Working with Claude Code, Cursor or another coding agent? Paste the setup prompt from [docs/agents.md](docs/agents.md) instead. It starts with "Add Afterimage so I can track this prototype's versions." The agent installs Afterimage, puts the pill on your prototype, saves a first version and starts your dev server with Afterimage beside it. It also copies Afterimage's instructions into the project, so "save a version called Remember me" works in plain words later.
29
29
 
30
30
  ## Usage
31
31
 
32
- Save a version whenever the prototype is worth keeping:
32
+ Run your prototype:
33
33
 
34
34
  ```bash
35
- npx afterimage save "First version"
36
- npx afterimage save "Remember me" --note "Keeps people signed in for 30 days."
35
+ npm run dev
37
36
  ```
38
37
 
39
- A save runs your build first when the prototype has one, then stores the result as the next version: v1, v2, v3. If nothing changed since the last version, nothing is saved.
38
+ The pill sits at the bottom right of the page. Save keeps the current state as the next version. History opens every version over the page, with what changed between any two, and Esc closes it. Once you deploy, the same pill on the live site shows everyone the versions, without Save.
40
39
 
41
- Open the history while you work:
40
+ You can also save from the command line, or have your agent do it:
42
41
 
43
42
  ```bash
44
- npx afterimage dev
43
+ npx afterimage save "First version"
44
+ npx afterimage save "Remember me" --note "Keeps people signed in for 30 days."
45
45
  ```
46
46
 
47
- It prints the viewer's address, `http://localhost:4321/afterimage/` unless that port is busy. Your app keeps running on its own dev server. In the viewer, `[` and `]` step through versions, `H` highlights what changed, `C` compares two versions, and `?` lists every shortcut.
47
+ A save runs your build first when the prototype has one, then stores the result as the next version: v1, v2, v3. If nothing changed since the last version, nothing is saved.
48
+
49
+ `npm run dev` also prints the history's own address, `http://localhost:4321/afterimage/` unless that port is busy. In the viewer, `[` and `]` step through versions, `H` highlights what changed, `C` compares two versions, and `?` lists every shortcut.
48
50
 
49
51
  Commit `afterimage/` with the rest of the project, along with `afterimage.config.json`, `package.json` and your lockfile, `.gitattributes`, and `vercel.json` or `netlify.toml`. `afterimage/` holds every saved version, and a fresh checkout can't get back a version that isn't in git. `.gitattributes` stops git from changing a saved version's line endings, which would break its fingerprint on another machine.
50
52
 
@@ -1,11 +1,25 @@
1
1
  ---
2
- description: Saves, names, compares and deploys versions of this prototype in its Afterimage history (afterimage-cli). Use when the user asks to save or name a version of the prototype, add a note to one, see what changed between versions, open the version history, or get the history ready to deploy. Not for git commits, branches or package versions.
2
+ description: Adds Afterimage (afterimage-cli) to this prototype and saves, names, compares and deploys versions in its history. Use when the user asks to add Afterimage or track versions, save or name a version of the prototype, add a note to one, see what changed between versions, open the version history, or get the history ready to deploy. Not for git commits, branches or package versions.
3
3
  alwaysApply: false
4
4
  ---
5
5
 
6
6
  # Afterimage
7
7
 
8
- Afterimage keeps a version history of this prototype. Each save builds the prototype and stores the built page as the next version (v1, v2, v3 and so on) in `afterimage/`. The viewer shows any saved version, and what changed between two of them. A version is the built page, kept to compare against and to share. It is not a backup of the source: the source belongs in git. Run every command from the project root, where `afterimage.config.json` is.
8
+ Afterimage keeps a version history of this prototype. Each save builds the prototype and stores the built page as the next version (v1, v2, v3 and so on) in `afterimage/`. A pill sits on the running prototype: Save keeps the current state as the next version, and History opens every version over the page, with what changed between any two. On the deployed site the same pill shows the history to everyone who opens it. A version is the built page, kept to compare against and to share. It is not a backup of the source: the source belongs in git. Run every command from the project root, where `afterimage.config.json` is.
9
+
10
+ The user works on the prototype, not in a terminal. Do the steps yourself and reply in a line or two, with a link when there is one. Never hand the user a command to run.
11
+
12
+ ## Add Afterimage
13
+
14
+ When the user asks to add Afterimage, or to track the prototype's versions, do all of this:
15
+
16
+ 1. If the project has no `package.json`, run `npm init -y`.
17
+ 2. Unless `package.json` already lists it, run `npm install --save-dev afterimage-cli`.
18
+ 3. Run `npx afterimage init --agent claude --no-input` if you are Claude Code, or `npx afterimage init --agent cursor --no-input` if you are Cursor. Handle what it prints as "Set up" below says.
19
+ 4. Init puts the pill on plain HTML pages and in a Vite app's `index.html` itself. For Next.js, Astro and SvelteKit it prints a note that starts with `Add the Afterimage pill to your app`. Make that change yourself, exactly as the note says.
20
+ 5. Unless `afterimage/versions.json` already lists a version, run `npx afterimage save "First version"`.
21
+ 6. Start `npm run dev` as a background process. If you started the project's dev server earlier in this session, stop that one first: this is the same server, with Afterimage beside it. Wait for the line that starts with `Afterimage is running at`.
22
+ 7. Tell the user where the prototype is running and that the pill at its bottom right saves a version and shows them all. The address is the app dev server's own (such as Vite's `Local:` line), or the one after `Your prototype is at` for plain HTML.
9
23
 
10
24
  ## Commands
11
25
 
@@ -15,23 +29,25 @@ Afterimage keeps a version history of this prototype. Each save builds the proto
15
29
  npx afterimage save "Remember me" --note "Keeps people signed in for 30 days."
16
30
  ```
17
31
 
18
- - It runs the prototype's build first when `afterimage.config.json` has one, then saves the result.
32
+ - It runs the prototype's build first when `afterimage.config.json` has one, then saves the result. The pill's Save button does the same.
19
33
  - The name goes in quotes, up to 120 characters. `--note` is optional and can be repeated, one note each, up to 500 characters.
20
34
  - Keep names and notes to plain text. A `"`, `$` or backtick inside them breaks the shell's quoting, so leave those out or escape them for the shell you are in.
21
- - On success it prints `Saved v4 "Remember me".` and the version's size. Tell the user the id it printed. If it says the history is over 100 MB, pass that line on too.
35
+ - On success it prints `Saved v4 "Remember me".` and the version's size. Tell the user the id in one line, such as "Saved v4, Remember me." If it says the history is over 100 MB, pass that line on too.
22
36
  - `Nothing changed since v3 "Passkeys". Nothing was saved.` means the prototype is the same as the last saved version. Tell the user and stop there.
37
+ - While dev runs, a save made here shows up in the pill and the history on their own.
23
38
 
24
- ### Open the history
39
+ ### Run the prototype with the pill
25
40
 
26
41
  ```bash
27
- npx afterimage dev
42
+ npm run dev
28
43
  ```
29
44
 
45
+ - Init makes the project's `dev` script start Afterimage beside the app: `vite` becomes `afterimage dev -- vite`, which runs both and stops both. A plain HTML folder with no dev script gets `afterimage dev`, which serves the folder itself.
46
+ - If the `dev` script doesn't start with `afterimage dev`, run the app's own dev command through it instead, such as `npx afterimage dev -- next dev`.
30
47
  - It keeps running until it is stopped. Start it as a background process, not a command you wait for.
31
- - It prints `Afterimage is running at http://localhost:4321/afterimage/`. The port starts at 4321 and moves to the next free one when 4321 is busy, so give the user the URL it printed.
32
- - If dev is already running from earlier, use the URL it printed then. When a save finishes, it rebuilds the history it serves and prints `Updated: N versions.` If that rebuild fails, it prints `Could not update the history` and keeps serving the last good copy.
33
- - It serves the saved versions only. The app keeps running on its own dev server.
34
- - It checks the history when it starts. With no saved versions it stops with `Save a first version with: afterimage save "Name"`.
48
+ - It prints `Afterimage is running at http://localhost:4321/afterimage/`, the history's own address. The port starts at 4321 and moves to the next free one when 4321 is busy, so use the URL it printed. With plain HTML it also prints `Your prototype is at` and the prototype's address.
49
+ - If dev is already running from earlier, use the URLs it printed then. When a save finishes, it rebuilds the history it serves and prints `Updated: N versions.` If that rebuild fails, it prints `Could not update the history` and keeps serving the last good copy.
50
+ - It starts with no saved versions too. Then the pill offers to save the first one.
35
51
 
36
52
  ### Build the deployable site
37
53
 
@@ -42,6 +58,7 @@ npx afterimage build
42
58
  - It runs the prototype's build, then writes `.afterimage/site/`: the app at the root and the history at `/afterimage/`. That folder is git-ignored.
43
59
  - With no saved versions it stops with `Save a first version with: afterimage save "Name"`.
44
60
  - The host runs the same build when it deploys: `vercel.json` and `netlify.toml` run `npm run afterimage:build` and serve `.afterimage/site`.
61
+ - On the deployed site the pill shows the versions and opens the history. It has no Save there.
45
62
 
46
63
  ### Set up
47
64
 
@@ -49,16 +66,16 @@ npx afterimage build
49
66
  npx afterimage init --agent claude --no-input
50
67
  ```
51
68
 
52
- - It writes `afterimage.config.json`, the `afterimage:save`, `afterimage:dev` and `afterimage:build` scripts in `package.json`, lines in `.gitattributes` and `.gitignore`, `vercel.json` and `netlify.toml`. Running it again is safe.
69
+ - It writes `afterimage.config.json`, the `afterimage:save`, `afterimage:dev` and `afterimage:build` scripts and a `dev` script that starts Afterimage beside the app in `package.json`, the pill's line in the prototype's pages, lines in `.gitattributes` and `.gitignore`, `vercel.json` and `netlify.toml`. Running it again is safe.
53
70
  - `--agent claude` copies these instructions as a Claude Code skill to `.claude/skills/afterimage/`. `--agent cursor` copies them as a Cursor rule to `.cursor/rules/afterimage.mdc`. Pass the one for the agent you are.
54
71
  - `--no-input` makes sure it never waits on a question. Where it would have asked, it stops with a message or prints a note instead.
55
72
  - If its message contains `no static build`, the project has no static build to save: Next.js without `output: 'export'`, Astro with an adapter but without `output: 'static'`, or SvelteKit without `@sveltejs/adapter-static`. Tell the user what has to change, and stop. Don't pass `--source` to get around it. Once the user has made the change, run init again.
56
73
  - Otherwise, if it stops with `Say where the prototype is`, it can't tell which folder holds the prototype. Ask the user which folder it is. Never guess. Then run init again with the same flags plus `--source <folder>`, and add `--build "<command>"` when a build command writes that folder.
57
- - Anything it prints after the list of files, such as a note about an existing `vercel.json`, is for the user. Pass it on.
74
+ - A note that starts with `Add the Afterimage pill to your app` is yours to do. Pass any other note it prints after the list of files, such as one about an existing `vercel.json`, on to the user.
58
75
 
59
76
  ## Links into the viewer
60
77
 
61
- Add these to the URL dev printed:
78
+ Add these to the URL that follows `Afterimage is running at`:
62
79
 
63
80
  - `?version=v3` opens one version.
64
81
  - `?version=v4&mode=compare&base=v2` compares v4 with the older v2.
@@ -68,12 +85,13 @@ With dev on its default port, a comparison is `http://localhost:4321/afterimage/
68
85
 
69
86
  `afterimage/versions.json` lists the versions newest first, so the first `id` in it is the latest. An id that isn't in the history opens the latest version instead, so check an id is listed before you link to it.
70
87
 
71
- ## What people ask, and what to run
88
+ ## What people ask, and what to do
72
89
 
73
- - **"Save a version called Remember me with a note that it keeps people signed in for 30 days."** Run `npx afterimage save "Remember me" --note "Keeps people signed in for 30 days."` and tell the user the id it printed.
74
- - **"What changed since v2?"** Read `afterimage/versions.json`. If v2 is the latest version, tell the user nothing has changed since v2, because it is the newest version, and don't open a comparison. If v2 isn't listed, say so. Otherwise make sure dev is running and give the user the URL dev printed with `?version=<latest>&mode=compare&base=v2` added. The viewer shows the changes, so don't write a text diff. It compares saved versions: if the prototype has changed since the last save, say that those changes aren't in the comparison.
75
- - **"Get the version history ready to deploy."** Run `npx afterimage build`. If the project isn't a git repository, tell the user the history has to be committed to the repository the site deploys from, and stop. Otherwise run `git status --short -- afterimage afterimage.config.json package.json package-lock.json pnpm-lock.yaml yarn.lock bun.lock bun.lockb .gitattributes vercel.json netlify.toml` and tell the user which of those aren't committed yet, since the host only sees what is in git. The rest of the project is the user's business. Tell them the site is in `.afterimage/site/` and the history will be at `/afterimage/` on the deployed site. Don't commit, push or deploy unless the user asks.
76
- - **"Show me the version history."** Start dev and give the user the URL it printed.
90
+ - **"Add Afterimage so I can track my versions."** Do everything in "Add Afterimage" above, then tell the user the prototype's address and that the pill on it saves versions and shows them all.
91
+ - **"Save a version called Remember me with a note that it keeps people signed in for 30 days."** Run `npx afterimage save "Remember me" --note "Keeps people signed in for 30 days."` and tell the user the id it printed, in one line.
92
+ - **"What changed since v2?"** Read `afterimage/versions.json`. If v2 is the latest version, tell the user nothing has changed since v2, because it is the newest version, and don't open a comparison. If v2 isn't listed, say so. Otherwise make sure dev is running and give the user the history's URL with `?version=<latest>&mode=compare&base=v2` added. The viewer shows the changes, so don't write a text diff. It compares saved versions: if the prototype has changed since the last save, say that those changes aren't in the comparison.
93
+ - **"Get the version history ready to deploy."** Run `npx afterimage build`. If the project isn't a git repository, tell the user the history has to be committed to the repository the site deploys from, and stop. Otherwise run `git status --short -- afterimage afterimage.config.json package.json package-lock.json pnpm-lock.yaml yarn.lock bun.lock bun.lockb .gitattributes vercel.json netlify.toml` and tell the user which of those aren't committed yet, since the host only sees what is in git. The rest of the project is the user's business. Tell them the history will be at `/afterimage/` on the deployed site, behind the same pill. Don't commit, push or deploy unless the user asks.
94
+ - **"Show me the version history."** Make sure dev is running, then tell the user to press History on the pill, and give them the history's URL too.
77
95
 
78
96
  ## Rules
79
97
 
@@ -1,11 +1,25 @@
1
1
  ---
2
2
  name: afterimage
3
- description: Saves, names, compares and deploys versions of this prototype in its Afterimage history (afterimage-cli). Use when the user asks to save or name a version of the prototype, add a note to one, see what changed between versions, open the version history, or get the history ready to deploy. Not for git commits, branches or package versions.
3
+ description: Adds Afterimage (afterimage-cli) to this prototype and saves, names, compares and deploys versions in its history. Use when the user asks to add Afterimage or track versions, save or name a version of the prototype, add a note to one, see what changed between versions, open the version history, or get the history ready to deploy. Not for git commits, branches or package versions.
4
4
  ---
5
5
 
6
6
  # Afterimage
7
7
 
8
- Afterimage keeps a version history of this prototype. Each save builds the prototype and stores the built page as the next version (v1, v2, v3 and so on) in `afterimage/`. The viewer shows any saved version, and what changed between two of them. A version is the built page, kept to compare against and to share. It is not a backup of the source: the source belongs in git. Run every command from the project root, where `afterimage.config.json` is.
8
+ Afterimage keeps a version history of this prototype. Each save builds the prototype and stores the built page as the next version (v1, v2, v3 and so on) in `afterimage/`. A pill sits on the running prototype: Save keeps the current state as the next version, and History opens every version over the page, with what changed between any two. On the deployed site the same pill shows the history to everyone who opens it. A version is the built page, kept to compare against and to share. It is not a backup of the source: the source belongs in git. Run every command from the project root, where `afterimage.config.json` is.
9
+
10
+ The user works on the prototype, not in a terminal. Do the steps yourself and reply in a line or two, with a link when there is one. Never hand the user a command to run.
11
+
12
+ ## Add Afterimage
13
+
14
+ When the user asks to add Afterimage, or to track the prototype's versions, do all of this:
15
+
16
+ 1. If the project has no `package.json`, run `npm init -y`.
17
+ 2. Unless `package.json` already lists it, run `npm install --save-dev afterimage-cli`.
18
+ 3. Run `npx afterimage init --agent claude --no-input` if you are Claude Code, or `npx afterimage init --agent cursor --no-input` if you are Cursor. Handle what it prints as "Set up" below says.
19
+ 4. Init puts the pill on plain HTML pages and in a Vite app's `index.html` itself. For Next.js, Astro and SvelteKit it prints a note that starts with `Add the Afterimage pill to your app`. Make that change yourself, exactly as the note says.
20
+ 5. Unless `afterimage/versions.json` already lists a version, run `npx afterimage save "First version"`.
21
+ 6. Start `npm run dev` as a background process. If you started the project's dev server earlier in this session, stop that one first: this is the same server, with Afterimage beside it. Wait for the line that starts with `Afterimage is running at`.
22
+ 7. Tell the user where the prototype is running and that the pill at its bottom right saves a version and shows them all. The address is the app dev server's own (such as Vite's `Local:` line), or the one after `Your prototype is at` for plain HTML.
9
23
 
10
24
  ## Commands
11
25
 
@@ -15,23 +29,25 @@ Afterimage keeps a version history of this prototype. Each save builds the proto
15
29
  npx afterimage save "Remember me" --note "Keeps people signed in for 30 days."
16
30
  ```
17
31
 
18
- - It runs the prototype's build first when `afterimage.config.json` has one, then saves the result.
32
+ - It runs the prototype's build first when `afterimage.config.json` has one, then saves the result. The pill's Save button does the same.
19
33
  - The name goes in quotes, up to 120 characters. `--note` is optional and can be repeated, one note each, up to 500 characters.
20
34
  - Keep names and notes to plain text. A `"`, `$` or backtick inside them breaks the shell's quoting, so leave those out or escape them for the shell you are in.
21
- - On success it prints `Saved v4 "Remember me".` and the version's size. Tell the user the id it printed. If it says the history is over 100 MB, pass that line on too.
35
+ - On success it prints `Saved v4 "Remember me".` and the version's size. Tell the user the id in one line, such as "Saved v4, Remember me." If it says the history is over 100 MB, pass that line on too.
22
36
  - `Nothing changed since v3 "Passkeys". Nothing was saved.` means the prototype is the same as the last saved version. Tell the user and stop there.
37
+ - While dev runs, a save made here shows up in the pill and the history on their own.
23
38
 
24
- ### Open the history
39
+ ### Run the prototype with the pill
25
40
 
26
41
  ```bash
27
- npx afterimage dev
42
+ npm run dev
28
43
  ```
29
44
 
45
+ - Init makes the project's `dev` script start Afterimage beside the app: `vite` becomes `afterimage dev -- vite`, which runs both and stops both. A plain HTML folder with no dev script gets `afterimage dev`, which serves the folder itself.
46
+ - If the `dev` script doesn't start with `afterimage dev`, run the app's own dev command through it instead, such as `npx afterimage dev -- next dev`.
30
47
  - It keeps running until it is stopped. Start it as a background process, not a command you wait for.
31
- - It prints `Afterimage is running at http://localhost:4321/afterimage/`. The port starts at 4321 and moves to the next free one when 4321 is busy, so give the user the URL it printed.
32
- - If dev is already running from earlier, use the URL it printed then. When a save finishes, it rebuilds the history it serves and prints `Updated: N versions.` If that rebuild fails, it prints `Could not update the history` and keeps serving the last good copy.
33
- - It serves the saved versions only. The app keeps running on its own dev server.
34
- - It checks the history when it starts. With no saved versions it stops with `Save a first version with: afterimage save "Name"`.
48
+ - It prints `Afterimage is running at http://localhost:4321/afterimage/`, the history's own address. The port starts at 4321 and moves to the next free one when 4321 is busy, so use the URL it printed. With plain HTML it also prints `Your prototype is at` and the prototype's address.
49
+ - If dev is already running from earlier, use the URLs it printed then. When a save finishes, it rebuilds the history it serves and prints `Updated: N versions.` If that rebuild fails, it prints `Could not update the history` and keeps serving the last good copy.
50
+ - It starts with no saved versions too. Then the pill offers to save the first one.
35
51
 
36
52
  ### Build the deployable site
37
53
 
@@ -42,6 +58,7 @@ npx afterimage build
42
58
  - It runs the prototype's build, then writes `.afterimage/site/`: the app at the root and the history at `/afterimage/`. That folder is git-ignored.
43
59
  - With no saved versions it stops with `Save a first version with: afterimage save "Name"`.
44
60
  - The host runs the same build when it deploys: `vercel.json` and `netlify.toml` run `npm run afterimage:build` and serve `.afterimage/site`.
61
+ - On the deployed site the pill shows the versions and opens the history. It has no Save there.
45
62
 
46
63
  ### Set up
47
64
 
@@ -49,16 +66,16 @@ npx afterimage build
49
66
  npx afterimage init --agent claude --no-input
50
67
  ```
51
68
 
52
- - It writes `afterimage.config.json`, the `afterimage:save`, `afterimage:dev` and `afterimage:build` scripts in `package.json`, lines in `.gitattributes` and `.gitignore`, `vercel.json` and `netlify.toml`. Running it again is safe.
69
+ - It writes `afterimage.config.json`, the `afterimage:save`, `afterimage:dev` and `afterimage:build` scripts and a `dev` script that starts Afterimage beside the app in `package.json`, the pill's line in the prototype's pages, lines in `.gitattributes` and `.gitignore`, `vercel.json` and `netlify.toml`. Running it again is safe.
53
70
  - `--agent claude` copies these instructions as a Claude Code skill to `.claude/skills/afterimage/`. `--agent cursor` copies them as a Cursor rule to `.cursor/rules/afterimage.mdc`. Pass the one for the agent you are.
54
71
  - `--no-input` makes sure it never waits on a question. Where it would have asked, it stops with a message or prints a note instead.
55
72
  - If its message contains `no static build`, the project has no static build to save: Next.js without `output: 'export'`, Astro with an adapter but without `output: 'static'`, or SvelteKit without `@sveltejs/adapter-static`. Tell the user what has to change, and stop. Don't pass `--source` to get around it. Once the user has made the change, run init again.
56
73
  - Otherwise, if it stops with `Say where the prototype is`, it can't tell which folder holds the prototype. Ask the user which folder it is. Never guess. Then run init again with the same flags plus `--source <folder>`, and add `--build "<command>"` when a build command writes that folder.
57
- - Anything it prints after the list of files, such as a note about an existing `vercel.json`, is for the user. Pass it on.
74
+ - A note that starts with `Add the Afterimage pill to your app` is yours to do. Pass any other note it prints after the list of files, such as one about an existing `vercel.json`, on to the user.
58
75
 
59
76
  ## Links into the viewer
60
77
 
61
- Add these to the URL dev printed:
78
+ Add these to the URL that follows `Afterimage is running at`:
62
79
 
63
80
  - `?version=v3` opens one version.
64
81
  - `?version=v4&mode=compare&base=v2` compares v4 with the older v2.
@@ -68,12 +85,13 @@ With dev on its default port, a comparison is `http://localhost:4321/afterimage/
68
85
 
69
86
  `afterimage/versions.json` lists the versions newest first, so the first `id` in it is the latest. An id that isn't in the history opens the latest version instead, so check an id is listed before you link to it.
70
87
 
71
- ## What people ask, and what to run
88
+ ## What people ask, and what to do
72
89
 
73
- - **"Save a version called Remember me with a note that it keeps people signed in for 30 days."** Run `npx afterimage save "Remember me" --note "Keeps people signed in for 30 days."` and tell the user the id it printed.
74
- - **"What changed since v2?"** Read `afterimage/versions.json`. If v2 is the latest version, tell the user nothing has changed since v2, because it is the newest version, and don't open a comparison. If v2 isn't listed, say so. Otherwise make sure dev is running and give the user the URL dev printed with `?version=<latest>&mode=compare&base=v2` added. The viewer shows the changes, so don't write a text diff. It compares saved versions: if the prototype has changed since the last save, say that those changes aren't in the comparison.
75
- - **"Get the version history ready to deploy."** Run `npx afterimage build`. If the project isn't a git repository, tell the user the history has to be committed to the repository the site deploys from, and stop. Otherwise run `git status --short -- afterimage afterimage.config.json package.json package-lock.json pnpm-lock.yaml yarn.lock bun.lock bun.lockb .gitattributes vercel.json netlify.toml` and tell the user which of those aren't committed yet, since the host only sees what is in git. The rest of the project is the user's business. Tell them the site is in `.afterimage/site/` and the history will be at `/afterimage/` on the deployed site. Don't commit, push or deploy unless the user asks.
76
- - **"Show me the version history."** Start dev and give the user the URL it printed.
90
+ - **"Add Afterimage so I can track my versions."** Do everything in "Add Afterimage" above, then tell the user the prototype's address and that the pill on it saves versions and shows them all.
91
+ - **"Save a version called Remember me with a note that it keeps people signed in for 30 days."** Run `npx afterimage save "Remember me" --note "Keeps people signed in for 30 days."` and tell the user the id it printed, in one line.
92
+ - **"What changed since v2?"** Read `afterimage/versions.json`. If v2 is the latest version, tell the user nothing has changed since v2, because it is the newest version, and don't open a comparison. If v2 isn't listed, say so. Otherwise make sure dev is running and give the user the history's URL with `?version=<latest>&mode=compare&base=v2` added. The viewer shows the changes, so don't write a text diff. It compares saved versions: if the prototype has changed since the last save, say that those changes aren't in the comparison.
93
+ - **"Get the version history ready to deploy."** Run `npx afterimage build`. If the project isn't a git repository, tell the user the history has to be committed to the repository the site deploys from, and stop. Otherwise run `git status --short -- afterimage afterimage.config.json package.json package-lock.json pnpm-lock.yaml yarn.lock bun.lock bun.lockb .gitattributes vercel.json netlify.toml` and tell the user which of those aren't committed yet, since the host only sees what is in git. The rest of the project is the user's business. Tell them the history will be at `/afterimage/` on the deployed site, behind the same pill. Don't commit, push or deploy unless the user asks.
94
+ - **"Show me the version history."** Make sure dev is running, then tell the user to press History on the pill, and give them the history's URL too.
77
95
 
78
96
  ## Rules
79
97
 
package/package.json CHANGED
@@ -1,61 +1,65 @@
1
- {
2
- "name": "afterimage-cli",
3
- "version": "0.1.0",
4
- "description": "A version history for prototypes, deployed with the prototype itself.",
5
- "license": "MIT",
6
- "keywords": [
7
- "version-history",
8
- "prototype",
9
- "prototyping",
10
- "design",
11
- "viewer",
12
- "compare",
13
- "diff",
14
- "static-site",
15
- "vercel",
16
- "netlify"
17
- ],
18
- "homepage": "https://github.com/uxlucas/Afterimage#readme",
19
- "repository": {
20
- "type": "git",
21
- "url": "git+https://github.com/uxlucas/Afterimage.git"
22
- },
23
- "bugs": {
24
- "url": "https://github.com/uxlucas/Afterimage/issues"
25
- },
26
- "type": "module",
27
- "bin": {
28
- "afterimage": "bin/afterimage.mjs"
29
- },
30
- "engines": {
31
- "node": ">=22"
32
- },
33
- "files": [
34
- "bin",
35
- "src/cli",
36
- "src/engine/manifest.js",
37
- "src/runtime",
38
- "viewer-dist",
39
- "agents",
40
- "README.md",
41
- "CHANGELOG.md",
42
- "LICENSE"
43
- ],
44
- "scripts": {
45
- "build:viewer": "node scripts/build-viewer.mjs",
46
- "install:examples": "node scripts/install-examples.mjs",
47
- "pretest:e2e": "npm run build:viewer && npm run install:examples",
48
- "prepack": "npm run build:viewer",
49
- "test": "node --test \"tests/*.test.mjs\"",
50
- "test:e2e": "node --test --test-concurrency=1 \"tests/e2e/*.test.mjs\"",
51
- "try:package": "node scripts/try-package.mjs"
52
- },
53
- "devDependencies": {
54
- "@vitejs/plugin-react": "6.1.2",
55
- "motion": "14.9.0",
56
- "playwright-core": "1.64.1",
57
- "react": "19.3.1",
58
- "react-dom": "19.3.1",
59
- "vite": "8.3.5"
60
- }
61
- }
1
+ {
2
+ "name": "afterimage-cli",
3
+ "version": "0.2.0",
4
+ "description": "A version history for prototypes, deployed with the prototype itself.",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "version-history",
8
+ "prototype",
9
+ "prototyping",
10
+ "design",
11
+ "viewer",
12
+ "compare",
13
+ "diff",
14
+ "static-site",
15
+ "vercel",
16
+ "netlify"
17
+ ],
18
+ "homepage": "https://github.com/uxlucas/Afterimage#readme",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/uxlucas/Afterimage.git"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/uxlucas/Afterimage/issues"
25
+ },
26
+ "type": "module",
27
+ "bin": {
28
+ "afterimage": "bin/afterimage.mjs"
29
+ },
30
+ "exports": {
31
+ "./overlay": "./src/runtime/overlay.js",
32
+ "./package.json": "./package.json"
33
+ },
34
+ "engines": {
35
+ "node": ">=22"
36
+ },
37
+ "files": [
38
+ "bin",
39
+ "src/cli",
40
+ "src/engine/manifest.js",
41
+ "src/runtime",
42
+ "viewer-dist",
43
+ "agents",
44
+ "README.md",
45
+ "CHANGELOG.md",
46
+ "LICENSE"
47
+ ],
48
+ "scripts": {
49
+ "build:viewer": "node scripts/build-viewer.mjs",
50
+ "install:examples": "node scripts/install-examples.mjs",
51
+ "pretest:e2e": "npm run build:viewer && npm run install:examples",
52
+ "prepack": "npm run build:viewer",
53
+ "test": "node --test \"tests/*.test.mjs\"",
54
+ "test:e2e": "node --test --test-concurrency=1 \"tests/e2e/*.test.mjs\"",
55
+ "try:package": "node scripts/try-package.mjs"
56
+ },
57
+ "devDependencies": {
58
+ "@vitejs/plugin-react": "6.1.2",
59
+ "motion": "14.9.0",
60
+ "playwright-core": "1.64.1",
61
+ "react": "19.3.1",
62
+ "react-dom": "19.3.1",
63
+ "vite": "8.3.5"
64
+ }
65
+ }