@vintasoftware/pr-review-canvas 0.3.0 → 0.5.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 (137) hide show
  1. package/README.md +79 -31
  2. package/docs/reference.md +396 -101
  3. package/package.json +9 -4
  4. package/pr-review.config.example.yml +44 -4
  5. package/prompts/chat-seed.md +3 -0
  6. package/prompts/generation-format.md +123 -26
  7. package/prompts/generation-strict-incremental.md +53 -0
  8. package/prompts/generation-strict.md +1 -27
  9. package/prompts/generation-surfacing-incremental.md +56 -0
  10. package/prompts/generation-surfacing.md +1 -58
  11. package/prompts/judging-strict.md +27 -0
  12. package/prompts/judging-surfacing.md +58 -0
  13. package/skills/pr-review-canvas/SKILL.md +81 -42
  14. package/src/acpx/acpx.ts +98 -5
  15. package/src/acpx/models.ts +43 -0
  16. package/src/canvas/comment.ts +24 -0
  17. package/src/canvas/import.ts +30 -9
  18. package/src/canvas/name.ts +1 -0
  19. package/src/canvas/zip.ts +21 -1
  20. package/src/chat/chat-manager.ts +67 -40
  21. package/src/chat/threads.ts +27 -26
  22. package/src/cli.ts +70 -8
  23. package/src/commands.ts +50 -17
  24. package/src/config.ts +14 -26
  25. package/src/contract/api.ts +58 -2
  26. package/src/contract/canvas-manifest.ts +7 -0
  27. package/src/contract/comments.ts +5 -0
  28. package/src/contract/discovery.ts +5 -2
  29. package/src/contract/generation-context.ts +76 -2
  30. package/src/contract/keys.ts +1 -0
  31. package/src/contract/pending.ts +49 -0
  32. package/src/contract/review-artifact.ts +50 -7
  33. package/src/contract/review-key.ts +51 -0
  34. package/src/contract/reviews.ts +26 -0
  35. package/src/contract/settings.ts +7 -0
  36. package/src/contract/state.ts +53 -22
  37. package/src/contract/validation.ts +1 -0
  38. package/src/git/environment.mjs +27 -0
  39. package/src/git/git.ts +109 -9
  40. package/src/git/local-target.ts +138 -0
  41. package/src/git/patch-lines.ts +34 -2
  42. package/src/git/pr-refs.ts +36 -0
  43. package/src/github/attachments.ts +9 -257
  44. package/src/github/canvas-comment.ts +22 -0
  45. package/src/github/capabilities.ts +3 -41
  46. package/src/github/comments.ts +3 -24
  47. package/src/github/post-comment.ts +3 -36
  48. package/src/github/post-review.ts +64 -23
  49. package/src/github/pr.ts +6 -87
  50. package/src/github/threads.ts +2 -2
  51. package/src/gitlab/attachments.ts +40 -0
  52. package/src/gitlab/canvas-comment.ts +26 -0
  53. package/src/gitlab/capabilities.ts +64 -0
  54. package/src/gitlab/comments.ts +164 -0
  55. package/src/gitlab/mr.ts +115 -0
  56. package/src/gitlab/post-comment.ts +111 -0
  57. package/src/gitlab/post-review.ts +93 -0
  58. package/src/gitlab/project.ts +13 -0
  59. package/src/gitlab/publish-drafts.ts +69 -0
  60. package/src/host/attachments.ts +293 -0
  61. package/src/host/capabilities.ts +38 -0
  62. package/src/host/client.ts +246 -0
  63. package/src/host/host.ts +154 -0
  64. package/src/host/pr.ts +51 -0
  65. package/src/host/remote.ts +42 -0
  66. package/src/project-config.ts +26 -0
  67. package/src/review/carry-marks.ts +131 -0
  68. package/src/review/carry-over.ts +79 -0
  69. package/src/review/doctor.ts +82 -38
  70. package/src/review/incremental.ts +107 -0
  71. package/src/review/normalize.ts +14 -4
  72. package/src/review/prepare.ts +111 -10
  73. package/src/review/prompt.ts +112 -5
  74. package/src/review/publish.ts +62 -10
  75. package/src/{github → review}/review-body.ts +17 -5
  76. package/src/review/skill-command.ts +5 -3
  77. package/src/review/test-paths.ts +44 -4
  78. package/src/review/validate-folds.ts +349 -24
  79. package/src/review/validate.ts +14 -5
  80. package/src/server/bundle.ts +324 -111
  81. package/src/server/context.ts +10 -8
  82. package/src/server/errors.ts +30 -8
  83. package/src/server/html.ts +35 -11
  84. package/src/server/routes/api.ts +63 -26
  85. package/src/server/routes/chat-routes.ts +91 -44
  86. package/src/server/routes/pages.ts +26 -9
  87. package/src/server/routes/review-routes.ts +278 -67
  88. package/src/store/canvas-store.ts +93 -55
  89. package/src/store/data-dir.ts +2 -1
  90. package/src/store/derived-store.ts +41 -27
  91. package/src/store/pr-store.ts +23 -14
  92. package/src/store/settings-store.ts +9 -1
  93. package/src/store/state-store.ts +105 -36
  94. package/src/upgrade.ts +338 -0
  95. package/static/js/api.js +87 -25
  96. package/static/js/app.js +50 -15
  97. package/static/js/chat-panel.js +32 -9
  98. package/static/js/chat.js +30 -6
  99. package/static/js/code-folds.js +171 -44
  100. package/static/js/composer.js +132 -17
  101. package/static/js/contract-types.d.ts +7 -0
  102. package/static/js/diff-decorations.js +67 -1
  103. package/static/js/diff-renderer.js +1 -1
  104. package/static/js/download.js +1 -1
  105. package/static/js/empty-state.js +102 -18
  106. package/static/js/errors.js +22 -6
  107. package/static/js/fold-levels.js +176 -0
  108. package/static/js/header.js +65 -15
  109. package/static/js/host.js +40 -0
  110. package/static/js/import-zone.js +1 -1
  111. package/static/js/interactions.js +274 -46
  112. package/static/js/keyboard.js +4 -1
  113. package/static/js/keys.js +12 -0
  114. package/static/js/layers.js +295 -32
  115. package/static/js/links.js +3 -3
  116. package/static/js/markdown.js +28 -1
  117. package/static/js/nav.js +22 -4
  118. package/static/js/pending.js +161 -0
  119. package/static/js/points.js +70 -9
  120. package/static/js/progress.js +4 -5
  121. package/static/js/quick-questions.js +15 -2
  122. package/static/js/reading-level.js +97 -0
  123. package/static/js/review-session.js +113 -29
  124. package/static/js/settings.js +55 -24
  125. package/static/js/signoff.js +79 -10
  126. package/static/js/skin.js +2 -2
  127. package/static/styles/chat-panel.css +22 -24
  128. package/static/styles/chat.css +4 -0
  129. package/static/styles/commands.css +6 -0
  130. package/static/styles/header.css +21 -0
  131. package/static/styles/panels.css +4 -0
  132. package/static/styles/pending.css +102 -0
  133. package/static/styles/review-actions.css +1 -0
  134. package/static/styles/review.css +4 -0
  135. package/static/styles/skin-github.css +7 -1
  136. package/static/styles.css +1 -0
  137. package/src/github/gh.ts +0 -211
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
 
