@vintasoftware/pr-review-canvas 0.2.0 → 0.4.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.
Files changed (138) hide show
  1. package/README.md +61 -26
  2. package/docs/reference.md +231 -121
  3. package/package.json +18 -4
  4. package/pr-review.config.example.yml +10 -4
  5. package/prompts/chat-seed.md +3 -0
  6. package/prompts/generation-format.md +3 -0
  7. package/skills/pr-review-canvas/SKILL.md +77 -40
  8. package/src/acpx/acpx.ts +21 -4
  9. package/src/acpx/events.ts +5 -1
  10. package/src/acpx/ndjson.ts +3 -1
  11. package/src/acpx/preflight.ts +5 -1
  12. package/src/canvas/comment.ts +24 -0
  13. package/src/canvas/export.ts +11 -2
  14. package/src/canvas/import.ts +30 -9
  15. package/src/canvas/name.ts +1 -0
  16. package/src/canvas/zip.ts +25 -2
  17. package/src/chat/chat-manager.ts +55 -41
  18. package/src/chat/context.ts +10 -3
  19. package/src/chat/seed.ts +3 -1
  20. package/src/chat/threads.ts +27 -26
  21. package/src/cli.ts +24 -9
  22. package/src/commands.ts +86 -25
  23. package/src/config.ts +24 -24
  24. package/src/contract/api.ts +32 -1
  25. package/src/contract/canvas-manifest.ts +2 -0
  26. package/src/contract/comments.ts +8 -1
  27. package/src/contract/discovery.ts +5 -2
  28. package/src/contract/generation-context.ts +27 -2
  29. package/src/contract/review-artifact.ts +14 -8
  30. package/src/contract/review-key.ts +51 -0
  31. package/src/contract/reviews.ts +17 -0
  32. package/src/contract/settings.ts +2 -0
  33. package/src/contract/state.ts +41 -19
  34. package/src/git/diff-collector.ts +2 -1
  35. package/src/git/environment.mjs +27 -0
  36. package/src/git/git.ts +117 -12
  37. package/src/git/local-target.ts +138 -0
  38. package/src/git/patch-lines.ts +34 -2
  39. package/src/git/pr-refs.ts +36 -0
  40. package/src/github/attachments.ts +9 -257
  41. package/src/github/canvas-comment.ts +22 -0
  42. package/src/github/capabilities.ts +3 -37
  43. package/src/github/comments.ts +9 -27
  44. package/src/github/post-comment.ts +7 -37
  45. package/src/github/post-review.ts +4 -19
  46. package/src/github/pr.ts +6 -84
  47. package/src/github/threads.ts +6 -2
  48. package/src/gitlab/attachments.ts +40 -0
  49. package/src/gitlab/canvas-comment.ts +26 -0
  50. package/src/gitlab/capabilities.ts +64 -0
  51. package/src/gitlab/comments.ts +164 -0
  52. package/src/gitlab/mr.ts +115 -0
  53. package/src/gitlab/post-comment.ts +111 -0
  54. package/src/gitlab/post-review.ts +54 -0
  55. package/src/gitlab/project.ts +13 -0
  56. package/src/host/attachments.ts +293 -0
  57. package/src/host/capabilities.ts +38 -0
  58. package/src/host/client.ts +245 -0
  59. package/src/host/host.ts +136 -0
  60. package/src/host/pr.ts +51 -0
  61. package/src/host/remote.ts +42 -0
  62. package/src/project-config.ts +25 -9
  63. package/src/prompt-files.ts +4 -3
  64. package/src/review/carry-over.ts +79 -0
  65. package/src/review/doctor.ts +31 -14
  66. package/src/review/normalize.ts +3 -1
  67. package/src/review/prepare.ts +87 -17
  68. package/src/review/prompt.ts +8 -2
  69. package/src/review/publish.ts +76 -13
  70. package/src/{github → review}/review-body.ts +17 -5
  71. package/src/review/skill-command.ts +5 -3
  72. package/src/review/trim-caps.ts +10 -6
  73. package/src/review/validate-folds.ts +2 -2
  74. package/src/review/validate.ts +67 -15
  75. package/src/server/app.ts +12 -4
  76. package/src/server/bundle.ts +320 -106
  77. package/src/server/context.ts +24 -10
  78. package/src/server/errors.ts +56 -10
  79. package/src/server/html.ts +36 -12
  80. package/src/server/node-server.ts +4 -2
  81. package/src/server/routes/api.ts +92 -31
  82. package/src/server/routes/chat-routes.ts +105 -46
  83. package/src/server/routes/pages.ts +25 -9
  84. package/src/server/routes/review-routes.ts +101 -35
  85. package/src/server/sse.ts +3 -1
  86. package/src/store/atomic-json.ts +5 -1
  87. package/src/store/canvas-store.ts +95 -46
  88. package/src/store/data-dir.ts +2 -1
  89. package/src/store/derived-store.ts +41 -23
  90. package/src/store/pr-store.ts +25 -15
  91. package/src/store/state-store.ts +42 -37
  92. package/static/brand.svg +19 -0
  93. package/static/js/api.js +47 -27
  94. package/static/js/app.js +27 -7
  95. package/static/js/chat-panel.js +93 -0
  96. package/static/js/chat.js +41 -17
  97. package/static/js/composer.js +30 -17
  98. package/static/js/contract-types.d.ts +3 -0
  99. package/static/js/diagram.js +2 -1
  100. package/static/js/diff-decorations.js +5 -3
  101. package/static/js/diff-renderer.js +7 -2
  102. package/static/js/dom.js +5 -7
  103. package/static/js/download.js +1 -1
  104. package/static/js/empty-state.js +85 -16
  105. package/static/js/errors.js +22 -6
  106. package/static/js/header.js +32 -9
  107. package/static/js/host.js +40 -0
  108. package/static/js/import-zone.js +1 -1
  109. package/static/js/interactions.js +56 -17
  110. package/static/js/keyboard.js +7 -2
  111. package/static/js/layers.js +26 -14
  112. package/static/js/links.js +9 -3
  113. package/static/js/markdown.js +28 -1
  114. package/static/js/nav.js +5 -2
  115. package/static/js/overview.js +32 -4
  116. package/static/js/points.js +5 -3
  117. package/static/js/progress.js +2 -1
  118. package/static/js/proposed-comment.js +4 -1
  119. package/static/js/quick-questions.js +2 -1
  120. package/static/js/regenerate.js +4 -1
  121. package/static/js/review-session.js +7 -2
  122. package/static/js/settings.js +2 -1
  123. package/static/js/signoff.js +9 -6
  124. package/static/styles/base.css +16 -6
  125. package/static/styles/chat-panel.css +81 -0
  126. package/static/styles/chat-tools.css +28 -0
  127. package/static/styles/chat.css +1 -1
  128. package/static/styles/commands.css +10 -4
  129. package/static/styles/diff.css +1 -1
  130. package/static/styles/header.css +18 -4
  131. package/static/styles/layout.css +4 -4
  132. package/static/styles/panels.css +4 -0
  133. package/static/styles/responsive.css +1 -15
  134. package/static/styles/review-actions.css +1 -0
  135. package/static/styles/review.css +24 -3
  136. package/static/styles/skin-github.css +99 -100
  137. package/static/styles.css +13 -12
  138. package/src/github/gh.ts +0 -196
