Repository navigation
feat(scripts): add adapter:new scaffolder for new adapters (#585) - #698
Merged
keysersoft merged 3 commits intoSep 25, 2026
Merged
Conversation
…ai#585) Adds `scripts/adapter-new.mjs <slug> --region <r> --auth <type>`, which writes a valid adapter skeleton with TODO markers, runs the existing validator on it, and prints the next three commands. Refuses to overwrite an existing adapter unless --force is passed. Adds a `todo-marker` warning to validate-adapters.mjs so leftover TODOs show up in the report, an `adapter:new` npm script, tests, and a note in CONTRIBUTING.md. Refs HelpCode-ai#585
|
👋 Welcome, @rangarajan19, and thanks for opening your first PR on AnythingMCP! A few quick pointers:
Someone from the core team will look at this within ~48h. If you don't hear back, please ping us in Discussions / Q&A. ⭐ While you wait — if you find AnythingMCP useful, a star helps others discover it. |
|
All contributors have signed the CLA ✍️ ✅ |
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
added 2 commits
September 25, 2026 13:00
- writeFileSync with flag 'wx' (or 'w' under --force) replaces the existsSync check, so "refuse to overwrite" happens in one step. CodeQL flagged the check-then-write as js/file-system-race. - ci.yml runs scripts/adapter-new.test.mjs next to validate-adapters.test.mjs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
npm run adapter:new, a scaffolder for new adapters, as discussed in #585. Instead of copying an existing adapter JSON and deleting parts of it, a contributor now starts from a file that already passes the validator, with aTODOat every spot that still needs filling in.Changes
scripts/adapter-new.mjs(new): writespackages/backend/src/adapters/<region>/<slug>.jsonwith the required fields, theconnectorblock and one example tool (slug-prefixed). It then runs the existing validator on the file it wrote and prints the next three commands (validate, regenerate catalog, run the backend). It refuses to overwrite an existing adapter unless--forceis passed.scripts/validate-adapters.mjs: newtodo-markerwarning for leftoverTODOs, reported with the path of each one, as you suggested. It is a warning, so it does not fail CI. The check is case-sensitive so words like "to-do list" in real adapters are not flagged; the current catalog gets no new warnings. I also addedexporttoREGIONSandALLOWED_AUTH_TYPESso the scaffolder uses the same lists as the validator instead of copying them.scripts/adapter-new.test.mjs(new) andscripts/validate-adapters.test.mjs: tests for the scaffolder and for the new rule.package.json: theadapter:newscript.CONTRIBUTING.md: a short note under "Add an adapter".Type
Testing
Added/updated unit tests
Tested manually (describe steps below)
No tests needed (explain why)
node --test scripts/validate-adapters.test.mjs: 15 pass.node --test scripts/adapter-new.test.mjs: 13 pass.node scripts/validate-adapters.mjs: 257 of 257 pass, no new warnings.node scripts/adapter-count.mjs --checkpasses, andregenerate-catalog.mjsleavescatalog.tswith no diff.Manually: ran
npm run adapter:new -- ...in the repo forAPI_KEYandBEARER_TOKEN, ranregenerate-catalog.mjson the result (the import was generated correctly), then removed the file and revertedcatalog.ts.I did not run the backend suite (
npm testinpackages/backend), lint or type-check; this change does not touch backend code.Checklist
npm test): only the script tests above were run, not the backend suiteNotes for review
A few small decisions you have not seen yet, so you can push back on any of them:
regenerate-catalog.mjsturns the slug into a JS identifier, so3m-trackerwould generateimport * as 3mTracker, which does not compile. The scaffolder refuses it.NONEandAPI_KEY. The skeleton writesauthConfig: { "credentials": "TODO: ..." }, so any--authvalue gives a valid file with a marker where the credentials go.validate-adapters.test.mjsby name, soadapter-new.test.mjsdoes not run there yet. I leftci.ymlalone; happy to add a step or fold the tests into the existing file, whichever you prefer.--(npm run adapter:new -- <slug> --region ...), otherwise npm swallows them.Related Issues
Closes #585