Code tours
A code tour is a short, ordered walk through code. An agent writes it to explain something to you: how a change works, where a request is checked, what a pull request touches and in which order to read it. Each step has a title, a note in Markdown and one or more code segments: a segment is a range of lines of one file, with its key lines and an optional caption, so one step can show the few places, in one file or several, that one idea spans. You read the tour on its Stamp page, with the code of each step's segments shown beside its note, and you can comment on any step. The agent that wrote the tour is told about your comment.
A tour is pinned to one commit. The code you see is the code at that commit, so the line numbers in the notes always match, even after the branch moves on. If the tour is attached to a pull request whose head has moved since, the page says the tour may be out of date.
Reading a tour
An agent gives you the tour's link. A tour attached to a pull request opens on that pull request's Tours tab, with the tour open:
https://stamp.build/github/OWNER/REPO/pull/42?server=SERVER&tab=tours&tour=tour_0123456789abcdef01234567A tour without a pull request has a page of its own:
https://stamp.build/s/SERVER/github/OWNER/REPO/tours/tour_0123456789abcdef01234567Open it while signed in to Stamp. The tour shows:
- the title, the repository, the commit and, when there is one, the pull request the tour belongs to;
- the steps in order: the title, the note, and each segment's lines with a few lines around them, its caption and the author's notes on single lines (annotations), shown beside those lines. Each segment links to the whole file at that commit;
- the comments on each step.
A pull request's tours are also listed with the pull request.
On a tour attached to a pull request, each segment can also show the diff of its lines: the parts of the pull request's change, from its base to the tour's commit, that touch those lines, and whether the file was added, changed or renamed. Stamp reads that comparison with your own GitHub account each time you open the tour; when it cannot be read, or GitHub gives no diff for a file (a binary or very large file), the segment says the diff is not available and the tour still shows its code. A very long diff is cut between hunks at 64 KiB.
When the pull request's head has moved past the tour's commit, each segment also says where its lines are at the new head: the same, moved (the file was renamed or lines above changed, its own lines did not), changed (with the diff of what changed in them since the tour's commit), removed (the file was deleted), or unknown. Its focus ranges and annotated lines follow it, and you can read its code at the new head. This comparison is read the same way, with your own GitHub account.
Such a tour has a Diff / Code switch above its code, on Diff when any segment has a diff. The choice stays as you move between steps and is kept in the link (&view=diff or &view=code). In the diff, the key lines have a solid bar at their left and each note on a line sits under it; a note on a line the diff does not show is listed under the diff with its line number. A segment whose lines the pull request did not change says so and shows its code; a renamed file shows its old and new path.
When the pull request's head has moved, the tour opens At head, with an At head / At tour commit switch above its code and a line naming the tour's commit and the pull request's head; at the head it also says how many segments changed since, or that the two could not be compared. At the head each segment shows its code there, with its key lines and notes on their new lines: a moved segment has a Moved badge (or Renamed, with both paths), a changed one shows what changed in its lines since the tour's commit, and a segment that was removed, or could not be compared, shows the tour's own code and says so. A note whose line was edited or deleted is listed under the code with its line at the tour's commit. The choice stays as you move between steps and is kept in the link (&at=head or &at=commit); the Diff / Code switch is there only at the tour's commit.


Marking steps as viewed
You can mark a step as viewed, and unmark it, as you read, with the Viewed button next to Previous and Next (on a phone, above the step). Moving to the next step never marks one for you. The list of steps shows a check next to each step you viewed, and the line under the tour's title counts them ("2 of 5 viewed · 1 changed since").
Stamp remembers what the step showed when you marked it: the files and the text of its lines, as the tour shows them (at the pull request's head when the tour reads it there, otherwise at the tour's commit). If that code changes later, for example a new push to the pull request edits those lines, the step says Changed since you viewed it, its Viewed box is clear again and the list of steps shows a different mark next to it, so you know to read it again and mark it again. Code that only moves, such as lines added above it, does not count as a change.
If the step's code changes between reading the page and pressing Viewed, Stamp does not mark it, reads the tour again and says so on the step. If Stamp can't save the mark (for example, GitHub is rate-limiting you), the box goes back and the step says to try again, and when if GitHub said. A step whose code Stamp couldn't read just now has no Viewed button until it can; a mark you already made still shows in the list. If your marks can't be loaded, the tour says so and shows no Viewed at all.
Your marks are yours alone: nobody else, the tour's author included, sees which steps you viewed. They are kept by Stamp, not in your browser, so they follow you to another one. A mark is deleted 60 days after you made it, or when you unmark the step. Agents do not have Viewed marks.
Commenting on a step
Write a comment under any step. Comments are Markdown, up to 16 KiB each. The agent that wrote the tour receives one notification for each comment, naming the tour, the step and you, and can reply on the step. You are never notified of your own comments.
Comments on a tour are Stamp's own: they are not posted to GitHub.
Who can see a tour
A tour shows private code, so Stamp shows it only to someone who can read its repository now:
- People: you see a tour only if the repository is one your Stamp server covers and your own GitHub account can read it, exactly as for the repository's code pages in Stamp. Stamp reads the code of each segment with your own GitHub account.
- Agents: an agent sees a tour only if it can read the repository through Stamp, as for reading its pull requests.
- A tour belongs to the Stamp server it was written on. Nobody on another server sees it.
Anyone who cannot see a tour gets the same answer as for a tour that does not exist (TOUR_NOT_FOUND); the page does not say which. Commenting needs the same access as reading.
When a Stamp server's GitHub App is uninstalled, its tours and their comments are deleted with the rest of its repository content (see Data retention).
For agents: writing a tour
Write the steps as a JSON file. Each step has a title, a note and 1 to 8 segments:
{
"title": "How a sign-up is saved",
"steps": [
{
"title": "The form arrives",
"note": "**The handler** reads the form; the checks come after.",
"segments": [
{"path": "signup/handler.go", "lines": [120, 148], "focus": [[126, 129]], "caption": "The handler reads the form.",
"annotations": [{"line": 127, "text": "The email is trimmed before it is compared."}]},
{"path": "signup/api.go", "lines": [30, 44], "caption": "The same handler for the JSON API."}
]
},
{
"title": "Each field is checked",
"note": "Then each field is checked against the form's rules.",
"segments": [{"path": "signup/validate.go", "lines": [40, 52]}]
}
]
}Then create the tour at the commit you mean, and send the person the link it prints:
stamp tour create --repo acme/web --ref feature/login --file tour.json --pr 42
# created code tour tour_0123456789abcdef01234567 of acme/web at 3f2c... (2 steps)
# page: https://stamp.build/github/acme/web/pull/42?server=acme&tab=tours&tour=tour_0123456789abcdef01234567With --pr, every link Stamp gives for the tour (this output, stamp tour view and stamp tour list, the url field of their --json, and the notification about a comment) is the pull request's Tours tab with the tour open. Without it, the link is the tour's own page.
When a person asks you to explain a pull request, or the change is large, write a code tour with stamp tour create --pr N and send them the link it prints (the PR's Tours tab).
--refis a branch, a tag or a commit. Stamp resolves it to a commit when the tour is created and pins the tour there. Push first: Stamp reads the commit on GitHub.- A step's
titleis required: plain text on one line, at most 120 characters (TOUR_STEP_TITLE_INVALIDwhen it is empty or holds a control, bidirectional, zero-width or line separator character;TOUR_STEP_TITLE_TOO_LONG). A segment'scaptionis optional, plain text on one line, at most 280 characters (TOUR_SEGMENT_CAPTION_INVALID,TOUR_SEGMENT_CAPTION_TOO_LONG). - Every segment's
pathmust be a text file at that commit (relative to the repository's root), and itslinesrange[FROM, TO]must lie within the file. Otherwise nothing is stored and the error names the step and the segment:TOUR_STEP_PATH_NOT_FOUND,TOUR_STEP_LINES_OUT_OF_RANGE,TOUR_STEP_FILE_NOT_TEXT. - A
pathhas no leading/, no..or.segment and no backslash, and no character that can make it read as something it is not: no control character, no bidirectional control (such as U+202E) or other invisible format character (zero-width spaces and joiners, U+FEFF), and no line or paragraph separator (U+2028, U+2029). Any other Unicode is fine, spaces, accented letters and CJK included. Such a path is refused withTOUR_INVALID, naming the step and segment, before anything is read. --pr Nattaches the tour to a pull request of the repository, so it is shown on that pull request's Tours tab, its link is that tab, and the notifications about it are grouped with that pull request.- Limits: at most 50 steps, at most 8 segments in a step (
TOUR_STEP_TOO_MANY_SEGMENTS) and 30 in the whole tour (TOUR_TOO_MANY_SEGMENTS), over at most 20 different files; a note at most 8 KiB, one segment at most 2000 lines, a title at most 200 characters (TOUR_TOO_LARGE). Every limit's refusal names it in its params:limit,max,given, andstepandsegmentwhen it is one step's or one segment's. - One agent creates at most 30 tours an hour on one Stamp server: the next is refused
TOUR_CREATE_RATE_LIMITED(HTTP 429) withretry_at, the time it is accepted again, and nothing is stored. - You need to be able to read the repository through Stamp, as for
stamp pr view. - The format before steps had titles and segments (a
path,linesandfocuson the step itself) is no longer accepted:stamp tour createrefuses such a file, and Stamp refuses it from an older CLI withTOUR_CLI_OUTDATED(paramsminimum, the first CLI that writes the new format, 0.29.0, andversion, the CLI's own, when it sent it). Upgrade the CLI and write each old step as one segment. Tours written in the old format were removed when this change was deployed.
Key lines (focus)
A segment may name its key lines with focus: up to 10 ranges [FROM, TO], each inside the segment's lines. The page highlights them inside the segment's code.
{"path": "signup/handler.go", "lines": [120, 148], "focus": [[126, 129], [140, 140]]}A range outside the segment's lines is refused with TOUR_STEP_FOCUS_OUT_OF_RANGE (params step, segment, focus).
Notes on single lines (annotations)
A segment may carry annotations: short notes on single lines, shown beside the line they name. Use them for what one line does, and keep the step's note for the idea the step explains.
{"path": "signup/handler.go", "lines": [120, 148],
"annotations": [
{"line": 126, "text": "The form is parsed before anything else is read."},
{"line": 140, "text": "An empty email stops here, with a message for the form."}
]}linemust lie inside the segment'slines(TOUR_ANNOTATION_LINE_OUT_OF_RANGE, paramsstep,segment,line,lines), and a line has at most one annotation (TOUR_ANNOTATION_LINE_DUPLICATE, the same params).textis plain text on one line, trimmed: not empty, no newline, no control, bidirectional, zero-width or line separator character (TOUR_ANNOTATION_TEXT_INVALID, paramsstep,segment,line,reasonemptyorunsafe_character), at most 500 characters (TOUR_ANNOTATION_TEXT_TOO_LONG). It is shown as written, never as Markdown.- At most 20 annotations in a segment (
TOUR_SEGMENT_TOO_MANY_ANNOTATIONS) and 200 in the whole tour (TOUR_TOO_MANY_ANNOTATIONS). These refusals carrylimit,maxandgiventoo. stamp tour viewprints each annotation under its segment (line 126: ...); the answers list them in line order.
Links in a note
A note is plain Markdown, stored as you wrote it. These link forms point into the code, and Stamp checks each one when the tour is created:
| Link | Points at |
|---|---|
[text](#L62), [text](#L62-L69) | Lines of the file of the step's first segment. They must exist in the file. |
[text](dir/file.go), [text](dir/file.go#L45-L52) | A file of the repository at the tour's commit, its path from the repository's root, under the same rules as a segment's path (no leading /, no .., no control, bidirectional or zero-width character). The file must exist and the lines lie within it. A linked file counts toward the 20 files. |
[text](#step-3) | Another step, numbered from 1 as on the page. |
Any other link, such as an https:// URL, is left alone. A link that does not check out is refused with TOUR_NOTE_LINK_INVALID, naming the step and the link; nothing is stored.
Write for a person reading the code for the first time: one idea per step, in the order the code runs or the order they should read it. Give a step more than one segment when that idea lives in several places (a caller and its callee, a type and where it is checked); keep each segment to the lines that matter, as the page shows a few lines around them.
When a person comments, you receive a notification such as artin commented on step 2 of your code tour "How a sign-up is saved" (acme/web#42). Read the comment and reply:
stamp tour view tour_0123456789abcdef01234567
stamp tour comment tour_0123456789abcdef01234567 --step 2 --body "The row is written only after this check."Command reference
| Command | What it does |
|---|---|
stamp tour create --repo OWNER/REPO --ref REF --file FILE [--title TITLE] [--pr N] | Creates a tour pinned to the commit REF names; prints its id and link (with --pr, the pull request's Tours tab). --file - reads standard input. |
stamp tour list --repo OWNER/REPO [--pr N] | The repository's tours on your server, newest first; --pr keeps those of one pull request. |
stamp tour view TOUR_ID | The tour's steps with their titles, segments and notes, and the comments on each step. |
stamp tour comment TOUR_ID --step N (--body TEXT | --body-file FILE) | Replies on step N (from 1). Nobody is notified of an agent's comment. |
Every command takes --json for Stamp's answer as it is.
Jump to definition (the symbol index)
Identifiers in a tour's excerpts that are defined in the repository can link to their definition at the tour's commit, with its signature and file and line. Stamp builds the index in the background after the tour is created, never while the agent waits. Go is read with Go's own parser, TypeScript and JavaScript with a light scanner. An index is built once per repository and commit on a server; a tour keeps only the definitions its excerpts and notes name. Names are matched by name: a definition in the same file wins, then one in the same directory, otherwise every candidate is listed (a name with too many candidates links nowhere).
Each repository is bounded (its file count, its size, the time the index takes and the size of its answer); vendored, generated and build directories are skipped, and a name defined more than 64 times links nowhere. A tour's segments, in every step and every file they name, are read up to 2000 lines in all, shared evenly between them; identifiers past that link nowhere. A tour whose repository is over a size bound says too_large; one whose index could not be built, or took longer than its time limit on every attempt, says failed (a later tour at the same commit tries again). The index and each tour's symbols are deleted with the server's repository content when its App is uninstalled.
Only someone who may read the tour sees its symbols, on the page and in stamp tour view --json. The answer carries symbols_state: pending while the index is being built (the page reads the tour again), ready, failed or too_large; it is left out for older tours. Only when it is ready, symbols lists at most 500 definitions the tour's segments or notes name (10 000 places in all): each with its name, its receiver or class, its kind (func, method, type, const, var, class or interface), its file and lines, a one-line signature, and where each segment names it (the step from 1, the segment from 1 within the step, that segment's file, the line, and the column from 1 and length, counted in UTF-16 code units as JavaScript counts a line). These names and signatures come from the repository's code: they are shown as plain text, never as markup, with no control, bidirectional or other format characters.