Skip to content

feat(scripts): add adapter:new scaffolder for new adapters (#585) - #698

Merged
keysersoft merged 3 commits into
HelpCode-ai:mainfrom
rangarajan19:feat/adapter-scaffolder
Sep 25, 2026
Merged

keysersoft merged 3 commits into
HelpCode-ai:mainfrom
rangarajan19:feat/adapter-scaffolder

Conversation

@rangarajan19

Copy link
Copy Markdown
Contributor

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 a TODO at every spot that still needs filling in.

npm run adapter:new -- acme-crm --region intl --auth API_KEY

Changes

  • scripts/adapter-new.mjs (new): writes packages/backend/src/adapters/<region>/<slug>.json with the required fields, the connector block 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 --force is passed.
  • scripts/validate-adapters.mjs: new todo-marker warning for leftover TODOs, 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 added export to REGIONS and ALLOWED_AUTH_TYPES so the scaffolder uses the same lists as the validator instead of copying them.
  • scripts/adapter-new.test.mjs (new) and scripts/validate-adapters.test.mjs: tests for the scaffolder and for the new rule.
  • package.json: the adapter:new script.
  • CONTRIBUTING.md: a short note under "Add an adapter".

Type

  • Bug fix
  • New feature
  • Documentation
  • Refactoring
  • Performance improvement
  • Other (describe below)

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 --check passes, and regenerate-catalog.mjs leaves catalog.ts with no diff.

  • Manually: ran npm run adapter:new -- ... in the repo for API_KEY and BEARER_TOKEN, ran regenerate-catalog.mjs on the result (the import was generated correctly), then removed the file and reverted catalog.ts.

I did not run the backend suite (npm test in packages/backend), lint or type-check; this change does not touch backend code.

Checklist

  • My code follows the existing code style
  • I have tested my changes locally
  • I have updated documentation (if applicable)
  • All existing tests pass (npm test): only the script tests above were run, not the backend suite
  • This PR has a descriptive title

Notes for review

A few small decisions you have not seen yet, so you can push back on any of them:

  • Slug must start with a letter. regenerate-catalog.mjs turns the slug into a JS identifier, so 3m-tracker would generate import * as 3mTracker, which does not compile. The scaffolder refuses it.
  • Credentials for auth types other than NONE and API_KEY. The skeleton writes authConfig: { "credentials": "TODO: ..." }, so any --auth value gives a valid file with a marker where the credentials go.
  • CI runs only validate-adapters.test.mjs by name, so adapter-new.test.mjs does not run there yet. I left ci.yml alone; happy to add a step or fold the tests into the existing file, whichever you prefer.
  • With npm, the flags need -- (npm run adapter:new -- <slug> --region ...), otherwise npm swallows them.

Related Issues

Closes #585

…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
@github-actions

Copy link
Copy Markdown

👋 Welcome, @rangarajan19, and thanks for opening your first PR on AnythingMCP!

A few quick pointers:

  • Make sure CI is green before requesting review (Backend, Frontend, Playwright, CodeQL, Trivy).
  • If this is a new adapter, the parametrised catalog.spec.ts test will validate it automatically.
  • Sign off your commits if you can — it's not blocking, just nice to have.

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.

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@rangarajan19

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Sep 24, 2026
Comment thread scripts/adapter-new.mjs Fixed
Matteo Morelli 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.
@keysersoft
keysersoft merged commit 6eef50c into HelpCode-ai:main Sep 25, 2026
12 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants