@a2f0/agent-tool 0.1.72 → 0.1.74
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 +10 -8
- package/package.json +2 -1
- package/skills/performance-pass/SKILL.md +107 -0
- package/skills/performance-pass/agents/openai.yaml +4 -0
- package/skills/performance-pass/references/lessons.md +30 -0
- package/skills/space-cleanup/SKILL.md +96 -0
- package/skills/space-cleanup/agents/openai.yaml +4 -0
- package/skills/take-screenshots/SKILL.md +103 -0
- package/skills/take-screenshots/agents/openai.yaml +4 -0
- package/skills/take-screenshots/references/adding-capture.md +121 -0
- package/src/cli.ts +14 -1
- package/src/perf/browser.ts +269 -0
- package/src/perf/command.ts +82 -0
- package/src/perf/diff.ts +115 -0
- package/src/perf/graph.ts +110 -0
- package/src/perf/options.ts +107 -0
- package/src/perf/serve.ts +163 -0
- package/src/permissions/catalog.ts +6 -1
- package/src/screenshots/build.ts +4 -3
- package/src/screenshots/store/capture.ts +317 -0
- package/src/screenshots/store/clones.ts +145 -0
- package/src/screenshots/store/command.ts +317 -0
- package/src/screenshots/store/git.ts +14 -0
- package/src/screenshots/store/link.ts +201 -0
- package/src/screenshots/store/lock.ts +94 -0
- package/src/screenshots/store/namespace.ts +311 -0
- package/src/screenshots/store/record.ts +157 -0
- package/src/screenshots/store/store.ts +47 -0
- package/src/screenshots/store/targets.ts +68 -0
- package/src/skills/bundled.ts +14 -0
- package/src/space/candidates.ts +228 -0
- package/src/space/command.ts +325 -0
- package/src/space/machine.ts +303 -0
- package/src/space/processes.ts +186 -0
- package/src/space/targets.ts +24 -0
- package/src/system/checkouts.ts +135 -0
package/README.md
CHANGED
|
@@ -4,10 +4,11 @@ agent-tool is a command-line tool and a set of portable skills for repositories
|
|
|
4
4
|
where Claude Code, Codex, OpenCode, or Hermes make the changes. It provides shared Git,
|
|
5
5
|
GitHub, review, validation, and release workflows: independent agent reviews of
|
|
6
6
|
a committed branch, guarded pushes and squash merges of the exact reviewed
|
|
7
|
-
commit, package versioning, brand image rendering, screenshot
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
commit, package versioning, brand image rendering, screenshot capture into a
|
|
8
|
+
store every clone shares and staging with a framework-free gallery, safe disk
|
|
9
|
+
cleanup, page-load measurement, a live SEO probe for websites, and compact
|
|
10
|
+
output for noisy commands. Repository policy stays in `agent-tool.json`; the
|
|
11
|
+
portable skills coordinate independently reviewed changes.
|
|
11
12
|
|
|
12
13
|
## Quick start
|
|
13
14
|
|
|
@@ -83,13 +84,14 @@ validation suite, and release procedures.
|
|
|
83
84
|
aggregate gates, release verification, durable validation receipts, and
|
|
84
85
|
toolchain/protection diagnostics.
|
|
85
86
|
- [CLI reference](docs/reference.md): existing review, version, skill installation,
|
|
86
|
-
command capture, the SEO probe, import-graph
|
|
87
|
-
distribution contracts.
|
|
87
|
+
command capture, disk cleanup, page performance, the SEO probe, import-graph
|
|
88
|
+
checks, configuration, and distribution contracts.
|
|
88
89
|
- [Development](docs/development.md): setup, source layout, validation, and release
|
|
89
90
|
procedures for this package.
|
|
90
91
|
- [Images](docs/images.md): declarative brand sources and generated outputs.
|
|
91
|
-
- [Screenshots](docs/screenshots.md):
|
|
92
|
-
website, and the gallery and carousel web
|
|
92
|
+
- [Screenshots](docs/screenshots.md): the shared capture store, staging
|
|
93
|
+
captured screenshots into a website, and the gallery and carousel web
|
|
94
|
+
components that show them.
|
|
93
95
|
- [Permissions](docs/permissions.md): which commands run without approval in
|
|
94
96
|
Claude Code and Codex, and the dependency commands that enforce it.
|
|
95
97
|
- [Dependency maintenance](docs/dependency-upgrades.md): active compatibility
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a2f0/agent-tool",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.74",
|
|
4
4
|
"packageManager": "bun@1.4.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Portable cross-agent review, PR workflows, and shared skills",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"@happy-dom/global-registrator": "21.0.4",
|
|
44
44
|
"@types/bun": "1.4.4",
|
|
45
45
|
"happy-dom": "21.0.4",
|
|
46
|
+
"playwright": "1.64.1",
|
|
46
47
|
"typescript": "7.0.2"
|
|
47
48
|
},
|
|
48
49
|
"dependencies": {
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: performance-pass
|
|
3
|
+
description: Make a page or embedded viewer load faster without changing what it shows, in measured rounds that each ship through ship-pr, then carry the release to every consumer. Use when the user asks to speed up loading, startup, or first render, or to dogfood a performance round; not for changing visual quality, content, or features.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Performance Pass
|
|
7
|
+
|
|
8
|
+
A pass is a few rounds. Each round measures, changes one thing, proves the
|
|
9
|
+
output is unchanged, measures again, and ships. Numbers decide what lands;
|
|
10
|
+
impressions do not. What the page shows is fixed: a faster load that changes a
|
|
11
|
+
pixel, a mesh, or a behaviour is a regression, not a win.
|
|
12
|
+
|
|
13
|
+
## The measuring command
|
|
14
|
+
|
|
15
|
+
`agent-tool perf` runs the measurements; run the repository's pinned
|
|
16
|
+
agent-tool (`bun run agent-tool perf` or `node_modules/.bin/agent-tool perf`).
|
|
17
|
+
It drives Chrome through the measured repository's own `playwright`, found
|
|
18
|
+
from the working directory or `--from <directory>` inside the checkout it
|
|
19
|
+
runs in, and never fetches one.
|
|
20
|
+
From a matrix workspace, measure a checkout with
|
|
21
|
+
`agent-tool perf <command> --from checkouts/<name>`. If the pinned agent-tool
|
|
22
|
+
predates the command, run `bunx --bun @a2f0/agent-tool@latest perf`.
|
|
23
|
+
|
|
24
|
+
| Command | Does |
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| `serve <dir> [--port N] [--http1]` | Serves a production build over HTTP/2 with gzip (compressed before the first request) and ETag revalidation, as a CDN does, never following links out of the directory. Start it with `agent-tool proc start --label serve -- node_modules/.bin/agent-tool perf serve <dir>` and stop it with `agent-tool proc stop`. |
|
|
27
|
+
| `measure <url> --ready <js>` | Cold, cache-disabled loads timed from the start of navigation (it waits only for the commit, never the `load` event); prints the median time until the `--ready` expression is true, requests, bytes, when the finished requests ended, and how many were still pending. `--waterfall` lists requests; `--profile` adds CPU self and inclusive times from an extra, unsampled run; `--json` prints the report as JSON. |
|
|
28
|
+
| `shot <url> --ready <js> --out <png>` | Screenshot of the ready state with a seeded `Math.random`, for fidelity diffs. `--eval <js>` runs an interaction first (switch a mode on); `--hide <css>` hides random decoration, reaching into open shadow roots. |
|
|
29
|
+
| `diff <a.png> <b.png>` | Counts differing pixels, and the busiest 50-pixel cells, without a browser; exits 1 on any. |
|
|
30
|
+
| `graph <dir> <entry...> [--out <file>]` | Relative static and dynamic import closure of ES modules, as JSON. |
|
|
31
|
+
|
|
32
|
+
Defaults: 5 runs, 40 ms latency, 20 Mbps, no CPU slowdown, 1600x900. Always
|
|
33
|
+
also measure a slow profile, `--latency 150 --mbps 5 --cpu 4`, since a
|
|
34
|
+
phone's CPU, not the network, is often what remains.
|
|
35
|
+
|
|
36
|
+
## Procedure
|
|
37
|
+
|
|
38
|
+
1. Scope. Name the pages, the ready signal (what "usable" means: first frame
|
|
39
|
+
drawn, `aria-busy` cleared, a hydration flag), and every consumer that
|
|
40
|
+
embeds the package. Read each repository's guidance first; it decides
|
|
41
|
+
validation, versioning, and shipping.
|
|
42
|
+
2. Baseline. Build the production output from the base commit into a scratch
|
|
43
|
+
copy (`git archive <base> | tar -x -C <dir>`, link `node_modules`), serve
|
|
44
|
+
it, and measure both profiles with `--waterfall --profile`. Check the live
|
|
45
|
+
deployment's headers with `curl -sSI -H 'Accept-Encoding: br, gzip'`
|
|
46
|
+
(compression, `cache-control`, HTTP version): local serving only stands in
|
|
47
|
+
for them.
|
|
48
|
+
3. Read the time. Split ready time into network (request chain depth, bytes,
|
|
49
|
+
queueing) and main thread (the CPU profile's inclusive table). A waterfall
|
|
50
|
+
whose requests start in steps is a dependency chain; a long tail after
|
|
51
|
+
`network done` is CPU.
|
|
52
|
+
4. Choose one change, safest first:
|
|
53
|
+
- Transport: preload hints for a known module graph, fewer chained
|
|
54
|
+
requests, compression, cache headers. Output cannot change.
|
|
55
|
+
- Deferral: build what the first frame does not show (hidden modes, unused
|
|
56
|
+
layers) on first use instead of at startup. The first frame must be
|
|
57
|
+
identical, and the deferred feature must still work when first used.
|
|
58
|
+
- Same-output speedups: faster algorithms, fewer allocations, typed arrays,
|
|
59
|
+
reused buffers. Prove byte-identical output (geometry arrays, generated
|
|
60
|
+
files), not just "looks the same".
|
|
61
|
+
- Never, unless the user asks: lower resolution, level of detail,
|
|
62
|
+
sampling, lossy re-encoding, removing content, or changing a bundler or
|
|
63
|
+
vendored engine against repository guidance.
|
|
64
|
+
5. Prove fidelity. Run the repository's own pixel, geometry, and browser
|
|
65
|
+
suites, and `shot` + `diff` the ready state of base and change at the same
|
|
66
|
+
viewport. First diff two base shots against each other: if the page is
|
|
67
|
+
not deterministic even when seeded, say which regions vary and compare
|
|
68
|
+
with that in mind, never by loosening the repository's own thresholds.
|
|
69
|
+
6. Measure again with the same commands and runs. Keep the change only when
|
|
70
|
+
both medians improve beyond the base's own min-max spread; report both
|
|
71
|
+
profiles' before and after medians and network-done times.
|
|
72
|
+
7. Ship with `ship-pr` in that repository, the measurements in the PR body.
|
|
73
|
+
Then, for each consumer, bump to the published version with its own
|
|
74
|
+
`ship-pr`, and measure the consumer's page the same way when it can be
|
|
75
|
+
served locally.
|
|
76
|
+
8. Learn. Repository-specific findings (what dominated, what was tried and
|
|
77
|
+
rejected and why) go in that repository's agent guidance or skill.
|
|
78
|
+
Cross-repository lessons go in agent-tool's
|
|
79
|
+
`skills/performance-pass/references/lessons.md`, by PR there. Next round
|
|
80
|
+
starts from step 3 with the new profile.
|
|
81
|
+
|
|
82
|
+
## Pitfalls
|
|
83
|
+
|
|
84
|
+
- Serve over HTTP/2. Browsers open six HTTP/1.1 connections per host, so a
|
|
85
|
+
plain local server queues a module graph that a CDN serves at once, and
|
|
86
|
+
makes preload changes look worthless.
|
|
87
|
+
- Compress once per file, not per request: a server compressing on every
|
|
88
|
+
request adds its own CPU time to the waterfall.
|
|
89
|
+
- Preload links that hosts' pages receive must go in the document head (not
|
|
90
|
+
a shadow root) and should be removed once loading settles; skip assets a
|
|
91
|
+
host replaces, such as a shared engine.
|
|
92
|
+
- Medians of one or two runs are noise; run at least five, seven for a
|
|
93
|
+
close call. Check `uptime` first: other sessions' test suites inflate the
|
|
94
|
+
CPU-throttled profile most. Under load, interleave base and change runs,
|
|
95
|
+
and back a CPU change with `--profile`, comparing the changed function's
|
|
96
|
+
inclusive time against what remains, rather than wall medians alone.
|
|
97
|
+
- Deferring work is only output-neutral if nothing the deferred work reads
|
|
98
|
+
changes before it runs. Find every writer of its inputs and make it run
|
|
99
|
+
before the first one, then test a deferred instance against an eager one
|
|
100
|
+
step by step.
|
|
101
|
+
|
|
102
|
+
## Ownership
|
|
103
|
+
|
|
104
|
+
agent-tool (`a2f0/agent-tool`) owns this skill at `skills/performance-pass/`
|
|
105
|
+
and the command at `src/perf/`, with its tests beside it; `agent-tool skills
|
|
106
|
+
install --apply` installs it in each adopting repository. Change it there,
|
|
107
|
+
never in an installed copy.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "Performance Pass"
|
|
3
|
+
short_description: "Speed up loading in measured rounds without changing output"
|
|
4
|
+
default_prompt: "Use $performance-pass to make this page load faster without changing what it shows: measure, change one thing, prove fidelity, measure again, and ship."
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Performance lessons
|
|
2
|
+
|
|
3
|
+
Cross-repository findings from performance passes, newest first. Each names
|
|
4
|
+
the repository and PR it came from; recheck before relying on one.
|
|
5
|
+
|
|
6
|
+
## Layers that change nothing until used can wait for first use
|
|
7
|
+
|
|
8
|
+
skyline built its colour-trial layer, which reads every vertex of every
|
|
9
|
+
building, before the first frame, though its shaders install only when colour,
|
|
10
|
+
a previewed time or a celebration is used. Making it on first use (and before
|
|
11
|
+
a celebration rewrites the greys it reads) took its 160 to 270 ms off the
|
|
12
|
+
first frame, pixel-identical in seven before/after interaction shots.
|
|
13
|
+
|
|
14
|
+
## Unbundled ES module graphs pay one round trip per import level
|
|
15
|
+
|
|
16
|
+
skyline (a2f0/skyline) ships tsc output without a bundler, so the viewer's
|
|
17
|
+
first frame waited on a chain seven requests deep. Listing the graph at build
|
|
18
|
+
time and preloading it with `modulepreload` from the mounting code moved
|
|
19
|
+
network-done from 1471 to 833 ms and the ready median from 2369 to 1763 ms at
|
|
20
|
+
40 ms / 20 Mbps (5204 to 4514 ms on the slow profile), pixel-identical with
|
|
21
|
+
the random stars hidden. Generate the list from the built files so it cannot
|
|
22
|
+
drift, leave out modules the host may replace, and expect a host-bundle size
|
|
23
|
+
budget to need room for the preloading code.
|
|
24
|
+
|
|
25
|
+
## Seeded randomness still drifts when load order changes
|
|
26
|
+
|
|
27
|
+
Three.js draws object UUIDs from `Math.random`, so a seeded page that builds
|
|
28
|
+
its scene earlier or later relative to random decoration (skyline's stars)
|
|
29
|
+
shows that decoration elsewhere. Hide the decoration with `shot --hide` and
|
|
30
|
+
diff the rest; two base shots must still diff to zero first.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: space-cleanup
|
|
3
|
+
description: Free disk space safely in a repository, across a matrix workspace and its checkouts, or in this machine's developer caches, by removing only regenerable, git-ignored output after a dry run. Use when the disk is low, `bun run health` asks for space, a command fails with ENOSPC, or the user asks to clean up space; not for deleting clones, branches, or anyone's work.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Space Cleanup
|
|
7
|
+
|
|
8
|
+
Free space by removing what a command can rebuild, never what a person made.
|
|
9
|
+
Measure first, remove the cheapest tier that frees enough, and report what
|
|
10
|
+
was freed from the volume's real free space, not from the estimate.
|
|
11
|
+
|
|
12
|
+
## Run it
|
|
13
|
+
|
|
14
|
+
`agent-tool space` does the work; run the repository's pinned agent-tool
|
|
15
|
+
(`bun run agent-tool space` or `node_modules/.bin/agent-tool space`). It is a
|
|
16
|
+
dry run until `--apply`.
|
|
17
|
+
|
|
18
|
+
- In a repository: `agent-tool space [path...] [flags]`. With no paths it
|
|
19
|
+
covers only the repository holding the working directory; each path names
|
|
20
|
+
the repository holding it.
|
|
21
|
+
- From a matrix workspace (`matrix.json` beside `checkouts/`):
|
|
22
|
+
`agent-tool space [checkout...] [flags]`. With no names it covers the
|
|
23
|
+
workspace and every checkout in `checkouts/`; names are checkout names or
|
|
24
|
+
`owner/name`.
|
|
25
|
+
- If the pinned agent-tool predates the command, run
|
|
26
|
+
`bunx --bun @a2f0/agent-tool@latest space`.
|
|
27
|
+
|
|
28
|
+
Caches are always included; each other flag adds its own tier independently:
|
|
29
|
+
|
|
30
|
+
| Flag | Removes | Cost to restore |
|
|
31
|
+
| --- | --- | --- |
|
|
32
|
+
| (default) | Caches: `.turbo`, `.parcel-cache`, `.eslintcache`, `.stylelintcache`, `coverage`, `.nyc_output`, test reports (`test-results`, `playwright-report`, `blob-report`), Python caches (`__pycache__`, `.pytest_cache`, `.mypy_cache`, `.ruff_cache`), `node_modules/.cache` and `.vite`, `.next/cache`, `.wrangler/tmp` | Next run is slower |
|
|
33
|
+
| `--builds` | Build output: `dist`, `build`, `out`, `.next`, `.nuxt`, `.output`, `.svelte-kit`, `.expo`, `.gradle`, `.build`, `DerivedData`, Rust `target`, `*.tsbuildinfo` | The repository's build |
|
|
34
|
+
| `--deps` | `node_modules`, `.venv`, CocoaPods `Pods`, `vendor/bundle` | The repository's documented install |
|
|
35
|
+
| `--machine` | Xcode DerivedData (not its `SourcePackages` clones), `brew cleanup`, Bun and npm caches, `pnpm store prune` | Re-downloads and rebuilds |
|
|
36
|
+
|
|
37
|
+
`--json` gives agents the same report, and the command exits 1 when a
|
|
38
|
+
repository could not be scanned or a removal failed, 2 when it cannot run at
|
|
39
|
+
all (an unknown option, or processes that cannot be listed).
|
|
40
|
+
`--include-busy` cleans repositories other processes are working in; use it
|
|
41
|
+
only after confirming those processes are your own or finished. It never
|
|
42
|
+
applies to `--machine` items, which always wait for running installs and Xcode
|
|
43
|
+
builds.
|
|
44
|
+
|
|
45
|
+
## Procedure
|
|
46
|
+
|
|
47
|
+
1. Check the volume: `df -h .` (on macOS, `df -h /System/Volumes/Data`). Note
|
|
48
|
+
how much the task needs; matrix sweeps want 50 GiB free.
|
|
49
|
+
2. Run the dry run with `--builds --deps --machine` to see every tier's size,
|
|
50
|
+
then choose the cheapest set of tiers that frees enough. Default caches
|
|
51
|
+
alone are always fine to apply.
|
|
52
|
+
3. Apply with only the chosen flags plus `--apply`. Read the `Free: before ->
|
|
53
|
+
after` line; APFS clones and hard links mean freed space can be far less
|
|
54
|
+
than the listed sizes, and Time Machine local snapshots can hold it until
|
|
55
|
+
macOS thins them.
|
|
56
|
+
4. After `--deps`, reinstall dependencies in each cleaned repository that will
|
|
57
|
+
be used next, with its documented setup, so hooks and `status` keep
|
|
58
|
+
working. Deleting `node_modules` also deletes the pinned agent-tool, so
|
|
59
|
+
where setup runs `bun run agent-tool bun install`, first bootstrap with the
|
|
60
|
+
repository's pinned Bun: `bun install --frozen-lockfile`.
|
|
61
|
+
After `--builds`, nothing is needed: the next build regenerates output.
|
|
62
|
+
5. Report the before and after free space, the tiers applied, repositories
|
|
63
|
+
skipped as busy, and the `review` items from `--machine` with their sizes,
|
|
64
|
+
so the user can decide about them.
|
|
65
|
+
|
|
66
|
+
## Safety rules
|
|
67
|
+
|
|
68
|
+
The command enforces these; keep them when cleaning by hand:
|
|
69
|
+
|
|
70
|
+
- Remove a repository path only when git reports it ignored, nothing under it
|
|
71
|
+
is tracked (rechecked just before removal), its name is on the tier's list,
|
|
72
|
+
nothing under it is a repository, `.env` file, `.secrets`, or SQLite
|
|
73
|
+
database, and neither it nor any parent inside the repository is a symlink. Untracked files that are not ignored
|
|
74
|
+
belong to someone: never remove them.
|
|
75
|
+
- Never run `git clean` (`-X` included), `rm -rf` on a whole ignored tree, or
|
|
76
|
+
delete `.env*`, `.secrets`, `.wrangler/state`, local databases, or anything
|
|
77
|
+
under `../matrix-secrets`.
|
|
78
|
+
- Skip a repository another process is working in (a dev server, a test run,
|
|
79
|
+
another agent session). Idle shells and the session running the command do
|
|
80
|
+
not count. When processes cannot be listed, the command stops instead of
|
|
81
|
+
guessing.
|
|
82
|
+
- Never delete clones, worktrees, branches, stashes, Docker data, Gradle
|
|
83
|
+
caches, simulator devices (unavailable ones included: they keep app data),
|
|
84
|
+
or iOS DeviceSupport on your own: the `--machine`
|
|
85
|
+
report lists the large ones as `review` for the user to decide.
|
|
86
|
+
- Package caches wait while an install runs, and DerivedData waits for Xcode.
|
|
87
|
+
- In a matrix workspace, cleaning ignored output does not change any
|
|
88
|
+
checkout's git state, so it is not a sweep and needs no ledger; a checkout's
|
|
89
|
+
`status` need not be `ready`.
|
|
90
|
+
|
|
91
|
+
## Ownership
|
|
92
|
+
|
|
93
|
+
agent-tool (`a2f0/agent-tool`) owns this skill at `skills/space-cleanup/` and
|
|
94
|
+
the command at `src/space/`, with its tests beside it; `agent-tool skills
|
|
95
|
+
install --apply` installs it in each adopting repository. Change it there,
|
|
96
|
+
never in an installed copy.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: take-screenshots
|
|
3
|
+
description: Capture a repository's app screenshots once into the shared matrix-artifacts store, so every clone builds and deploys the newest captures, and check a capture's provenance before a deploy. Use when asked to take, refresh, or check screenshots, before deploying a site or store listing that shows them, or when adding screenshot capture to a repository.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Take Screenshots
|
|
7
|
+
|
|
8
|
+
Screenshots are captured once, in any clone, into the shared store's
|
|
9
|
+
`matrix-artifacts/<project>/screenshots`, beside the matrix workspace (or
|
|
10
|
+
beside the clone outside one). Every clone of the repository links its
|
|
11
|
+
gitignored `.screenshots` there, so a website deploy or
|
|
12
|
+
store upload in another clone publishes the same, newest captures without
|
|
13
|
+
recapturing. Brand images are not part of this: they render from
|
|
14
|
+
`assets/brand/*.svg` in each clone.
|
|
15
|
+
|
|
16
|
+
## Run it
|
|
17
|
+
|
|
18
|
+
`agent-tool screenshots status|link|capture` does the work; run the
|
|
19
|
+
repository's pinned agent-tool (`bun run agent-tool screenshots ...` or
|
|
20
|
+
`node_modules/.bin/agent-tool screenshots ...`). `link` and `capture` are dry
|
|
21
|
+
runs until `--apply`; `--json` gives agents the report.
|
|
22
|
+
|
|
23
|
+
- From any clone: `agent-tool screenshots <command>` covers that repository.
|
|
24
|
+
- From a matrix workspace: `agent-tool screenshots <command> [checkout...]`;
|
|
25
|
+
with no names it covers every checkout that captures.
|
|
26
|
+
- If the pinned agent-tool predates these commands, run
|
|
27
|
+
`bunx --bun @a2f0/agent-tool@latest screenshots <command>`.
|
|
28
|
+
|
|
29
|
+
| Command | Does |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| `status [repo...] [--all]` | Link state of each clone and its newest capture relative to HEAD |
|
|
32
|
+
| `link [repo...] [--all] [--apply] [--supersede]` | Point `.screenshots` at the store; moves an existing capture into an empty store, or with `--supersede` to `<project>/superseded/` |
|
|
33
|
+
| `capture [repo] [--apply] [--allow-dirty] [-- args...]` | Once its checks pass, link every clone of the store's projects that has no `.screenshots`, then run the repository's `screenshots` package script under the project lock and record `capture.json` |
|
|
34
|
+
|
|
35
|
+
`--all` selects every clone on this machine whose project the store already
|
|
36
|
+
holds, beside the store or in a matrix workspace's checkouts, worktrees
|
|
37
|
+
included: `link --all --apply` links them all in one run.
|
|
38
|
+
|
|
39
|
+
`MATRIX_ARTIFACTS_DIR` overrides the store location, and `--project <name>`
|
|
40
|
+
names the namespace of a repository without a GitHub origin. `status` exits 1
|
|
41
|
+
while a selected clone is not linked, `link` while one is blocked, and an
|
|
42
|
+
applied `capture` when it did not finish `complete`; each exits 2 when it
|
|
43
|
+
cannot run at all.
|
|
44
|
+
|
|
45
|
+
## Procedure
|
|
46
|
+
|
|
47
|
+
1. `status` first. If the clone is not `linked`, run `link`, then
|
|
48
|
+
`link --apply`; `capture` links a clone with no `.screenshots` itself, and
|
|
49
|
+
`status --all` or `link --all` covers every clone on this machine. A
|
|
50
|
+
`blocked` result names what a person must decide (two
|
|
51
|
+
different captures: compare their dates and commits, and if the store's is
|
|
52
|
+
newer rerun with `--supersede`, a link that points elsewhere, a `.screenshots/` ignore
|
|
53
|
+
pattern that needs its trailing slash removed in a PR).
|
|
54
|
+
2. Decide whether to capture. If the newest capture is `complete`, `merged`,
|
|
55
|
+
and no screens changed since its commit, reuse it: that is the point of the
|
|
56
|
+
store. Recapture after UI, seed data, or capture-code changes, after a
|
|
57
|
+
`failed` capture, or when asked.
|
|
58
|
+
3. Commit first: capture refuses a dirty tree, because the shared store would
|
|
59
|
+
publish uncommitted work. `--allow-dirty` is for a local-only look: it marks the
|
|
60
|
+
capture `dirty`, which builds refuse, so recapture from a commit before
|
|
61
|
+
anyone deploys.
|
|
62
|
+
4. Read the repository's capture docs for prerequisites (simulators, Maestro,
|
|
63
|
+
Playwright browsers, seed data, mise-pinned tools). Maestro drives one
|
|
64
|
+
device at a time on this machine: check for a running `maestro` first.
|
|
65
|
+
5. Run `capture` as a dry run, then with `--apply` through output capture
|
|
66
|
+
(`agent-tool run --label screenshots -- agent-tool screenshots capture
|
|
67
|
+
--apply`, with the repository's pinned agent-tool for both). Captures take
|
|
68
|
+
minutes; run them in the background and do not start a second one for the
|
|
69
|
+
same project (the lock refuses it).
|
|
70
|
+
6. Verify the result, not just the exit code: `status` shows `complete` at your
|
|
71
|
+
commit, and spot-check a few images (open them; check light and dark, each
|
|
72
|
+
layout, and the expected dimensions).
|
|
73
|
+
7. Report the capture's commit, whether it was partial (`args`), and which
|
|
74
|
+
clones see it. Before a deploy, quote `status` for the deploying clone.
|
|
75
|
+
|
|
76
|
+
## Rules
|
|
77
|
+
|
|
78
|
+
- Never run a repository's `screenshots` package script directly for a shared
|
|
79
|
+
capture; the lock and `capture.json` keep clones from publishing a partial
|
|
80
|
+
or concurrent capture.
|
|
81
|
+
- Never commit screenshots, copy them into a repository, or delete the store.
|
|
82
|
+
Never remove `.screenshots` itself; capture code clears files inside it.
|
|
83
|
+
- Builds and deploys never capture. `agent-tool screenshots build`, which
|
|
84
|
+
stages screenshots into a website, reads `.screenshots/capture.json` before
|
|
85
|
+
and after copying, and refuses `running`, `failed`, `incomplete`, or `dirty`
|
|
86
|
+
captures and a record that changed meanwhile.
|
|
87
|
+
- Before a deploy that publishes screenshots, run `status` and report the
|
|
88
|
+
capture's commit; recapture only when the screens it shows changed since.
|
|
89
|
+
|
|
90
|
+
## Adding capture to a repository
|
|
91
|
+
|
|
92
|
+
Follow `references/adding-capture.md`: the package script, ignore pattern, and
|
|
93
|
+
output layout every repository shares, and the Playwright (web) and Maestro
|
|
94
|
+
(native) patterns tearleads and nc use. In a matrix workspace, its audit checks
|
|
95
|
+
it with `bun run audit --rule screenshots-store`.
|
|
96
|
+
|
|
97
|
+
## Ownership
|
|
98
|
+
|
|
99
|
+
agent-tool (`a2f0/agent-tool`) owns this skill at `skills/take-screenshots/`
|
|
100
|
+
and the commands at `src/screenshots/store/`, with their tests beside them;
|
|
101
|
+
`agent-tool skills install --apply` installs it in each adopting repository.
|
|
102
|
+
The store's layout and record are described in its `docs/screenshots.md`.
|
|
103
|
+
Change them there, never in an installed copy.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "Take Screenshots"
|
|
3
|
+
short_description: "Capture app screenshots once into the shared matrix-artifacts store"
|
|
4
|
+
default_prompt: "Use $take-screenshots to check this repository's screenshots and capture them into the shared store if they are stale."
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Adding screenshot capture to a repository
|
|
2
|
+
|
|
3
|
+
Every repository that captures screenshots follows one contract, so
|
|
4
|
+
`agent-tool screenshots capture`, the shared store, and the matrix audit work
|
|
5
|
+
the same way everywhere. The capture code itself stays in the repository: it knows the
|
|
6
|
+
app's routes, seed data, and devices.
|
|
7
|
+
|
|
8
|
+
## Contract
|
|
9
|
+
|
|
10
|
+
- Root package script `screenshots` runs the whole capture and forwards extra
|
|
11
|
+
arguments (a layout or project filter) to the runner.
|
|
12
|
+
- It writes below `<root>/.screenshots/`, resolved from the repository root,
|
|
13
|
+
never from the current directory. Honor `SCREENSHOT_OUTPUT_DIR` when the
|
|
14
|
+
runner already supports it, defaulting to `.screenshots`.
|
|
15
|
+
- The root `.gitignore` lists `.screenshots` with no trailing slash, so the
|
|
16
|
+
symlink to the store is ignored too.
|
|
17
|
+
- Capture code removes or replaces files inside `.screenshots`, never
|
|
18
|
+
`.screenshots` itself, and leaves `capture.json` alone.
|
|
19
|
+
- Builds never capture. A `build:*` or deploy script reads `.screenshots`
|
|
20
|
+
only. A build that publishes screenshots checks `.screenshots/capture.json`
|
|
21
|
+
before and after copying and prints the capture's commit (see
|
|
22
|
+
[deploy guard and gallery](#deploy-guard-and-gallery)).
|
|
23
|
+
- Browser phone layouts are captured at the full 390x844 screen, so framed
|
|
24
|
+
phones keep a real phone's proportions; native store captures keep each
|
|
25
|
+
device's required size.
|
|
26
|
+
- Build caches stay honest: a cached task that copies screenshots hashes them
|
|
27
|
+
through the link, or runs uncached (see [build caches](#build-caches)).
|
|
28
|
+
- Document the prerequisites and output layout in the repository's own docs,
|
|
29
|
+
and point agents at this skill from `AGENTS.md` in one sentence.
|
|
30
|
+
|
|
31
|
+
## Layout
|
|
32
|
+
|
|
33
|
+
Use one of two shapes, named by what consumes them:
|
|
34
|
+
|
|
35
|
+
| Consumer | Layout | Example |
|
|
36
|
+
| --- | --- | --- |
|
|
37
|
+
| Website gallery or docs | `<layout>/<theme>/<screen>.png`, layouts `web`, `ipad`, `mobile`, themes `light`, `dark` | tearleads `.screenshots/mobile/dark/home.png` |
|
|
38
|
+
| Store listings (fastlane) | `<platform>/<device>/<NN-screen>[-dark].png` | nc `.screenshots/ios/iphone/01-home.png` |
|
|
39
|
+
|
|
40
|
+
Screen names are kebab-case and stable: a website keeps an allowlist and order
|
|
41
|
+
of them, so renaming one is a change to both.
|
|
42
|
+
|
|
43
|
+
## Web capture with Playwright
|
|
44
|
+
|
|
45
|
+
The pattern tearleads uses (`packages/app-web/playwright.screenshots.config.ts`
|
|
46
|
+
and `packages/app-web/screenshots/`):
|
|
47
|
+
|
|
48
|
+
- A separate Playwright config, so capture never runs in the e2e suite:
|
|
49
|
+
`workers: 1`, `retries: 0`, a long test timeout, fixed `locale` and
|
|
50
|
+
`timezoneId`.
|
|
51
|
+
- One project per layout:
|
|
52
|
+
- `web`: `viewport: { width: 1440, height: 900 }`, `deviceScaleFactor: 2`;
|
|
53
|
+
- `ipad`: `...devices["iPad Pro 11"]`;
|
|
54
|
+
- `mobile`: `...devices["iPhone 13"]` with `viewport` and `screen` set to
|
|
55
|
+
`{ width: 390, height: 844 }`, the full phone screen of an installed app
|
|
56
|
+
(1170x2532 PNGs). The profile's own 390x664 viewport is Safari's visible
|
|
57
|
+
area and makes framed phones look too wide;
|
|
58
|
+
- `browserName: "chromium"` for all three, so output does not depend on
|
|
59
|
+
WebKit; the device profiles still give touch input, viewport, and scale.
|
|
60
|
+
- Its own `webServer` entries on fixed, repository-specific ports with
|
|
61
|
+
`reuseExistingServer: false`, against deterministic seed data or in-memory
|
|
62
|
+
backends, never staging or production.
|
|
63
|
+
- Each theme is pinned through the app's stored preference and a reload, then
|
|
64
|
+
verified (for example on `data-theme`) before capturing.
|
|
65
|
+
- Animations disabled with injected CSS after every navigation; wait for real
|
|
66
|
+
readiness (data rendered, images decoded) instead of fixed sleeps.
|
|
67
|
+
- `page.screenshot({ path })` for routed layouts, or an element screenshot for
|
|
68
|
+
a windowed desktop app; `mkdir` the theme directory first.
|
|
69
|
+
|
|
70
|
+
## Native capture with Maestro
|
|
71
|
+
|
|
72
|
+
The pattern nc uses (`scripts/testing/takeIosScreenshots.sh`,
|
|
73
|
+
`takeAndroidScreenshots.sh`, `maestro/screenshots/`):
|
|
74
|
+
|
|
75
|
+
- Dedicated, named simulators and emulators created on demand, so captures
|
|
76
|
+
never depend on a day-to-day device's state; shut them down on exit.
|
|
77
|
+
- Status bar overridden to 9:41, full signal, battery discharging at 100%
|
|
78
|
+
(`xcrun simctl status_bar ... override`; Android demo mode).
|
|
79
|
+
- Appearance set per capture (`xcrun simctl ui <udid> appearance dark`), with a
|
|
80
|
+
short settle before the screenshot.
|
|
81
|
+
- Maestro flows only navigate; the shell script takes the screenshot
|
|
82
|
+
(`xcrun simctl io <udid> screenshot --mask=ignored`, `adb exec-out screencap`).
|
|
83
|
+
- Validate every file: the exact store size for the device, and no alpha
|
|
84
|
+
channel, which App Store Connect and Play reject.
|
|
85
|
+
- Maestro's driver uses port 7001 for every device, so one Maestro run drives
|
|
86
|
+
this machine at a time: check for a running `maestro` before starting.
|
|
87
|
+
|
|
88
|
+
## Deploy guard and gallery
|
|
89
|
+
|
|
90
|
+
A website that publishes screenshots stages them with
|
|
91
|
+
`agent-tool screenshots build <target>` from the pinned `@a2f0/agent-tool`
|
|
92
|
+
(0.1.32 or later), configured in the `screenshots` section of
|
|
93
|
+
`agent-tool.json`, rather than its own copy script. It copies the allowlisted
|
|
94
|
+
`<project>/<theme>/<screen>.png` files with content-hashed URLs and writes a
|
|
95
|
+
manifest, and it checks `.screenshots/capture.json` before and after copying.
|
|
96
|
+
Every capture writes a `running` record before it touches an image, so an
|
|
97
|
+
unchanged `complete` record on both sides proves no capture overlapped the
|
|
98
|
+
copy. It refuses a capture that is not complete, names no commit, is
|
|
99
|
+
dirty, or changed meanwhile, and a linked, non-empty store with no record
|
|
100
|
+
(its images have no known commit, as after `link` moves an older capture into
|
|
101
|
+
the store). A missing or plain `.screenshots` (CI, an unlinked clone) builds
|
|
102
|
+
with what it holds, or an empty manifest.
|
|
103
|
+
|
|
104
|
+
Pages render that manifest with the package's framework-free elements from
|
|
105
|
+
`@a2f0/agent-tool/screenshots/gallery` and its stylesheet:
|
|
106
|
+
`<screenshot-gallery>` for a `/screenshots/[...slug]` route (deep links per
|
|
107
|
+
project and screen, a scrolling stage, a filmstrip, phone bezels) and
|
|
108
|
+
`<screenshot-carousel>` for a looping row of every phone screen on a home
|
|
109
|
+
page. Sites theme them with `--shots-*` custom properties. The package's
|
|
110
|
+
`docs/screenshots.md` has the configuration, attributes, and an Astro example;
|
|
111
|
+
tearleads and balebase are the references.
|
|
112
|
+
|
|
113
|
+
A non-website consumer (a store upload) that copies captures itself must apply
|
|
114
|
+
the same before-and-after record check.
|
|
115
|
+
|
|
116
|
+
## Build caches
|
|
117
|
+
|
|
118
|
+
Turbo and similar caches hash declared inputs. A task that stages screenshots
|
|
119
|
+
must see changes made through the link: confirm that its input globs follow
|
|
120
|
+
the `.screenshots` symlink (recapture one screen and check the task misses its
|
|
121
|
+
cache), or mark the staging task `cache: false`.
|
package/src/cli.ts
CHANGED
|
@@ -8,6 +8,9 @@ import { checkGraph } from "./graph/check";
|
|
|
8
8
|
import { stateMachinesCommand } from "./stateMachines/command";
|
|
9
9
|
import { seoCommand } from "./seo/probe";
|
|
10
10
|
import { buildScreenshots, describeScreenshots } from "./screenshots/build";
|
|
11
|
+
import { screenshotsStoreCommand } from "./screenshots/store/command";
|
|
12
|
+
import { spaceCommand } from "./space/command";
|
|
13
|
+
import { perfCommand } from "./perf/command";
|
|
11
14
|
import { review } from "./harnesses";
|
|
12
15
|
import { carryReviewCommand } from "./review/carry";
|
|
13
16
|
import { runAgentToolAction } from "./runAgentToolAction";
|
|
@@ -89,9 +92,16 @@ Usage: agent-tool [--repo <directory>] [--config <file>] <command>
|
|
|
89
92
|
images list [target...] JSON files each image target writes
|
|
90
93
|
images build [target...] [--out <dir>] Render assets/brand/*.svg per agent-tool.json
|
|
91
94
|
screenshots build [target...] [--out <dir>] [--json] Stage guarded captures and a gallery manifest
|
|
95
|
+
screenshots status [repo...] [--all] [--json] Each clone's link to the shared store and its newest capture
|
|
96
|
+
screenshots link [repo...] [--all] [--apply] [--supersede] [--json] Point .screenshots at the shared store
|
|
97
|
+
screenshots capture [repo] [--apply] [--allow-dirty] [--json] [-- args...] Run the screenshots script under the store lock and record it
|
|
92
98
|
graph check Import cycles and layer violations per agent-tool.json
|
|
93
99
|
state-machines [path...] [--limit N] [--min-score N] [--json] Rank files that look like implicit state machines
|
|
94
100
|
seo probe [--page|--headers|--links|--sitemap] <host> [path...] Live search and preview metadata of a site
|
|
101
|
+
space [checkout-or-path...] [--builds] [--deps] [--machine] [--include-busy] [--apply] [--json]
|
|
102
|
+
Regenerable, git-ignored output and developer caches; dry run until --apply
|
|
103
|
+
perf serve <dir> | measure <url> | shot <url> --out <png> | diff <a.png> <b.png> | graph <dir> <entry...>
|
|
104
|
+
Page load timing, seeded screenshots, and pixel diffs; perf --help lists options
|
|
95
105
|
init Create agent-tool.json without overwriting
|
|
96
106
|
config show
|
|
97
107
|
doctor JSON versions and supported review flags
|
|
@@ -170,8 +180,9 @@ export function main(argv = process.argv.slice(2)): number | Promise<number> {
|
|
|
170
180
|
});
|
|
171
181
|
}
|
|
172
182
|
if (command === "screenshots") {
|
|
183
|
+
if (args[0] === "status" || args[0] === "link" || args[0] === "capture") return screenshotsStoreCommand(args);
|
|
173
184
|
const action = args.shift();
|
|
174
|
-
usage(action === "build", "Usage: agent-tool screenshots build [target...] [--out <dir>] [--json]");
|
|
185
|
+
usage(action === "build", "Usage: agent-tool screenshots build [target...] [--out <dir>] [--json] | status|link|capture [repo...] [options]");
|
|
175
186
|
const names: string[] = [];
|
|
176
187
|
let out: string | undefined, json = false;
|
|
177
188
|
while (args.length) {
|
|
@@ -191,6 +202,8 @@ export function main(argv = process.argv.slice(2)): number | Promise<number> {
|
|
|
191
202
|
}
|
|
192
203
|
if (command === "state-machines") return stateMachinesCommand(args, process.cwd(), undefined, invoked);
|
|
193
204
|
if (command === "seo") return seoCommand(args);
|
|
205
|
+
if (command === "space") return spaceCommand(args);
|
|
206
|
+
if (command === "perf") return perfCommand(args);
|
|
194
207
|
if (command === "skills") {
|
|
195
208
|
const action = args.shift();
|
|
196
209
|
if (action === "list") { usage(args.length === 0, "Usage: agent-tool skills list"); output(Object.keys(BUNDLED_SKILLS)); return 0; }
|