@@ -43,6 +63,18 @@ Install the command globally once, for use in any project:
43
63
  npm install -g @vintasoftware/pr-review-canvas
44
64
  ```
45
65
 
66
+ ### Upgrade
67
+
68
+ Run this from a project that has the skill installed:
69
+
70
+ ```bash
71
+ pr-review upgrade
72
+ ```
73
+
74
+ It updates pr-review, acpx, and the project's skill copies, after showing the plan and asking.
75
+ Commit and push any refreshed skill copies so your team uses the same skill. `--yes` skips the
76
+ question.
77
+
46
78
  ## Set up a project
47
79
 
48
80
  ```bash
@@ -53,14 +85,14 @@ pr-review doctor --all-checks
53
85
 
54
86
  `install-skill` sets up **both Claude Code and Codex** in one command: `.claude/skills/pr-review-canvas`
55
87
  and `.agents/skills/pr-review-canvas`, respectively. These are portable copies you can commit to Git.
56
- Re-run `pr-review install-skill` after upgrading the CLI to refresh them. It also adds `.pr-review/settings.yml` to the
57
- project's `.gitignore`. Restart your coding agent if the skill
58
- does not appear. Repeat this setup for each project you want to review.
88
+ `pr-review upgrade` refreshes them after the CLI changes. It also adds `.pr-review/settings.yml` to the
89
+ project's `.gitignore`. Restart your coding agent if the skill does not appear. Repeat this setup for each project you want to review.
59
90
 
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.
91
+ `doctor` checks Git, your GitHub or GitLab remote, the matching CLI (`gh` or `glab`) and its login,
92
+ write access to the local canvas directory, and whether installed skills match the current package.
93
+ It prints a JSON report with a result for each check and suggested fixes for failures.
94
+ `doctor --all-checks` also checks that `acpx` runs and reports its version. Exit code `0` means all
95
+ checks passed.
64
96
 
