Repository navigation
add the new-plugin starter command - #124
Conversation
go run ./cmd/new-plugin --api <id> --provider <Name> --format <format> scaffolds a provider on any of the eight format plugins: the definition, its Register line, a registered/golden/drop test over placeholder sources, testdata rows, the provider page, the docs/plugins.md row and docs/plugins.json. It refuses a taken id and then changes nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: adssib <75389300+adssib@users.noreply.github.com>
|
Claude finished @adssib's task in 2m 32s —— View job ✅ Ready to merge (after #121): the starter adds no plugin, all checks I ran pass, I found no blocking bugs, and it meets every acceptance criterion in #116. Rules
BugsNone found that block the merge. Things I checked by reading the code:
One edge case: if the Verified
Non-blocking (optional)
Thanks, this is a careful piece of work: the refusal-changes-nothing test that hashes the whole tree is a nice touch. |
| case strings.Contains(c, "url"): | ||
| cells = append(cells, "TODO(new-plugin): "+source) | ||
| case strings.Contains(c, "saved") || strings.Contains(c, "date") || strings.Contains(c, "fetched"): |
There was a problem hiding this comment.
Non-blocking: plugins/openapi/testdata/README.md heads its table | Files | Source | Checked | License | Quote |, so neither source nor checked matches here. For --format openapi those two cells get a bare TODO(new-plugin) with no URL or date hint. Matching source with the URL and checked with the date would fix it:
| case strings.Contains(c, "url"): | |
| cells = append(cells, "TODO(new-plugin): "+source) | |
| case strings.Contains(c, "saved") || strings.Contains(c, "date") || strings.Contains(c, "fetched"): | |
| case strings.Contains(c, "url") || strings.Contains(c, "source"): | |
| cells = append(cells, "TODO(new-plugin): "+source) | |
| case strings.Contains(c, "saved") || strings.Contains(c, "date") || strings.Contains(c, "fetched") || strings.Contains(c, "checked"): |
| if end < 0 { | ||
| return nil, fmt.Errorf("%s: no %s", pluginlist.Table, pluginlist.EndMarker) | ||
| } | ||
| row := fmt.Sprintf("| [`%s`](https://github.com/patch-it-dev/patch-it-plugins/blob/main/providers/%s.md) | %s | %s | %s | `%s` | [%s](%s) | live |\n", |
There was a problem hiding this comment.
Non-blocking, but worth thinking about: this row is live, and the plugin is registered in plugins/all, so an unfinished scaffold merged by mistake would be run by patch-it's hosted ingestion service with a placeholder source. I checked every format's placeholders and none of them can emit an event: the feed reader returns nil, Keep matches only placeholder-text-*, the openapi adapter returns errors, and the GitHub sources point at TODO-owner/TODO-repo. So the risk is noise, not wrong PRs. Right now the only guard is a PR-template checkbox. A make check step (not go test, so the "passes right after" criterion still holds) that fails on TODO(new-plugin) outside cmd/new-plugin/ would make it a real guard, since AGENTS.md already asks everyone to run make check.
Also: quotes and backslashes refused in --provider and --watches, the openapi testdata table's Source and Checked columns get their hints. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: adssib <75389300+adssib@users.noreply.github.com>
Stacked on #121 (needs its
docs/plugins.json,Layercolumn andmake plugins-json). Review/merge #121 first; this PR's diff againstmake-checkis one commit.Closes #116
What this changes
go run ./cmd/new-plugin --api <id> --provider <Name> --format <format>scaffolds a provider on any of the eight format plugins (openapi,retirements,migrationguide,removedmembers,changelog,feed,apichangelog,catalog), following how the existing providers are added:openapiadapter/<api>.go(a stubAdapter:LatestTag/Fetchto write)Plugin{Adapter: adapter.X{}}retirementsretire/<api>.go(retire.Page) + itsmigrate/providers entryPlugin{Page: retire.X, Archiver: kit.Wayback{}}migrationguidesdkguide/<api>.go(sdkguide.Guide) + itsmigrate/guides entryPlugin{Guide: sdkguide.X}removedmembers,changelog,feed,apichangelog,catalogplugins/<format>/<api>.goPlugin{…}For every format it also writes:
plugin.Registerline, added to the format's existinginit(parsed withgo/parser, formatted withgo/format), so all registrations stay in one place;plugins/<format>/<api>_test.go:Test<X>RegistersItself(kittest.Registered),Test<X>Golden(kittest.Goldenover the in-memorykittest.Mem) andTest<X>DropsANonChange, over placeholder sources intestdata/, and the golden file written from them (go test -run … -update);testdata/README.md(URL / date / license / quote placeholders; a "Saved sources" table when the README has none);providers/<api>.mdfromproviders/_template.md, or with--page <name>nothing new, linking the provider's existing page (the three algolia plugins shareproviders/algolia.md);docs/plugins.mdrow (statuslive: a plugin in the code is live), thendocs/plugins.jsonregenerated.Every place to fill in says
TODO(new-plugin). It prints the next steps (save the page, fill in the definition,go test ./plugins/<format> -run Test<X> -update, fill in "Why this source",make check, PR). It refuses an invalid id,all, a registered id, an id with a row, an existing file or a Go name already declared in the package, and then changes nothing. File names avoid Go build-constraint suffixes (acme-linux→acme_linux_plugin.go).Docs:
docs/writing-a-plugin.mdstep 1 is now the starter (the rest renumbered), and CONTRIBUTING.md and AGENTS.md point to it.Guard (from the review):
make todosfails while anyTODO(new-plugin)is left inplugins/,adapter/,retire/,sdkguide/,migrate/,providers/ordocs/plugins.md. It's part ofmake checkand a step in CI_go (one cheap grep, same job). Also from the review: quotes and backslashes are refused in--provider/--watcheswith a clear message, and the openapi testdata table'sSource/Checkedcolumns get their hints.Acceptance criteria (#116)
docs/plugins.mdrow), andgo test ./...passes right after:TestScaffoldEveryFormatscaffolds one plugin of each of the eight formats into a copy of the repo, then runsgo build ./...,go vet ./...andgo testoverplugins/,internal/andmigrate/.docs/writing-a-plugin.mdand CONTRIBUTING.md point to the command.cmd/new-plugin/main_test.go: every format, refusal, shared provider page, bad input, file names).Flag name: the ticket suggests
--name; I used--api(it's the--apiid users select the plugin by, and every event'sapi) plus--providerfor the display name.Checklist
env.Get/kit/(the generated openapi adapter is the only code that will fetch, inadapter/, as today)make checkpasses locally (except the known local-gofmt mismatch onplugins/openapi/vercel_test.go, see add make check and docs/plugins.json #121)Calls I made (please check)
removedmembers,migrationguideandretirementsevery row the parser accepts is an event, so their placeholder golden has one event, and their drop test checks that a specific placeholder row (another table / another call / a modelKeepdrops) produces none, instead of "no events at all".live(the rule from plugins list: every plugin in the code is live #122: a plugin in the code is live). The TODOs in the generated files mark it unfinished, andmake todos(CI_go) fails until they're gone, so an unfinished scaffold can't merge green.go(test-updateandcmd/list-plugins) itself, sogo test ./...passes immediately.migrate/migrate.go's maps (otherwise v1 → v2 conversion rejects their events); the generator adds it. Provider slug = provider name lowercased with hyphens.Related PRs
🤖 Generated with Claude Code