@picahq/cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +11 -0
- package/.github/workflows/publish.yml +29 -0
- package/README.md +148 -0
- package/SKILL.md +199 -0
- package/bin/cli.js +3 -0
- package/package.json +29 -0
- package/src/commands/actions.ts +385 -0
- package/src/commands/connection.ts +196 -0
- package/src/commands/init.ts +548 -0
- package/src/commands/platforms.ts +92 -0
- package/src/index.ts +140 -0
- package/src/lib/actions.ts +59 -0
- package/src/lib/agents.ts +191 -0
- package/src/lib/api.ts +191 -0
- package/src/lib/browser.ts +20 -0
- package/src/lib/config.ts +47 -0
- package/src/lib/platforms.ts +73 -0
- package/src/lib/table.ts +60 -0
- package/src/lib/types.ts +89 -0
- package/test/all-emails.json +3479 -0
- package/test/fetch-emails.ts +82 -0
- package/tsconfig.json +16 -0
- package/tsup.config.ts +10 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Publish Package to NPM
|
|
2
|
+
on:
|
|
3
|
+
release:
|
|
4
|
+
types: [created]
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
id-token: write
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
- uses: actions/setup-node@v4
|
|
14
|
+
with:
|
|
15
|
+
node-version: '20.x'
|
|
16
|
+
registry-url: 'https://registry.npmjs.org/'
|
|
17
|
+
- name: Install latest npm
|
|
18
|
+
run: npm install -g npm@latest
|
|
19
|
+
- name: Install dependencies
|
|
20
|
+
run: |
|
|
21
|
+
if [ -f package-lock.json ]; then
|
|
22
|
+
npm ci
|
|
23
|
+
else
|
|
24
|
+
npm install
|
|
25
|
+
fi
|
|
26
|
+
- name: Build
|
|
27
|
+
run: npm run build
|
|
28
|
+
- name: Publish
|
|
29
|
+
run: npm publish --access public
|
package/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# pica
|
|
2
|
+
|
|
3
|
+
CLI for managing Pica integrations. Connect to 200+ platforms, discover their APIs, and execute actions from the terminal.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install
|
|
9
|
+
npm run build
|
|
10
|
+
npm link
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Requires Node.js 18+.
|
|
14
|
+
|
|
15
|
+
## Setup
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pica init
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
This prompts for your Pica API key, saves it to `~/.pica/config.json`, and installs the MCP server into your AI agents (Claude Code, Claude Desktop, Cursor, Windsurf).
|
|
22
|
+
|
|
23
|
+
Get your API key at [app.picaos.com/settings/api-keys](https://app.picaos.com/settings/api-keys).
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
### Connect a platform
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pica add gmail
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Opens a browser to complete OAuth. The CLI polls until the connection is live.
|
|
34
|
+
|
|
35
|
+
### List connections
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pica list
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
● gmail operational
|
|
43
|
+
live::gmail::default::abc123
|
|
44
|
+
● slack operational
|
|
45
|
+
live::slack::default::def456
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Browse platforms
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pica platforms
|
|
52
|
+
pica platforms -c "CRM"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Search actions
|
|
56
|
+
|
|
57
|
+
Find available API actions on any connected platform:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pica search gmail "send email"
|
|
61
|
+
pica search slack "post message"
|
|
62
|
+
pica search stripe "list payments"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
POST /gmail/v1/users/{{userId}}/messages/send
|
|
67
|
+
Send Message
|
|
68
|
+
conn_mod_def::ABC123::XYZ789
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Read API docs
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pica actions knowledge <actionId>
|
|
75
|
+
pica actions k <actionId> --full # no truncation
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Shows method, path, path variables, parameter schemas, and request/response examples.
|
|
79
|
+
|
|
80
|
+
### Execute an action
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pica exec <actionId> \
|
|
84
|
+
-c live::gmail::default::abc123 \
|
|
85
|
+
-d '{"to": "test@example.com", "subject": "Hello", "body": "Hi there"}' \
|
|
86
|
+
-p userId=me
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
If you omit flags, the CLI prompts interactively:
|
|
90
|
+
- Auto-selects the connection if only one exists for the platform
|
|
91
|
+
- Prompts for each `{{path variable}}` not provided via `-p`
|
|
92
|
+
- Prompts for the request body on POST/PUT/PATCH if `-d` is missing
|
|
93
|
+
|
|
94
|
+
## Commands
|
|
95
|
+
|
|
96
|
+
| Command | Description |
|
|
97
|
+
|---------|-------------|
|
|
98
|
+
| `pica init` | Set up API key and install MCP |
|
|
99
|
+
| `pica add <platform>` | Connect a platform via OAuth |
|
|
100
|
+
| `pica list` | List connections with keys |
|
|
101
|
+
| `pica platforms` | Browse available platforms |
|
|
102
|
+
| `pica search <platform> [query]` | Search for actions |
|
|
103
|
+
| `pica actions knowledge <id>` | Get API docs for an action |
|
|
104
|
+
| `pica exec <id>` | Execute an action |
|
|
105
|
+
|
|
106
|
+
Every command supports `--json` for machine-readable output.
|
|
107
|
+
|
|
108
|
+
### Aliases
|
|
109
|
+
|
|
110
|
+
| Short | Full |
|
|
111
|
+
|-------|------|
|
|
112
|
+
| `pica ls` | `pica list` |
|
|
113
|
+
| `pica p` | `pica platforms` |
|
|
114
|
+
| `pica a search` | `pica actions search` |
|
|
115
|
+
| `pica a k` | `pica actions knowledge` |
|
|
116
|
+
| `pica a x` | `pica actions execute` |
|
|
117
|
+
|
|
118
|
+
## How it works
|
|
119
|
+
|
|
120
|
+
All API calls route through Pica's passthrough proxy (`api.picaos.com/v1/passthrough`), which injects auth credentials, handles rate limiting, and normalizes responses. Your connection keys tell Pica which credentials to use. You never touch raw OAuth tokens.
|
|
121
|
+
|
|
122
|
+
## Development
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
npm run dev # watch mode
|
|
126
|
+
npm run build # production build
|
|
127
|
+
npm run typecheck # type check without emitting
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Project structure
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
src/
|
|
134
|
+
index.ts # Commander setup and command registration
|
|
135
|
+
commands/
|
|
136
|
+
init.ts # pica init (API key + MCP setup)
|
|
137
|
+
connection.ts # pica add, pica list
|
|
138
|
+
platforms.ts # pica platforms
|
|
139
|
+
actions.ts # pica search, actions knowledge, exec
|
|
140
|
+
lib/
|
|
141
|
+
api.ts # HTTP client for Pica API
|
|
142
|
+
types.ts # TypeScript interfaces
|
|
143
|
+
actions.ts # Action ID normalization, path variable helpers
|
|
144
|
+
config.ts # ~/.pica/config.json read/write
|
|
145
|
+
agents.ts # MCP config for Claude, Cursor, Windsurf
|
|
146
|
+
platforms.ts # Platform search and fuzzy matching
|
|
147
|
+
browser.ts # Open browser for OAuth and API key pages
|
|
148
|
+
```
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pica
|
|
3
|
+
description: Interact with third-party platforms (Gmail, Slack, HubSpot, Stripe, etc.) via Pica. Use when the user wants to search for available API actions, read API documentation, execute API calls, manage connections, or do anything involving third-party integrations.
|
|
4
|
+
triggers:
|
|
5
|
+
- "search actions"
|
|
6
|
+
- "find actions"
|
|
7
|
+
- "execute action"
|
|
8
|
+
- "run action"
|
|
9
|
+
- "list connections"
|
|
10
|
+
- "add connection"
|
|
11
|
+
- "list platforms"
|
|
12
|
+
- "pica"
|
|
13
|
+
- "integration"
|
|
14
|
+
- "send email"
|
|
15
|
+
- "check calendar"
|
|
16
|
+
- "post to slack"
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# Pica
|
|
20
|
+
|
|
21
|
+
Pica gives you access to 200+ third-party platforms (Gmail, Slack, HubSpot, Stripe, Shopify, etc.) through a single interface. It handles auth, rate limiting, and retries so you just call the action you need.
|
|
22
|
+
|
|
23
|
+
## How to interact with Pica
|
|
24
|
+
|
|
25
|
+
Pica provides two interfaces: the **MCP tools** and the **CLI**. Use the right one for the job.
|
|
26
|
+
|
|
27
|
+
### MCP tools (primary, for AI agents)
|
|
28
|
+
|
|
29
|
+
The Pica MCP is your primary interface. It gives you structured JSON in/out with no parsing overhead. Always prefer MCP tools for discovering, inspecting, and executing actions.
|
|
30
|
+
|
|
31
|
+
The MCP exposes 5 tools:
|
|
32
|
+
|
|
33
|
+
| Tool | Purpose |
|
|
34
|
+
|------|---------|
|
|
35
|
+
| `mcp__pica__list_pica_integrations` | List all available platforms and active connections |
|
|
36
|
+
| `mcp__pica__search_pica_platform_actions` | Search for actions on a platform |
|
|
37
|
+
| `mcp__pica__get_pica_action_knowledge` | Get full API docs for an action (MUST call before execute) |
|
|
38
|
+
| `mcp__pica__execute_pica_action` | Execute an action on a connected platform |
|
|
39
|
+
|
|
40
|
+
### CLI (secondary, for setup and human-facing tasks)
|
|
41
|
+
|
|
42
|
+
The `pica` CLI is better for tasks that require a browser (OAuth), interactive prompts, or human-readable output. Use it for:
|
|
43
|
+
|
|
44
|
+
- **Setup**: `pica init` (configures API key and installs MCP)
|
|
45
|
+
- **Adding connections**: `pica add gmail` (opens browser for OAuth)
|
|
46
|
+
- **Browsing platforms**: `pica platforms` (visual, categorized list)
|
|
47
|
+
- **Quick lookups by a human**: `pica list`, `pica search gmail "send"`
|
|
48
|
+
|
|
49
|
+
## When to use which
|
|
50
|
+
|
|
51
|
+
| Task | Use |
|
|
52
|
+
|------|-----|
|
|
53
|
+
| Execute an API action | MCP |
|
|
54
|
+
| Search for actions | MCP |
|
|
55
|
+
| Read action docs | MCP |
|
|
56
|
+
| List connections/platforms | MCP |
|
|
57
|
+
| Add a new connection (OAuth) | CLI |
|
|
58
|
+
| Initial setup | CLI |
|
|
59
|
+
| Show a user what's available (visual output) | CLI |
|
|
60
|
+
|
|
61
|
+
**Rule of thumb:** If you're doing the work, use MCP. If a human needs to interact (OAuth, setup), use CLI.
|
|
62
|
+
|
|
63
|
+
## Setup and prerequisites
|
|
64
|
+
|
|
65
|
+
The MCP server is installed via `pica init`. If the MCP tools are not available, the CLI needs to be installed and init needs to run:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pica --version
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
If the command is not found, install it:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
cd /Users/moe/projects/one/connection-cli
|
|
75
|
+
npm install
|
|
76
|
+
npm run build
|
|
77
|
+
npm link
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Then run setup:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pica init
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
This stores the API key in `~/.pica/config.json` and installs the MCP server into Claude Code, Claude Desktop, Cursor, and Windsurf. After init, the MCP tools will be available.
|
|
87
|
+
|
|
88
|
+
## MCP workflow
|
|
89
|
+
|
|
90
|
+
This is the standard workflow for any integration task.
|
|
91
|
+
|
|
92
|
+
### Step 1: List connections and platforms
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
mcp__pica__list_pica_integrations()
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Returns all active connections (with connection keys) and available platforms. Check this first to see what's connected.
|
|
99
|
+
|
|
100
|
+
### Step 2: Search for the right action
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
mcp__pica__search_pica_platform_actions({
|
|
104
|
+
platform: "gmail",
|
|
105
|
+
query: "send email",
|
|
106
|
+
agentType: "execute"
|
|
107
|
+
})
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Use `agentType: "execute"` when the intent is to run the action. Use `"knowledge"` when the user wants to understand the API or write code against it.
|
|
111
|
+
|
|
112
|
+
The platform name must be in kebab-case (e.g., `ship-station`, `hubspot`, `google-calendar`). Get the exact name from `list_pica_integrations`.
|
|
113
|
+
|
|
114
|
+
### Step 3: Get action knowledge (required before execute)
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
mcp__pica__get_pica_action_knowledge({
|
|
118
|
+
actionId: "conn_mod_def::ABC123::XYZ789",
|
|
119
|
+
platform: "gmail"
|
|
120
|
+
})
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
This returns full API documentation: parameters, request/response schemas, caveats, examples. You MUST call this before executing to understand what the action expects.
|
|
124
|
+
|
|
125
|
+
### Step 4: Execute
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
mcp__pica__execute_pica_action({
|
|
129
|
+
actionId: "conn_mod_def::ABC123::XYZ789",
|
|
130
|
+
connectionKey: "live::gmail::default::abc123",
|
|
131
|
+
platform: "gmail",
|
|
132
|
+
data: { to: "someone@example.com", subject: "Hello", body: "Hi there" },
|
|
133
|
+
pathVariables: { userId: "me" }
|
|
134
|
+
})
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Pass the `connectionKey` from step 1, the `actionId` from step 2, and the parameters from step 3.
|
|
138
|
+
|
|
139
|
+
## CLI reference
|
|
140
|
+
|
|
141
|
+
For when you need the CLI (setup, OAuth, human-facing output):
|
|
142
|
+
|
|
143
|
+
| Command | Description |
|
|
144
|
+
|---------|-------------|
|
|
145
|
+
| `pica init` | Set up API key and install MCP |
|
|
146
|
+
| `pica list` | List connections with keys |
|
|
147
|
+
| `pica add <platform>` | Add a new connection via OAuth (opens browser) |
|
|
148
|
+
| `pica platforms` | Browse all available platforms |
|
|
149
|
+
| `pica search <platform> [query]` | Search for actions |
|
|
150
|
+
| `pica actions knowledge <id>` | Get API docs for an action |
|
|
151
|
+
| `pica exec <id>` | Execute an action |
|
|
152
|
+
|
|
153
|
+
### CLI options for exec
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
pica exec <actionId> \
|
|
157
|
+
-c <connectionKey> \
|
|
158
|
+
-d '{"key": "value"}' \
|
|
159
|
+
-p pathVar=value \
|
|
160
|
+
-q queryParam=value \
|
|
161
|
+
--json
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
All commands support `--json` for machine-readable output.
|
|
165
|
+
|
|
166
|
+
## Key concepts
|
|
167
|
+
|
|
168
|
+
- **Connection key**: Identifies which authenticated connection to use. Format: `live::gmail::default::abc123` or `test::gmail::default::abc123`. Get these from `list_pica_integrations` or `pica list`.
|
|
169
|
+
- **Action ID**: Identifies a specific API action. Always starts with `conn_mod_def::`. Get these from search results.
|
|
170
|
+
- **Platform name**: Kebab-case identifier (e.g., `gmail`, `hubspot`, `google-calendar`, `ship-station`). Get the exact name from `list_pica_integrations`.
|
|
171
|
+
- **Passthrough proxy**: All actions route through Pica's proxy which injects auth, handles rate limits, and normalizes responses. You never touch raw OAuth tokens.
|
|
172
|
+
- **Pagination**: Some actions return `nextPageToken` or similar. Pass it back in subsequent requests to page through results.
|
|
173
|
+
|
|
174
|
+
## Common patterns
|
|
175
|
+
|
|
176
|
+
### Send an email
|
|
177
|
+
1. Search: `platform: "gmail", query: "send email"`
|
|
178
|
+
2. Knowledge: get the action docs
|
|
179
|
+
3. Execute with `data: { to, subject, body, connectionKey }`
|
|
180
|
+
|
|
181
|
+
### Read emails
|
|
182
|
+
1. Search: `platform: "gmail", query: "get emails"`
|
|
183
|
+
2. Knowledge: understand pagination (numberOfEmails, pageToken)
|
|
184
|
+
3. Execute with `data: { connectionKey, numberOfEmails, label, query }`
|
|
185
|
+
|
|
186
|
+
### Post to Slack
|
|
187
|
+
1. Search: `platform: "slack", query: "post message"`
|
|
188
|
+
2. Knowledge: get channel ID format
|
|
189
|
+
3. Execute with `data: { channel, text }`
|
|
190
|
+
|
|
191
|
+
### CRM operations
|
|
192
|
+
1. Search: `platform: "hubspot"` or `"attio"`, query: `"create contact"` / `"list contacts"` / etc.
|
|
193
|
+
2. Knowledge: understand required fields
|
|
194
|
+
3. Execute with the right data shape
|
|
195
|
+
|
|
196
|
+
### Calendar
|
|
197
|
+
1. Search: `platform: "google-calendar", query: "list events"`
|
|
198
|
+
2. Knowledge: understand time format, calendar ID
|
|
199
|
+
3. Execute with date range parameters
|
package/bin/cli.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@picahq/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI for managing Pica integrations",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"pica": "./bin/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsup",
|
|
11
|
+
"dev": "tsup --watch",
|
|
12
|
+
"start": "node bin/cli.js",
|
|
13
|
+
"typecheck": "tsc --noEmit"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@clack/prompts": "^0.9.1",
|
|
17
|
+
"commander": "^13.1.0",
|
|
18
|
+
"open": "^10.1.0",
|
|
19
|
+
"picocolors": "^1.1.1"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/node": "^22.13.1",
|
|
23
|
+
"tsup": "^8.3.6",
|
|
24
|
+
"typescript": "^5.7.3"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=18"
|
|
28
|
+
}
|
|
29
|
+
}
|