@kaptures/cli 0.0.1 → 0.0.4

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 CHANGED
@@ -4,47 +4,112 @@ Kapture compares Storybook builds from an exact base commit and head commit in
4
4
  one explicit browser environment. It produces a self-contained visual report
5
5
  and can publish a SHA-bound review status to GitHub.
6
6
 
7
- Node.js 24 or later is required.
7
+ Node.js 24 or later is required. Both Storybook builds must register the
8
+ matching `@kaptures/storybook@0.0.4` preview adapter. Kapture does not fall back
9
+ to Storybook private globals, legacy decorators, or Chromatic parameters.
8
10
 
9
11
  ```bash
10
- npx -y @kaptures/cli@0.0.1 --help
11
- npx -y @kaptures/cli@0.0.1 browser install
12
+ npx -y @kaptures/cli@0.0.4 --help
13
+ npx -y @kaptures/cli@0.0.4 browser install
12
14
  ```
13
15
 
14
16
  ## Compare Storybooks
15
17
 
16
18
  ```bash
17
- npx -y @kaptures/cli@0.0.1 test \
19
+ npx -y @kaptures/cli@0.0.4 test \
18
20
  --base-dir .kapture/storybook/base \
19
21
  --head-dir .kapture/storybook/head \
20
22
  --base-revision "$BASE_SHA" \
21
23
  --head-revision "$HEAD_SHA" \
22
24
  --output .kapture
23
25
 
24
- npx -y @kaptures/cli@0.0.1 validate \
26
+ npx -y @kaptures/cli@0.0.4 validate \
25
27
  --report .kapture/report/report.json
26
28
  ```
27
29
 
28
30
  Visual changes are a review result, not an execution failure. Capture and
29
31
  comparison errors exit with code 2.
30
32
 
33
+ The default browser locale and time zone are `en-US` and `UTC`. Override them
34
+ explicitly with `--locale <bcp47>` and `--timezone <iana-zone>` when the
35
+ consumer Storybook requires another environment.
36
+
37
+ ## Optional hosted report
38
+
39
+ Kapture does not require a report deployment. The generated `index.html`
40
+ remains self-contained and can be opened through a `file://` URL after the
41
+ artifact is downloaded. To publish a browser URL from a privileged workflow,
42
+ rebuild the untrusted artifact with the dashboard embedded in the pinned CLI:
43
+
44
+ ```bash
45
+ npx -y @kaptures/cli@0.0.4 report build \
46
+ --input downloaded-kapture-report \
47
+ --output trusted-kapture-report
48
+ ```
49
+
50
+ Deploy only `trusted-kapture-report/` with the repository's existing static
51
+ hosting. The builder validates the strict report schema and referenced PNGs,
52
+ and never executes or copies artifact HTML, JavaScript, CSS, fonts, symlinks,
53
+ or unreferenced files.
54
+
31
55
  ## GitHub
32
56
 
33
- Use the three-workflow example in the repository: an unprivileged
34
- `pull_request` workflow captures the report, a trusted `workflow_run` validates
35
- that JSON and updates the PR, and an `issue_comment` workflow handles
36
- `/kapture approve <full-head-sha>` without checking out PR code.
57
+ Run every checkout, repository script, Storybook build, and browser capture in
58
+ the read-only `pull_request` workflow without secrets. Pass only an immutable
59
+ context artifact plus `report.json` and its referenced PNGs to the default
60
+ branch's `workflow_run`; intermediate Storybook artifacts stay inside the
61
+ read-only run.
62
+
63
+ The `workflow_run` resolves exact artifact IDs from the triggering run and
64
+ cross-checks their provenance, bounded archive size, full base/head SHAs, and
65
+ current open pull request. The actual PR head SHA comes from the immutable
66
+ context and live pull request; `workflow_run.head_sha` may be a synthetic merge
67
+ commit and is not treated as the PR head. SHA-pinned `download-artifact@v8`
68
+ fails closed on an archive digest mismatch, then validates entry paths and
69
+ uncompressed limits before extraction. A job without write permission runs
70
+ `github verify` and rebuilds the report from strict JSON and validated PNGs
71
+ with the pinned CLI. A separate write job publishes only that trusted output.
72
+ Neither job checks out PR code or executes artifact code. The `issue_comment`
73
+ workflow similarly handles
74
+ `/kapture approve <full-head-sha> <report-digest>` without checking out PR
75
+ code.
37
76
 
38
77
  ```bash
39
- npx -y @kaptures/cli@0.0.1 github report \
40
- --report .kapture/report/report.json \
41
- --report-url "https://github.com/OWNER/REPO/actions/runs/RUN_ID"
78
+ npx -y @kaptures/cli@0.0.4 github verify \
79
+ --report .kapture/report/report.json
42
80
 
43
- npx -y @kaptures/cli@0.0.1 github approve
81
+ npx -y @kaptures/cli@0.0.4 github report \
82
+ --report trusted-kapture-report/report.json \
83
+ --report-url "https://github.com/OWNER/REPO/actions/runs/RUN_ID/artifacts/ARTIFACT_ID"
84
+
85
+ npx -y @kaptures/cli@0.0.4 github approve
44
86
  ```
45
87
 
46
88
  GitHub commands read authentication and event data only from `GITHUB_TOKEN`
47
89
  and `GITHUB_EVENT_PATH`. Do not pass tokens as command-line arguments.
90
+ `github verify` and `github report` require the normalized
91
+ `kapture.schemaVersion: 1` event created by the trusted example workflow; do
92
+ not pass GitHub's raw `workflow_run` payload because its `head_sha` may be a
93
+ synthetic merge commit. `github approve` consumes the raw `issue_comment`
94
+ event.
95
+ `github verify` validates the strict report and its full base/head SHAs against
96
+ the current pull request without writing a status or comment. Run it before
97
+ deployment. A privileged report job must pass the output of `report build`;
98
+ `github report` requires its image-bound `report.json` before writing. Version
99
+ 3 approval markers bind the base SHA, head SHA, full report structure, actual
100
+ bytes of every referenced PNG, capture run ID and attempt, workflow ID, head
101
+ repository ID, head branch, and report URL. Approval rechecks that marker's run
102
+ is the latest successful capture run for the same PR head repository and branch.
103
+ The current status for the PR head must also be the final approval-ready
104
+ `pending` in the selected context and target the same report URL. The transient
105
+ publishing status is not approvable. Therefore, a base-branch update, new head
106
+ commit, changed report image, or failed rerun at the same SHA prevents an old
107
+ marker and digest from restoring success.
108
+
109
+ The default status context is `Kapture Visual Review`, and report and approval
110
+ comments default to English. Consumers can set `--status-context <name>` and
111
+ `--comment-language en|ko` on both `github report` and `github approve` without
112
+ changing the verification boundary.
48
113
 
49
114
  ## License
50
115