package/README.md CHANGED
@@ -1,25 +1,42 @@
1
1
  # PR Review Canvas
2
2
 
3
- Review a GitHub pull request canvas: layers by topic, with grouped diffs, attention points, comments,
4
- and an optional AI chat. Everything runs locally at **http://localhost:3010**.
3
+ Review a GitHub pull request or GitLab merge request canvas: layers by topic, with grouped diffs,
4
+ attention points, comments, and an optional AI chat. Everything runs locally at **http://localhost:3010**.
5
5
 
6
6
  ## Quick start: author generates, reviewers review
7
7
 
8
8
  ### Author side
9
9
 
10
- Each PR author should generate a canvas and attach its zip to the **PR description** before
11
- requesting review. After the project setup below, run the installed skill in Claude Code or Codex:
10
+ Each PR author generates a canvas before requesting review. The skill shares it automatically
11
+ in a comment on the GitHub PR or GitLab MR. After the project setup below, run the installed skill in Claude Code or Codex:
12
12
 
13
13
  ```text
14
14
  /pr-review-canvas 123
15
15
  ```
16
16
 
17
- Replace **123** with your PR number. The skill reads the PR, generates and validates the canvas,
18
- then returns a local review URL and the exported zip's path. Open the URL to check the canvas.
17
+ Replace **123** with your PR number. The skill reads the PR, generates and validates the canvas, then publishes a compressed canvas
18
+ comment using your `gh` or `glab` login. It returns a local review URL and the comment link.
19
19
 
