@clix-so/clix-agent-skills 0.1.1
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/README.md +90 -0
- package/dist/bin/cli.js +29 -0
- package/dist/bin/commands/install.js +108 -0
- package/dist/bin/utils/mcp.js +131 -0
- package/package.json +53 -0
- package/skills/integration/LICENSE.txt +202 -0
- package/skills/integration/SKILL.md +426 -0
- package/skills/integration/examples/android-integration.kt +38 -0
- package/skills/integration/examples/flutter-integration.dart +81 -0
- package/skills/integration/examples/ios-integration.swift +36 -0
- package/skills/integration/examples/react-native-integration.tsx +18 -0
- package/skills/integration/references/error-handling.md +265 -0
- package/skills/integration/references/framework-patterns.md +201 -0
- package/skills/integration/references/mcp-integration.md +284 -0
- package/skills/integration/references/sdk-reference.md +217 -0
- package/skills/integration/scripts/install-mcp.sh +244 -0
- package/skills/integration/scripts/validate-sdk.sh +380 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
# Error Handling & Troubleshooting
|
|
2
|
+
|
|
3
|
+
Common errors and solutions when integrating Clix SDK.
|
|
4
|
+
|
|
5
|
+
## Initialization Errors
|
|
6
|
+
|
|
7
|
+
### Error: "Project ID is required"
|
|
8
|
+
|
|
9
|
+
**Symptoms:**
|
|
10
|
+
|
|
11
|
+
- SDK fails to initialize
|
|
12
|
+
- Error message indicates missing project ID
|
|
13
|
+
|
|
14
|
+
**Solutions:**
|
|
15
|
+
|
|
16
|
+
1. Verify `.env` file exists and contains `CLIX_PROJECT_ID`
|
|
17
|
+
2. Check environment variable name matches exactly (case-sensitive)
|
|
18
|
+
3. Ensure environment variables are loaded before initialization
|
|
19
|
+
4. For frameworks with prefixes, use correct prefix (e.g., `NEXT_PUBLIC_`,
|
|
20
|
+
`VITE_`)
|
|
21
|
+
|
|
22
|
+
**Prevention:**
|
|
23
|
+
|
|
24
|
+
- Always check for environment variables before initialization
|
|
25
|
+
- Provide default empty string if optional
|
|
26
|
+
- Log warning if project ID is missing
|
|
27
|
+
|
|
28
|
+
### Error: "Invalid API key"
|
|
29
|
+
|
|
30
|
+
**Symptoms:**
|
|
31
|
+
|
|
32
|
+
- SDK initializes but API calls fail
|
|
33
|
+
- 401 Unauthorized errors
|
|
34
|
+
|
|
35
|
+
**Solutions:**
|
|
36
|
+
|
|
37
|
+
1. Verify API key is correct in environment variables
|
|
38
|
+
2. Check for extra spaces or newlines in `.env` file
|
|
39
|
+
3. Ensure API key hasn't been rotated/revoked
|
|
40
|
+
4. Verify API key has correct permissions
|
|
41
|
+
|
|
42
|
+
**Prevention:**
|
|
43
|
+
|
|
44
|
+
- Never commit API keys to version control
|
|
45
|
+
- Use environment variables, never hardcode
|
|
46
|
+
- Validate API key format if possible
|
|
47
|
+
|
|
48
|
+
### Error: "SDK already initialized"
|
|
49
|
+
|
|
50
|
+
**Symptoms:**
|
|
51
|
+
|
|
52
|
+
- Warning or error about double initialization
|
|
53
|
+
- May cause unexpected behavior
|
|
54
|
+
|
|
55
|
+
**Solutions:**
|
|
56
|
+
|
|
57
|
+
1. Ensure initialization happens only once
|
|
58
|
+
2. Check for multiple initialization calls
|
|
59
|
+
3. Use singleton pattern or guard clause
|
|
60
|
+
|
|
61
|
+
**Prevention:**
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
let initialized = false;
|
|
65
|
+
|
|
66
|
+
if (!initialized) {
|
|
67
|
+
Clix.initialize(config);
|
|
68
|
+
initialized = true;
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Environment Variable Issues
|
|
73
|
+
|
|
74
|
+
### Variables Not Loading
|
|
75
|
+
|
|
76
|
+
**Symptoms:**
|
|
77
|
+
|
|
78
|
+
- `process.env.CLIX_PROJECT_ID` is `undefined`
|
|
79
|
+
- Values are empty strings
|
|
80
|
+
|
|
81
|
+
**Solutions:**
|
|
82
|
+
|
|
83
|
+
**Node.js:**
|
|
84
|
+
|
|
85
|
+
- Ensure `dotenv` is installed and configured
|
|
86
|
+
- Call `require('dotenv').config()` before using variables
|
|
87
|
+
- Check `.env` file is in project root
|
|
88
|
+
|
|
89
|
+
**React/Vite:**
|
|
90
|
+
|
|
91
|
+
- Use correct prefix: `VITE_CLIX_PROJECT_ID`
|
|
92
|
+
- Restart dev server after adding variables
|
|
93
|
+
- Check `.env` file is in project root
|
|
94
|
+
|
|
95
|
+
**Next.js:**
|
|
96
|
+
|
|
97
|
+
- Use `NEXT_PUBLIC_` prefix for client-side variables
|
|
98
|
+
- Restart dev server after changes
|
|
99
|
+
- Check `.env.local` for local development
|
|
100
|
+
|
|
101
|
+
**React Native:**
|
|
102
|
+
|
|
103
|
+
- Use `react-native-config` package
|
|
104
|
+
- Rebuild native apps after adding variables
|
|
105
|
+
- Check `.env` file is in project root
|
|
106
|
+
|
|
107
|
+
### Wrong Variable Names
|
|
108
|
+
|
|
109
|
+
**Symptoms:**
|
|
110
|
+
|
|
111
|
+
- Variables exist but have different names
|
|
112
|
+
- SDK can't find credentials
|
|
113
|
+
|
|
114
|
+
**Solutions:**
|
|
115
|
+
|
|
116
|
+
1. Check existing `.env` files for variable names
|
|
117
|
+
2. Use consistent naming: `CLIX_PROJECT_ID` and `CLIX_PUBLIC_API_KEY`
|
|
118
|
+
3. Update all references to use correct names
|
|
119
|
+
|
|
120
|
+
## Platform-Specific Errors
|
|
121
|
+
|
|
122
|
+
### iOS: "No such module 'Clix'"
|
|
123
|
+
|
|
124
|
+
**Solutions:**
|
|
125
|
+
|
|
126
|
+
1. Run `pod install` in project directory
|
|
127
|
+
2. Clean build folder (Cmd+Shift+K)
|
|
128
|
+
3. Verify Podfile includes Clix dependency
|
|
129
|
+
4. Check Xcode project settings for Swift Package Manager
|
|
130
|
+
|
|
131
|
+
### Android: "Unresolved reference: Clix"
|
|
132
|
+
|
|
133
|
+
**Solutions:**
|
|
134
|
+
|
|
135
|
+
1. Sync Gradle files
|
|
136
|
+
2. Verify `build.gradle` includes Clix dependency
|
|
137
|
+
3. Check package name matches: `so.clix.core.Clix`
|
|
138
|
+
4. Rebuild project
|
|
139
|
+
|
|
140
|
+
### React Native: "Cannot find module '@clix-so/react-native-sdk'"
|
|
141
|
+
|
|
142
|
+
**Solutions:**
|
|
143
|
+
|
|
144
|
+
1. Run `npm install` or `yarn install`
|
|
145
|
+
2. Run `pod install` in `ios/` directory
|
|
146
|
+
3. Rebuild native apps
|
|
147
|
+
4. Check `package.json` includes dependency
|
|
148
|
+
|
|
149
|
+
### Node.js: "Cannot find module '@clix/node-sdk'"
|
|
150
|
+
|
|
151
|
+
**Solutions:**
|
|
152
|
+
|
|
153
|
+
1. Run `npm install` or `yarn install`
|
|
154
|
+
2. Check `package.json` includes dependency
|
|
155
|
+
3. Verify node_modules directory exists
|
|
156
|
+
4. Clear npm cache and reinstall
|
|
157
|
+
|
|
158
|
+
### Web: "Clix is not defined"
|
|
159
|
+
|
|
160
|
+
**Solutions:**
|
|
161
|
+
|
|
162
|
+
1. Ensure SDK is imported before use
|
|
163
|
+
2. Check bundle includes SDK code
|
|
164
|
+
3. Verify initialization happens before SDK usage
|
|
165
|
+
4. Check for build/bundling errors
|
|
166
|
+
|
|
167
|
+
## MCP Server Errors
|
|
168
|
+
|
|
169
|
+
### Error: "MCP server not found"
|
|
170
|
+
|
|
171
|
+
**Solutions:**
|
|
172
|
+
|
|
173
|
+
1. Verify MCP server is installed: `npx -y @clix-so/clix-mcp-server@latest`
|
|
174
|
+
2. Check MCP config file syntax is valid JSON
|
|
175
|
+
3. Verify config file is in correct location for agent
|
|
176
|
+
4. Restart AI agent after configuration changes
|
|
177
|
+
|
|
178
|
+
### Error: "MCP tool calls failing"
|
|
179
|
+
|
|
180
|
+
**Solutions:**
|
|
181
|
+
|
|
182
|
+
1. Check MCP server can be invoked manually
|
|
183
|
+
2. Verify credentials are accessible to MCP server
|
|
184
|
+
3. Check network connectivity
|
|
185
|
+
4. Review MCP server logs for errors
|
|
186
|
+
|
|
187
|
+
## Integration Verification
|
|
188
|
+
|
|
189
|
+
### Verify SDK Initialization
|
|
190
|
+
|
|
191
|
+
**Checklist:**
|
|
192
|
+
|
|
193
|
+
1. ✅ SDK initialized before any usage
|
|
194
|
+
2. ✅ Initialization completed without errors
|
|
195
|
+
3. ✅ Environment variables are accessible
|
|
196
|
+
4. ✅ No console errors or warnings during initialization
|
|
197
|
+
5. ✅ SDK is properly imported/required
|
|
198
|
+
|
|
199
|
+
**Verification Steps:**
|
|
200
|
+
|
|
201
|
+
1. Run `bash scripts/validate-sdk.sh` to check installation
|
|
202
|
+
2. Check console logs for initialization messages
|
|
203
|
+
3. Verify SDK import/require statements are correct
|
|
204
|
+
4. Confirm environment variables are loaded correctly
|
|
205
|
+
|
|
206
|
+
## Best Practices for Error Handling
|
|
207
|
+
|
|
208
|
+
### Always Handle Errors Gracefully
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
try {
|
|
212
|
+
Clix.initialize(config);
|
|
213
|
+
} catch (error) {
|
|
214
|
+
console.error("Clix initialization failed:", error);
|
|
215
|
+
// Don't crash the app - continue execution
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Validate Configuration
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
if (!config.projectId) {
|
|
223
|
+
console.warn("Clix: Project ID is missing");
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
Clix.initialize(config);
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Log Errors for Debugging
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
try {
|
|
234
|
+
Clix.trackEvent("event", properties);
|
|
235
|
+
} catch (error) {
|
|
236
|
+
console.error("Clix tracking failed:", error);
|
|
237
|
+
// Optionally send to error tracking service
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Provide Fallbacks
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
const projectId =
|
|
245
|
+
process.env.CLIX_PROJECT_ID || process.env.REACT_APP_CLIX_PROJECT_ID || "";
|
|
246
|
+
|
|
247
|
+
if (!projectId) {
|
|
248
|
+
console.warn("Clix: No project ID found, analytics disabled");
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Getting Help
|
|
254
|
+
|
|
255
|
+
If you encounter errors not covered here:
|
|
256
|
+
|
|
257
|
+
1. Check SDK documentation for your platform
|
|
258
|
+
2. Review GitHub issues for similar problems
|
|
259
|
+
3. Enable debug mode and check logs
|
|
260
|
+
4. Verify SDK version is up to date
|
|
261
|
+
5. Contact Clix support with:
|
|
262
|
+
- Error message
|
|
263
|
+
- Platform and version
|
|
264
|
+
- SDK version
|
|
265
|
+
- Steps to reproduce
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# Framework-Specific Integration Patterns (Mobile)
|
|
2
|
+
|
|
3
|
+
This document provides detailed patterns for integrating the Clix SDK into
|
|
4
|
+
**mobile** frameworks and platforms:
|
|
5
|
+
|
|
6
|
+
- iOS (Swift)
|
|
7
|
+
- Android (Kotlin)
|
|
8
|
+
- Flutter
|
|
9
|
+
- React Native
|
|
10
|
+
|
|
11
|
+
Examples below are derived strictly from the official SDK source code (via Clix
|
|
12
|
+
MCP `search_sdk`), with credentials shown as placeholders (`YOUR_PROJECT_ID`,
|
|
13
|
+
`YOUR_PUBLIC_API_KEY`).
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
> **Note: Fallback Source** This document serves as a **fallback** when the Clix
|
|
20
|
+
> MCP Server is unavailable. Agents should **prioritize** using `search_sdk` to
|
|
21
|
+
> fetch the latest live patterns from the official SDK repositories before
|
|
22
|
+
> relying on these static examples.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## iOS (Swift)
|
|
27
|
+
|
|
28
|
+
### AppDelegate Pattern (UIKit)
|
|
29
|
+
|
|
30
|
+
**Reference**: `ClixConfig.swift` (from `clix-ios-sdk`)
|
|
31
|
+
|
|
32
|
+
```swift
|
|
33
|
+
import UIKit
|
|
34
|
+
import Clix
|
|
35
|
+
|
|
36
|
+
@main
|
|
37
|
+
class AppDelegate: UIResponder, UIApplicationDelegate {
|
|
38
|
+
func application(
|
|
39
|
+
_ application: UIApplication,
|
|
40
|
+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
|
41
|
+
) -> Bool {
|
|
42
|
+
// Initialize ClixConfig with params
|
|
43
|
+
let config = ClixConfig(
|
|
44
|
+
projectId: ProcessInfo.processInfo.environment["CLIX_PROJECT_ID"] ?? "",
|
|
45
|
+
apiKey: ProcessInfo.processInfo.environment["CLIX_PUBLIC_API_KEY"] ?? "",
|
|
46
|
+
logLevel: .info // Optional: .debug, .info, .error
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
// Pass config to initialize
|
|
50
|
+
try? Clix.initialize(config: config)
|
|
51
|
+
|
|
52
|
+
return true
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### SwiftUI Pattern
|
|
58
|
+
|
|
59
|
+
```swift
|
|
60
|
+
import SwiftUI
|
|
61
|
+
import Clix
|
|
62
|
+
|
|
63
|
+
@main
|
|
64
|
+
struct MyApp: App {
|
|
65
|
+
init() {
|
|
66
|
+
let config = ClixConfig(
|
|
67
|
+
projectId: ProcessInfo.processInfo.environment["CLIX_PROJECT_ID"] ?? "",
|
|
68
|
+
apiKey: ProcessInfo.processInfo.environment["CLIX_PUBLIC_API_KEY"] ?? ""
|
|
69
|
+
)
|
|
70
|
+
try? Clix.initialize(config: config)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
var body: some Scene {
|
|
74
|
+
WindowGroup {
|
|
75
|
+
ContentView()
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Android (Kotlin)
|
|
82
|
+
|
|
83
|
+
**Reference**: `ClixConfig.kt` (from `clix-android-sdk`)
|
|
84
|
+
|
|
85
|
+
### Application Class Pattern
|
|
86
|
+
|
|
87
|
+
```kotlin
|
|
88
|
+
import android.app.Application
|
|
89
|
+
import so.clix.core.Clix
|
|
90
|
+
import so.clix.core.ClixConfig
|
|
91
|
+
import so.clix.utils.logging.ClixLogLevel
|
|
92
|
+
|
|
93
|
+
class MyApplication : Application() {
|
|
94
|
+
override fun onCreate() {
|
|
95
|
+
super.onCreate()
|
|
96
|
+
|
|
97
|
+
val projectId = BuildConfig.CLIX_PROJECT_ID ?: ""
|
|
98
|
+
val apiKey = BuildConfig.CLIX_PUBLIC_API_KEY ?: ""
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
val config = ClixConfig(
|
|
102
|
+
projectId = projectId,
|
|
103
|
+
apiKey = apiKey,
|
|
104
|
+
logLevel = ClixLogLevel.INFO
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
Clix.initialize(this, config)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## React Native
|
|
113
|
+
|
|
114
|
+
**Reference**: `index.js` (from `clix-react-native-sdk`)
|
|
115
|
+
|
|
116
|
+
### Root Component Pattern
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
// App.tsx
|
|
120
|
+
import React, { useEffect } from 'react';
|
|
121
|
+
import { Clix } from '@clix-so/react-native-sdk'; // Note user scope @clix-so
|
|
122
|
+
import Config from 'react-native-config';
|
|
123
|
+
|
|
124
|
+
export default function App() {
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
// Initialize takes a config object
|
|
127
|
+
Clix.initialize({
|
|
128
|
+
projectId: Config.CLIX_PROJECT_ID || '',
|
|
129
|
+
apiKey: Config.CLIX_PUBLIC_API_KEY,
|
|
130
|
+
// logLevel: 'info' // Optional
|
|
131
|
+
});
|
|
132
|
+
}, []);
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
// Your app components
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Flutter
|
|
141
|
+
|
|
142
|
+
**Reference**: `clix_config.dart` (from `clix-flutter-sdk`)
|
|
143
|
+
|
|
144
|
+
### Main Function Pattern
|
|
145
|
+
|
|
146
|
+
```dart
|
|
147
|
+
import 'package:clix_flutter/clix_flutter.dart';
|
|
148
|
+
import 'package:flutter/material.dart';
|
|
149
|
+
|
|
150
|
+
Future<void> main() async {
|
|
151
|
+
WidgetsFlutterBinding.ensureInitialized();
|
|
152
|
+
|
|
153
|
+
const projectId = String.fromEnvironment('CLIX_PROJECT_ID');
|
|
154
|
+
const apiKey = String.fromEnvironment('CLIX_PUBLIC_API_KEY');
|
|
155
|
+
|
|
156
|
+
// Initialize with ClixConfig object
|
|
157
|
+
await Clix.initialize(
|
|
158
|
+
ClixConfig(
|
|
159
|
+
projectId: projectId,
|
|
160
|
+
apiKey: apiKey,
|
|
161
|
+
logLevel: ClixLogLevel.info,
|
|
162
|
+
),
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
runApp(const MyApp());
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Common Patterns
|
|
170
|
+
|
|
171
|
+
### Error Handling
|
|
172
|
+
|
|
173
|
+
Always wrap initialization in try-catch (Swift) or catch errors (Promise-based
|
|
174
|
+
platforms):
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
// React Native / Flutter
|
|
178
|
+
try {
|
|
179
|
+
await Clix.initialize(config);
|
|
180
|
+
} catch (error) {
|
|
181
|
+
console.error("Clix initialization failed:", error);
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Conditional Initialization
|
|
186
|
+
|
|
187
|
+
Only initialize in production or specific environments:
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
if (!__DEV__) {
|
|
191
|
+
Clix.initialize(config);
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Credentials
|
|
196
|
+
|
|
197
|
+
- Use placeholders like `YOUR_PROJECT_ID` and `YOUR_PUBLIC_API_KEY` in examples
|
|
198
|
+
- In real apps, load credentials from safe configuration (config files, build
|
|
199
|
+
config, secret managers)
|
|
200
|
+
- Avoid hardcoding real credentials directly in source code or examples checked
|
|
201
|
+
into version control
|