Skip to content

Conversation

@USERNAME-STOCK
Copy link

@USERNAME-STOCK USERNAME-STOCK commented Nov 8, 2025

PR Type

Enhancement, Documentation


Description

  • Restructured all AI prompts with hybrid markdown + XML format for consistency

    • Added explicit role definitions, task descriptions, and structured outputs
    • Implemented detailed instructions with step-by-step guidance
    • Added constraints to prevent hallucination and improve reliability
  • Simplified build process to Chrome-only with single output variant

    • Removed Firefox and Safari build configurations
    • Disabled webpack concatenateModules for better debugging
    • Removed minimal build variants (without-katex-and-tiktoken)
  • Streamlined locale support to English only

    • Removed all non-English language files and configurations
    • Simplified language detection and selection logic
    • Updated documentation to reflect Chrome-only, English-only build

Diagram Walkthrough

flowchart LR
  A["Old Simple Prompts"] -->|"Restructure with<br/>Markdown + XML"| B["Structured Prompts<br/>with Role/Task/Instructions"]
  C["Multi-platform Build<br/>Chrome/Firefox/Safari"] -->|"Simplify to<br/>Chrome-only"| D["Single Chromium<br/>Output"]
  E["Multi-locale Support<br/>12+ languages"] -->|"Reduce to<br/>English only"| F["English-only<br/>Configuration"]
  B --> G["Better AI Response<br/>Quality & Consistency"]
  D --> H["Faster Build<br/>Process"]
  F --> I["Reduced<br/>Complexity"]
Loading

File Walkthrough

Relevant files
Enhancement
8 files
index.mjs
Rewrite selection tool prompts with structured format       
+471/-35
index.mjs
Enhance GitHub issue/PR analyzer prompts with structure   
+164/-26
shared.mjs
Upgrade system prompts with detailed capabilities and guidelines
+140/-8 
index.jsx
Restructure search engine handler prompt with instructions
+77/-7   
index.mjs
Add structured academic paper analysis prompt format         
+71/-8   
index.mjs
Implement structured page summarization prompt                     
+82/-1   
index.mjs
Enhance video summarizer with structured output format     
+60/-4   
index.mjs
Enhance Bilibili video summarizer with structured format 
+60/-4   
Configuration changes
5 files
build.mjs
Simplify build to Chrome-only with single output                 
+3/-25   
index.mjs
Set default model to English and simplify language detection
+3/-4     
language.mjs
Reduce language list to English only                                         
+5/-10   
is-firefox.mjs
Hardcode Firefox detection to false for Chrome-only build
+2/-1     
is-safari.mjs
Hardcode Safari detection to false for Chrome-only build 
+2/-1     
Documentation
1 files
AGENTS.md
Update documentation for Chrome-only, English-only build 
+5/-11   
Additional files
27 files
pre-release-build.yml +0/-18   
tagged-release.yml +0/-21   
README_IN.md +0/-140 
README_JA.md +0/-138 
README_TR.md +0/-141 
README_ZH.md +0/-143 
package.json +0/-1     
appdmg.json +0/-8     
build.sh +0/-13   
export-options.plist +0/-8     
project.patch +0/-2     
project.pre.patch +0/-18   
project_developer.patch +0/-196 
main.json +0/-163 
main.json +0/-163 
main.json +0/-163 
main.json +0/-163 
main.json +0/-163 
main.json +0/-163 
main.json +0/-163 
main.json +0/-163 
resources.mjs +0/-48   
main.json +0/-163 
main.json +0/-163 
main.json +0/-170 
main.json +0/-165 
manifest.v2.json +0/-90   

Summary by CodeRabbit

  • Chores

    • Streamlined build system to support Chrome only; discontinued Firefox and Safari builds.
    • Removed all non-English language support and localized documentation.
  • Refactor

    • Restructured content analysis and chat prompts with multi-section templates including role, task, instructions, and formatted output sections for improved clarity and consistency.

…iled instructions

Upgraded all AI prompts throughout the extension to use a hybrid markdown + XML
structure with explicit role definitions, task descriptions, instructions, output
formats, and constraints. This provides better clarity and more consistent,
high-quality responses from AI models.

