rechrome 1.9.0 → 1.9.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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/rech.js +30 -10
  3. package/rech.ts +30 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rechrome",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/snomiao/rechrome.git"
package/rech.js CHANGED
@@ -517,10 +517,23 @@ async function daemonUninstall(): Promise<void> {
517
517
  async function setup(opts: { profile?: string } = {}): Promise<void> {
518
518
  const { createInterface } = await import("readline");
519
519
  const isTTY = process.stdin.isTTY ?? false;
520
- const rl = isTTY ? createInterface({ input: process.stdin, output: process.stdout }) : null;
520
+ let rl: ReturnType<typeof createInterface> | null = null;
521
+ let stdinQueue: string[] | null = null;
522
+ if (isTTY) {
523
+ rl = createInterface({ input: process.stdin, output: process.stdout });
524
+ } else {
525
+ // Pre-read all piped stdin lines so readline close doesn't block later prompts
526
+ stdinQueue = await new Promise<string[]>(resolve => {
527
+ const lines: string[] = [];
528
+ const r = createInterface({ input: process.stdin });
529
+ r.on("line", l => lines.push(l));
530
+ r.on("close", () => resolve(lines));
531
+ });
532
+ }
521
533
  const ask = (q: string, def = "") => {
522
- if (!rl) { process.stdout.write(`${q}${def}\n`); return Promise.resolve(def); }
523
- return new Promise<string>(r => rl.question(q, r));
534
+ process.stdout.write(q);
535
+ if (stdinQueue !== null) { const ans = stdinQueue.shift() ?? def; process.stdout.write(ans + "\n"); return Promise.resolve(ans); }
536
+ return new Promise<string>(r => rl!.question("", ans => r(ans || def)));
524
537
  };
525
538
 
526
539
  // [1/4] Daemon
@@ -611,13 +624,19 @@ async function setup(opts: { profile?: string } = {}): Promise<void> {
611
624
  const statusUrl = `chrome-extension://${extId}/status.html`;
612
625
  console.log(`\n Get auth token from the extension:`);
613
626
  console.log(` ${statusUrl}`);
614
- Bun.spawn(
615
- ["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
616
- `--profile-directory=${profileDir}`, statusUrl],
617
- { stdout: "ignore", stderr: "ignore", detached: true },
618
- );
619
- console.log(`\n Or click the extension icon in the Chrome toolbar.`);
620
- console.log(` Copy the token shown on the page (PLAYWRIGHT_MCP_EXTENSION_TOKEN=...).\n`);
627
+ if (isTTY) {
628
+ Bun.spawn(
629
+ ["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
630
+ `--profile-directory=${profileDir}`, statusUrl],
631
+ { stdout: "ignore", stderr: "ignore", detached: true },
632
+ );
633
+ console.log(`\n Or click the extension icon in the Chrome toolbar.`);
634
+ console.log(` Copy the token shown on the page (PLAYWRIGHT_MCP_EXTENSION_TOKEN=...).\n`);
635
+ } else {
636
+ console.log(`\n [agent] Open the URL above in Chrome (profile: ${profileDisplay})`);
637
+ console.log(` [agent] Find PLAYWRIGHT_MCP_EXTENSION_TOKEN=... on that page`);
638
+ console.log(` [agent] Provide the token value on next stdin line:\n`);
639
+ }
621
640
  const tokenInput = (await ask(" Paste token: ")).trim();
622
641
  const token = tokenInput.replace(/^.*?=/, "").trim();
623
642
  if (!token || token.length < 20) { console.error(" Invalid token (too short)"); return null; }
@@ -648,6 +667,7 @@ async function setup(opts: { profile?: string } = {}): Promise<void> {
648
667
  if (userDataDir) rechUrl.searchParams.set("user_data_dir", userDataDir);
649
668
  const newLine = `RECHROME_URL=${rechUrl.toString()}`;
650
669
  console.log(`\n[4/4] Your RECHROME_URL:\n\n ${newLine}\n`);
670
+ if (!isTTY) console.log(` [agent] Provide save destination on next stdin line: 1=cwd, 2=cwd rechrome-only, 3=home, 4=skip\n`);
651
671
 
652
672
  const pwdEnvPath = join(process.cwd(), ".env.local");
653
673
  const pwdRechPath = join(process.cwd(), ".rechrome", ".env.local");
package/rech.ts CHANGED
@@ -517,10 +517,23 @@ async function daemonUninstall(): Promise<void> {
517
517
  async function setup(opts: { profile?: string } = {}): Promise<void> {
518
518
  const { createInterface } = await import("readline");
519
519
  const isTTY = process.stdin.isTTY ?? false;
520
- const rl = isTTY ? createInterface({ input: process.stdin, output: process.stdout }) : null;
520
+ let rl: ReturnType<typeof createInterface> | null = null;
521
+ let stdinQueue: string[] | null = null;
522
+ if (isTTY) {
523
+ rl = createInterface({ input: process.stdin, output: process.stdout });
524
+ } else {
525
+ // Pre-read all piped stdin lines so readline close doesn't block later prompts
526
+ stdinQueue = await new Promise<string[]>(resolve => {
527
+ const lines: string[] = [];
528
+ const r = createInterface({ input: process.stdin });
529
+ r.on("line", l => lines.push(l));
530
+ r.on("close", () => resolve(lines));
531
+ });
532
+ }
521
533
  const ask = (q: string, def = "") => {
522
- if (!rl) { process.stdout.write(`${q}${def}\n`); return Promise.resolve(def); }
523
- return new Promise<string>(r => rl.question(q, r));
534
+ process.stdout.write(q);
535
+ if (stdinQueue !== null) { const ans = stdinQueue.shift() ?? def; process.stdout.write(ans + "\n"); return Promise.resolve(ans); }
536
+ return new Promise<string>(r => rl!.question("", ans => r(ans || def)));
524
537
  };
525
538
 
526
539
  // [1/4] Daemon
@@ -611,13 +624,19 @@ async function setup(opts: { profile?: string } = {}): Promise<void> {
611
624
  const statusUrl = `chrome-extension://${extId}/status.html`;
612
625
  console.log(`\n Get auth token from the extension:`);
613
626
  console.log(` ${statusUrl}`);
614
- Bun.spawn(
615
- ["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
616
- `--profile-directory=${profileDir}`, statusUrl],
617
- { stdout: "ignore", stderr: "ignore", detached: true },
618
- );
619
- console.log(`\n Or click the extension icon in the Chrome toolbar.`);
620
- console.log(` Copy the token shown on the page (PLAYWRIGHT_MCP_EXTENSION_TOKEN=...).\n`);
627
+ if (isTTY) {
628
+ Bun.spawn(
629
+ ["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
630
+ `--profile-directory=${profileDir}`, statusUrl],
631
+ { stdout: "ignore", stderr: "ignore", detached: true },
632
+ );
633
+ console.log(`\n Or click the extension icon in the Chrome toolbar.`);
634
+ console.log(` Copy the token shown on the page (PLAYWRIGHT_MCP_EXTENSION_TOKEN=...).\n`);
635
+ } else {
636
+ console.log(`\n [agent] Open the URL above in Chrome (profile: ${profileDisplay})`);
637
+ console.log(` [agent] Find PLAYWRIGHT_MCP_EXTENSION_TOKEN=... on that page`);
638
+ console.log(` [agent] Provide the token value on next stdin line:\n`);
639
+ }
621
640
  const tokenInput = (await ask(" Paste token: ")).trim();
622
641
  const token = tokenInput.replace(/^.*?=/, "").trim();
623
642
  if (!token || token.length < 20) { console.error(" Invalid token (too short)"); return null; }
@@ -648,6 +667,7 @@ async function setup(opts: { profile?: string } = {}): Promise<void> {
648
667
  if (userDataDir) rechUrl.searchParams.set("user_data_dir", userDataDir);
649
668
  const newLine = `RECHROME_URL=${rechUrl.toString()}`;
650
669
  console.log(`\n[4/4] Your RECHROME_URL:\n\n ${newLine}\n`);
670
+ if (!isTTY) console.log(` [agent] Provide save destination on next stdin line: 1=cwd, 2=cwd rechrome-only, 3=home, 4=skip\n`);
651
671
 
652
672
  const pwdEnvPath = join(process.cwd(), ".env.local");
653
673
  const pwdRechPath = join(process.cwd(), ".rechrome", ".env.local");