go-tokenless 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Continuous-Actions
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 CHANGED
@@ -1,3 +1,133 @@
1
- # Temporary Holding Version
1
+ # go-tokenless
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Delete your `NPM_TOKEN`.** One command switches your GitHub Actions release workflow to [npm trusted publishing](https://docs.npmjs.com/trusted-publishers) (OIDC), so no long-lived npm token has to be stored anywhere.
4
+
5
+ ```bash
6
+ npx go-tokenless # show what would change (writes nothing)
7
+ npx go-tokenless apply # make the changes
8
+ ```
9
+
10
+ npm is retiring direct publishing with tokens: from **January 2027** a granular token with "bypass 2FA" can no longer publish on its own ([npm docs](https://docs.npmjs.com/about-access-tokens/)). Trusted publishing is the replacement for CI. It also adds a provenance badge to every release.
11
+
12
+ ## What it does
13
+
14
+ It reads your workflows and `package.json` files, then:
15
+
16
+ | Problem | Fix it makes |
17
+ |---|---|
18
+ | `NODE_AUTH_TOKEN` / `NPM_TOKEN` passed to the publish step or job | Removes it (a token, even an empty one, stops npm from using OIDC) |
19
+ | Job can't request an OIDC token | Adds `permissions: id-token: write` (keeping the permissions the job already had) |
20
+ | Node 22 or older ships npm < 11.5.1 | Adds an `npm install -g npm@^12` step (pinned to one major, see [npm version](#npm-version)), or moves Node < 22 to 24 |
21
+ | `actions/setup-node` without `registry-url` | Adds `registry-url: https://registry.npmjs.org` |
22
+ | `changesets/action@v1`, `JS-DevTools/npm-publish@v3` | Updates to the version that supports trusted publishing |
23
+ | Script writes `_authToken` into `.npmrc` | Removes those lines |
24
+ | `repository` missing or in the wrong form in `package.json` | Adds `git+https://github.com/<owner>/<repo>.git` (with `directory` in monorepos) |
25
+
26
+ It also prints the exact `npm trust github …` command for every package and the remaining manual steps.
27
+
28
+ It **refuses** (exit code 1) rather than guessing when trusted publishing can't work: self-hosted runners, or a `repository` field pointing at another repo. It leaves jobs that publish to GitHub Packages alone.
29
+
30
+ ## Example
31
+
32
+ ```text
33
+ $ npx go-tokenless
34
+ go-tokenless: Ready to go tokenless. (acme/widgets)
35
+
36
+ Changes:
37
+ .github/workflows/release.yml
38
+ - publish: remove `NODE_AUTH_TOKEN` from job env
39
+ - publish: grant `id-token: write`
40
+ - publish: raise setup-node from Node 20 to 24 (trusted publishing needs Node 22.14+)
41
+ package.json
42
+ - widgets: add repository.url git+https://github.com/acme/widgets.git
43
+
44
+ Next:
45
+ 1. Run `npx go-tokenless apply` (or apply the diff above) and commit the changes on a branch.
46
+ 2. Add a trusted publisher for each package. With npm 11.15+ logged in with 2FA, run:
47
+ npm trust github widgets --repo acme/widgets --file release.yml --allow-publish --yes
48
+ 3. Merge, then let the release workflow publish once. Check the new version shows a provenance badge.
49
+ 4. Delete the old secret (`gh secret delete NPM_TOKEN`) and revoke the token on npmjs.com.
50
+ ```
51
+
52
+ The default command also prints a unified diff. Your file's comments, quoting and layout are kept: only the lines that need to change are touched.
53
+
54
+ ## Supported release setups
55
+
56
+ | Setup | Supported | Notes |
57
+ |---|---|---|
58
+ | `npm publish` (incl. workspaces) | ✓ | |
59
+ | pnpm `publish` / `-r publish` | ✓ | pnpm 10 hands off to npm; pnpm 11 needs 11.1.3+ |
60
+ | Yarn Berry `yarn npm publish` | ✓ | Yarn 4.10.3+; remove `npmAuthToken` from `.yarnrc.yml` |
61
+ | changesets (`changesets/action`) | ✓ | updated to v2 |
62
+ | semantic-release | ✓ | needs @semantic-release/npm 13.1.0+ (semantic-release 25+) |
63
+ | release-please + `npm publish` | ✓ | |
64
+ | Lerna / Nx release | ✓ | Lerna 9+ |
65
+ | JS-DevTools/npm-publish | ✓ | updated to v4 |
66
+ | release-it | ✓ | also set `npm.skipChecks: true` |
67
+ | Yarn 1 `yarn publish`, `bun publish` | warns | not supported by those tools yet; switch the command to `npm publish` |
68
+ | Reusable workflows (`workflow_call`) | ✓ | npm checks the *calling* workflow's file name; the plan uses it |
69
+
70
+ Version floors are checked against your `package.json` where possible.
71
+
72
+ ## Things only you can do
73
+
74
+ The tool never touches your npm account. After applying:
75
+
76
+ 1. **Add a trusted publisher** for each package: the printed `npm trust github …` commands (npm 11.15+, needs your 2FA), or npmjs.com → package → **Settings → Trusted publishing**.
77
+ 2. **Brand-new packages** must be published once by hand first; npm can only attach a trusted publisher to a package that exists. The plan flags these.
78
+ 3. **Delete the secret** and revoke the token once a release has gone out.
79
+
80
+ ## Use it from an AI coding agent
81
+
82
+ Agents can run the CLI with `--json` (stable shape, `status` field, exit codes), or use the MCP server:
83
+
84
+ ```bash
85
+ claude mcp add go-tokenless -- npx -y go-tokenless mcp
86
+ ```
87
+
88
+ ```json
89
+ { "mcpServers": { "go-tokenless": { "command": "npx", "args": ["-y", "go-tokenless", "mcp"] } } }
90
+ ```
91
+
92
+ Tools: `plan_trusted_publishing` (read-only) and `apply_trusted_publishing` (writes files, no git or network writes). There is also an [Agent Skill](skills/go-tokenless/SKILL.md):
93
+
94
+ ```bash
95
+ npx skills add Continuous-Actions/go-tokenless
96
+ ```
97
+
98
+ Just ask: *"Move our npm publishing to trusted publishing."*
99
+
100
+ ## Options
101
+
102
+ ```text
103
+ npx go-tokenless [plan|apply|mcp] [--json] [--diff] [--repo owner/repo] [--cwd dir] [--offline]
104
+ [--npm-version <range>] [--npm-args "<args>"]
105
+ ```
106
+
107
+ | Option | Meaning |
108
+ |---|---|
109
+ | `--json` | Print the full plan as JSON |
110
+ | `--diff` | Include the diff (always on for `plan`) |
111
+ | `--repo` | GitHub `owner/repo`, when the `origin` remote isn't GitHub |
112
+ | `--offline` | Skip the npm registry lookup that checks each package already exists |
113
+ | `--npm-version <range>` | npm version for the inserted upgrade step. Default `^12` |
114
+ | `--npm-args "<args>"` | Extra arguments appended to every npm command it generates: the upgrade step and the `npm trust` commands (for example `--registry=…` or `--loglevel=warn`) |
115
+
116
+ Exit codes: `0` ok, `1` blocked (errors to fix by hand), `2` usage error, `3` unexpected error. Needs Node 22.14+.
117
+
118
+ ### npm version
119
+
120
+ When a publish job runs on a Node version whose bundled npm is too old, go-tokenless adds `npm install -g npm@^12`. It is pinned to one major on purpose: a new npm major can change how publishing behaves, and a release pipeline should not change under you. npm 12 needs Node 22.22.2+ or 24.15+; jobs pinned to an older exact Node 22 get a warning.
121
+
122
+ To use a different npm, pass `--npm-version` (for example `--npm-version ^11.6.0`). go-tokenless warns that an untested version may break the release, and refuses versions older than 11.5.1, which cannot use trusted publishing.
123
+
124
+ ## Troubleshooting the errors people hit
125
+
126
+ - **`npm error code ENEEDAUTH`**: the job has no `id-token: write`, npm is older than 11.5.1, or the workflow file name doesn't match the trusted publisher exactly (case-sensitive, with `.yml`).
127
+ - **`npm error 404 Not Found - PUT https://registry.npmjs.org/...`**: usually the same causes as ENEEDAUTH, an `environment` mismatch, or the package has no trusted publisher yet.
128
+ - **`npm error code E422` … `repository.url`**: `package.json` `repository` doesn't match the GitHub repo. `go-tokenless apply` fixes the format; a different repo is reported as an error.
129
+ - **Publishing still uses the token**: something still sets `NODE_AUTH_TOKEN`, `NPM_TOKEN`, an `.npmrc` `_authToken`, or `.yarnrc.yml` `npmAuthToken`. Run `npx go-tokenless` again; it reports leftovers.
130
+
131
+ ## License
132
+
133
+ MIT