flingit 0.0.18 → 0.0.20
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/dist/cli/commands/plugin.d.ts +3 -10
- package/dist/cli/commands/plugin.d.ts.map +1 -1
- package/dist/cli/commands/plugin.js +103 -209
- package/dist/cli/commands/plugin.js.map +1 -1
- package/dist/cli/commands/push.d.ts +5 -0
- package/dist/cli/commands/push.d.ts.map +1 -1
- package/dist/cli/commands/push.js +21 -33
- package/dist/cli/commands/push.js.map +1 -1
- package/dist/cli/deploy/bundler.d.ts +14 -10
- package/dist/cli/deploy/bundler.d.ts.map +1 -1
- package/dist/cli/deploy/bundler.js +44 -70
- package/dist/cli/deploy/bundler.js.map +1 -1
- package/dist/cli/utils/config.d.ts +12 -4
- package/dist/cli/utils/config.d.ts.map +1 -1
- package/dist/cli/utils/config.js +49 -6
- package/dist/cli/utils/config.js.map +1 -1
- package/dist/runtime/discord.d.ts +18 -59
- package/dist/runtime/discord.d.ts.map +1 -1
- package/dist/runtime/discord.js +20 -60
- package/dist/runtime/discord.js.map +1 -1
- package/dist/runtime/slack.d.ts +83 -0
- package/dist/runtime/slack.d.ts.map +1 -0
- package/dist/runtime/slack.js +87 -0
- package/dist/runtime/slack.js.map +1 -0
- package/dist/shared/discord-types.d.ts +0 -24
- package/dist/shared/discord-types.d.ts.map +1 -1
- package/dist/shared/plugin-metadata.d.ts +28 -0
- package/dist/shared/plugin-metadata.d.ts.map +1 -0
- package/dist/shared/plugin-metadata.js +65 -0
- package/dist/shared/plugin-metadata.js.map +1 -0
- package/dist/shared/slack-types.d.ts +61 -0
- package/dist/shared/slack-types.d.ts.map +1 -0
- package/dist/shared/slack-types.js +8 -0
- package/dist/shared/slack-types.js.map +1 -0
- package/dist/worker-runtime/discord.d.ts +75 -27
- package/dist/worker-runtime/discord.d.ts.map +1 -1
- package/dist/worker-runtime/discord.js +156 -108
- package/dist/worker-runtime/discord.js.map +1 -1
- package/dist/worker-runtime/index.d.ts +1 -1
- package/dist/worker-runtime/index.d.ts.map +1 -1
- package/dist/worker-runtime/index.js +0 -4
- package/dist/worker-runtime/index.js.map +1 -1
- package/dist/worker-runtime/plugin-common.d.ts +27 -0
- package/dist/worker-runtime/plugin-common.d.ts.map +1 -0
- package/dist/worker-runtime/plugin-common.js +91 -0
- package/dist/worker-runtime/plugin-common.js.map +1 -0
- package/dist/worker-runtime/slack.d.ts +67 -0
- package/dist/worker-runtime/slack.d.ts.map +1 -0
- package/dist/worker-runtime/slack.js +135 -0
- package/dist/worker-runtime/slack.js.map +1 -0
- package/package.json +10 -2
- package/templates/default/skills/fling/.hash +1 -1
- package/templates/default/skills/fling/DISCORD.md +69 -126
- package/templates/default/skills/fling/SKILL.md +13 -0
- package/templates/default/skills/fling/SLACK.md +214 -0
|
@@ -215,6 +215,8 @@ When the user's request is complete and working locally, offer to deploy it. Bu
|
|
|
215
215
|
To deploy:
|
|
216
216
|
**Run `npm exec fling push` directly** - you have bash access, don't ask the user to run commands.
|
|
217
217
|
|
|
218
|
+
After each deploy, tell the user what the deployed URL is.
|
|
219
|
+
|
|
218
220
|
### After First Deployment
|
|
219
221
|
|
|
220
222
|
After your first `fling push`, consider asking the user if they want a custom URL.
|
|
@@ -249,6 +251,13 @@ Slugs must be:
|
|
|
249
251
|
- All other paths serve static assets from `dist/client/`
|
|
250
252
|
- If no asset matches, `index.html` is served (SPA fallback)
|
|
251
253
|
|
|
254
|
+
## Security
|
|
255
|
+
|
|
256
|
+
If the user does not want their app to be deployed because of security issues, or asks about that, offer implementing proper backend-supported security. In particular, suggest these two auth methods first:
|
|
257
|
+
|
|
258
|
+
- Login with Google, with a filter on which emails/domains are allowed
|
|
259
|
+
- Simple password-based auth, where the backend has a list of allowed passwords (hashed)
|
|
260
|
+
|
|
252
261
|
## Collaborating with Others
|
|
253
262
|
|
|
254
263
|
If the user asks how to collaborate with another user on their Fling project, the best approach is:
|
|
@@ -337,3 +346,7 @@ This approach:
|
|
|
337
346
|
**For large assets:** Serve them from the frontend (`public/` folder) instead.
|
|
338
347
|
|
|
339
348
|
See API.md for detailed API reference, EXAMPLES.md for common patterns, and FEEDBACK.md for collecting user feedback.
|
|
349
|
+
|
|
350
|
+
## Updates
|
|
351
|
+
|
|
352
|
+
When the fling CLI mentions that there is a new version available, strongly suggest to the user to update, becasue it might contain bug fixes or new features.
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# Slack Skill
|
|
2
|
+
|
|
3
|
+
Build Slack chatops bots with Fling. Respond to @mentions, send messages, and react to events — all from your Fling project.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
Slack requires a one-time setup before use:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm exec fling plugin install slack # Connect Slack workspace (opens browser)
|
|
11
|
+
npm exec fling push # Deploy code
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Run these commands yourself — you have bash access.
|
|
15
|
+
|
|
16
|
+
## Quick Reference
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { app } from "flingit";
|
|
20
|
+
import { slack } from "flingit/plugin/slack";
|
|
21
|
+
|
|
22
|
+
// 1. Handle @mentions of your bot
|
|
23
|
+
slack.onMention(async (event) => {
|
|
24
|
+
// Parse the mention text (remove the bot mention prefix)
|
|
25
|
+
const text = event.text.replace(/<@[A-Z0-9]+>\s*/, "").trim();
|
|
26
|
+
|
|
27
|
+
if (text.startsWith("deploy")) {
|
|
28
|
+
const branch = text.split(" ")[1] ?? "main";
|
|
29
|
+
await slack.sendMessage({
|
|
30
|
+
channelId: event.channel,
|
|
31
|
+
threadTs: event.ts,
|
|
32
|
+
text: `Deploying ${branch}...`,
|
|
33
|
+
});
|
|
34
|
+
} else {
|
|
35
|
+
await slack.sendMessage({
|
|
36
|
+
channelId: event.channel,
|
|
37
|
+
threadTs: event.ts,
|
|
38
|
+
text: "Hello! How can I help?",
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// 2. Send messages proactively (e.g., from webhooks or cron)
|
|
44
|
+
app.post("/api/notify", async (c) => {
|
|
45
|
+
const { channelId, text } = await c.req.json();
|
|
46
|
+
|
|
47
|
+
await slack.sendMessage({
|
|
48
|
+
channelId,
|
|
49
|
+
text
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return c.json({ sent: true });
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## API Reference
|
|
57
|
+
|
|
58
|
+
All methods are imported from `"flingit/plugin/slack"`:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { slack } from "flingit/plugin/slack";
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### slack.onMention(handler)
|
|
65
|
+
|
|
66
|
+
Register a handler for @mentions of your bot. Triggered when someone mentions your Fling app in a channel.
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
slack.onMention(async (event) => {
|
|
70
|
+
// event.channel = which channel
|
|
71
|
+
// event.user = who mentioned the bot
|
|
72
|
+
// event.text = full mention text (includes <@BOT_ID>)
|
|
73
|
+
// event.ts = message timestamp
|
|
74
|
+
// event.thread_ts = thread timestamp (if in thread)
|
|
75
|
+
|
|
76
|
+
await slack.sendMessage({
|
|
77
|
+
channelId: event.channel,
|
|
78
|
+
threadTs: event.ts, // Reply in thread
|
|
79
|
+
text: "Got it!",
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The platform verifies Slack's HMAC-SHA256 signature before forwarding to your code — you don't need to handle that.
|
|
85
|
+
|
|
86
|
+
### slack.onEvent(handler)
|
|
87
|
+
|
|
88
|
+
Register a fallback handler for raw Slack events that aren't handled by `onMention`. Use this for advanced cases.
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
slack.onEvent(async (event) => {
|
|
92
|
+
console.log("Raw event:", event.type);
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### slack.sendMessage(options)
|
|
97
|
+
|
|
98
|
+
Send a message to any channel. Use this for notifications, alerts, or proactive messages.
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
const msg = await slack.sendMessage({
|
|
102
|
+
channelId: "C123456789",
|
|
103
|
+
text: "Deployment complete!",
|
|
104
|
+
blocks: [{
|
|
105
|
+
type: "section",
|
|
106
|
+
text: { type: "mrkdwn", text: "*Deploy Report*\nv2.1.0 is now live" }
|
|
107
|
+
}]
|
|
108
|
+
});
|
|
109
|
+
// Returns: { channelId, ts, text }
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
To reply in a thread:
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
await slack.sendMessage({
|
|
116
|
+
channelId: "C123456789",
|
|
117
|
+
text: "Thread reply here",
|
|
118
|
+
threadTs: "1234567890.123456" // Parent message timestamp
|
|
119
|
+
});
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### slack.editMessage(channelId, ts, options)
|
|
123
|
+
|
|
124
|
+
Edit a previously sent message.
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
const msg = await slack.sendMessage({
|
|
128
|
+
channelId: channel,
|
|
129
|
+
text: "Deploying..."
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// Later, update it
|
|
133
|
+
await slack.editMessage(channel, msg.ts, {
|
|
134
|
+
text: "Deploy complete!"
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### slack.addReaction(channelId, ts, emoji)
|
|
139
|
+
|
|
140
|
+
Add an emoji reaction to a message.
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
await slack.addReaction(channelId, ts, "white_check_mark");
|
|
144
|
+
await slack.addReaction(channelId, ts, "rocket");
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Note: Use emoji names without colons (e.g., `"thumbsup"` not `":thumbsup:"`).
|
|
148
|
+
|
|
149
|
+
## Block Kit
|
|
150
|
+
|
|
151
|
+
Slack uses Block Kit for rich message formatting. Common block types:
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
// Section block with markdown
|
|
155
|
+
{
|
|
156
|
+
type: "section",
|
|
157
|
+
text: { type: "mrkdwn", text: "*Bold* and _italic_" }
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Section with fields
|
|
161
|
+
{
|
|
162
|
+
type: "section",
|
|
163
|
+
fields: [
|
|
164
|
+
{ type: "mrkdwn", text: "*Status:*\nActive" },
|
|
165
|
+
{ type: "mrkdwn", text: "*Region:*\nus-east-1" }
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Divider
|
|
170
|
+
{ type: "divider" }
|
|
171
|
+
|
|
172
|
+
// Context (small text)
|
|
173
|
+
{
|
|
174
|
+
type: "context",
|
|
175
|
+
elements: [
|
|
176
|
+
{ type: "mrkdwn", text: "Deployed by <@U123> at 3:42 PM" }
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
For more block types, see the Slack Block Kit documentation.
|
|
182
|
+
|
|
183
|
+
## CLI Commands
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
# Setup
|
|
187
|
+
npm exec fling plugin install slack # Connect Slack (OAuth), auto-claims workspace
|
|
188
|
+
|
|
189
|
+
# Status
|
|
190
|
+
npm exec fling plugin permissions slack # Show connection status + workspaces
|
|
191
|
+
|
|
192
|
+
# Deployment
|
|
193
|
+
npm exec fling push
|
|
194
|
+
|
|
195
|
+
# Teardown
|
|
196
|
+
npm exec fling plugin remove slack # Disconnect, release all workspaces
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## How It Works
|
|
200
|
+
|
|
201
|
+
1. **`fling plugin install slack`** opens a browser for Slack OAuth. You authorize the Fling app for your workspace, and it's automatically claimed for your project.
|
|
202
|
+
2. **`slack.onMention(handler)`** registers a handler that receives `app_mention` events when someone @mentions your bot in a channel.
|
|
203
|
+
3. The platform verifies Slack's HMAC-SHA256 signature, looks up the owning project, and forwards the event to your worker.
|
|
204
|
+
4. Your handler receives the event and uses `slack.sendMessage()` to respond (typically replying in-thread).
|
|
205
|
+
|
|
206
|
+
## Important Constraints
|
|
207
|
+
|
|
208
|
+
1. **Slack features only work in deployed workers** — They throw errors locally. Use `fling push` to deploy, then test in Slack.
|
|
209
|
+
|
|
210
|
+
2. **Mention-based interaction** — Users interact with your bot by @mentioning it in a channel. Parse the mention text to understand intent.
|
|
211
|
+
|
|
212
|
+
3. **One project per workspace** — A Slack workspace can only be claimed by one Fling project at a time.
|
|
213
|
+
|
|
214
|
+
4. **Plugin must be installed first** — Run `fling plugin install slack` before using any Slack features. Check with `fling plugin permissions slack`.
|