yiyan-browser-agent 1.7.3 → 1.7.4

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/browser.js +32 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yiyan-browser-agent",
3
- "version": "1.7.3",
3
+ "version": "1.7.4",
4
4
  "description": "AI coding agent powered by Yiyan (文心一言) via browser automation — no API key needed",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/browser.js CHANGED
@@ -411,11 +411,17 @@ class YiyanBrowser {
411
411
  if (node.nodeType !== Node.ELEMENT_NODE) return;
412
412
  const tag = node.tagName.toLowerCase();
413
413
 
414
+ // 排除思考过程区域
415
+ const cls = node.className || '';
416
+ if (cls.includes('container__SPpahQHm') || cls.includes('thinking') || cls.includes('Thinking')) {
417
+ return; // 跳过思考区域
418
+ }
419
+
414
420
  if (tag === 'pre') {
415
421
  const codeEl = node.querySelector('code');
416
422
  if (codeEl) {
417
- const cls = codeEl.className || '';
418
- const lang = (cls.match(/language-(\S+)/) || [])[1] || '';
423
+ const cls2 = codeEl.className || '';
424
+ const lang = (cls2.match(/language-(\S+)/) || [])[1] || '';
419
425
  const body = codeEl.textContent || '';
420
426
  result += '\n```' + lang + '\n' + body + '\n```\n';
421
427
  } else {
@@ -444,7 +450,7 @@ class YiyanBrowser {
444
450
  return result.trim();
445
451
  }
446
452
 
447
- // ── 优先:仅从 answer_text_id 提取内容 ──
453
+ // ── 优先:仅从 answer_text_id 提取内容(排除思考区域)──
448
454
  const answerEl = document.querySelector('#answer_text_id');
449
455
  if (answerEl) {
450
456
  const t = getFullText(answerEl);
@@ -605,7 +611,26 @@ class YiyanBrowser {
605
611
  _cleanText(text) {
606
612
  if (!text) return '';
607
613
 
608
- // Remove everything before "准备输出结果" (Yiyan's thinking process)
614
+ // Remove thinking process markers (Yiyan's 思考过程)
615
+ const thinkingMarkers = [
616
+ '正在思考中',
617
+ '正在思考',
618
+ '思考过程',
619
+ '我来',
620
+ '我需要',
621
+ '根据搜索结果',
622
+ '参考',
623
+ 'picaole需要',
624
+ ];
625
+
626
+ // Remove lines that contain thinking markers
627
+ for (const marker of thinkingMarkers) {
628
+ // 如果整行包含思考标记,移除该行
629
+ const lines = text.split('\n');
630
+ text = lines.filter(line => !line.includes(marker)).join('\n');
631
+ }
632
+
633
+ // Remove everything before "准备输出结果" (Yiyan's thinking process end marker)
609
634
  const outputMarker = '准备输出结果';
610
635
  const markerIndex = text.indexOf(outputMarker);
611
636
  if (markerIndex !== -1) {
@@ -624,6 +649,9 @@ class YiyanBrowser {
624
649
 
625
650
  return text
626
651
  // Strip any remaining AI thinking blocks
652
+ .replace(/阶段性总结[\s\S]*?(?=```|$)/gi, '')
653
+ .replace(/根据搜索结果[\s\S]*?(?=```|$)/gi, '')
654
+ // Strip think tags
627
655
  .replace(/<think>[\s\S]*?<\/think>\n?/gi, '')
628
656
  // Strip copy-code button artifacts
629
657
  .replace(/^\d+(?:Copy|Run|Insert|Edit)\b.*$/gm, '')