instar 0.7.6 → 0.7.8

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.
@@ -285,33 +285,52 @@ If the user declines, accept it in one sentence and move on — but they should
285
285
 
286
286
  ### Browser Automation Strategy
287
287
 
288
- **CRITICAL: Use ONLY Playwright (mcp__playwright__*) tools for browser automation.**
288
+ **Goal: Automate Telegram setup with a visible browser. Manual instructions are the absolute last resort.**
289
289
 
290
- **DO NOT use Claude in Chrome (mcp__claude-in-chrome__*) tools.** The Chrome extension has issues when Chrome is already open and runs in the user's existing browser session which causes conflicts. Playwright opens its own clean browser window — visible, reliable, and independent.
290
+ The wizard detects what browser tools are available and picks the best path. The user should never have to figure out browser automation themselves.
291
291
 
292
- If you see both Playwright and Chrome extension tools available, **always choose Playwright**. Never fall back to Chrome extension.
292
+ **CRITICAL UX RULE: Never silently attempt browser automation.** The user must know what's happening at every step. If something fails, explain what happened and try the next approach.
293
293
 
294
- **CRITICAL UX RULE: Never silently attempt browser automation.** The user must know what's happening at every step. If something fails, explain what happened — don't just report "it didn't work."
294
+ #### Step 3a: Detect Browser Capabilities
295
295
 
296
- #### Step 3a: Verify Playwright is Available
296
+ Run through this detection waterfall. Stop at the first one that works:
297
297
 
298
- Before doing anything with the browser, verify Playwright works:
298
+ **Option A: Playwright (preferred)**
299
299
 
300
+ Check if `mcp__playwright__*` tools are available. If yes, try:
300
301
  ```
301
302
  mcp__playwright__browser_navigate({ url: "about:blank" })
302
303
  ```
303
304
 
304
- If this succeeds, Playwright is available and a visible browser window should appear. Proceed to Step 3b.
305
+ If this succeeds a visible Chromium window should appear. You're good — proceed to **Step 3b** with Playwright.
305
306
 
306
- If Playwright tools are NOT available (tool not found errors), tell the user:
307
+ If the tool exists but fails with a browser-not-installed error try the built-in install tool:
308
+ ```
309
+ mcp__playwright__browser_install()
310
+ ```
311
+ Wait for it to complete, then retry `browser_navigate`. If it works now → proceed with Playwright.
312
+
313
+ **Option B: Claude in Chrome (fallback)**
314
+
315
+ If Playwright tools are NOT available (tool not found) or Playwright failed even after `browser_install`:
316
+
317
+ Check if `mcp__claude-in-chrome__*` tools are available. If yes, tell the user:
318
+
319
+ > "I'll use the Chrome extension for browser automation. For the smoothest experience, please **close all Chrome windows** before I start — the extension works best with a fresh Chrome session."
320
+ >
321
+ > "Ready? Say OK and I'll open it."
322
+
323
+ Wait for confirmation. Then use `mcp__claude-in-chrome__tabs_context_mcp` to initialize, then `mcp__claude-in-chrome__tabs_create_mcp` for a new tab, and `mcp__claude-in-chrome__navigate` to go to Telegram Web.
307
324
 
308
- > "I need the Playwright browser tools to automate the Telegram setup. They don't seem to be configured."
309
- > "You can add them by running: `npx @playwright/mcp@latest`"
310
- > "Or I can walk you through the manual setup instead."
325
+ **Option C: Manual (last resort)**
311
326
 
312
- If the user chooses manual, go to **Manual Fallback** (Step 3g).
327
+ If NEITHER Playwright nor Chrome extension tools are available:
313
328
 
314
- **Do NOT fall back to Chrome extension tools.** If Playwright isn't available, use manual instructions.
329
+ > "I don't have browser automation tools available right now. No problem — I'll walk you through the Telegram setup step by step. It takes about 2 minutes."
330
+
331
+ Go to **Step 3g: Manual Fallback**.
332
+
333
+ **IMPORTANT: Do NOT skip to manual prematurely.** Try BOTH automation options before falling back. The goal is zero manual steps whenever possible.
315
334
 
316
335
  #### Step 3b: Announce What's About to Happen
317
336
 
