Idiomark Adapter Generator CLI - User Guide
Overview
The Idiomark Adapter Generator CLI is a fully functional command-line tool that generates new adapters with minimal manual work. Users can run one command and get a working adapter skeleton.
Installation
The CLI is part of the @idiomark/cli package:
cd /e/dev/projects/idiomark
pnpm install
pnpm build
Available Commands
1. Create New Adapter
idiomark adapter create <name> [options]
Options:
-t, --template <type>- Adapter template (rest, graphql, scrape, rss, email, forum)-a, --auth <type>- Auth type (oauth2, bearer, apikey, none)-b, --base-url <url>- API base URL-d, --docs <url>- API documentation URL-o, --output <path>- Output directory-D, --description <text>- Adapter description-i, --interactive- Interactive mode with prompts
Example:
idiomark adapter create discord --template rest --auth oauth2 --base-url https://discord.com/api/v10
What it generates:
packages/adapters/discord/
├── package.json
├── tsconfig.json
├── tsup.config.ts
├── README.md (with API docs link)
└── src/
├── index.ts (adapter implementation)
├── types.ts (TypeScript types)
├── api.ts (API client)
└── config.ts (configuration)
2. Validate Adapter
idiomark adapter validate <name>
Options:
-s, --strict- Strict validation mode
Checks:
- Implements BaseAdapter interface correctly
- Has proper TypeScript types
- Exports required functions
- README is complete
- Builds successfully
3. Test Adapter
idiomark adapter test <name> [options]
Options:
-m, --mock- Use mock data (default)-l, --live- Make real API calls-u, --username <user>- Test with specific user
4. List Adapters
idiomark adapter list
Shows:
- All installed adapters
- Their status (working, deprecated, experimental)
- API availability
- Rate limit info
5. Adapter Info
idiomark adapter info <name>
Shows detailed info:
- Description
- API documentation links
- Authentication setup
- Rate limits
- Example usage
Adapter Templates
REST API
Best for traditional REST APIs with endpoints.
GraphQL
Best for GraphQL APIs with query/mutation support.
Web Scraper
Best for platforms without public APIs. Includes anti-detection measures.
RSS/Atom Feed
Best for blogs, news sites, and feeds.
Email/Newsletter
Best for email servers and newsletters (IMAP/POP3).
Forum/Community
Best for discussion forums and community platforms.
Example Workflow
- Create a new adapter:
idiomark adapter create reddit --template rest --auth bearer --base-url https://oauth.reddit.com
- Navigate to the adapter:
cd packages/adapters/reddit
- Install dependencies:
npm install
-
Implement the adapter methods in
src/index.ts -
Build the adapter:
npm run build
- Validate the adapter:
idiomark adapter validate reddit
- Test the adapter:
idiomark adapter test reddit --live
Generated Code Features
All generated adapters include:
- Full TypeScript support with type definitions
- Proper error handling
- Rate limiting (where applicable)
- Caching support
- Authentication handling (OAuth2, Bearer, API Key, or none)
- Example usage in README
- Build configuration with tsup
- Test file templates
Interactive Mode
For a guided experience, use the interactive flag:
idiomark adapter create myadapter --interactive
You'll be prompted for:
- Adapter template type
- Authentication type
- API base URL
- Documentation URL
- Description
- Output directory
Project Structure
packages/cli/
├── src/
│ ├── commands/
│ │ └── adapter.ts # Main adapter commands
│ ├── generators/
│ │ ├── rest-generator.ts # REST API generator
│ │ ├── graphql-generator.ts # GraphQL generator
│ │ ├── scrape-generator.ts # Web scraper generator
│ │ ├── rss-generator.ts # RSS feed generator
│ │ ├── email-generator.ts # Email generator
│ │ └── forum-generator.ts # Forum generator
│ ├── validators/
│ │ └── adapter-validator.ts # Adapter validation
│ ├── utils/
│ │ └── test-runner.ts # Test execution
│ └── index.ts # CLI entry point
└── package.json
Contributing
To add a new adapter template:
- Create a new generator file in
src/generators/ - Implement the
generate[Template]Adapterfunction - Add it to the generators object in
commands/adapter.ts - Update the CLI help text
License
MIT