@a2f0/agent-tool 0.1.73 → 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 +8 -7
- package/package.json +1 -1
- package/skills/performance-pass/SKILL.md +1 -1
- 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 +6 -1
- package/src/perf/graph.ts +13 -3
- package/src/permissions/catalog.ts +3 -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 +6 -1
- package/src/system/checkouts.ts +29 -7
package/README.md
CHANGED
|
@@ -4,11 +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
|
-
framework-free gallery, safe disk
|
|
9
|
-
|
|
10
|
-
stays in `agent-tool.json`; the
|
|
11
|
-
reviewed changes.
|
|
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.
|
|
12
12
|
|
|
13
13
|
## Quick start
|
|
14
14
|
|
|
@@ -89,8 +89,9 @@ validation suite, and release procedures.
|
|
|
89
89
|
- [Development](docs/development.md): setup, source layout, validation, and release
|
|
90
90
|
procedures for this package.
|
|
91
91
|
- [Images](docs/images.md): declarative brand sources and generated outputs.
|
|
92
|
-
- [Screenshots](docs/screenshots.md):
|
|
93
|
-
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.
|
|
94
95
|
- [Permissions](docs/permissions.md): which commands run without approval in
|
|
95
96
|
Claude Code and Codex, and the dependency commands that enforce it.
|
|
96
97
|
- [Dependency maintenance](docs/dependency-upgrades.md): active compatibility
|
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@ predates the command, run `bunx --bun @a2f0/agent-tool@latest perf`.
|
|
|
24
24
|
| Command | Does |
|
|
25
25
|
| --- | --- |
|
|
26
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
|
|
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
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
29
|
| `diff <a.png> <b.png>` | Counts differing pixels, and the busiest 50-pixel cells, without a browser; exits 1 on any. |
|
|
30
30
|
| `graph <dir> <entry...> [--out <file>]` | Relative static and dynamic import closure of ES modules, as JSON. |
|
|
@@ -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,7 @@ 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";
|
|
11
12
|
import { spaceCommand } from "./space/command";
|
|
12
13
|
import { perfCommand } from "./perf/command";
|
|
13
14
|
import { review } from "./harnesses";
|
|
@@ -91,6 +92,9 @@ Usage: agent-tool [--repo <directory>] [--config <file>] <command>
|
|
|
91
92
|
images list [target...] JSON files each image target writes
|
|
92
93
|
images build [target...] [--out <dir>] Render assets/brand/*.svg per agent-tool.json
|
|
93
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
|
|
94
98
|
graph check Import cycles and layer violations per agent-tool.json
|
|
95
99
|
state-machines [path...] [--limit N] [--min-score N] [--json] Rank files that look like implicit state machines
|
|
96
100
|
seo probe [--page|--headers|--links|--sitemap] <host> [path...] Live search and preview metadata of a site
|
|
@@ -176,8 +180,9 @@ export function main(argv = process.argv.slice(2)): number | Promise<number> {
|
|
|
176
180
|
});
|
|
177
181
|
}
|
|
178
182
|
if (command === "screenshots") {
|
|
183
|
+
if (args[0] === "status" || args[0] === "link" || args[0] === "capture") return screenshotsStoreCommand(args);
|
|
179
184
|
const action = args.shift();
|
|
180
|
-
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]");
|
|
181
186
|
const names: string[] = [];
|
|
182
187
|
let out: string | undefined, json = false;
|
|
183
188
|
while (args.length) {
|
package/src/perf/graph.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** `perf graph`: the relative import closure of ES modules, for preload lists generated from built files. */
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
2
|
+
import { readFileSync, realpathSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -82,6 +82,12 @@ export function importsOf(source: string): string[] {
|
|
|
82
82
|
/** Every module reachable from the entries through relative imports, as paths within `root`, entries first. */
|
|
83
83
|
export function moduleGraph(root: string, entries: string[]): string[] {
|
|
84
84
|
const seen = new Set<string>();
|
|
85
|
+
let base: string;
|
|
86
|
+
try {
|
|
87
|
+
base = realpathSync(root);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
throw new Error(`Cannot read ${root}: ${(error as NodeJS.ErrnoException).code ?? (error as Error).message}.`);
|
|
90
|
+
}
|
|
85
91
|
const walk = (rel: string, from: string | undefined) => {
|
|
86
92
|
const where = from === undefined ? `entry ${rel}` : `${rel}, imported by ${from}`;
|
|
87
93
|
if (rel === ".." || rel.startsWith("../") || path.posix.isAbsolute(rel)) throw new Error(`The graph leaves ${root} at ${where}.`);
|
|
@@ -89,9 +95,13 @@ export function moduleGraph(root: string, entries: string[]): string[] {
|
|
|
89
95
|
seen.add(rel);
|
|
90
96
|
let source: string;
|
|
91
97
|
try {
|
|
92
|
-
|
|
98
|
+
// A symbolic link inside the directory can lead out of it, as `..` can.
|
|
99
|
+
const real = realpathSync(path.join(root, rel));
|
|
100
|
+
if (!real.startsWith(`${base}${path.sep}`)) throw new Error(`The graph leaves ${root} at ${where}, through a symbolic link.`);
|
|
101
|
+
source = readFileSync(real, "utf8");
|
|
93
102
|
} catch (error) {
|
|
94
|
-
|
|
103
|
+
if (!(error as NodeJS.ErrnoException).code) throw error;
|
|
104
|
+
throw new Error(`Cannot read ${where}: ${(error as NodeJS.ErrnoException).code}.`);
|
|
95
105
|
}
|
|
96
106
|
for (const spec of importsOf(source)) walk(path.posix.normalize(path.posix.join(path.posix.dirname(rel), spec)), rel);
|
|
97
107
|
};
|
|
@@ -19,7 +19,7 @@ export type Decision = "allow" | "ask";
|
|
|
19
19
|
export interface CatalogEntry { command: string; class: PermissionClass; applyClass?: PermissionClass }
|
|
20
20
|
|
|
21
21
|
export const CATALOG: CatalogEntry[] = [
|
|
22
|
-
...["--help", "--version", "logs", "runs list", "doctor", "config show", "branch check", "branch status", "commits check", "checks binaries", "repo context", "policy check", "toolchain check", "ci gate", "release plan", "release verify", "pr context", "pr checks", "pr logs", "pr preflight", "pr threads list", "versions plan", "versions check", "dependencies check-terraform-plan", "dependencies diff", "skills list", "skills check", "hooks check", "push-gate hook", "push-gate check", "repo base-health", "review carry", "images list", "graph check", "state-machines", "permissions show", "permissions check", "proc list", "perf diff"]
|
|
22
|
+
...["--help", "--version", "logs", "runs list", "doctor", "config show", "branch check", "branch status", "commits check", "checks binaries", "repo context", "policy check", "toolchain check", "ci gate", "release plan", "release verify", "pr context", "pr checks", "pr logs", "pr preflight", "pr threads list", "versions plan", "versions check", "dependencies check-terraform-plan", "dependencies diff", "skills list", "skills check", "hooks check", "push-gate hook", "push-gate check", "repo base-health", "review carry", "images list", "graph check", "state-machines", "permissions show", "permissions check", "proc list", "perf diff", "screenshots status"]
|
|
23
23
|
.map(command => ({ command, class: "read" as const })),
|
|
24
24
|
...["bun install", "bun update", "bun remove", "bun test", "branch create", "versions bump", "versions prepare", "versions resolve-conflicts", "images build", "screenshots build", "review", "init", "proc stop"]
|
|
25
25
|
.map(command => ({ command, class: "local" as const })),
|
|
@@ -43,6 +43,8 @@ export const CATALOG: CatalogEntry[] = [
|
|
|
43
43
|
// So do `perf measure` and `perf shot`, which open any URL in Chrome and evaluate the JavaScript their arguments give,
|
|
44
44
|
// `perf serve`, which serves a directory to every local user, `perf graph`, whose --out overwrites any file, and `space`, whose --apply removes output in other
|
|
45
45
|
// checkouts and developer caches across the machine, with --include-busy even where other sessions work.
|
|
46
|
+
// `screenshots link` and `screenshots capture` keep it as well: --apply links every clone on the machine with
|
|
47
|
+
// --all and writes the shared store outside the checkout, and capture runs the repository's `screenshots` script.
|
|
46
48
|
// `bun x` runs only executables that `permissions.executables` classifies; project.ts adds those.
|
|
47
49
|
// Package scripts are not classified, so `bun run` keeps the harness default.
|
|
48
50
|
|
package/src/screenshots/build.ts
CHANGED
|
@@ -5,9 +5,10 @@ import { pngSize } from "../images/png";
|
|
|
5
5
|
import { assertNoLinks, replaceFile } from "../system/files";
|
|
6
6
|
import type { ScreenshotsConfig, ScreenshotTarget } from "./config";
|
|
7
7
|
import type { ScreenshotCapture, ScreenshotEntry, ScreenshotManifest } from "./manifest";
|
|
8
|
+
import { RECORD } from "./store/record";
|
|
8
9
|
|
|
9
|
-
/** The record
|
|
10
|
-
export const CAPTURE_RECORD =
|
|
10
|
+
/** The record `screenshots capture` keeps beside a shared capture. */
|
|
11
|
+
export const CAPTURE_RECORD = RECORD;
|
|
11
12
|
const MANIFEST = "manifest.json";
|
|
12
13
|
const IMAGES = "img";
|
|
13
14
|
|
|
@@ -41,7 +42,7 @@ export function checkCapture(root: string, source: string, raw: string | undefin
|
|
|
41
42
|
try { record = JSON.parse(raw) as CaptureRecord; } catch { throw new Error(`The shared screenshot capture record ${CAPTURE_RECORD} is not JSON; recapture.`); }
|
|
42
43
|
if (!record || typeof record !== "object") throw new Error(`The shared screenshot capture record ${CAPTURE_RECORD} is not an object; recapture.`);
|
|
43
44
|
if (record.status !== "complete") throw new Error(`The shared screenshot capture is ${String(record.status)}; wait for it or recapture.`);
|
|
44
|
-
if (typeof record.commit !== "string" || !/^[0-9a-f]{40}
|
|
45
|
+
if (typeof record.commit !== "string" || !/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/.test(record.commit)) throw new Error("The shared screenshot capture record names no commit; recapture.");
|
|
45
46
|
if (record.dirty !== false) throw new Error("The shared screenshots were captured from uncommitted changes; recapture from a commit.");
|
|
46
47
|
const partial = Array.isArray(record.args) ? record.args.map(String) : [];
|
|
47
48
|
return { commit: record.commit, finishedAt: typeof record.finishedAt === "string" ? record.finishedAt : null, partial };
|