20
- The skill ends with upload instructions. If you're happy with the produced canvas, edit the PR
21
- description in GitHub's UI, drag the zip into the editor, wait for the upload to finish, and save.
22
- Uploading the zip is a manual browser step due to restrictions of GitHub's API.
20
+ If automatic sharing fails (including a canvas too large for one comment), the skill warns you
21
+ and gives you a ZIP path. Drag that ZIP into the PR or MR description, wait for the upload, and
22
+ save. This manual upload is only a fallback.
23
+
24
+ ### Before you open the pull request
25
+
26
+ To read your own change the way a reviewer will, generate a canvas for the work in your clone:
27
+
28
+ ```text
29
+ /pr-review-canvas branch # the current branch against the default branch
30
+ /pr-review-canvas uncommitted # the same, with your working-tree edits and new files on top
31
+ ```
32
+
33
+ Start `pr-review serve` and open **http://localhost:3010/review/branch** or
34
+ **/review/uncommitted**. The two are separate reviews, so generating one leaves the other alone.
35
+
36
+ Nothing is posted anywhere: local work has no pull request, so the comment and sign-off commands
37
+ stay off. Add `--base <ref>` to compare against another branch. Committing after `branch`, or
38
+ editing a file after `uncommitted`, moves the head: the next time you open the page or press
39
+ refresh, the canvas is marked outdated and the page offers to generate it again.
23
40
 
24
41
  ### Review side
25
42
 
@@ -29,13 +46,16 @@ Start the canvas server from the project you want to review:
29
46
  pr-review serve
30
47
  ```
31
48
 
32
- Open **http://localhost:3010**, enter a PR number, and leave the terminal running while you
33
- review. Stop the server with **Ctrl+C**. To use another port, run `pr-review serve --port 3011`.
49
+ Open **http://localhost:3010**, enter a PR number (or follow a link to a local review), and
50
+ leave the terminal running while you review. Stop the server with **Ctrl+C**. To use another port, run `pr-review serve --port 3011`.
34
51
 
35
52
  ## Install
36
53
 
37
- You need Node.js 22+, npm, Git, and [GitHub CLI](https://cli.github.com).
38
- Sign in to GitHub with `gh auth login`.
54
+ You need Node.js 22+, npm, Git, and the CLI for your host:
55
+
56
+ - GitHub: [GitHub CLI](https://cli.github.com). Sign in with `gh auth login`.
57
+ - GitLab: [GitLab CLI (glab)](https://gitlab.com/gitlab-org/cli). Sign in with `glab auth login`.
58
+ Self-hosted GitLab whose hostname does not contain `gitlab` needs `PR_REVIEW_HOST=gitlab`.
39
59
 
40
60
  Install the command globally once, for use in any project:
41
61
 
@@ -57,10 +77,11 @@ Re-run `pr-review install-skill` after upgrading the CLI to refresh them. It als
57
77
  project's `.gitignore`. Restart your coding agent if the skill
58
78
  does not appear. Repeat this setup for each project you want to review.
59
79
 
60
- `doctor` checks Git, your GitHub remote, the GitHub CLI and its login, write access to the local
61
- canvas directory, and whether installed skills match the current package. It prints a JSON report with a result for
62
- each check and suggested fixes for failures. `doctor --all-checks` also checks that `acpx` runs and
63
- reports its version. Exit code `0` means all checks passed.
80
+ `doctor` checks Git, your GitHub or GitLab remote, the matching CLI (`gh` or `glab`) and its login,
81
+ write access to the local canvas directory, and whether installed skills match the current package.
82
+ It prints a JSON report with a result for each check and suggested fixes for failures.
83
+ `doctor --all-checks` also checks that `acpx` runs and reports its version. Exit code `0` means all
84
+ checks passed.
64
85
 
65
86
  `serve` automatically runs the skill check and warns on stderr if a skill is missing, outdated,
66
87
  or modified. The warning includes the reinstall command and does not block startup.
@@ -89,22 +110,26 @@ See the [CLI and configuration reference](docs/reference.md) for detailed option
89
110
  pr-review export --pr 123
90
111
  ```
