instar 0.7.39 → 0.7.41

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.
@@ -86,13 +86,21 @@ export async function runSetup(opts) {
86
86
  catch {
87
87
  gitContext = ' This directory is NOT inside a git repository.';
88
88
  }
89
- // Pre-install Playwright browser binaries so the wizard has browser automation
90
- // available from the start. This runs BEFORE launching Claude Code, eliminating
91
- // the "need to restart to load MCP" problem. Silent on success, warns on failure.
89
+ // Pre-install Playwright browser binaries AND register the MCP server so the
90
+ // wizard has browser automation available from the start. Both are required:
91
+ // - Browser binaries: Chromium needs to be downloaded before Playwright MCP can use it
92
+ // - MCP registration: Claude Code loads MCP servers from .claude/settings.json at startup,
93
+ // so the file must exist BEFORE we spawn the Claude session
94
+ //
95
+ // The .claude/settings.json is excluded from the npm package (.npmignore) since it's
96
+ // dev-only config, so we need to create it here for fresh installations.
92
97
  const instarRoot = findInstarRoot();
93
98
  console.log(pc.dim(' Preparing browser automation for Telegram setup...'));
99
+ // Step 1: Ensure .claude/settings.json has Playwright MCP registered
100
+ ensurePlaywrightMcp(instarRoot);
101
+ // Step 2: Pre-install Playwright browser binaries
94
102
  try {
95
- execFileSync('npx', ['playwright', 'install', 'chromium'], {
103
+ execFileSync('npx', ['-y', 'playwright', 'install', 'chromium'], {
96
104
  cwd: instarRoot,
97
105
  stdio: ['pipe', 'pipe', 'pipe'],
98
106
  timeout: 120000, // 2 minutes — first install downloads ~150MB
@@ -135,6 +143,38 @@ export async function runSetup(opts) {
135
143
  });
136
144
  });
137
145
  }
146
+ /**
147
+ * Ensure .claude/settings.json in the given directory has the Playwright MCP
148
+ * server registered. This is critical for the setup wizard — Claude Code loads
149
+ * MCP servers at startup, so the file must exist BEFORE spawning the session.
150
+ *
151
+ * The .npmignore excludes .claude/settings*.json from the published package,
152
+ * so this function creates it for fresh npx installations.
153
+ */
154
+ function ensurePlaywrightMcp(dir) {
155
+ const claudeDir = path.join(dir, '.claude');
156
+ fs.mkdirSync(claudeDir, { recursive: true });
157
+ const settingsPath = path.join(claudeDir, 'settings.json');
158
+ let settings = {};
159
+ if (fs.existsSync(settingsPath)) {
160
+ try {
161
+ settings = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
162
+ }
163
+ catch { /* start fresh if corrupted */ }
164
+ }
165
+ // Register Playwright MCP server if not already present
166
+ if (!settings.mcpServers) {
167
+ settings.mcpServers = {};
168
+ }
169
+ const mcpServers = settings.mcpServers;
170
+ if (!mcpServers.playwright) {
171
+ mcpServers.playwright = {
172
+ command: 'npx',
173
+ args: ['-y', '@playwright/mcp@latest'],
174
+ };
175
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
176
+ }
177
+ }
138
178
  /**
139
179
  * Find the root of the instar package (where .claude/skills/ lives).
140
180
  * Works whether running from source, linked global, or node_modules.
@@ -394,6 +434,21 @@ async function runClassicSetup() {
394
434
  fs.writeFileSync(gitignorePath, instarIgnores.trim() + '\n');
395
435
  console.log(` ${pc.green('✓')} Created .gitignore`);
396
436
  }
437
+ // Install Playwright MCP for browser automation in future Claude sessions
438
+ ensurePlaywrightMcp(projectDir);
439
+ console.log(` ${pc.green('✓')} Configured browser automation (Playwright MCP)`);
440
+ // Pre-install Playwright browser binaries so first use doesn't hang
441
+ try {
442
+ execFileSync('npx', ['-y', 'playwright', 'install', 'chromium'], {
443
+ cwd: projectDir,
444
+ stdio: ['pipe', 'pipe', 'pipe'],
445
+ timeout: 120000,
446
+ });
447
+ console.log(` ${pc.green('✓')} Installed browser binaries`);
448
+ }
449
+ catch {
450
+ console.log(pc.dim(' (Browser binaries will be installed on first use)'));
451
+ }
397
452
  // Install Telegram relay script if configured
398
453
  if (telegramConfig?.chatId) {
399
454
  installTelegramRelay(projectDir, port);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instar",
3
- "version": "0.7.39",
3
+ "version": "0.7.41",
4
4
  "description": "Persistent autonomy infrastructure for AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",