@@ -319,7 +338,7 @@ If the user chooses manual, go to **Manual Fallback** (Step 3g).
319
338
 
320
339
  > "I'm going to open a browser window to set up Telegram automatically. I'll create a bot, set up a group, and configure everything."
321
340
  >
322
- > "A Chromium browser window will appear on your screen — you'll need to log into Telegram there."
341
+ > "You'll see a browser window appear — you'll need to log into Telegram there."
323
342
  >
324
343
  > "Ready? Say OK and I'll open it."
325
344
 
@@ -327,25 +346,29 @@ If the user chooses manual, go to **Manual Fallback** (Step 3g).
327
346
 
328
347
  #### Step 3c: Open Browser and Navigate
329
348
 
330
- Navigate to Telegram Web:
349
+ **If using Playwright:**
331
350
  ```
332
351
  mcp__playwright__browser_navigate({ url: "https://web.telegram.org/a/" })
333
352
  ```
334
353
 
335
- The user should see a Chromium window open on their screen. If they report they don't see a browser window, Playwright may be running headless. Tell them:
354
+ **If using Chrome extension:**
355
+ ```
356
+ mcp__claude-in-chrome__navigate({ url: "https://web.telegram.org/a/", tabId: <tab_id> })
357
+ ```
336
358
 
337
- > "It seems the browser opened in headless mode (invisible). Let me close it and we'll do the manual setup instead."
359
+ The user should see a browser window. If they report they don't see one:
360
+ - For Playwright: may be running headless. Try closing and re-opening. If still invisible, try Chrome extension (Option B).
361
+ - For Chrome extension: Chrome may need to be opened. Tell the user to open Chrome, then retry.
338
362
 
339
- Then close the browser and go to Manual Fallback.
363
+ If the user STILL can't see a browser after both attempts, go to Manual Fallback.
340
364
 
341
- After navigating, take a snapshot to check the page state:
342
- ```
343
- mcp__playwright__browser_snapshot()
344
- ```
365
+ After navigating, check the page state:
366
+ - Playwright: `mcp__playwright__browser_snapshot()`
367
+ - Chrome: `mcp__claude-in-chrome__read_page({ tabId: <tab_id> })`
345
368
 
346
369
  #### Step 3d: Handle Login
347
370
 
348
- Check the snapshot for login indicators (QR code screen, "Log in" text, phone number input). Two possible states:
371
+ Check the page for login indicators (QR code screen, "Log in" text, phone number input). Two possible states:
349
372
 
350
373
  **If already logged in** (you see a chat list, search bar, contacts):
351
374
  > "You're logged in. Starting the setup now."
@@ -355,13 +378,13 @@ Proceed to Step 3e.
355
378
  **If NOT logged in** (you see QR code or login screen):
356
379
 
357
380
  Tell the user:
358
- > "I see the Telegram login screen in the browser window I just opened."
381
+ > "I see the Telegram login screen in the browser window."
359
382
  >
360
- > "Please log in now — you can scan the QR code with your phone's Telegram app (Settings > Devices > Link Desktop Device)."
383
+ > "Please log in now — scan the QR code with your phone's Telegram app (Settings > Devices > Link Desktop Device)."
361
384
  >
362
385
  > "Let me know when you're logged in and I'll continue."
363
386
 
364
- **Wait for the user to confirm they've logged in.** Then take another snapshot to verify. If still not logged in, tell them what you see and ask again. Do NOT proceed until login is confirmed by snapshot.
387
+ **Wait for the user to confirm they've logged in.** Then take another snapshot to verify. If still not logged in, tell them what you see and ask again. Do NOT proceed until login is confirmed.
365
388
 
366
389
  #### Step 3e: Automated Telegram Setup
367
390
 
@@ -440,10 +463,9 @@ curl -s "https://api.telegram.org/bot${TOKEN}/getUpdates?timeout=5"
440
463
  After all steps succeed, tell the user:
441
464
  > "Telegram is set up! Bot token and chat ID saved."
442
465
 
443
- Close the browser if using Playwright:
444
- ```
445
- mcp__playwright__browser_close()
446
- ```
466
+ Close the browser:
467
+ - Playwright: `mcp__playwright__browser_close()`
468
+ - Chrome extension: No need to close — the user's Chrome stays open
447
469
 
448
470
  #### Step 3g: Manual Fallback
