@mermaid-company/trail 0.0.0-stage → 0.1.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.
- package/LICENSE +218 -0
- package/NOTICE +17 -0
- package/README.md +424 -2
- package/dist/THIRD_PARTY_LICENSES.txt +848 -0
- package/dist/cli.js +26 -0
- package/dist/main.js +1274 -0
- package/dist/server.js +1835 -0
- package/dist/web/assets/index-DWC2Hl96.css +1 -0
- package/dist/web/assets/index-DxCeqwvT.js +152 -0
- package/dist/web/index.html +14 -0
- package/package.json +67 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
Trail
|
|
2
|
+
Copyright (c) 2026 Diego Valadares Sá Fortes, working together with IARA (https://iara.app.br)
|
|
3
|
+
|
|
4
|
+
Trail is licensed under the Apache License, Version 2.0, subject to the two
|
|
5
|
+
conditions below. The full text of the Apache License follows them.
|
|
6
|
+
|
|
7
|
+
In short, and without replacing the terms themselves: you may use, copy, change
|
|
8
|
+
and share Trail free of charge, including at work. You may not sell it, and you
|
|
9
|
+
may not present it as your own original work.
|
|
10
|
+
|
|
11
|
+
================================================================================
|
|
12
|
+
|
|
13
|
+
“Commons Clause” License Condition v1.0
|
|
14
|
+
|
|
15
|
+
The Software is provided to you by the Licensor under the License, as defined below, subject to the following condition.
|
|
16
|
+
|
|
17
|
+
Without limiting other conditions in the License, the grant of rights under the License will not include, and the License does not grant to you, the right to Sell the Software.
|
|
18
|
+
|
|
19
|
+
For purposes of the foregoing, “Sell” means practicing any or all of the rights granted to you under the License to provide to third parties, for a fee or other consideration (including without limitation fees for hosting or consulting/ support services related to the Software), a product or service whose value derives, entirely or substantially, from the functionality of the Software. Any license notice or attribution required by the License must also include this Commons Clause License Condition notice.
|
|
20
|
+
|
|
21
|
+
Software: Trail
|
|
22
|
+
|
|
23
|
+
License: Apache License, Version 2.0
|
|
24
|
+
|
|
25
|
+
Licensor: Diego Valadares Sá Fortes, working together with IARA (https://iara.app.br)
|
|
26
|
+
|
|
27
|
+
================================================================================
|
|
28
|
+
|
|
29
|
+
Authorship Condition
|
|
30
|
+
|
|
31
|
+
The Software is also provided subject to the following condition, in addition to
|
|
32
|
+
the notice requirements of the License.
|
|
33
|
+
|
|
34
|
+
The origin of the Software must not be misrepresented. You must not claim that
|
|
35
|
+
you wrote the original Software. You must not remove or alter the copyright and
|
|
36
|
+
authorship notices that accompany it, including the NOTICE file. Altered
|
|
37
|
+
versions must be plainly marked as such and must not be presented as being the
|
|
38
|
+
original Software. Any license notice or attribution required by the License
|
|
39
|
+
must also include this Authorship Condition notice.
|
|
40
|
+
|
|
41
|
+
================================================================================
|
|
42
|
+
|
|
43
|
+
Apache License
|
|
44
|
+
Version 2.0, January 2004
|
|
45
|
+
http://www.apache.org/licenses/
|
|
46
|
+
|
|
47
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
48
|
+
|
|
49
|
+
1. Definitions.
|
|
50
|
+
|
|
51
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
52
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
53
|
+
|
|
54
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
55
|
+
the copyright owner that is granting the License.
|
|
56
|
+
|
|
57
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
58
|
+
other entities that control, are controlled by, or are under common
|
|
59
|
+
control with that entity. For the purposes of this definition,
|
|
60
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
61
|
+
direction or management of such entity, whether by contract or
|
|
62
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
63
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
64
|
+
|
|
65
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
66
|
+
exercising permissions granted by this License.
|
|
67
|
+
|
|
68
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
69
|
+
including but not limited to software source code, documentation
|
|
70
|
+
source, and configuration files.
|
|
71
|
+
|
|
72
|
+
"Object" form shall mean any form resulting from mechanical
|
|
73
|
+
transformation or translation of a Source form, including but
|
|
74
|
+
not limited to compiled object code, generated documentation,
|
|
75
|
+
and conversions to other media types.
|
|
76
|
+
|
|
77
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
78
|
+
Object form, made available under the License, as indicated by a
|
|
79
|
+
copyright notice that is included in or attached to the work
|
|
80
|
+
(an example is provided in the Appendix below).
|
|
81
|
+
|
|
82
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
83
|
+
form, that is based on (or derived from) the Work and for which the
|
|
84
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
85
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
86
|
+
of this License, Derivative Works shall not include works that remain
|
|
87
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
88
|
+
the Work and Derivative Works thereof.
|
|
89
|
+
|
|
90
|
+
"Contribution" shall mean any work of authorship, including
|
|
91
|
+
the original version of the Work and any modifications or additions
|
|
92
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
93
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
94
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
95
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
96
|
+
means any form of electronic, verbal, or written communication sent
|
|
97
|
+
to the Licensor or its representatives, including but not limited to
|
|
98
|
+
communication on electronic mailing lists, source code control systems,
|
|
99
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
100
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
101
|
+
excluding communication that is conspicuously marked or otherwise
|
|
102
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
103
|
+
|
|
104
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
105
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
106
|
+
subsequently incorporated within the Work.
|
|
107
|
+
|
|
108
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
109
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
110
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
111
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
112
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
113
|
+
Work and such Derivative Works in Source or Object form.
|
|
114
|
+
|
|
115
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
116
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
117
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
118
|
+
(except as stated in this section) patent license to make, have made,
|
|
119
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
120
|
+
where such license applies only to those patent claims licensable
|
|
121
|
+
by such Contributor that are necessarily infringed by their
|
|
122
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
123
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
124
|
+
institute patent litigation against any entity (including a
|
|
125
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
126
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
127
|
+
or contributory patent infringement, then any patent licenses
|
|
128
|
+
granted to You under this License for that Work shall terminate
|
|
129
|
+
as of the date such litigation is filed.
|
|
130
|
+
|
|
131
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
132
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
133
|
+
modifications, and in Source or Object form, provided that You
|
|
134
|
+
meet the following conditions:
|
|
135
|
+
|
|
136
|
+
(a) You must give any other recipients of the Work or
|
|
137
|
+
Derivative Works a copy of this License; and
|
|
138
|
+
|
|
139
|
+
(b) You must cause any modified files to carry prominent notices
|
|
140
|
+
stating that You changed the files; and
|
|
141
|
+
|
|
142
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
143
|
+
that You distribute, all copyright, patent, trademark, and
|
|
144
|
+
attribution notices from the Source form of the Work,
|
|
145
|
+
excluding those notices that do not pertain to any part of
|
|
146
|
+
the Derivative Works; and
|
|
147
|
+
|
|
148
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
149
|
+
distribution, then any Derivative Works that You distribute must
|
|
150
|
+
include a readable copy of the attribution notices contained
|
|
151
|
+
within such NOTICE file, excluding those notices that do not
|
|
152
|
+
pertain to any part of the Derivative Works, in at least one
|
|
153
|
+
of the following places: within a NOTICE text file distributed
|
|
154
|
+
as part of the Derivative Works; within the Source form or
|
|
155
|
+
documentation, if provided along with the Derivative Works; or,
|
|
156
|
+
within a display generated by the Derivative Works, if and
|
|
157
|
+
wherever such third-party notices normally appear. The contents
|
|
158
|
+
of the NOTICE file are for informational purposes only and
|
|
159
|
+
do not modify the License. You may add Your own attribution
|
|
160
|
+
notices within Derivative Works that You distribute, alongside
|
|
161
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
162
|
+
that such additional attribution notices cannot be construed
|
|
163
|
+
as modifying the License.
|
|
164
|
+
|
|
165
|
+
You may add Your own copyright statement to Your modifications and
|
|
166
|
+
may provide additional or different license terms and conditions
|
|
167
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
168
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
169
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
170
|
+
the conditions stated in this License.
|
|
171
|
+
|
|
172
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
173
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
174
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
175
|
+
this License, without any additional terms or conditions.
|
|
176
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
177
|
+
the terms of any separate license agreement you may have executed
|
|
178
|
+
with Licensor regarding such Contributions.
|
|
179
|
+
|
|
180
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
181
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
182
|
+
except as required for reasonable and customary use in describing the
|
|
183
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
184
|
+
|
|
185
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
186
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
187
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
189
|
+
implied, including, without limitation, any warranties or conditions
|
|
190
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
191
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
192
|
+
appropriateness of using or redistributing the Work and assume any
|
|
193
|
+
risks associated with Your exercise of permissions under this License.
|
|
194
|
+
|
|
195
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
196
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
197
|
+
unless required by applicable law (such as deliberate and grossly
|
|
198
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
199
|
+
liable to You for damages, including any direct, indirect, special,
|
|
200
|
+
incidental, or consequential damages of any character arising as a
|
|
201
|
+
result of this License or out of the use or inability to use the
|
|
202
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
203
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
204
|
+
other commercial damages or losses), even if such Contributor
|
|
205
|
+
has been advised of the possibility of such damages.
|
|
206
|
+
|
|
207
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
208
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
209
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
210
|
+
or other liability obligations and/or rights consistent with this
|
|
211
|
+
License. However, in accepting such obligations, You may act only
|
|
212
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
213
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
214
|
+
defend, and hold each Contributor harmless for any liability
|
|
215
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
216
|
+
of your accepting any such warranty or additional liability.
|
|
217
|
+
|
|
218
|
+
END OF TERMS AND CONDITIONS
|
package/NOTICE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Trail
|
|
2
|
+
Copyright (c) 2026 Diego Valadares Sá Fortes, working together with IARA (https://iara.app.br)
|
|
3
|
+
|
|
4
|
+
Trail was created by Diego Valadares Sá Fortes, working together with
|
|
5
|
+
IARA (https://iara.app.br).
|
|
6
|
+
|
|
7
|
+
Trail is licensed under the Apache License, Version 2.0, subject to the Commons
|
|
8
|
+
Clause License Condition v1.0 and the Authorship Condition set out in the
|
|
9
|
+
LICENSE file. It may not be sold, and its origin may not be misrepresented.
|
|
10
|
+
|
|
11
|
+
Third-party software
|
|
12
|
+
|
|
13
|
+
The published package also contains code from other projects, compiled into the
|
|
14
|
+
files in dist/. Each of them remains under its own licence and copyright, not
|
|
15
|
+
under the terms above. Their names, versions and full licence texts are in
|
|
16
|
+
dist/THIRD_PARTY_LICENSES.txt. The build writes that file from what it bundles,
|
|
17
|
+
so it is in the published package and not in the source repository.
|
package/README.md
CHANGED
|
@@ -1,3 +1,425 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Trail
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Trail is a command-line tool and local web app for reviewing pull requests, built for
|
|
4
|
+
changes written by AI coding agents. You pick a pull request in the terminal, and Trail
|
|
5
|
+
opens it in your browser with Claude Code next to the diff. Trail runs on your own machine,
|
|
6
|
+
with no online service or account of its own, and uses your existing GitHub and Claude Code
|
|
7
|
+
logins.
|
|
8
|
+
|
|
9
|
+
It helps with the three things that make AI-written pull requests tiring to review:
|
|
10
|
+
|
|
11
|
+
| Problem | What Trail does |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| The change is spread over many files, listed alphabetically. | Claude writes a **walkthrough**: the hunks grouped into chapters, in the order the logic runs. |
|
|
14
|
+
| Small methods were moved between files, shown as a deletion and an addition. | **Moved code is folded** into one line that links to where it went. |
|
|
15
|
+
| You have to leave the diff to see what a function does. | **Click any name** in the diff to see its definition and usages. |
|
|
16
|
+
|
|
17
|
+
Trail is an independent project. It is not affiliated with, or endorsed by, Anthropic or GitHub.
|
|
18
|
+
|
|
19
|
+
## Contents
|
|
20
|
+
|
|
21
|
+
- [Requirements](#requirements) and [Install](#install)
|
|
22
|
+
- [First review](#first-review)
|
|
23
|
+
- [Commands](#commands)
|
|
24
|
+
- [The review page](#the-review-page)
|
|
25
|
+
- [Settings](#settings) and [Updating](#updating)
|
|
26
|
+
- [What Trail does on your machine and on GitHub](#what-trail-does-on-your-machine-and-on-github)
|
|
27
|
+
- [Reviewing code you do not trust](#reviewing-code-you-do-not-trust)
|
|
28
|
+
- [Troubleshooting](#troubleshooting) and [Limits](#limits)
|
|
29
|
+
- [Development](#development)
|
|
30
|
+
- [Licence](#licence)
|
|
31
|
+
|
|
32
|
+
## Requirements
|
|
33
|
+
|
|
34
|
+
| What | Version | Needed for |
|
|
35
|
+
| --- | --- | --- |
|
|
36
|
+
| [Node.js](https://nodejs.org) | **22.13 or newer** | Running Trail. Older versions are refused with a message saying so. |
|
|
37
|
+
| `git` | any recent | Reading the code |
|
|
38
|
+
| [GitHub CLI](https://cli.github.com) (`gh`), logged in | any recent | Pull requests. Not needed for local repositories. |
|
|
39
|
+
| [Claude Code](https://claude.com/claude-code) (`claude`), logged in | a current release | Walkthroughs, questions and edits |
|
|
40
|
+
|
|
41
|
+
Trail has been used on macOS. Linux should work. Windows is untested, and is not safe for
|
|
42
|
+
code you do not trust: see [Reviewing code you do not trust](#reviewing-code-you-do-not-trust).
|
|
43
|
+
|
|
44
|
+
## Install
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
npm install -g @mermaid-company/trail
|
|
48
|
+
trail doctor
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`trail doctor` checks each requirement above and tells you how to fix anything missing.
|
|
52
|
+
|
|
53
|
+
Then save the GitHub user or organisation that owns your repositories, so you only have to
|
|
54
|
+
type repository names:
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
trail config owner my-org
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## First review
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
trail my-repo # choose from the repository's open pull requests
|
|
64
|
+
trail my-repo 123 # or go straight to one
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The first time you open a repository, Trail clones it, which can take a minute. Your
|
|
68
|
+
browser then opens the review at http://localhost:4477.
|
|
69
|
+
|
|
70
|
+
## Commands
|
|
71
|
+
|
|
72
|
+
### Open one pull request
|
|
73
|
+
|
|
74
|
+
| Command | What it opens |
|
|
75
|
+
| --- | --- |
|
|
76
|
+
| `trail my-repo 123` | Pull request 123 of `<saved owner>/my-repo` |
|
|
77
|
+
| `trail my-repo/123` | The same in one word |
|
|
78
|
+
| `trail my-repo 123 --owner other-org` | The same repository name under another owner, for this command only |
|
|
79
|
+
| `trail other-org/my-repo 123` | The owner written with the repository |
|
|
80
|
+
| `trail other-org/my-repo/123` | The same in one word |
|
|
81
|
+
| `trail https://github.com/owner/repo/pull/123` | A pull request by its GitHub address |
|
|
82
|
+
| `trail github.com/owner/repo/pull/123/files` | Any pasted form of that address: without `https://`, or with `/files`, `?diff=split`, `#discussion…` after the number |
|
|
83
|
+
|
|
84
|
+
Quote an address that contains `?` or `#`, so your shell passes it through unchanged. Only
|
|
85
|
+
github.com is supported.
|
|
86
|
+
|
|
87
|
+
### Choose from a list
|
|
88
|
+
|
|
89
|
+
Leave out the number and Trail lists the pull requests for you to pick one, so you never
|
|
90
|
+
have to look the number up on GitHub.
|
|
91
|
+
|
|
92
|
+
| Command | What it lists |
|
|
93
|
+
| --- | --- |
|
|
94
|
+
| `trail my-repo` | Open pull requests of `<saved owner>/my-repo` |
|
|
95
|
+
| `trail other-org/my-repo` | The same for any repository. Its address (`github.com/other-org/my-repo`) works too |
|
|
96
|
+
| `trail --list` | Open pull requests waiting for your review, across the saved owner (across all of GitHub when none is saved) |
|
|
97
|
+
|
|
98
|
+
In the list:
|
|
99
|
+
|
|
100
|
+
- **Arrow keys and Enter** move and open the pull request in Trail.
|
|
101
|
+
- **Typing** narrows the list by title, number, author or branch. `author:name`,
|
|
102
|
+
`reviewer:name` and `label:name` look in one field.
|
|
103
|
+
- **Tab** switches between all pull requests, those waiting for your review, and your own.
|
|
104
|
+
- **Esc** leaves.
|
|
105
|
+
|
|
106
|
+
Each row shows the size of the change, its age, and its review state: draft, approved,
|
|
107
|
+
changes requested, or whose review is requested. Pull requests you have already opened in
|
|
108
|
+
Trail show how far you got.
|
|
109
|
+
|
|
110
|
+
To fetch a narrower list from GitHub in the first place, add filters:
|
|
111
|
+
|
|
112
|
+
| Filter | Meaning |
|
|
113
|
+
| --- | --- |
|
|
114
|
+
| `--mine` or `--author <login>` | Written by you, or by someone else |
|
|
115
|
+
| `--for-me` or `--reviewer <login>` | Review requested from you, from someone else, or from a team (`org/team`) |
|
|
116
|
+
| `--label <name>` | Carrying a label |
|
|
117
|
+
| `--state open\|closed\|merged\|all` | Default is `open` |
|
|
118
|
+
| `--search "<words>"` | Anything in GitHub's search syntax. Write `--search=-label:wip`, with `=`, when it starts with a dash |
|
|
119
|
+
| `--limit <n>` | How many to fetch. Default is 50 |
|
|
120
|
+
|
|
121
|
+
For example, `trail my-repo --for-me` lists what is waiting for you in one repository, and
|
|
122
|
+
`trail --list --mine` lists your own open pull requests across the saved owner.
|
|
123
|
+
|
|
124
|
+
Two things to know about lists across repositories (`--list`):
|
|
125
|
+
|
|
126
|
+
- They come from GitHub's search, which reports no sizes and no review state. A row there
|
|
127
|
+
says nothing about reviews, which does not mean none is needed.
|
|
128
|
+
- Giving any filter replaces the default "waiting for your review".
|
|
129
|
+
|
|
130
|
+
When the output is piped instead of shown in a terminal, the list is printed one pull
|
|
131
|
+
request per line. Leaving the list with Ctrl-C ends with exit status 130.
|
|
132
|
+
|
|
133
|
+
### Review a local repository
|
|
134
|
+
|
|
135
|
+
| Command | What it reviews |
|
|
136
|
+
| --- | --- |
|
|
137
|
+
| `trail .` | The repository you are in: its current branch against the base branch, uncommitted changes included |
|
|
138
|
+
| `trail ~/code/app` | The same for a repository elsewhere |
|
|
139
|
+
| `trail ~/code/app --base develop` | Against a base branch you choose |
|
|
140
|
+
|
|
141
|
+
This is the way to review an agent's work before it becomes a pull request.
|
|
142
|
+
|
|
143
|
+
### Folder or GitHub name?
|
|
144
|
+
|
|
145
|
+
- Anything starting with `.`, `/` or `~` is a folder. Write a folder in the current
|
|
146
|
+
directory as `./my-folder`.
|
|
147
|
+
- Any other word is read as a GitHub repository or pull request.
|
|
148
|
+
- When such a word also exists on disk, Trail stops and asks which one you mean, instead of
|
|
149
|
+
guessing. Two exceptions, where only one reading is possible: with `--base` it is the
|
|
150
|
+
folder, and a single name with no owner saved is the folder.
|
|
151
|
+
- `name/123` is pull request 123 of the repository `name`. For a repository that is itself
|
|
152
|
+
named with a number, add `--list` or use its address.
|
|
153
|
+
|
|
154
|
+
### Other commands
|
|
155
|
+
|
|
156
|
+
| Command | What it does |
|
|
157
|
+
| --- | --- |
|
|
158
|
+
| `trail` | Opens the list of your reviews in the browser |
|
|
159
|
+
| `trail config` | Shows your saved settings. `trail config owner my-org` saves one |
|
|
160
|
+
| `trail doctor` | Checks that everything Trail needs is installed and logged in |
|
|
161
|
+
| `trail stop` | Stops Trail's background server |
|
|
162
|
+
| `trail serve` | Runs the server in the foreground, for watching its output |
|
|
163
|
+
| `trail --help` | Lists all commands |
|
|
164
|
+
|
|
165
|
+
Add `--no-open` to any command to print the address without opening the browser.
|
|
166
|
+
|
|
167
|
+
## The review page
|
|
168
|
+
|
|
169
|
+
The page has three columns.
|
|
170
|
+
|
|
171
|
+
**Left: where you are.** Two tabs. *Walkthrough* lists the chapters once you have generated
|
|
172
|
+
one; *Files* lists the changed files. Each entry shows how many of its hunks you have viewed.
|
|
173
|
+
|
|
174
|
+
**Middle: the diff.**
|
|
175
|
+
|
|
176
|
+
- Press **Generate walkthrough** on the overview to have Claude order the change into
|
|
177
|
+
chapters. Each chapter explains what that step does and what to check. Every change
|
|
178
|
+
appears in exactly one chapter, including binary files, renames and permission changes;
|
|
179
|
+
anything Claude did not place gets its own chapter, so nothing is hidden.
|
|
180
|
+
- Code that only moved shows as one folded line, such as *12 lines moved unchanged to
|
|
181
|
+
src/validation.ts:4*. Click the path to see the other side, or *show lines* to unfold it.
|
|
182
|
+
- Underlined names are links. Click one to see its definition and usages in the right-hand
|
|
183
|
+
column, and keep clicking there to follow the chain.
|
|
184
|
+
- Tick **Viewed** on a hunk when you are done with it. It collapses, and the progress bar
|
|
185
|
+
at the top advances.
|
|
186
|
+
- Hover a line and press **+** to leave a note on it.
|
|
187
|
+
- Select some code to get **Explain**, **Ask Claude** and **Find problems** buttons.
|
|
188
|
+
|
|
189
|
+
**Right: Claude, Navigate, Notes.**
|
|
190
|
+
|
|
191
|
+
- *Claude* is a chat with Claude Code, which reads the repository to answer. In **Ask**
|
|
192
|
+
mode it can only read. In **Edit** mode it can change files; you see the resulting diff
|
|
193
|
+
and decide whether to discard it or commit and push it.
|
|
194
|
+
- *Navigate* shows the definition or usages you clicked on.
|
|
195
|
+
- *Notes* lists your notes. From there you can post them to GitHub as a review, or turn
|
|
196
|
+
them into a change request for Claude.
|
|
197
|
+
|
|
198
|
+
The **Model** and **Effort** selectors are in the top bar and under the chat box. They
|
|
199
|
+
start at Opus and Medium, and your choice is remembered.
|
|
200
|
+
|
|
201
|
+
### Keyboard
|
|
202
|
+
|
|
203
|
+
| Key | Action |
|
|
204
|
+
| --- | --- |
|
|
205
|
+
| `j` / `k` | Next / previous hunk |
|
|
206
|
+
| `v` | Mark the hunk viewed and move to the next |
|
|
207
|
+
| `n` / `p` | Next / previous chapter |
|
|
208
|
+
| `x` | Explain the focused hunk |
|
|
209
|
+
| `a` | Ask about the focused hunk |
|
|
210
|
+
| `/` | Go to the chat box |
|
|
211
|
+
| `m` / `e` | Next model / next effort level |
|
|
212
|
+
| `f` | Fold or unfold moved code |
|
|
213
|
+
| `1` `2` `3` | Claude, Navigate, Notes |
|
|
214
|
+
| `[` / `]` | Back / forward in Navigate |
|
|
215
|
+
| `?` | Show all shortcuts |
|
|
216
|
+
|
|
217
|
+
## Settings
|
|
218
|
+
|
|
219
|
+
Three things can be saved with `trail config <name> <value>`. `trail config` shows them, and
|
|
220
|
+
`trail config <name> --unset` removes one.
|
|
221
|
+
|
|
222
|
+
| Setting | Default | Meaning |
|
|
223
|
+
| --- | --- | --- |
|
|
224
|
+
| `owner` | none | GitHub user or organisation used when you give only a repository name |
|
|
225
|
+
| `port` | `4477` | Port of the local web page |
|
|
226
|
+
| `home` | `~/.trail` | Where Trail keeps its database, clones and checkouts |
|
|
227
|
+
|
|
228
|
+
They are stored in `~/.trail/config.json`. Changing the port or the folder stops the
|
|
229
|
+
running server, and the next command starts it with the new value.
|
|
230
|
+
|
|
231
|
+
The environment variables `TRAIL_OWNER`, `TRAIL_PORT` and `TRAIL_HOME` override the saved
|
|
232
|
+
values for one command or one shell. Setting `TRAIL_HOME` gives you a separate Trail with
|
|
233
|
+
its own data and its own settings; give it its own port as well if both should run at once.
|
|
234
|
+
|
|
235
|
+
The owner for a command is taken from the first of these that is present: an owner written
|
|
236
|
+
with the repository, `--owner`, `TRAIL_OWNER`, the saved `owner`. Writing two different
|
|
237
|
+
owners in one command is refused.
|
|
238
|
+
|
|
239
|
+
## Updating
|
|
240
|
+
|
|
241
|
+
```sh
|
|
242
|
+
npm install -g @mermaid-company/trail@latest
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
The next command notices the update and restarts Trail's background server, unless Claude
|
|
246
|
+
or an import is in the middle of something. In that case it tells you, and you run
|
|
247
|
+
`trail stop` once that work is done. Your reviews, notes and settings are kept.
|
|
248
|
+
|
|
249
|
+
## What Trail does on your machine and on GitHub
|
|
250
|
+
|
|
251
|
+
- **GitHub, read:** pull requests are fetched with your `gh` login and cloned into
|
|
252
|
+
`~/.trail/repos`.
|
|
253
|
+
- **GitHub, write:** only when you press a button and confirm. **Submit to GitHub** posts
|
|
254
|
+
your notes as one review. **Commit and push** pushes Claude's edits to the pull request
|
|
255
|
+
branch. Trail itself sends nothing else to GitHub. Another program on your computer could
|
|
256
|
+
ask Trail's server for the same two things: see
|
|
257
|
+
[Reviewing code you do not trust](#reviewing-code-you-do-not-trust).
|
|
258
|
+
- **Claude:** questions and walkthroughs use your own Claude Code login, as if you had run
|
|
259
|
+
`claude` in a terminal, and count against your own plan. Trail has no API key of its own.
|
|
260
|
+
The code and diffs Claude reads to answer are sent to Anthropic, or to whichever provider
|
|
261
|
+
your Claude Code is set up to use, exactly as when you use Claude Code yourself.
|
|
262
|
+
- **Your repositories:** for a pull request, Claude works in Trail's own checkout under
|
|
263
|
+
`~/.trail/worktrees`, never in your copy. For a local review, Edit mode changes your
|
|
264
|
+
working tree directly.
|
|
265
|
+
- **Your notes, viewed marks and conversations** are kept in `~/.trail/trail.db`. Claude Code
|
|
266
|
+
also keeps its own record of each conversation under `~/.claude/projects`, as it does for
|
|
267
|
+
any session.
|
|
268
|
+
- **Nothing else:** Trail has no telemetry and no update check. It contacts nothing itself;
|
|
269
|
+
everything that leaves your machine goes through `git`, `gh` or `claude`.
|
|
270
|
+
|
|
271
|
+
## Reviewing code you do not trust
|
|
272
|
+
|
|
273
|
+
A pull request can contain anything, including files meant to attack whoever opens it.
|
|
274
|
+
Trail assumes that:
|
|
275
|
+
|
|
276
|
+
- Claude Code starts in the pull request's checkout with `--restricted --safe-mode`. No
|
|
277
|
+
hooks, plugins, settings or `CLAUDE.md` are loaded, from the pull request or from your own
|
|
278
|
+
setup, so nothing in the checkout can make Claude Code run a program. Settings managed by
|
|
279
|
+
your organisation still apply. One consequence: the "Auto" model there is Claude Code's
|
|
280
|
+
built-in default, not the one in your settings.
|
|
281
|
+
- A local repository gets your normal Claude Code setup only if you have already accepted
|
|
282
|
+
Claude Code's trust prompt for that folder.
|
|
283
|
+
- Claude can read and search files, and edit them in Edit mode. It has no shell. In a pull
|
|
284
|
+
request's checkout its file tools are limited to that checkout and Trail's copy of the
|
|
285
|
+
diff, and refuse to follow a symbolic link out of them.
|
|
286
|
+
- Text from GitHub is cleaned before it is shown. Titles and branch names cannot send
|
|
287
|
+
control codes to your terminal, and descriptions and answers on the page cannot contain
|
|
288
|
+
forms or images. Links on the page work only to github.com.
|
|
289
|
+
- Trail's web server listens only on your own machine and refuses requests that come from
|
|
290
|
+
other websites.
|
|
291
|
+
- Trail takes nothing from the folder you run it in. Running `trail .` inside another
|
|
292
|
+
project does not load that project's `.env` or any of its configuration: the installed
|
|
293
|
+
command is a few bundled files that load nothing from the folder you run them in, and its
|
|
294
|
+
settings live in your home folder.
|
|
295
|
+
|
|
296
|
+
What these measures do not cover:
|
|
297
|
+
|
|
298
|
+
- **Other accounts on the same computer.** The web server has no password. Another account
|
|
299
|
+
on the computer can connect to it and use Trail as you: read the code under review, run
|
|
300
|
+
Claude, push Claude's edits and post reviews. Trail's data folder is also created with
|
|
301
|
+
your system's default permissions, which often let other accounts read it. Do not run
|
|
302
|
+
Trail on a computer that people you do not trust can log in to. (A program running under
|
|
303
|
+
your own account can do the same, but it could already use your GitHub login without
|
|
304
|
+
Trail.)
|
|
305
|
+
- **Windows.** Trail starts `git` and `claude` by name from inside the checkout, and on
|
|
306
|
+
Windows a program is looked for in the current folder first. Code that contains its own
|
|
307
|
+
`git.exe` could have it run. Do not open code you do not trust with Trail on Windows,
|
|
308
|
+
whether as a pull request or as a local folder.
|
|
309
|
+
- **Git filter programs.** Git runs the filter programs set up in your own Git
|
|
310
|
+
configuration, such as Git LFS, on the files a pull request marks for them in its
|
|
311
|
+
`.gitattributes`. With Git LFS, a pull request can also name the server the files are
|
|
312
|
+
downloaded from. If you use Git LFS, set `GIT_LFS_SKIP_SMUDGE=1` in the terminal that
|
|
313
|
+
starts Trail's server, which tells Git LFS not to download files when a pull request is
|
|
314
|
+
checked out.
|
|
315
|
+
- **Environment variables.** Trail's background server keeps the environment variables of
|
|
316
|
+
the terminal that started it. If a project's tooling puts variables such as `GH_TOKEN` or
|
|
317
|
+
`ANTHROPIC_API_KEY` in your shell, reviews use them until the server stops. Run
|
|
318
|
+
`trail stop` and start Trail again from a clean terminal.
|
|
319
|
+
|
|
320
|
+
Claude is told to treat text in the repository as material under review, not as
|
|
321
|
+
instructions. That lowers the risk of a pull request steering its answers but cannot remove
|
|
322
|
+
it, so treat what Claude says as a second opinion.
|
|
323
|
+
|
|
324
|
+
## Troubleshooting
|
|
325
|
+
|
|
326
|
+
Start with `trail doctor`. It names what is missing and how to fix it, and shows which
|
|
327
|
+
data folder, settings file and port Trail is using.
|
|
328
|
+
|
|
329
|
+
| Message or symptom | What to do |
|
|
330
|
+
| --- | --- |
|
|
331
|
+
| `Trail needs Node.js 22.13 or newer` | Update Node.js, then run the command again. |
|
|
332
|
+
| `No owner for "my-repo"`, or `"my-repo" … has no owner to look it up under on GitHub` | Run `trail config owner <name>`, or add `--owner <name>`. |
|
|
333
|
+
| `Could not resolve to a Repository` | The owner or repository name is wrong, or your `gh` login cannot see it. Check `gh auth status`. |
|
|
334
|
+
| `… is a file or folder here and also reads as …` | Write `./name` for the folder, or add `--list` (or the number) for the GitHub repository. |
|
|
335
|
+
| ``The `claude` command was not found`` | Install Claude Code and make sure `claude` runs in your terminal. |
|
|
336
|
+
| `Trail did not start` | Read `server.log` in the data folder that `trail doctor` shows. Most often the port is taken: run `trail config port <number>`. |
|
|
337
|
+
| `… is in use by a Trail server for another data folder` | Two Trails are set to the same port. Give one of them another with `trail config port <number>`. |
|
|
338
|
+
| Refresh says Claude is still working | Wait for the answer to finish or press **Stop** in the chat, then refresh. |
|
|
339
|
+
|
|
340
|
+
## Limits
|
|
341
|
+
|
|
342
|
+
- Navigation finds definitions by name, not by compiling the code. Functions that share a
|
|
343
|
+
name all show up, nearest first, and names that come from dependencies are not found.
|
|
344
|
+
- Code counts as moved only if its text is identical. A method that was moved and edited
|
|
345
|
+
shows its edited lines as ordinary changes. So does code that changes indentation inside
|
|
346
|
+
one file, because that usually means an `if` or a loop was added or removed around it.
|
|
347
|
+
- A moved block is recognised only when it has at least three lines of real content; a line
|
|
348
|
+
holding just a brace or a few characters does not count. A shorter method that moved
|
|
349
|
+
shows as a deletion and an addition.
|
|
350
|
+
- A viewed mark is tied to a hunk and the lines around it. If new commits change either,
|
|
351
|
+
the hunk comes back as not viewed.
|
|
352
|
+
- After a refresh, a note follows its line if the line moved. If the line changed, the note
|
|
353
|
+
is marked outdated and is posted in the review summary, not on a line.
|
|
354
|
+
- Only lockfiles, minified files, source maps, snapshots and protobuf output are hidden by
|
|
355
|
+
default as generated files.
|
|
356
|
+
- Pushing Claude's edits is offered only for pull requests from a branch of the same
|
|
357
|
+
repository, not from forks.
|
|
358
|
+
- In a list, the "waiting for my review" tab counts requests made to you directly, not to
|
|
359
|
+
a team you belong to.
|
|
360
|
+
- Review comments that already exist on GitHub are not shown.
|
|
361
|
+
- The box on the home page opens one pull request; choosing from a list is in the terminal.
|
|
362
|
+
|
|
363
|
+
## Development
|
|
364
|
+
|
|
365
|
+
Trail is TypeScript and runs on Node.js. To work on it from a clone of the repository:
|
|
366
|
+
|
|
367
|
+
```sh
|
|
368
|
+
npm install
|
|
369
|
+
npm run build # builds everything that gets published, into dist/
|
|
370
|
+
npm run trail -- my-repo # runs the command from source
|
|
371
|
+
npm run dev # server on :4477 restarting on change, web page on :4478 with reload
|
|
372
|
+
npm test
|
|
373
|
+
npm run typecheck
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
`npm run dev` uses the same port and data folder as an installed Trail. Run `trail stop`
|
|
377
|
+
first, or give the development copy its own with `TRAIL_HOME` and `TRAIL_PORT`.
|
|
378
|
+
|
|
379
|
+
| Folder | Contents |
|
|
380
|
+
| --- | --- |
|
|
381
|
+
| `bin/` | The `trail` command: version check (`trail.ts`), the program (`main.ts`), arguments (`args.ts`), pull request lists (`list.ts`), the terminal picker (`picker.ts`) |
|
|
382
|
+
| `server/` | Local web server: import (`importer.ts`), diff parsing (`diff.ts`), move detection (`moves.ts`), definition index (`symbols.ts`), Claude Code bridge (`claude.ts`, `chat.ts`, `walkthrough.ts`) |
|
|
383
|
+
| `web/src/` | The page, in React |
|
|
384
|
+
| `shared/` | Types, pull request reference parsing and settings used by more than one part |
|
|
385
|
+
| `scripts/` | Build steps: the list of third-party licences (`third-party.ts`) |
|
|
386
|
+
|
|
387
|
+
The published package contains `dist/`, plus this README, `LICENSE` and `NOTICE`. In `dist/`
|
|
388
|
+
are `cli.js` (a few lines that check the Node version before anything else loads), `main.js`
|
|
389
|
+
(the command) and `server.js`, each bundled with no dependencies to install, the built web
|
|
390
|
+
page, and `THIRD_PARTY_LICENSES.txt`. That last file holds the licences of the libraries
|
|
391
|
+
compiled into the others; the build writes it from what it bundles, and stops if a bundled
|
|
392
|
+
library has no licence file. `npm pack` shows exactly what would be published. Reviews are
|
|
393
|
+
stored with Node's built-in SQLite, which is why Node 22.13 is the minimum.
|
|
394
|
+
|
|
395
|
+
To change the model and effort Trail starts with, edit `DEFAULT_SETTINGS` in `shared/types.ts`.
|
|
396
|
+
|
|
397
|
+
## Licence
|
|
398
|
+
|
|
399
|
+
Trail is free to use and its source is public, with two restrictions. The exact terms are
|
|
400
|
+
in [LICENSE](LICENSE); this is a summary.
|
|
401
|
+
|
|
402
|
+
**You may:**
|
|
403
|
+
|
|
404
|
+
- use Trail free of charge, for personal work or at your company
|
|
405
|
+
- read, copy and change the code
|
|
406
|
+
- share it, changed or unchanged, as long as the licence and notices go with it
|
|
407
|
+
|
|
408
|
+
**You may not:**
|
|
409
|
+
|
|
410
|
+
- sell Trail, or offer a paid product or service (including paid hosting or support) whose
|
|
411
|
+
value comes mainly from Trail
|
|
412
|
+
- remove the copyright and authorship notices, claim you wrote the original, or pass off a
|
|
413
|
+
changed version as the original
|
|
414
|
+
|
|
415
|
+
The terms are the Apache License 2.0 with the Commons Clause, which removes the right to
|
|
416
|
+
sell, and an authorship condition. Because of the no-selling rule this is a
|
|
417
|
+
source-available licence, not an open-source one in the formal sense.
|
|
418
|
+
|
|
419
|
+
The published package also contains libraries by other authors, such as React and
|
|
420
|
+
highlight.js, compiled into its files. They keep their own licences, which are reproduced in
|
|
421
|
+
full in `dist/THIRD_PARTY_LICENSES.txt` inside the npm package. The build writes that file,
|
|
422
|
+
so it is not in this repository.
|
|
423
|
+
|
|
424
|
+
Trail was created by Diego Valadares Sá Fortes, working together with
|
|
425
|
+
[IARA](https://iara.app.br). For any use these terms do not allow, ask the author.
|