91
112
 
92
- The command prints the zip's absolute path. Both `export` and `publish` save locally; neither
93
- uploads an attachment to GitHub.
113
+ The command prints the zip's absolute path. `export` saves locally; `publish` also shares PR/MR
114
+ canvases automatically as compressed comments.
94
115
 
95
116
  The zip contains `manifest.json` and `review.json`: the PR description, file/hunk metadata,
96
- and generated review notes. Check these before sharing, since they can contain private
97
- information. Each reviewer gets source diffs from their own clone; chat history stays local.
117
+ and generated review notes. Publishing shares this information with everyone who can read the PR/MR. Each reviewer gets source diffs from their own clone; chat history stays local.
98
118
 
99
119
  ### Update an outdated canvas
100
120
 
101
121
  After pushing new commits, run `/pr-review-canvas 123` again. To rewrite a canvas for the
102
- same commit, run `/pr-review-canvas 123 --force`. Replace the zip in the PR description.
122
+ same commit, run `/pr-review-canvas 123 --force`. Publishing updates your canvas comment automatically.
103
123
  Reviewers click **refresh**.
104
124
 
105
125
  When the saved canvas describes a different PR head, **Canvas is outdated** appears at
106
126
  the top. You can still read the older canvas, with its commit and distance shown; posting
107
- from that view is disabled. Click **refresh** to check GitHub for changes and a newer zip.
127
+ from that view is disabled. Click **refresh** to check GitHub or GitLab for changes and a newer canvas.
128
+
129
+ A head whose diff is identical to the canvas's does not outdate it: after **Update branch**
130
+ merged `main` in without touching the changed files, for example, the canvas still applies
131
+ and the page says so. Set `canvas.keepForIdenticalDiff: false` in the project config to treat
132
+ every commit as a new head.
108
133
 
109
134
  ## Configuration
110
135
 
@@ -138,9 +163,9 @@ Customize generation and AI Chat prompts with the `prompts` map in your project'
138
163
 
139
164
  ```yaml
140
165
  prompts:
141
- generation-format.md: review-prompts/generation-format.md
142
- generation-surfacing.md: review-prompts/generation-surfacing.md
143
- chat-seed.md: review-prompts/chat-seed.md
166
+ generation-format.md: review-prompts/generation-format.md
167
+ generation-surfacing.md: review-prompts/generation-surfacing.md
168
+ chat-seed.md: review-prompts/chat-seed.md
144
169
  ```
145
170
 
146
171
  Copy the installed templates to start editing (for an npm global install):
@@ -161,6 +186,10 @@ Restart the server after changing the config; chat template edits apply to new t
161
186
  See the [prompt template reference](docs/reference.md#prompt-templates) for supported keys,
162
187
  path rules, validation, and upgrades.
163
188
 
189
+ ## Website
190
+
191
+ The [project website](https://vintasoftware.github.io/pr-review-canvas/) introduces the review workflow with a real PR walkthrough. See [website development and publishing](docs/website.md) for local preview commands and the GitHub Pages deployment workflow.
192
+
164
193
  ## Contributing
165
194
 
166
195
  In a clone of this tool, use pnpm for the shared lockfile and development checks:
@@ -168,11 +197,17 @@ In a clone of this tool, use pnpm for the shared lockfile and development checks
168
197
  ```bash
169
198
  corepack pnpm --version
170
199
  corepack pnpm install --frozen-lockfile
200
+ corepack pnpm hooks:install
171
201
  corepack pnpm exec playwright install --with-deps chromium
172
202
  corepack pnpm verify
173
203
  corepack pnpm start --repo /path/to/your-project
174
204
  ```
175
205
 
206
+ The pre-commit hook runs `pnpm precommit`: lint, formatting, strict type checks, and tests.
207
+ Any failure blocks the commit. Run `pnpm hooks:install`
208
+ once per clone to enable it. Use `pnpm lint:fix` and `pnpm format` to apply automatic fixes.
209
+ CI runs the same checks through `pnpm verify`, with coverage executing the unit tests once.
210
+
176
211
  Run the full `pnpm verify` before pushing. Keep branch coverage at least 96% when adding or
177
212
  changing behavior, leaving a margin above CI's 95% minimum. Cover meaningful failure and boundary
178
213
  cases rather than lowering thresholds. Each CI job uploads `coverage-node-<version>` with branch