65
97
  `serve` automatically runs the skill check and warns on stderr if a skill is missing, outdated,
66
98
  or modified. The warning includes the reinstall command and does not block startup.
@@ -70,7 +102,7 @@ or modified. The warning includes the reinstall command and does not block start
70
102
  To ask questions about a PR inside the canvas, install `acpx` globally:
71
103
 
72
104
  ```bash
73
- npm install -g acpx
105
+ npm install -g acpx@latest
74
106
  acpx --version
75
107
  pr-review doctor --all-checks
76
108
  ```
@@ -89,34 +121,46 @@ See the [CLI and configuration reference](docs/reference.md) for detailed option
89
121
  pr-review export --pr 123
90
122
  ```
91
123
 
92
- The command prints the zip's absolute path. Both `export` and `publish` save locally; neither
93
- uploads an attachment to GitHub.
124
+ The command prints the zip's absolute path. `export` saves locally; `publish` also shares PR/MR
125
+ canvases automatically as compressed comments.
94
126
 
95
127
  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.
128
+ 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
129
 
99
130
  ### Update an outdated canvas
100
131
 
101
132
  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.
133
+ same commit, run `/pr-review-canvas 123 --force`. Publishing updates your canvas comment automatically.
103
134
  Reviewers click **refresh**.
104
135
 
105
136
  When the saved canvas describes a different PR head, **Canvas is outdated** appears at
106
137
  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.
138
+ from that view is disabled. Click **refresh** to check GitHub or GitLab for changes and a newer canvas.
139
+
140
+ A head whose diff is identical to the canvas's does not outdate it: after **Update branch**
141
+ merged `main` in without touching the changed files, for example, the canvas still applies
142
+ and the page says so. Set `canvas.keepForIdenticalDiff: false` in the project config to treat
143
+ every commit as a new head.
144
+
145
+ Regenerating for a new head updates the previous canvas. Content for untouched files is kept,
146
+ and your review progress on them follows. `--force` starts from a blank page, and
147
+ `canvas.incremental: false` turns this off. See [Incremental canvases](docs/reference.md#incremental-canvases).
108
148
 
109
149
  ## Configuration
110
150
 
111
151
  ### User-local preferences
112
152
 
113
- Your appearance and AI Chat preferences are saved in `.pr-review/settings.yml` in your local
114
- project directory. This file is ignored by Git, so each teammate can use their own settings.
153
+ Your appearance, reading level, and AI Chat preferences are saved in `.pr-review/settings.yml`
154
+ in your local project directory. This file is ignored by Git, so each teammate can use their own
155
+ settings.
115
156
 
116
- Use **skin** and **theme** in the header to change the appearance.
157
+ Use **skin** and **theme** in the header to change the appearance, and **Hide code by default**
158
+ in the settings dialog to choose how much code a review hides when it opens.
117
159
 
118
160
  For AI Chat, open **settings**, choose Claude Code or Codex, and optionally enter a model ID.
119
- Leave the model blank to use the agent's default. You can also adjust the reply timeout and
161
+ Leave the model blank to use the agent's default. A model ID runs as the newest model of its family
162
+ (`claude-opus-4-8` runs as `opus`); write `pin:claude-opus-4-8` to use that exact model. See
163
+ [Model families](docs/reference.md#model-families). You can also adjust the reply timeout and
120
164
  maximum turns. Click **Test agent** to check the connection, then **save**.
121
165
 
122
166
  Switching agents starts a new thread and keeps earlier threads. Server flags `--agent` and
@@ -161,6 +205,10 @@ Restart the server after changing the config; chat template edits apply to new t
161
205
  See the [prompt template reference](docs/reference.md#prompt-templates) for supported keys,
162
206
  path rules, validation, and upgrades.
163
207
 
208
+ ## Website
209
+
210
+ 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.
211
+
164
212
  ## Contributing
165
213
 
166
214
  In a clone of this tool, use pnpm for the shared lockfile and development checks: