instar 0.3.6 → 0.3.7
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.
|
@@ -262,7 +262,95 @@ For **Project Agents**: Telegram is strongly recommended but optional. The agent
|
|
|
262
262
|
|
|
263
263
|
If the user declines, that's their choice — but make the tradeoff clear in one sentence.
|
|
264
264
|
|
|
265
|
-
|
|
265
|
+
#### Browser-Automated Setup (Default)
|
|
266
|
+
|
|
267
|
+
**You have Playwright browser automation available.** Use it to do ALL of this for the user. They just need to be logged into Telegram Web.
|
|
268
|
+
|
|
269
|
+
Tell the user:
|
|
270
|
+
> "I'll set up Telegram for you automatically using the browser. Just make sure you're logged into web.telegram.org. I'll handle the bot creation, group setup, and everything else."
|
|
271
|
+
|
|
272
|
+
Then ask:
|
|
273
|
+
> "Are you logged into web.telegram.org?"
|
|
274
|
+
|
|
275
|
+
If yes, proceed with full browser automation. If no, tell them to log in first and wait.
|
|
276
|
+
|
|
277
|
+
**The automated flow:**
|
|
278
|
+
|
|
279
|
+
1. **Navigate to web.telegram.org** using Playwright:
|
|
280
|
+
```
|
|
281
|
+
mcp__playwright__browser_navigate({ url: "https://web.telegram.org/a/" })
|
|
282
|
+
```
|
|
283
|
+
Take a snapshot to verify the user is logged in (look for the chat list, search bar, etc.). If you see a login/QR code screen, tell the user they need to log in first and wait.
|
|
284
|
+
|
|
285
|
+
2. **Create a bot via @BotFather**:
|
|
286
|
+
- Take a snapshot, find the search input, click it
|
|
287
|
+
- Type "BotFather" in the search bar
|
|
288
|
+
- Take a snapshot, find @BotFather in the results, click it
|
|
289
|
+
- Take a snapshot, find the message input area
|
|
290
|
+
- If you see a "Start" button, click it. Otherwise type `/start` and press Enter
|
|
291
|
+
- Wait 2 seconds for BotFather to respond
|
|
292
|
+
- Type `/newbot` and press Enter
|
|
293
|
+
- Wait 2 seconds for BotFather to ask for a name
|
|
294
|
+
- Type the bot display name (use the project name, e.g., "My Project Agent") and press Enter
|
|
295
|
+
- Wait 2 seconds for BotFather to ask for a username
|
|
296
|
+
- Type the bot username (e.g., `myproject_agent_bot` — must end in "bot", use lowercase + underscores) and press Enter
|
|
297
|
+
- Wait 3 seconds for BotFather to respond with the token
|
|
298
|
+
- Take a snapshot and extract the bot token from BotFather's response. The token looks like `7123456789:AAHn3-xYz_example`. Look for text containing a colon between a number and alphanumeric characters.
|
|
299
|
+
- **CRITICAL: Store the token** — you'll need it for config.json
|
|
300
|
+
|
|
301
|
+
3. **Create a group**:
|
|
302
|
+
- Take a snapshot of the main Telegram screen
|
|
303
|
+
- Find and click the "New Message" / compose / pencil button (usually bottom-left area of chat list)
|
|
304
|
+
- Take a snapshot, find "New Group" option, click it
|
|
305
|
+
- In the "Add Members" search, type the bot username you just created
|
|
306
|
+
- Take a snapshot, find the bot in results, click to select it
|
|
307
|
+
- Find and click the "Next" / arrow button to proceed
|
|
308
|
+
- Type the group name (use the project name, e.g., "My Project")
|
|
309
|
+
- Find and click "Create" / checkmark button
|
|
310
|
+
- Wait 2 seconds for the group to be created
|
|
311
|
+
|
|
312
|
+
4. **Enable Topics**:
|
|
313
|
+
- Take a snapshot of the new group chat
|
|
314
|
+
- Click on the group name/header at the top to open group info
|
|
315
|
+
- Take a snapshot, find the Edit / pencil button, click it
|
|
316
|
+
- Take a snapshot, look for "Topics" toggle and enable it
|
|
317
|
+
- If you don't see Topics directly, look for "Group Type" or "Chat Type" first — changing this may reveal the Topics toggle
|
|
318
|
+
- Find and click Save / checkmark
|
|
319
|
+
- Wait 2 seconds
|
|
320
|
+
|
|
321
|
+
5. **Make bot admin**:
|
|
322
|
+
- Take a snapshot of the group info or edit screen
|
|
323
|
+
- Navigate to Administrators section (may need to click group name first, then Edit)
|
|
324
|
+
- Click "Add Admin" or "Add Administrator"
|
|
325
|
+
- Search for your bot username
|
|
326
|
+
- Take a snapshot, find the bot, click to select
|
|
327
|
+
- Click Save / Done to confirm admin rights
|
|
328
|
+
- Wait 2 seconds
|
|
329
|
+
|
|
330
|
+
6. **Detect chat ID**:
|
|
331
|
+
- Type "hello" in the group chat and send it (this triggers the bot to see the group)
|
|
332
|
+
- Wait 3 seconds for the message to propagate to the bot
|
|
333
|
+
- Use Bash to call the Telegram Bot API:
|
|
334
|
+
```bash
|
|
335
|
+
curl -s "https://api.telegram.org/bot${TOKEN}/getUpdates?offset=-1" > /dev/null
|
|
336
|
+
curl -s "https://api.telegram.org/bot${TOKEN}/getUpdates?timeout=5"
|
|
337
|
+
```
|
|
338
|
+
- Parse the response to find `chat.id` where `chat.type` is "supergroup" or "group"
|
|
339
|
+
- If auto-detection fails, try once more (send another message, wait, call API again)
|
|
340
|
+
|
|
341
|
+
**Browser automation tips:**
|
|
342
|
+
- **Always take a snapshot** before interacting. Telegram Web's UI changes frequently.
|
|
343
|
+
- **Use `mcp__playwright__browser_snapshot`** to see the accessibility tree (more reliable than screenshots for finding elements).
|
|
344
|
+
- **Use `mcp__playwright__browser_click`** with element refs from the snapshot.
|
|
345
|
+
- **Use `mcp__playwright__browser_type`** to type text into inputs. For the Telegram message input, you may need to find the message input ref and use `submit: true` to send.
|
|
346
|
+
- **Wait 2-3 seconds** after each action for Telegram to process. Use `mcp__playwright__browser_wait_for({ time: 2 })`.
|
|
347
|
+
- **If an element isn't found**, take a fresh snapshot — Telegram may have changed the view.
|
|
348
|
+
- **Telegram Web uses version "a"** (web.telegram.org/a/) — this is the React-based client.
|
|
349
|
+
- **If something goes wrong**, tell the user what happened and offer to retry that step or fall back to manual instructions.
|
|
350
|
+
|
|
351
|
+
#### Manual Fallback
|
|
352
|
+
|
|
353
|
+
If Playwright tools are not available, or if browser automation fails, fall back to the manual walkthrough:
|
|
266
354
|
|
|
267
355
|
1. **Create a bot** via @BotFather on Telegram:
|
|
268
356
|
- Open https://web.telegram.org
|
|
@@ -276,7 +364,6 @@ Walk through setup step by step:
|
|
|
276
364
|
|
|
277
365
|
3. **Enable Topics**:
|
|
278
366
|
- Open group info, Edit, turn on Topics
|
|
279
|
-
- This gives you separate threads (like Slack channels)
|
|
280
367
|
|
|
281
368
|
4. **Make bot admin**:
|
|
282
369
|
- Group info, Edit, Administrators, Add your bot
|
package/dist/commands/init.js
CHANGED
|
@@ -1157,6 +1157,17 @@ function installClaudeSettings(projectDir) {
|
|
|
1157
1157
|
},
|
|
1158
1158
|
];
|
|
1159
1159
|
}
|
|
1160
|
+
// MCP Servers: Playwright for browser automation (used by setup wizard, Telegram setup, etc.)
|
|
1161
|
+
if (!settings.mcpServers) {
|
|
1162
|
+
settings.mcpServers = {};
|
|
1163
|
+
}
|
|
1164
|
+
const mcpServers = settings.mcpServers;
|
|
1165
|
+
if (!mcpServers.playwright) {
|
|
1166
|
+
mcpServers.playwright = {
|
|
1167
|
+
command: 'npx',
|
|
1168
|
+
args: ['-y', '@playwright/mcp@latest'],
|
|
1169
|
+
};
|
|
1170
|
+
}
|
|
1160
1171
|
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
|
1161
1172
|
}
|
|
1162
1173
|
//# sourceMappingURL=init.js.map
|
|
@@ -55,6 +55,11 @@ export declare class PostUpdateMigrator {
|
|
|
55
55
|
* Never overwrites existing scripts (user may have customized them).
|
|
56
56
|
*/
|
|
57
57
|
private migrateScripts;
|
|
58
|
+
/**
|
|
59
|
+
* Ensure .claude/settings.json has required MCP servers.
|
|
60
|
+
* Only adds — never removes existing configuration.
|
|
61
|
+
*/
|
|
62
|
+
private migrateSettings;
|
|
58
63
|
private getSessionStartHook;
|
|
59
64
|
private getDangerousCommandGuard;
|
|
60
65
|
private getGroundingBeforeMessaging;
|
|
@@ -37,6 +37,7 @@ export class PostUpdateMigrator {
|
|
|
37
37
|
this.migrateHooks(result);
|
|
38
38
|
this.migrateClaudeMd(result);
|
|
39
39
|
this.migrateScripts(result);
|
|
40
|
+
this.migrateSettings(result);
|
|
40
41
|
return result;
|
|
41
42
|
}
|
|
42
43
|
/**
|
|
@@ -191,6 +192,50 @@ Strip the \`[telegram:N]\` prefix before interpreting the message. Respond natur
|
|
|
191
192
|
result.skipped.push('scripts/health-watchdog.sh (already exists)');
|
|
192
193
|
}
|
|
193
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* Ensure .claude/settings.json has required MCP servers.
|
|
197
|
+
* Only adds — never removes existing configuration.
|
|
198
|
+
*/
|
|
199
|
+
migrateSettings(result) {
|
|
200
|
+
const settingsPath = path.join(this.config.projectDir, '.claude', 'settings.json');
|
|
201
|
+
if (!fs.existsSync(settingsPath)) {
|
|
202
|
+
result.skipped.push('.claude/settings.json (not found — will be created on next init)');
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
let settings;
|
|
206
|
+
try {
|
|
207
|
+
settings = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
|
|
208
|
+
}
|
|
209
|
+
catch (err) {
|
|
210
|
+
result.errors.push(`settings.json read: ${err instanceof Error ? err.message : String(err)}`);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
let patched = false;
|
|
214
|
+
// Playwright MCP server — required for browser automation (Telegram setup, etc.)
|
|
215
|
+
if (!settings.mcpServers) {
|
|
216
|
+
settings.mcpServers = {};
|
|
217
|
+
}
|
|
218
|
+
const mcpServers = settings.mcpServers;
|
|
219
|
+
if (!mcpServers.playwright) {
|
|
220
|
+
mcpServers.playwright = {
|
|
221
|
+
command: 'npx',
|
|
222
|
+
args: ['-y', '@playwright/mcp@latest'],
|
|
223
|
+
};
|
|
224
|
+
patched = true;
|
|
225
|
+
result.upgraded.push('.claude/settings.json: added Playwright MCP server');
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
result.skipped.push('.claude/settings.json: Playwright MCP already configured');
|
|
229
|
+
}
|
|
230
|
+
if (patched) {
|
|
231
|
+
try {
|
|
232
|
+
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
|
233
|
+
}
|
|
234
|
+
catch (err) {
|
|
235
|
+
result.errors.push(`settings.json write: ${err instanceof Error ? err.message : String(err)}`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
194
239
|
// ── Hook Templates ─────────────────────────────────────────────────
|
|
195
240
|
getSessionStartHook() {
|
|
196
241
|
return `#!/bin/bash
|