History

docs: add contributor guide and PR template

bairon.dev committed 4 months ago

Commit 96162591 parent 400b86a3 files · +92 −1Browse files

Showing the changes to CONTRIBUTING.md (1 of 3 files). Show all

Unified · Split

CONTRIBUTING.md+74−0
@@ -0,0 +1,74 @@
1+# Contributing to torlink
2+
3+torlink stays small on purpose. The best way in is to read the code you're about to touch, match how it already works, and keep your change tight. Three recent pull requests set the bar, and this guide points back at them throughout:
4+
5+- [#4](https://github.com/baairon/torlink/pull/4) gave the arrow keys spatial pane navigation without breaking a single existing shortcut.
6+- [#5](https://github.com/baairon/torlink/pull/5) turned a cryptic crash on old Node into a one-line "upgrade me" message.
7+- [#6](https://github.com/baairon/torlink/pull/6) added copy-magnet, cross-platform, with tests.
8+
9+None of them were big. All of them fit the grain. That's the whole idea.
10+
11+## Set up
12+
13+```sh
14+git clone https://github.com/baairon/torlink
15+cd torlink
16+npm install
17+npm run dev
18+```
19+
20+`npm run dev` runs the live TUI through tsx, no build step. The README's [Contributing](README.md#contributing) section has the build variant if you want it.
21+
22+## Before you open a PR
23+
24+Run these and make sure they're clean:
25+
26+```sh
27+npm run typecheck # tsc --noEmit, zero errors
28+npm test # vitest, all green
29+```
30+
31+Then check your change against the standards below. The pull request template walks you through the same list.
32+
33+## The standards
34+
35+### Match the existing grain
36+
37+Reuse what's there before you write something new. Cursor movement goes through `wrapStep` (`src/ui/move.ts`). Key hints live in the `Hint` / `HELP_GROUPS` / `footerHints` system (`src/ui/keymap.ts`). Shared app state is the `Store` interface (`src/ui/store.ts`).
38+
39+#4 is the model here: it added a whole navigation mode and still introduced no new state, it leaned on the existing `region` and `captureMode` flags and reused `wrapStep`. If you catch yourself adding a parallel way to do something the codebase already does, stop and use the one that's already there.
40+
41+### Stay additive, never break muscle memory
42+
43+People already have the current keys in their fingers. New behavior should layer on, not overwrite. #4 lit up the arrow keys (which did nothing before) while leaving tab, enter, esc, and every letter command exactly where they were. If your change retrains an existing key, it needs a real reason and a clear note in the PR.
44+
45+### Cross-platform or it doesn't ship
46+
47+torlink runs on Windows, macOS, and Linux, so anything that touches the OS branches all three. Look at `writeClipboard` in `src/util/clipboard.ts` from #6: powershell on win32, pbcopy on darwin, then wl-copy, xclip, xsel on linux. #5's `scripts/cli-entry.cjs` is the same instinct aimed at the Node runtime. "Works on my machine" is not the bar.
48+
49+### Fail soft, never crash
50+
51+When something the user can't control goes wrong, degrade gracefully and say so. #5 prints a friendly upgrade message and exits cleanly instead of letting old Node spit out a parse error. #6's `writeClipboard` returns `false` and surfaces a notice when no clipboard tool exists, it never throws. Reach for a clear message and a fallback before you reach for an exception.
52+
53+### Test the logic
54+
55+Non-trivial logic gets a vitest test. Pure functions are easy, see `src/util/format.test.ts`. For code that shells out or leans on a platform, mock the node built-in, see `src/util/clipboard.test.ts` from #6 mocking `node:child_process`. Run the suite with `npm test`.
56+
57+### Wire the UI surface, and keep it minimal
58+
59+torlink shows one contextual footer plus a `?` cheatsheet, never a wall of commands. Two rules when you add to it:
60+
61+- A new key means updating both halves of `src/ui/keymap.ts`: `HELP_GROUPS` (the `?` sheet) and `footerHints` (the footer). #6 did both for `y`.
62+- A new `Store` field means adding a matching entry to `makeStore` in `scripts/render-previews-impl.tsx`, or `npm run previews` (the README screenshots) breaks. #6's `copyMagnet` sits in there as a noop for exactly this reason.
63+
64+### Respect the calm theme
65+
66+torlink is pastel-violet and quiet. There is exactly one gradient, the wordmark sheen. Everything else is solid color. Please don't add a second gradient.
67+
68+## Commits and pull requests
69+
70+- Use [Conventional Commits](https://www.conventionalcommits.org) prefixes: `feat:`, `fix:`, `docs:`, `chore:`, `refactor:`.
71+- Say why, not just what. The diff already shows the what.
72+- One concern per pull request. Two unrelated ideas are two PRs.
73+
74+Thanks for helping keep torlink sharp.