Skip to content

Commit 40ffd2f

Browse files
authored
v0.5.109: obsidian and evernote integrations, slack fixes, remove memory instrumentation
0 parents  commit 40ffd2f

File tree

7,046 files changed

+2319721
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

7,046 files changed

+2319721
-0
lines changed

.claude/commands/add-block.md

Lines changed: 825 additions & 0 deletions
Large diffs are not rendered by default.

.claude/commands/add-integration.md

Lines changed: 760 additions & 0 deletions
Large diffs are not rendered by default.

.claude/commands/add-tools.md

Lines changed: 321 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,321 @@
1+
---
2+
description: Create tool configurations for a Sim integration by reading API docs
3+
argument-hint: <service-name> [api-docs-url]
4+
---
5+
6+
# Add Tools Skill
7+
8+
You are an expert at creating tool configurations for Sim integrations. Your job is to read API documentation and create properly structured tool files.
9+
10+
## Your Task
11+
12+
When the user asks you to create tools for a service:
13+
1. Use Context7 or WebFetch to read the service's API documentation
14+
2. Create the tools directory structure
15+
3. Generate properly typed tool configurations
16+
17+
## Directory Structure
18+
19+
Create files in `apps/sim/tools/{service}/`:
20+
```
21+
tools/{service}/
22+
├── index.ts # Barrel export
23+
├── types.ts # Parameter & response types
24+
└── {action}.ts # Individual tool files (one per operation)
25+
```
26+
27+
## Tool Configuration Structure
28+
29+
Every tool MUST follow this exact structure:
30+
31+
```typescript
32+
import type { {ServiceName}{Action}Params } from '@/tools/{service}/types'
33+
import type { ToolConfig } from '@/tools/types'
34+
35+
interface {ServiceName}{Action}Response {
36+
success: boolean
37+
output: {
38+
// Define output structure here
39+
}
40+
}
41+
42+
export const {serviceName}{Action}Tool: ToolConfig<
43+
{ServiceName}{Action}Params,
44+
{ServiceName}{Action}Response
45+
> = {
46+
id: '{service}_{action}', // snake_case, matches tool name
47+
name: '{Service} {Action}', // Human readable
48+
description: 'Brief description', // One sentence
49+
version: '1.0.0',
50+
51+
// OAuth config (if service uses OAuth)
52+
oauth: {
53+
required: true,
54+
provider: '{service}', // Must match OAuth provider ID
55+
},
56+
57+
params: {
58+
// Hidden params (system-injected, only use hidden for oauth accessToken)
59+
accessToken: {
60+
type: 'string',
61+
required: true,
62+
visibility: 'hidden',
63+
description: 'OAuth access token',
64+
},
65+
// User-only params (credentials, api key, IDs user must provide)
66+
someId: {
67+
type: 'string',
68+
required: true,
69+
visibility: 'user-only',
70+
description: 'The ID of the resource',
71+
},
72+
// User-or-LLM params (everything else, can be provided by user OR computed by LLM)
73+
query: {
74+
type: 'string',
75+
required: false, // Use false for optional
76+
visibility: 'user-or-llm',
77+
description: 'Search query',
78+
},
79+
},
80+
81+
request: {
82+
url: (params) => `https://api.service.com/v1/resource/${params.id}`,
83+
method: 'POST',
84+
headers: (params) => ({
85+
Authorization: `Bearer ${params.accessToken}`,
86+
'Content-Type': 'application/json',
87+
}),
88+
body: (params) => ({
89+
// Request body - only for POST/PUT/PATCH
90+
// Trim ID fields to prevent copy-paste whitespace errors:
91+
// userId: params.userId?.trim(),
92+
}),
93+
},
94+
95+
transformResponse: async (response: Response) => {
96+
const data = await response.json()
97+
return {
98+
success: true,
99+
output: {
100+
// Map API response to output
101+
// Use ?? null for nullable fields
102+
// Use ?? [] for optional arrays
103+
},
104+
}
105+
},
106+
107+
outputs: {
108+
// Define each output field
109+
},
110+
}
111+
```
112+
113+
## Critical Rules for Parameters
114+
115+
### Visibility Options
116+
- `'hidden'` - System-injected (OAuth tokens, internal params). User never sees.
117+
- `'user-only'` - User must provide (credentials, api keys, account-specific IDs)
118+
- `'user-or-llm'` - User provides OR LLM can compute (search queries, content, filters, most fall into this category)
119+
120+
### Parameter Types
121+
- `'string'` - Text values
122+
- `'number'` - Numeric values
123+
- `'boolean'` - True/false
124+
- `'json'` - Complex objects (NOT 'object', use 'json')
125+
- `'file'` - Single file
126+
- `'file[]'` - Multiple files
127+
128+
### Required vs Optional
129+
- Always explicitly set `required: true` or `required: false`
130+
- Optional params should have `required: false`
131+
132+
## Critical Rules for Outputs
133+
134+
### Output Types
135+
- `'string'`, `'number'`, `'boolean'` - Primitives
136+
- `'json'` - Complex objects (use this, NOT 'object')
137+
- `'array'` - Arrays with `items` property
138+
- `'object'` - Objects with `properties` property
139+
140+
### Optional Outputs
141+
Add `optional: true` for fields that may not exist in the response:
142+
```typescript
143+
closedAt: {
144+
type: 'string',
145+
description: 'When the issue was closed',
146+
optional: true,
147+
},
148+
```
149+
150+
### Typed JSON Outputs
151+
152+
When using `type: 'json'` and you know the object shape in advance, **always define the inner structure** using `properties` so downstream consumers know what fields are available:
153+
154+
```typescript
155+
// BAD: Opaque json with no info about what's inside
156+
metadata: {
157+
type: 'json',
158+
description: 'Response metadata',
159+
},
160+
161+
// GOOD: Define the known properties
162+
metadata: {
163+
type: 'json',
164+
description: 'Response metadata',
165+
properties: {
166+
id: { type: 'string', description: 'Unique ID' },
167+
status: { type: 'string', description: 'Current status' },
168+
count: { type: 'number', description: 'Total count' },
169+
},
170+
},
171+
```
172+
173+
For arrays of objects, define the item structure:
174+
```typescript
175+
items: {
176+
type: 'array',
177+
description: 'List of items',
178+
items: {
179+
type: 'object',
180+
properties: {
181+
id: { type: 'string', description: 'Item ID' },
182+
name: { type: 'string', description: 'Item name' },
183+
},
184+
},
185+
},
186+
```
187+
188+
Only use bare `type: 'json'` without `properties` when the shape is truly dynamic or unknown.
189+
190+
## Critical Rules for transformResponse
191+
192+
### Handle Nullable Fields
193+
ALWAYS use `?? null` for fields that may be undefined:
194+
```typescript
195+
transformResponse: async (response: Response) => {
196+
const data = await response.json()
197+
return {
198+
success: true,
199+
output: {
200+
id: data.id,
201+
title: data.title,
202+
body: data.body ?? null, // May be undefined
203+
assignee: data.assignee ?? null, // May be undefined
204+
labels: data.labels ?? [], // Default to empty array
205+
closedAt: data.closed_at ?? null, // May be undefined
206+
},
207+
}
208+
}
209+
```
210+
211+
### Never Output Raw JSON Dumps
212+
DON'T do this:
213+
```typescript
214+
output: {
215+
data: data, // BAD - raw JSON dump
216+
}
217+
```
218+
219+
DO this instead - extract meaningful fields:
220+
```typescript
221+
output: {
222+
id: data.id,
223+
name: data.name,
224+
status: data.status,
225+
metadata: {
226+
createdAt: data.created_at,
227+
updatedAt: data.updated_at,
228+
},
229+
}
230+
```
231+
232+
## Types File Pattern
233+
234+
Create `types.ts` with interfaces for all params and responses:
235+
236+
```typescript
237+
import type { ToolResponse } from '@/tools/types'
238+
239+
// Parameter interfaces
240+
export interface {Service}{Action}Params {
241+
accessToken: string
242+
requiredField: string
243+
optionalField?: string
244+
}
245+
246+
// Response interfaces (extend ToolResponse)
247+
export interface {Service}{Action}Response extends ToolResponse {
248+
output: {
249+
field1: string
250+
field2: number
251+
optionalField?: string | null
252+
}
253+
}
254+
```
255+
256+
## Index.ts Barrel Export Pattern
257+
258+
```typescript
259+
// Export all tools
260+
export { serviceTool1 } from './{action1}'
261+
export { serviceTool2 } from './{action2}'
262+
263+
// Export types
264+
export * from './types'
265+
```
266+
267+
## Registering Tools
268+
269+
After creating tools, remind the user to:
270+
1. Import tools in `apps/sim/tools/registry.ts`
271+
2. Add to the `tools` object with snake_case keys:
272+
```typescript
273+
import { serviceActionTool } from '@/tools/{service}'
274+
275+
export const tools = {
276+
// ... existing tools ...
277+
{service}_{action}: serviceActionTool,
278+
}
279+
```
280+
281+
## V2 Tool Pattern
282+
283+
If creating V2 tools (API-aligned outputs), use `_v2` suffix:
284+
- Tool ID: `{service}_{action}_v2`
285+
- Variable name: `{action}V2Tool`
286+
- Version: `'2.0.0'`
287+
- Outputs: Flat, API-aligned (no content/metadata wrapper)
288+
289+
## Naming Convention
290+
291+
All tool IDs MUST use `snake_case`: `{service}_{action}` (e.g., `x_create_tweet`, `slack_send_message`). Never use camelCase or PascalCase for tool IDs.
292+
293+
## Checklist Before Finishing
294+
295+
- [ ] All tool IDs use snake_case
296+
- [ ] All params have explicit `required: true` or `required: false`
297+
- [ ] All params have appropriate `visibility`
298+
- [ ] All nullable response fields use `?? null`
299+
- [ ] All optional outputs have `optional: true`
300+
- [ ] No raw JSON dumps in outputs
301+
- [ ] Types file has all interfaces
302+
- [ ] Index.ts exports all tools
303+
304+
## Final Validation (Required)
305+
306+
After creating all tools, you MUST validate every tool before finishing:
307+
308+
1. **Read every tool file** you created — do not skip any
309+
2. **Cross-reference with the API docs** to verify:
310+
- All required params are marked `required: true`
311+
- All optional params are marked `required: false`
312+
- Param types match the API (string, number, boolean, json)
313+
- Request URL, method, headers, and body match the API spec
314+
- `transformResponse` extracts the correct fields from the API response
315+
- All output fields match what the API actually returns
316+
- No fields are missing from outputs that the API provides
317+
- No extra fields are defined in outputs that the API doesn't return
318+
3. **Verify consistency** across tools:
319+
- Shared types in `types.ts` match all tools that use them
320+
- Tool IDs in the barrel export match the tool file definitions
321+
- Error handling is consistent (error checks, meaningful messages)

0 commit comments

Comments
 (0)