Changes:
- YouTube/Bilibili video summarizers: Added structured output format with
  overview, main topics, key takeaways, and important details sections
- GitHub analyzer: Separate improved prompts for issues/PRs and commits with
  conventional commit message format support
- arXiv paper analyzer: Added research domain classification, methodology
  breakdown, and relevance keywords
- Search engine handler: Enhanced with search intent classification and
  structured answer format
- Selection tools (Explain, Translate, Summary, Polish, Code, Sentiment):
  Complete rewrite with detailed instructions and structured outputs
- Menu tools: Improved page summarization with content type identification
- System prompts: Enhanced base prompts for Chat/Completion/Custom APIs with
  explicit capabilities, guidelines, and constraints

All prompts now include:
- Clear role and task definitions
- Step-by-step instructions
- Structured output format templates
- Explicit constraints to prevent hallucination
- Multi-language support where appropriate

This addresses the need for more reliable, structured AI responses across all
extension features.
…locale

Streamlined the build configuration to reduce complexity and build time:

Build Simplification:
- Removed Firefox build output (kept Chrome/Chromium only)
- Disabled webpack concatenateModules for better debugging
- Removed minimal build variants (without-katex-and-tiktoken)
- Removed Safari build script from package.json
- Build now produces single chromium/ output directory with full features

Locale Simplification:
- Removed all non-English locales (de, es, fr, in, it, ja, ko, pt, ru, tr, zh-hans, zh-hant)
- Kept only English (en) locale
- Updated languageList to only include auto and en
- Simplified getNavigatorLanguage() to always return 'en'
- Removed language-specific model defaults (Chinese → Moonshot)
- Updated resources.mjs to import only English translations

Documentation:
- Removed non-English README files (README_IN.md, README_JA.md, README_TR.md, README_ZH.md)
- Kept only main README.md

Benefits:
- Faster build times (single target, no variants)
- Smaller codebase (~13 locale directories removed)
- Easier maintenance (one browser target)
- Better debuggability (no concatenation)
- Clearer output structure

Build output: build/chromium/ and build/chromium.zip
Complete platform cleanup to streamline development for Chrome/Chromium only:

**Deleted Safari-related files:**
- safari/ directory (build scripts, patches, app-dmg config)

**Deleted Firefox-related files:**
- src/manifest.v2.json (Firefox manifest)

**Modified browser detection:**
- src/utils/is-safari.mjs - now always returns false
- src/utils/is-firefox.mjs - now always returns false

**Updated CI/CD workflows:**
- .github/workflows/pre-release-build.yml - removed Firefox build artifacts
- .github/workflows/tagged-release.yml - removed Safari and Firefox release uploads

**Updated documentation:**
- AGENTS.md - reflected Chrome-only build structure

This cleanup builds upon the previous localization and build simplification,
creating a focused Chrome-only development environment with faster builds
and reduced maintenance overhead.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 8, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The PR consolidates the project to Chrome-only support by removing Firefox, Safari, and Chromium-without-KaTeX build variants, simplifying CI/CD workflows. All non-English localization files and localized README documents are deleted. Configuration is updated to hardcoded English language support and Chrome-specific behavior. Prompt templates across content-script modules are restructured into formal multi-section formats with explicit Role, Task, Instructions, and Output Format blocks.

Changes