449
471
 
@@ -463,15 +485,14 @@ curl -s "https://api.telegram.org/bot${TOKEN}/getUpdates?timeout=5"
463
485
 
464
486
  ### Browser Automation Tips
465
487
 
466
- - **ONLY use `mcp__playwright__*` tools.** Never use `mcp__claude-in-chrome__*` even if available.
467
- - **Always take a snapshot before interacting.** Telegram Web's UI changes frequently.
468
- - **Use `mcp__playwright__browser_snapshot`** (accessibility tree) over screenshots for finding elements more reliable.
469
- - **Use `mcp__playwright__browser_click`** with ref from snapshots for clicking.
470
- - **Use `mcp__playwright__browser_type`** for typing into inputs. Use `submit: true` to send messages.
471
- - **Wait 2-3 seconds** after each action for Telegram to process. Use `mcp__playwright__browser_wait_for({ time: 2 })`.
488
+ - **Prefer Playwright, fall back to Chrome extension.** Playwright gets a clean browser; Chrome extension reuses the user's session. Both work.
489
+ - **Always take a snapshot/read_page before interacting.** Telegram Web's UI changes frequently.
490
+ - **Playwright**: Use `browser_snapshot` (accessibility tree) for finding elements. Use `browser_click` with ref. Use `browser_type` with `submit: true` for messages. Use `browser_wait_for({ time: 2 })` between actions.
491
+ - **Chrome extension**: Use `read_page` for accessibility tree. Use `computer` with `left_click` for clicking. Use `computer` with `type` for text input. Use `computer` with `wait` between actions.
472
492
  - **If an element isn't found**, take a fresh snapshot — the view may have changed.
473
493
  - **Telegram Web uses version "a"** (web.telegram.org/a/) — this is the React-based client.
474
494
  - **If something goes wrong**, tell the user exactly what happened and what you see. Offer to retry that specific step or fall back to manual for just the remaining steps.
495
+ - **If one automation tool fails mid-flow**, you can switch to the other tool or to manual FOR JUST THE REMAINING STEPS. Don't restart from scratch.
475
496
  - **NEVER silently fail.** If a browser action doesn't work, say "I tried to click X but it didn't respond. Here's what I see on screen: [describe]. Let me try another approach."
476
497
 
477
498
  ## Phase 4: Technical Configuration
@@ -85,6 +85,22 @@ export async function runSetup(opts) {
85
85
  catch {
86
86
  gitContext = ' This directory is NOT inside a git repository.';
87
87
  }
88
+ // Pre-install Playwright browser binaries so the wizard has browser automation
89
+ // available from the start. This runs BEFORE launching Claude Code, eliminating
90
+ // the "need to restart to load MCP" problem. Silent on success, warns on failure.
91
+ const instarRoot = findInstarRoot();
92
+ console.log(pc.dim(' Preparing browser automation for Telegram setup...'));
93
+ try {
94
+ execFileSync('npx', ['playwright', 'install', 'chromium'], {
95
+ cwd: instarRoot,
96
+ stdio: ['pipe', 'pipe', 'pipe'],
97
+ timeout: 120000, // 2 minutes — first install downloads ~150MB
98
+ });
99
+ }
100
+ catch {
101
+ // Non-fatal — wizard will fall back to manual if browser isn't available
102
+ console.log(pc.dim(' (Browser automation may not be available — the wizard can still guide you manually)'));
103
+ }
88
104
  // Launch Claude Code from the instar package root (where .claude/skills/ lives)
89
105
  // and pass the target project directory + git context in the prompt.
90
106
  //
@@ -93,7 +109,6 @@ export async function runSetup(opts) {
93
109
  // project. Without it, Claude would prompt for permissions to modify the
94
110
  // user's project directory, which breaks the interactive flow. The wizard
95
111
  // only writes to well-defined locations (.instar/, .claude/, CLAUDE.md).
96
- const instarRoot = findInstarRoot();
97
112
  const child = spawn(claudePath, [
98
113
  '--dangerously-skip-permissions',
99
114
  `/setup-wizard The project to set up is at: ${projectDir}.${gitContext}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instar",
3
- "version": "0.7.6",
3
+ "version": "0.7.8",
4
4
  "description": "Persistent autonomy infrastructure for AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",