@patchlight/cli 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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +150 -0
  3. package/dist/cli.js +170 -0
  4. package/package.json +55 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Patchlight
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,150 @@
1
+ # @patchlight/cli
2
+
3
+ [Patchlight](https://patchlight.dev) in your terminal: AI security scanning of the
4
+ code on your disk **right now** — uncommitted work included — with findings
5
+ streaming in one at a time and keyboard triage when they land.
6
+
7
+ Node.js 18.17+.
8
+
9
+ ```bash
10
+ npm install -g @patchlight/cli
11
+ patchlight login
12
+ cd your-repo && patchlight scan --diff
13
+ ```
14
+
15
+ ## Why this and not `@patchlight/sdk`
16
+
17
+ They are the same product with different jobs.
18
+
19
+ | | `@patchlight/sdk` | `@patchlight/cli` |
20
+ |---|---|---|
21
+ | For | CI pipelines | developers at a terminal |
22
+ | Runtime dependencies | **zero** | ink, react, highlight.js |
23
+ | Auth | `PATCHLIGHT_API_KEY` | `patchlight login` (browser) |
24
+ | Output | plain text / `--json` | live TUI, then triage |
25
+
26
+ Everything non-interactive — `review`, `status`, `findings`, `repos`,
27
+ `balance`, `--fail-on` — behaves identically here, because this package
28
+ delegates those commands to the SDK's own implementation rather than
29
+ reimplementing them. Installing this does not change what your pipeline does.
30
+
31
+ ## Sign in
32
+
33
+ ```bash
34
+ patchlight login
35
+ ```
36
+
37
+ Opens a browser, shows you a short code to confirm, and stores a token in
38
+ `~/.patchlight/credentials.json` (mode `0600`). No secret passes through your
39
+ shell history, and the machine appears in the dashboard under **API Keys** where
40
+ you can revoke it.
41
+
42
+ Headless box or over SSH? The code and URL are always printed — open them
43
+ anywhere you are signed in.
44
+
45
+ `PATCHLIGHT_API_KEY` still wins when it is set, so a CI job on a machine somebody
46
+ once logged into uses the credential its pipeline configured.
47
+
48
+ ## Scan
49
+
50
+ ```bash
51
+ patchlight scan
52
+ ```
53
+
54
+ Asks what to scan, then runs it:
55
+
56
+ - **Changed files** — what this branch touched, uncommitted work included. Seconds
57
+ and cents. This is the one to run on every push.
58
+ - **Whole repository** — every scannable file here. The monthly one.
59
+ - **A directory** — one subtree.
60
+
61
+ Skip the picker with flags:
62
+
63
+ ```bash
64
+ patchlight scan --diff # changed files
65
+ patchlight scan --diff --base main # against an explicit base
66
+ patchlight scan --path src/api # one subtree
67
+ patchlight scan --no-neighbours # with --diff, changed files only
68
+ ```
69
+
70
+ ### What happens
71
+
72
+ 1. **Local walk** — instant, no network. Skips `node_modules`, build output,
73
+ lockfiles and binaries.
74
+ 2. **Preflight** — checks your balance and the size caps before a single byte of
75
+ code is uploaded.
76
+ 3. **Upload** — a bounded snapshot of the working tree.
77
+ 4. **Triage** — how much of it is worth reading, summarised by weakness family.
78
+ 5. **Findings** — streamed as the model completes them, not batched to the end.
79
+
80
+ All of it runs fullscreen, and the terminal you started in is left exactly as it
81
+ was when you quit — with a short summary of what was found printed under your
82
+ prompt.
83
+
84
+ ### Triage
85
+
86
+ When the scan ends you are already in it — no second command, nothing to copy.
87
+ Each finding shows the offending lines **read from your disk**, syntax
88
+ highlighted by highlight.js on a tinted block with the flagged line picked out,
89
+ and the suggested fix underneath — code highlighted, advice as plain text.
90
+
91
+ ```
92
+ ↑↓ move · d dismiss · r resolve · u reopen · o open in $EDITOR · q quit
93
+ ```
94
+
95
+ `g` / `G` jump to the first and last finding; `PgUp` / `PgDn` move a page at a
96
+ time. `o` hands the terminal over to `$EDITOR` at the right line and takes it
97
+ back when you quit — `vim`, `code`, `cursor`, `subl` and `zed` all get the
98
+ argument form they actually want.
99
+
100
+ Triage writes through to the same place the dashboard reads, so a dismissal here
101
+ is a dismissal everywhere.
102
+
103
+ ### `--diff` is the one to learn
104
+
105
+ A full-repo scan is a monthly thing. A branch scan is a per-push thing: it reads
106
+ only what you changed (plus same-directory siblings, so cross-file flows are still
107
+ visible), takes seconds, and costs cents. It also sees code you have not committed
108
+ — which a server that clones your repository structurally cannot.
109
+
110
+ ## Non-interactive use
111
+
112
+ Piping or redirecting output turns off the picker, the fullscreen UI and the
113
+ triage keys: the scan runs whole-repo and prints one plain report.
114
+
115
+ ```bash
116
+ patchlight scan --diff > scan.log
117
+ ```
118
+
119
+ | Exit code | Meaning |
120
+ |-----------|---------|
121
+ | `0` | Scan completed |
122
+ | `1` | Findings at or above `--fail-on` (the delegated CI commands) |
123
+ | `2` | Scan failed |
124
+ | `3` | Usage/authentication error |
125
+ | `4` | Transient — safe to retry |
126
+
127
+ ## Environment
128
+
129
+ | Variable | Meaning |
130
+ |---|---|
131
+ | `PATCHLIGHT_API_KEY` | API key; overrides a stored login |
132
+ | `PATCHLIGHT_BASE_URL` | API origin override |
133
+ | `PATCHLIGHT_CONFIG_DIR` | Credential directory (default `~/.patchlight`) |
134
+ | `EDITOR` / `VISUAL` | Used by `o` in triage |
135
+ | `NO_COLOR` / `FORCE_COLOR` | Standard colour control; honoured by the whole UI |
136
+
137
+ ## Privacy
138
+
139
+ `patchlight scan` uploads the text files of your working tree, under the skip
140
+ rules and size caps above, to the Patchlight API for analysis. It never uploads
141
+ binaries, lockfiles, dependency directories, or anything outside the repository
142
+ root. Use `--path` or `--diff` to narrow what is sent.
143
+
144
+ ## Documentation
145
+
146
+ <https://patchlight.dev/docs/cli>
147
+
148
+ ## License
149
+
150
+ MIT