Cohort / File(s) Summary
Workflow & CI/CD simplification
.github/workflows/pre-release-build.yml, .github/workflows/tagged-release.yml
Removed artifact uploads for Firefox, Safari, and Chromium-without-KaTeX builds; retained only Chromium build. Removed macOS tooling setup and Safari export steps from tagged-release workflow.
Documentation updates
AGENTS.md
Updated build documentation from plural "variants" to singular "output"; consolidated to Chrome-only distribution artifact; removed references to Firefox and Safari manifests.
Localization file removal
src/_locales/de/main.json, src/_locales/es/main.json, src/_locales/fr/main.json, src/_locales/in/main.json, src/_locales/it/main.json, src/_locales/ja/main.json, src/_locales/ko/main.json, src/_locales/pt/main.json, src/_locales/ru/main.json, src/_locales/tr/main.json, src/_locales/zh-hans/main.json, src/_locales/zh-hant/main.json
Deleted all non-English locale JSON files containing UI translation mappings.
Localization config
src/_locales/resources.mjs
Removed all non-English language imports and entries from exported resources object; retained only English locale.
Translated README removal
README_IN.md, README_JA.md, README_TR.md, README_ZH.md
Deleted Indonesian, Japanese, Turkish, and Chinese README localization files.
Safari/macOS build infrastructure
safari/appdmg.json, safari/build.sh, safari/export-options.plist, safari/project.patch, safari/project.pre.patch, safari/project_developer.patch
Removed all Safari-specific build scripts, configuration files, and Xcode project patches.
Build system updates
build.mjs
Removed Firefox output directory creation, manifest.v2 usage, and multi-variant (KaTeX/TikToken) build logic; consolidated to single Chromium-only build with concatenateModules always false.
Build script configuration
package.json
Removed build:safari npm script entry.
Manifest file cleanup
src/manifest.v2.json
Deleted Chrome extension Manifest V2 configuration file.
Language & config simplification
src/config/index.mjs, src/config/language.mjs
Fixed defaultConfig.modelName to claude2WebFree and getNavigatorLanguage() to always return 'en'; narrowed languageList to auto and English only.
Browser detection stubs
src/utils/is-firefox.mjs, src/utils/is-safari.mjs
Changed isFirefox() and isSafari() to always return false with clarifying comments.
Prompt template restructuring (core content)
src/content-script/index.jsx, src/content-script/menu-tools/index.mjs
Replaced simple prompts with structured multi-section templates including Role, Task, Instructions, Output Format, and Input Data blocks.
Selection tools prompt refactoring
src/content-script/selection-tools/index.mjs
Converted static prompt generators to async genPrompt functions with dynamic language-aware multi-section prompts for Explain, Translate, TranslateToEn, TranslateToZh, Summary, Polish, Sentiment, and Code Explain operations.
Site adapter prompt restructuring
src/content-script/site-adapters/arxiv/index.mjs, src/content-script/site-adapters/bilibili/index.mjs, src/content-script/site-adapters/github/index.mjs, src/content-script/site-adapters/youtube/index.mjs
Replaced ad-hoc prompts with standardized Role/Task/Instructions/Output Format templates; added explicit constraints and structured input data blocks for each adapter (arXiv, Bilibili, GitHub, YouTube).
API service prompts
src/services/apis/shared.mjs
Expanded base system, completion, and custom API prompts from single-line strings to multi-section formats with roles, capabilities, guidelines, and response approach sections.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Localization/documentation deletions: Straightforward removals with no logic dependencies (12 locale files, 4 READMEs, Safari infrastructure).
  • Prompt restructuring across 7+ modules: Requires individual review of each prompt's Role/Task/Instructions/Output Format transitions to verify semantic equivalence and accuracy of new templates.
  • Build system consolidation: Moderate logic changes with removal of multi-variant build paths and Firefox/Safari-specific logic.
  • Browser detection changes: Simple constant returns, but verify no other code paths depend on true values.

Areas requiring extra attention:

  • src/content-script/selection-tools/index.mjs — Multiple async genPrompt conversions with language-aware customization; verify prompt semantics align with original intent.
  • src/content-script/site-adapters/github/index.mjs — Complex differentiation between issue/PR vs. patch prompts and restructured input data sections; confirm output format changes don't break downstream parsing.
  • build.mjs — Verify removal of multi-variant build scaffolding doesn't inadvertently break conditional build logic or trigger unintended optimization side-effects.
  • src/config/index.mjs and src/config/language.mjs — Confirm hardcoded English language support doesn't cause unexpected fallback or error conditions elsewhere.

Possibly related PRs

  • Refine built-in prompts #866: Directly related; both PRs modify and refactor prompt strings across src/content-script modules (selection-tools, menu-tools, site-adapters) with similar multi-section prompt template restructuring patterns.

Suggested labels

Review effort 2/5, codex

Poem

🐰 Chrome alone now hops with glee,
Firefox and Safari? Adieu, farewell, be free!
Prompts dressed in Role and Task attire,
English whispers, structured and dire—
A simpler build, one language to admire! ✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7b99ec5 and 38b5d71.

