Thanks for your interest in contributing to OpenCLI.
# 1. Fork & clone
git clone git@github.com:<your-username>/opencli.git
cd opencli
# 2. Install dependencies
npm install
# 3. Build
npm run build
# 4. Run a few checks
npx tsc --noEmit
npx vitest run src/
# 5. Link globally (optional, for testing `opencli` command)
npm linkThis is the most common type of contribution. Start with YAML when possible, and use TypeScript only when you need browser-side logic or multi-step flows.
Create a file like src/clis/<site>/<command>.yaml:
site: mysite
name: trending
description: Trending posts on MySite
domain: www.mysite.com
strategy: public # public | cookie | header
browser: false # true if browser session is needed
args:
limit:
type: int
default: 20
description: Number of items
pipeline:
- fetch:
url: https://api.mysite.com/trending
- map:
rank: ${{ index + 1 }}
title: ${{ item.title }}
score: ${{ item.score }}
url: ${{ item.url }}
- limit: ${{ args.limit }}
columns: [rank, title, score, url]See hackernews/top.yaml for a real example.
Create a file like src/clis/<site>/<command>.ts:
import { cli, Strategy } from '../../registry.js';
cli({
site: 'mysite',
name: 'search',
description: 'Search MySite',
domain: 'www.mysite.com',
strategy: Strategy.COOKIE,
args: [
{ name: 'query', required: true, help: 'Search query' },
{ name: 'limit', type: 'int', default: 10, help: 'Max results' },
],
columns: ['title', 'url', 'date'],
func: async (page, kwargs) => {
const { query, limit = 10 } = kwargs;
await page.goto('https://www.mysite.com');
const data = await page.evaluate(`
(async () => {
const res = await fetch('/api/search?q=${encodeURIComponent(query)}', {
credentials: 'include'
});
return (await res.json()).results;
})()
`);
return data.slice(0, Number(limit)).map((item: any) => ({
title: item.title,
url: item.url,
date: item.created_at,
}));
},
});Use opencli explore <url> to discover APIs and see CLI-EXPLORER.md if you need the full adapter workflow.
# Validate YAML syntax and schema
opencli validate
# Test your command
opencli <site> <command> --limit 3 -f json
# Verbose mode for debugging
opencli <site> <command> -vSee TESTING.md for the full guide and exact test locations.
npx vitest run src/ # Unit tests
npx vitest run tests/e2e/ # E2E tests
npx vitest run # All tests- TypeScript strict mode — avoid
anywhere possible. - ES Modules — use
.jsextensions in imports (TypeScript output). - Naming:
kebab-casefor files,camelCasefor variables/functions,PascalCasefor types/classes. - No default exports — use named exports.
We use Conventional Commits:
feat(twitter): add thread command
fix(browser): handle CDP timeout gracefully
docs: update CONTRIBUTING.md
test(reddit): add e2e test for save command
chore: bump vitest to v4
Common scopes: site name (twitter, reddit) or module name (browser, pipeline, engine).
- Create a feature branch:
git checkout -b feat/mysite-trending - Make your changes and add tests when relevant
- Run the checks that apply:
npx tsc --noEmit # Type check npx vitest run src/ # Unit tests opencli validate # YAML validation (if applicable)
- Commit using conventional commit format
- Push and open a PR
By contributing, you agree that your contributions will be licensed under the Apache-2.0 License.