📒 Files selected for processing (41)
  • .github/workflows/pre-release-build.yml (0 hunks)
  • .github/workflows/tagged-release.yml (0 hunks)
  • AGENTS.md (2 hunks)
  • README_IN.md (0 hunks)
  • README_JA.md (0 hunks)
  • README_TR.md (0 hunks)
  • README_ZH.md (0 hunks)
  • build.mjs (3 hunks)
  • package.json (0 hunks)
  • safari/appdmg.json (0 hunks)
  • safari/build.sh (0 hunks)
  • safari/export-options.plist (0 hunks)
  • safari/project.patch (0 hunks)
  • safari/project.pre.patch (0 hunks)
  • safari/project_developer.patch (0 hunks)
  • src/_locales/de/main.json (0 hunks)
  • src/_locales/es/main.json (0 hunks)
  • src/_locales/fr/main.json (0 hunks)
  • src/_locales/in/main.json (0 hunks)
  • src/_locales/it/main.json (0 hunks)
  • src/_locales/ja/main.json (0 hunks)
  • src/_locales/ko/main.json (0 hunks)
  • src/_locales/pt/main.json (0 hunks)
  • src/_locales/resources.mjs (0 hunks)
  • src/_locales/ru/main.json (0 hunks)
  • src/_locales/tr/main.json (0 hunks)
  • src/_locales/zh-hans/main.json (0 hunks)
  • src/_locales/zh-hant/main.json (0 hunks)
  • src/config/index.mjs (2 hunks)
  • src/config/language.mjs (1 hunks)
  • src/content-script/index.jsx (1 hunks)
  • src/content-script/menu-tools/index.mjs (1 hunks)
  • src/content-script/selection-tools/index.mjs (3 hunks)
  • src/content-script/site-adapters/arxiv/index.mjs (1 hunks)
  • src/content-script/site-adapters/bilibili/index.mjs (1 hunks)
  • src/content-script/site-adapters/github/index.mjs (3 hunks)
  • src/content-script/site-adapters/youtube/index.mjs (1 hunks)
  • src/manifest.v2.json (0 hunks)
  • src/services/apis/shared.mjs (1 hunks)
  • src/utils/is-firefox.mjs (1 hunks)
  • src/utils/is-safari.mjs (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@qodo-merge-pro
Copy link
Contributor

qodo-merge-pro bot commented Nov 8, 2025

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
Prompt data exposure

Description: Newly added prompt construction injects unvalidated page input directly into a large
template, which could inadvertently include sensitive on-page data; ensure
cropping/sanitization always runs and size limits are enforced to avoid excessive data
exfiltration.
index.jsx [153-229]

Referred Code
    if (input) {
      const preferredLanguage = await getPreferredLanguage()
      return `## Role
<role>
You are a knowledgeable research assistant helping users understand search queries and providing relevant information.
</role>

## Task
<task>
Interpret the user's search query and provide comprehensive, useful information related to their search intent.
</task>

## Instructions
<instructions>
1. **Interpret search intent**:
   - Informational (learning about a topic)
   - Navigational (finding a specific site/resource)
   - Transactional (looking to perform an action)
   - Investigational (comparing options)

2. **Provide relevant information**:


 ... (clipped 56 lines)
Excessive data to API

Description: Expanded, verbose default system prompts increase token usage which may leak more
conversational context to external APIs; verify no sensitive data is included by default
and that users consent to sending long prompts.
shared.mjs [1-148]

Referred Code
export const getChatSystemPromptBase = async () => {
  return `## Role
<role>
You are an intelligent, helpful AI assistant designed to engage in natural, informative conversations while being respectful, accurate, and user-focused.
</role>

## Capabilities
<capabilities>
- Answer questions across diverse topics with accurate, well-reasoned responses
- Engage in creative tasks (writing, brainstorming, problem-solving)
- Provide explanations tailored to user's knowledge level
- Communicate effectively in multiple languages
- Assist with analysis, research, and decision-making
- Maintain context throughout multi-turn conversations
</capabilities>

## Guidelines
<guidelines>
1. **Be helpful**: Prioritize user's needs and provide actionable information
2. **Be accurate**: Base responses on reliable knowledge; acknowledge uncertainty when appropriate
3. **Be clear**: Use language appropriate for the user's expertise level


 ... (clipped 127 lines)
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
Missing audit logging: The new prompt-generation and content handling logic does not include any logging of
critical actions or user identifiers, but it is unclear whether logging is handled
elsewhere in the extension.

Referred Code
async function getInput(inputQuery) {
  let input
  if (typeof inputQuery === 'function') {
    input = await inputQuery()
    const replyPromptBelow = `Reply in ${await getPreferredLanguage()}. Regardless of the language of content I provide below. !!This is very important!!`
    const replyPromptAbove = `Reply in ${await getPreferredLanguage()}. Regardless of the language of content I provide above. !!This is very important!!`
    if (input) return `${replyPromptBelow}\n\n` + input + `\n\n${replyPromptAbove}`
    return input
  }
  const searchInput = getPossibleElementByQuerySelector(inputQuery)
  if (searchInput) {
    if (searchInput.value) input = searchInput.value
    else if (searchInput.textContent) input = searchInput.textContent
    if (input) {
      const preferredLanguage = await getPreferredLanguage()
      return `## Role
<role>
You are a knowledgeable research assistant helping users understand search queries and providing relevant information.
</role>

## Task


 ... (clipped 69 lines)
Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Minimal catch handling: The try/catch only logs to console without actionable context or fallback behavior, which
may be insufficient for robust error handling in production.

Referred Code
export default {
  inputQuery: async () => {
    try {
      const title = document.querySelector('.title')?.textContent.trim()
      const authors = document.querySelector('.authors')?.textContent
      const abstract = document.querySelector('blockquote.abstract')?.textContent.trim()

      return await cropText(
        `## Role
<role>
You are an academic research analyst with expertise in scientific paper evaluation across multiple disciplines.
</role>

## Task
<task>
Analyze the provided arXiv paper metadata (title, authors, abstract) and generate a structured academic summary suitable for researchers quickly evaluating relevance.
</task>

## Instructions
<instructions>
1. **Identify research domain**: Classify the field (CS, Physics, Math, Bio, etc.)


 ... (clipped 60 lines)
Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status:
Unstructured data logs: Newly added prompts embed potentially user-derived content directly in large strings
without evidence of structured, redacted logging or safeguards against leaking sensitive
data if later logged.

Referred Code
function createChatGPtSummaryPrompt(issueData, isIssue = true) {
  // Destructure the issueData object into messages and commentBoxContent
  const { title, messages, commentBoxContent } = issueData

  // Start crafting the prompt
  let prompt = `## Role
<role>
You are an expert software engineer specializing in code review and issue tracking analysis.
</role>

## Task
<task>
Analyze the GitHub thread (${
    isIssue ? 'issue' : 'pull request'
  }) and provide a structured summary that captures the problem, discussion, and resolution status.
</task>

## Instructions
<instructions>
1. **Identify thread type**: This is a ${isIssue ? 'issue report' : 'pull request'}
2. **Extract problem statement**: ${


 ... (clipped 68 lines)
Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status:
Missing input sanitization: External page-derived subtitle and title content are interpolated directly into prompts
without visible sanitization or validation, which could risk prompt injection or unwanted
content propagation.

Referred Code
      while (subtitleData.indexOf('">') !== -1) {
        subtitleData = subtitleData.substring(subtitleData.indexOf('">') + 2)
        subtitleContent += subtitleData.substring(0, subtitleData.indexOf('<')) + ','
      }

      subtitleContent = replaceHtmlEntities(subtitleContent)

      return await cropText(
        `## Role
<role>
You are an expert video content analyst specializing in distilling long-form video content into actionable insights.
</role>

## Task
<task>
Create a structured summary of the YouTube video based on the subtitle transcript provided.
</task>

## Instructions
<instructions>
1. **Open with context**: Begin with the video title and a one-sentence overview


 ... (clipped 48 lines)
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@gemini-code-assist
Copy link

Summary of Changes

Hello @USERNAME-STOCK, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on simplifying the project's build process by targeting Chrome exclusively and modernizing the codebase. It also enhances the AI's output quality through improved prompt engineering and reduces the project's complexity by removing multi-language support.

Highlights

  • Build Simplification: The build process has been streamlined to focus solely on creating a Chrome-only extension, removing Firefox and Safari variants.
  • Code Modernization: Updates have been made to modernize the codebase, including changes to module concatenation and the removal of legacy build scripts.
  • Prompt Engineering: The prompts used for various features like summarization, translation, and code explanation have been significantly enhanced with detailed roles, instructions, and output formats to improve the quality and consistency of the AI's responses.
  • Localization Removal: All localization files except for English have been removed, simplifying the project's language support.
Ignored Files
  • Ignored by pattern: .github/workflows/** (2)
    • .github/workflows/pre-release-build.yml
    • .github/workflows/tagged-release.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@USERNAME-STOCK USERNAME-STOCK deleted the claude/review-src-files-011CUvUyQzzb4X4VPkZeG4fM branch November 8, 2025 15:11
@qodo-merge-pro
Copy link
Contributor

qodo-merge-pro bot commented Nov 8, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
High-level
PR removes core features without justification

The PR removes support for Firefox, Safari, and all non-English languages, and
overhauls all prompts to a verbose, structured format. These major, undocumented
changes alter the project's scope and should be justified before merging.

Examples:

build.mjs [303-309]
  // chromium only
  const chromiumOutputDir = `./${outdir}/chromium${outputDirSuffix}`
  await copyFiles(
    [...commonFiles, { src: 'src/manifest.json', dst: 'manifest.json' }],
    chromiumOutputDir,
  )
  if (isProduction) await zipFolder(chromiumOutputDir)
src/_locales/resources.mjs [1-7]
import en from './en/main.json'

export const resources = {
  en: {
    translation: en,
  },
}

Solution Walkthrough:

Before:

// build.mjs - Multi-browser build logic
// chromium
const chromiumOutputDir = `./${outdir}/chromium${outputDirSuffix}`
await copyFiles(...)
// firefox
const firefoxOutputDir = `./${outdir}/firefox${outputDirSuffix}`
await copyFiles(...)

// src/_locales/resources.mjs - Multiple languages
import de from './de/main.json'
import en from './en/main.json'
import es from './es/main.json'
// ... many other languages

// src/content-script/selection-tools/index.mjs - Simple prompt
genPrompt: createGenPrompt({
  message:
    'You are an expert teacher. Explain the following content in simple terms and highlight the key points',
  includeLanguagePrefix: true,
}),

After:

// build.mjs - Chrome-only build logic
// chromium only
const chromiumOutputDir = `./${outdir}/chromium${outputDirSuffix}`
await copyFiles(...)
// firefox build logic is removed

// src/_locales/resources.mjs - English only
import en from './en/main.json'
export const resources = {
  en: { translation: en },
}

// src/content-script/selection-tools/index.mjs - Verbose, structured prompt
genPrompt: async (selection) => {
  return `## Role
<role>
You are an expert teacher...
</role>
## Task
<task>
Explain the selected content...
</task>
... (many more lines of structured prompt) ...`
},
Suggestion importance[1-10]: 10

__

Why: The suggestion correctly identifies two undocumented, major strategic changes—removing multi-browser/multi-language support and overhauling all prompts—that fundamentally alter the project's scope, user base, and cost, making it a critical and high-impact observation.

High
General
Update bidirectional translation prompt for consistency

Update the translateBidi prompt to use the new structured format for consistency
with other translation tools in the file.

src/content-script/selection-tools/index.mjs [259-266]

 translateBidi: {
   icon: <Globe />,
   label: 'Translate (Bidirectional)',
-  genPrompt: createGenPrompt({
-    isTranslation: true,
-    enableBidirectional: true,
-  }),
+  genPrompt: async (selection) => {
+    const preferredLanguage = await getPreferredLanguage()
+    const sourceLanguage = 'auto-detect'
+    return `## Role
+<role>
+You are a professional translator. Your task is to perform a bidirectional translation.
+</role>
+
+## Task
+<task>
+1. Translate the source text into the user's preferred language (${preferredLanguage}).
+2. Translate the source text into English.
+3. Present both translations clearly.
+</task>
+
+## Instructions
+<instructions>
+- If the source text is already in English, for the English translation, state "Source is in English".
+- If the source text is already in the user's preferred language, for that translation, state "Source is in ${preferredLanguage}".
+- Preserve original formatting (markdown, line breaks).
+</instructions>
+
+## Output Format
+<output_format>
+### Translation to ${preferredLanguage}
+[Translated text in ${preferredLanguage}]
+
+---
+
+### Translation to English
+[Translated text in English]
+</output_format>
+
+## Input Data
+<input_data>
+Source Text:
+${selection}
+</input_data>
+
+## Constraints
+<constraints>
+- Provide ONLY the two translations in the specified format.
+- Do not add any extra commentary.
+</constraints>`
+  },
 },
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies that the translateBidi prompt was not updated to the new structured format, unlike other translation prompts in the PR, and proposes a consistent update.

Low
Update paragraph division prompt for consistency

Update the divide tool's prompt to the new structured format to maintain
consistency with other tools in the file.

src/content-script/selection-tools/index.mjs [447-454]

 divide: {
   icon: <CardList />,
   label: 'Divide Paragraphs',
-  genPrompt: createGenPrompt({
-    message:
-      'You are a skilled editor. Divide the following text into clear, easy-to-read and easy-to-understand paragraphs',
-  }),
+  genPrompt: async (selection) => {
+    return `## Role
+<role>
+You are a skilled editor specializing in improving text structure and readability.
+</role>
+
+## Task
+<task>
+Restructure the following text by dividing it into clear, logically separated paragraphs.
+</task>
+
+## Instructions
+<instructions>
+1. Analyze the text to identify distinct ideas or topics.
+2. Insert paragraph breaks where the topic shifts or a new idea is introduced.
+3. Ensure each new paragraph has a clear focus.
+4. Do not alter the original wording or sentence structure.
+</instructions>
+
+## Output Format
+<output_format>
+[The full text, correctly divided into paragraphs]
+</output_format>
+
+## Input Data
+<input_data>
+Text to be divided:
+${selection}
+</input_data>
+
+## Constraints
+<constraints>
+- Return ONLY the restructured text.
+- Do not add, remove, or change any words from the original text.
+- The only modification should be the addition of paragraph breaks (newlines).
+</constraints>`
+  },
 },
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly points out that the divide prompt was missed in the refactoring to a new structured prompt format and provides a consistent, improved version.

Low
Update 'ask' tool prompt for consistency

Update the ask tool's prompt to use the new structured format for consistency
and improved reliability.

src/content-script/selection-tools/index.mjs [559-567]

 ask: {
   icon: <QuestionCircle />,
   label: 'Ask',
-  genPrompt: createGenPrompt({
-    message:
-      'Analyze the following content carefully and provide a concise answer or opinion with a short explanation',
-    includeLanguagePrefix: true,
-  }),
+  genPrompt: async (selection, question) => {
+    const preferredLanguage = await getPreferredLanguage()
+    return `## Role
+<role>
+You are an expert analyst. Your task is to answer a specific question based on the provided text.
+</role>
+
+## Task
+<task>
+Analyze the provided content and use it to answer the user's question.
+</task>
+
+## Instructions
+<instructions>
+1. Read the user's question to understand the information being sought.
+2. Carefully analyze the provided text to find the answer.
+3. Formulate a concise answer based *only* on the information in the text.
+4. If the text does not contain the answer, state that the information is not available in the provided content.
+5. Reply in ${preferredLanguage}.
+</instructions>
+
+## Output Format
+<output_format>
+**Answer**: [Your concise answer based on the text]
+
+**Explanation**: [A brief explanation of how you arrived at the answer, referencing parts of the text if necessary]
+</output_format>
+
+## Input Data
+<input_data>
+User's Question: ${question}
+
+Provided Text:
+${selection}
+</input_data>
+
+## Constraints
+<constraints>
+- Base your answer strictly on the provided text. Do not use external knowledge.
+- If the answer cannot be found, explicitly state it.
+- Be direct and concise.
+</constraints>`
+  },
 },
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies that the ask prompt was not updated to the new structured format, unlike most other tools in the file, and proposes a consistent, improved version.

Low
  • More

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant and valuable refactoring. The AI prompts have been completely restructured into a more detailed and consistent markdown/XML format, which should greatly improve the quality and reliability of AI responses. The build process has also been simplified by focusing on a Chrome-only, English-only distribution, which reduces complexity and speeds up development. The removal of support for other browsers and languages is a major change, but it's well-documented and aligns with the stated goals. My review includes one suggestion for improving maintainability by reducing code duplication in the new prompt templates.

Comment on lines 173 to 258
translateToEn: {
icon: <Globe />,
label: 'Translate (To English)',
genPrompt: createGenPrompt({
isTranslation: true,
targetLanguage: 'English',
}),
genPrompt: async (selection) => {
const targetLanguage = 'English'
return `## Role
<role>
You are a professional translator with expertise in maintaining semantic accuracy, cultural nuance, and stylistic tone across languages.
</role>
## Task
<task>
Translate the selected text into ${targetLanguage} while preserving the original meaning, tone, style, and formatting.
</task>
## Instructions
<instructions>
1. **Analyze source text**: Identify tone and cultural elements
2. **Translate accurately**: Preserve semantic meaning and style
3. **Preserve formatting**: Maintain markdown and structure
4. **Cultural adaptation**: Use appropriate cultural equivalents
</instructions>
## Output Format
<output_format>
[Translated text with original formatting preserved]
</output_format>
## Input Data
<input_data>
Target Language: ${targetLanguage}
Source Text:
${selection}
</input_data>
## Constraints
<constraints>
- Provide ONLY the translated text
- Preserve all formatting exactly as in source
- If text is already in ${targetLanguage}, state "Text is already in ${targetLanguage}"
</constraints>`
},
},
translateToZh: {
icon: <Globe />,
label: 'Translate (To Chinese)',
genPrompt: createGenPrompt({
isTranslation: true,
targetLanguage: 'Chinese',
}),
genPrompt: async (selection) => {
const targetLanguage = 'Chinese'
return `## Role
<role>
You are a professional translator with expertise in maintaining semantic accuracy, cultural nuance, and stylistic tone across languages.
</role>
## Task
<task>
Translate the selected text into ${targetLanguage} while preserving the original meaning, tone, style, and formatting.
</task>
## Instructions
<instructions>
1. **Analyze source text**: Identify tone and cultural elements
2. **Translate accurately**: Preserve semantic meaning and style
3. **Preserve formatting**: Maintain markdown and structure
4. **Cultural adaptation**: Use appropriate cultural equivalents
</instructions>
## Output Format
<output_format>
[Translated text with original formatting preserved]
</output_format>
## Input Data
<input_data>
Target Language: ${targetLanguage}
Source Text:
${selection}
</input_data>
## Constraints
<constraints>
- Provide ONLY the translated text
- Preserve all formatting exactly as in source
- If text is already in ${targetLanguage}, state "Text is already in ${targetLanguage}"
</constraints>`
},
},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The prompts for translateToEn and translateToZh are nearly identical, leading to significant code duplication. To improve maintainability, you can extract the common logic into a helper function.

You could define a createTranslationPrompt helper at the top of the file:

const createTranslationPrompt = (targetLanguage) => async (selection) => {
  return `## Role
<role>
You are a professional translator with expertise in maintaining semantic accuracy, cultural nuance, and stylistic tone across languages.
</role>

## Task
<task>
Translate the selected text into ${targetLanguage} while preserving the original meaning, tone, style, and formatting.
</task>

## Instructions
<instructions>
1. **Analyze source text**: Identify tone and cultural elements
2. **Translate accurately**: Preserve semantic meaning and style
3. **Preserve formatting**: Maintain markdown and structure
4. **Cultural adaptation**: Use appropriate cultural equivalents
</instructions>

## Output Format
<output_format>
[Translated text with original formatting preserved]
</output_format>

## Input Data
<input_data>
Target Language: ${targetLanguage}
Source Text:
${selection}
</input_data>

## Constraints
<constraints>
- Provide ONLY the translated text
- Preserve all formatting exactly as in source
- If text is already in ${targetLanguage}, state "Text is already in ${targetLanguage}"
</constraints>`
}

Then, you can simplify the translateToEn and translateToZh definitions like this:

  translateToEn: {
    icon: <Globe />,
    label: 'Translate (To English)',
    genPrompt: createTranslationPrompt('English'),
  },
  translateToZh: {
    icon: <Globe />,
    label: 'Translate (To Chinese)',
    genPrompt: createTranslationPrompt('Chinese'),
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants