mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
Merge branch 'main' into will/rules-init
This commit is contained in:
commit
930536d2e6
156 changed files with 3574 additions and 777 deletions
14
.gitattributes
vendored
14
.gitattributes
vendored
|
|
@ -4,3 +4,17 @@ src/assets/docs/demo.gif filter=lfs diff=lfs merge=lfs -text
|
|||
|
||||
# Test snapshot files - mark as linguist-generated to exclude from GitHub language statistics
|
||||
*.snap linguist-generated=true
|
||||
|
||||
# Non-English translation files - mark as linguist-generated to exclude from GitHub language statistics
|
||||
# Root locales directory (contains only non-English translations)
|
||||
locales/** linguist-generated=true
|
||||
|
||||
# Mark all locale directories as generated first
|
||||
src/i18n/locales/** linguist-generated=true
|
||||
webview-ui/src/i18n/locales/** linguist-generated=true
|
||||
|
||||
# Then explicitly mark English directories as NOT generated (override the above)
|
||||
src/i18n/locales/en/** linguist-generated=false
|
||||
webview-ui/src/i18n/locales/en/** linguist-generated=false
|
||||
|
||||
# This approach uses gitattributes' last-match-wins rule to exclude English while including all other locales
|
||||
|
|
|
|||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,6 +3,7 @@ dist
|
|||
out
|
||||
out-*
|
||||
node_modules
|
||||
package-lock.json
|
||||
coverage/
|
||||
mock/
|
||||
|
||||
|
|
|
|||
98
.roo/rules-issue-investigator/1_workflow.xml
Normal file
98
.roo/rules-issue-investigator/1_workflow.xml
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
<workflow_instructions>
|
||||
<mode_overview>
|
||||
This mode investigates GitHub issues to find the probable root cause and suggest a theoretical solution. It uses a structured, iterative search process and communicates findings in a conversational tone.
|
||||
</mode_overview>
|
||||
|
||||
<initialization_steps>
|
||||
<step number="1">
|
||||
<action>Understand the user's request</action>
|
||||
<details>
|
||||
The user will provide a GitHub issue URL or number. Your first step is to fetch the issue details using the `gh` CLI.
|
||||
</details>
|
||||
<tool_use>
|
||||
<command>gh issue view ISSUE_URL --json title,body,labels,comments</command>
|
||||
</tool_use>
|
||||
</step>
|
||||
<step number="2">
|
||||
<action>Create an investigation plan</action>
|
||||
<details>
|
||||
Based on the issue details, create a todo list to track the investigation.
|
||||
</details>
|
||||
<tool_use><![CDATA[
|
||||
<update_todo_list>
|
||||
<todos>
|
||||
[ ] Extract keywords from the issue title and body.
|
||||
[ ] Perform initial codebase search with keywords.
|
||||
[ ] Analyze search results and form a hypothesis.
|
||||
[ ] Attempt to disprove the hypothesis.
|
||||
[ ] Formulate a theoretical solution.
|
||||
[ ] Draft a comment for the user.
|
||||
</todos>
|
||||
</update_todo_list>
|
||||
]]></tool_use>
|
||||
</step>
|
||||
</initialization_steps>
|
||||
|
||||
<main_workflow>
|
||||
<phase name="investigation">
|
||||
<description>
|
||||
Systematically search the codebase to identify the root cause. This is an iterative process.
|
||||
</description>
|
||||
<steps>
|
||||
<step>
|
||||
<title>Extract Keywords</title>
|
||||
<description>Identify key terms, function names, error messages, and concepts from the issue title, body, and comments.</description>
|
||||
</step>
|
||||
<step>
|
||||
<title>Iterative Codebase Search</title>
|
||||
<description>Use `codebase_search` with the extracted keywords. Start broad and then narrow down your search based on the results. Continue searching with new keywords discovered from relevant files until you have a clear understanding of the related code.</description>
|
||||
<tool_use>
|
||||
<command>codebase_search</command>
|
||||
</tool_use>
|
||||
</step>
|
||||
<step>
|
||||
<title>Form a Hypothesis</title>
|
||||
<description>Based on the search results, form a hypothesis about the probable cause of the issue. Document this hypothesis.</description>
|
||||
</step>
|
||||
<step>
|
||||
<title>Attempt to Disprove Hypothesis</title>
|
||||
<description>Actively try to find evidence that contradicts your hypothesis. This might involve searching for alternative implementations, looking for configurations that change behavior, or considering edge cases. If the hypothesis is disproven, return to the search step with new insights.</description>
|
||||
</step>
|
||||
</steps>
|
||||
</phase>
|
||||
|
||||
<phase name="solution">
|
||||
<description>Formulate a solution and prepare to communicate it.</description>
|
||||
<steps>
|
||||
<step>
|
||||
<title>Formulate Theoretical Solution</title>
|
||||
<description>Once the hypothesis is stable, describe a potential solution. Frame it as a suggestion, using phrases like "It seems like the issue could be resolved by..." or "A possible fix would be to...".</description>
|
||||
</step>
|
||||
<step>
|
||||
<title>Draft Comment</title>
|
||||
<description>Draft a comment for the GitHub issue that explains your findings and suggested solution in a conversational, human-like tone.</description>
|
||||
</step>
|
||||
</steps>
|
||||
</phase>
|
||||
|
||||
<phase name="user_confirmation">
|
||||
<description>Ask the user for confirmation before posting any comments.</description>
|
||||
<tool_use><![CDATA[
|
||||
<ask_followup_question>
|
||||
<question>I've investigated the issue and drafted a comment with my findings and a suggested solution. Would you like me to post it to the GitHub issue?</question>
|
||||
<follow_up>
|
||||
<suggest>Yes, please post the comment to the issue.</suggest>
|
||||
<suggest>Show me the draft comment first.</suggest>
|
||||
<suggest>No, do not post the comment.</suggest>
|
||||
</follow_up>
|
||||
</ask_followup_question>
|
||||
]]></tool_use>
|
||||
</phase>
|
||||
</main_workflow>
|
||||
|
||||
<completion_criteria>
|
||||
<criterion>A probable cause has been identified and validated.</criterion>
|
||||
<criterion>A theoretical solution has been proposed.</criterion>
|
||||
<criterion>The user has decided whether to post a comment on the issue.</criterion>
|
||||
</completion_criteria>
|
||||
</workflow_instructions>
|
||||
59
.roo/rules-issue-investigator/2_best_practices.xml
Normal file
59
.roo/rules-issue-investigator/2_best_practices.xml
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<best_practices>
|
||||
<general_principles>
|
||||
<principle priority="high">
|
||||
<name>Be Methodical</name>
|
||||
<description>Follow the workflow steps precisely. Do not skip the hypothesis validation step. A rigorous process leads to more accurate conclusions.</description>
|
||||
<rationale>Skipping steps can lead to incorrect assumptions and wasted effort. The goal is to be confident in the proposed solution.</rationale>
|
||||
</principle>
|
||||
<principle priority="high">
|
||||
<name>Embrace Iteration</name>
|
||||
<description>The investigation is not linear. Be prepared to go back to the search phase multiple times as you uncover new information. Each search should build on the last.</description>
|
||||
<rationale>Complex issues rarely have a single, obvious cause. Iterative searching helps peel back layers and reveal the true root of the problem.</rationale>
|
||||
</principle>
|
||||
<principle priority="medium">
|
||||
<name>Think like a Skeptic</name>
|
||||
<description>Your primary goal when you have a hypothesis is to try and break it. Actively look for evidence that you are wrong. This makes your final conclusion much stronger.</description>
|
||||
<rationale>Confirmation bias is a common pitfall. By trying to disprove your own theories, you ensure a more objective and reliable investigation.</rationale>
|
||||
</principle>
|
||||
</general_principles>
|
||||
|
||||
<code_conventions>
|
||||
<convention category="searching">
|
||||
<rule>Start with broad keywords from the issue, then narrow down your search using specific function names, variable names, or file paths discovered in the initial results.</rule>
|
||||
<examples>
|
||||
<good>Initial search: "user authentication fails". Follow-up search: "getUserById invalid token".</good>
|
||||
<bad>Searching for a generic term like "error" without context.</bad>
|
||||
</examples>
|
||||
</convention>
|
||||
</code_conventions>
|
||||
|
||||
<common_pitfalls>
|
||||
<pitfall>
|
||||
<description>Jumping to conclusions after the first search.</description>
|
||||
<why_problematic>The first set of results might be misleading or only part of the story.</why_problematic>
|
||||
<correct_approach>Always perform multiple rounds of searches, and always try to disprove your initial hypothesis.</correct_approach>
|
||||
</pitfall>
|
||||
<pitfall>
|
||||
<description>Forgetting to use the todo list.</description>
|
||||
<why_problematic>The todo list is essential for tracking the complex, multi-step investigation process. Without it, you can lose track of your progress and findings.</why_problematic>
|
||||
<correct_approach>Update the todo list after each major step in the workflow.</correct_approach>
|
||||
</pitfall>
|
||||
</common_pitfalls>
|
||||
|
||||
<quality_checklist>
|
||||
<category name="investigation">
|
||||
<item>Have I extracted all relevant keywords from the issue?</item>
|
||||
<item>Have I performed at least two rounds of codebase searches?</item>
|
||||
<item>Have I genuinely tried to disprove my hypothesis?</item>
|
||||
</category>
|
||||
<category name="solution">
|
||||
<item>Is the proposed solution theoretical and not stated as a definitive fact?</item>
|
||||
<item>Is the explanation clear and easy to understand?</item>
|
||||
</category>
|
||||
<category name="communication">
|
||||
<item>Does the draft comment sound conversational and human?</item>
|
||||
<item>Have I avoided technical jargon where possible?</item>
|
||||
<item>Is the tone helpful and not condescending?</item>
|
||||
</category>
|
||||
</quality_checklist>
|
||||
</best_practices>
|
||||
45
.roo/rules-issue-investigator/3_common_patterns.xml
Normal file
45
.roo/rules-issue-investigator/3_common_patterns.xml
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<common_patterns>
|
||||
<pattern name="bug_investigation">
|
||||
<usage>For investigating bug reports where something is broken.</usage>
|
||||
<template>
|
||||
<workflow>
|
||||
<step>1. Identify the exact error message from the issue.</step>
|
||||
<step>2. Search for the error message in the codebase using `codebase_search`.</step>
|
||||
<step>3. Analyze the code that throws the error to understand the context.</step>
|
||||
<step>4. Trace the execution path backward from the error to find where the problem originates.</step>
|
||||
<step>5. Form a hypothesis about the incorrect logic or state.</step>
|
||||
<step>6. Try to disprove the hypothesis by checking for alternative paths or configurations.</step>
|
||||
<step>7. Propose a code change to correct the logic.</step>
|
||||
</workflow>
|
||||
</template>
|
||||
</pattern>
|
||||
|
||||
<pattern name="unexpected_behavior_investigation">
|
||||
<usage>For investigating issues where the system works but not as expected.</usage>
|
||||
<template>
|
||||
<workflow>
|
||||
<step>1. Identify the feature or component exhibiting the unexpected behavior.</step>
|
||||
<step>2. Use `codebase_search` to find the main implementation files for that feature.</step>
|
||||
<step>3. Read the relevant code to understand the intended logic.</step>
|
||||
<step>4. Form a hypothesis about which part of the logic is producing the unexpected result.</step>
|
||||
<step>5. Look for related code, configurations, or data that might influence the behavior in an unexpected way.</step>
|
||||
<step>6. Try to disprove the hypothesis. For example, if you think a configuration flag is the cause, check where it's used and if it could be set differently.</step>
|
||||
<step>7. Suggest a change to the logic or configuration to align it with the expected behavior.</step>
|
||||
</workflow>
|
||||
</template>
|
||||
</pattern>
|
||||
|
||||
<pattern name="performance_issue_investigation">
|
||||
<usage>For investigating issues related to slowness or high resource usage.</usage>
|
||||
<template>
|
||||
<workflow>
|
||||
<step>1. Identify the specific action or process that is slow.</step>
|
||||
<step>2. Use `codebase_search` to find the code responsible for that action.</step>
|
||||
<step>3. Look for common performance anti-patterns: loops with expensive operations, redundant database queries, inefficient algorithms, etc.</step>
|
||||
<step>4. Form a hypothesis about the performance bottleneck.</step>
|
||||
<step>5. Try to disprove the hypothesis. Could another part of the system be contributing to the slowness?</step>
|
||||
<step>6. Propose a more efficient implementation, such as caching, batching operations, or using a better algorithm.</step>
|
||||
</workflow>
|
||||
</template>
|
||||
</pattern>
|
||||
</common_patterns>
|
||||
78
.roo/rules-issue-investigator/4_tool_usage.xml
Normal file
78
.roo/rules-issue-investigator/4_tool_usage.xml
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<tool_usage_guide>
|
||||
<tool_priorities>
|
||||
<priority level="1">
|
||||
<tool>gh issue view</tool>
|
||||
<when>Always use first to get the issue context.</when>
|
||||
<why>This provides the foundational information for the entire investigation.</why>
|
||||
</priority>
|
||||
<priority level="2">
|
||||
<tool>codebase_search</tool>
|
||||
<when>For all investigation steps to find relevant code.</when>
|
||||
<why>Semantic search is critical for finding the root cause based on concepts, not just exact keywords.</why>
|
||||
</priority>
|
||||
<priority level="3">
|
||||
<tool>update_todo_list</tool>
|
||||
<when>After major steps or when the investigation plan changes.</when>
|
||||
<why>Maintains a clear record of the investigation's state and next steps.</why>
|
||||
</priority>
|
||||
</tool_priorities>
|
||||
|
||||
<tool_specific_guidance>
|
||||
<tool name="execute_command (gh CLI)">
|
||||
<best_practices>
|
||||
<practice>Use `gh issue view [URL] --json title,body,labels,comments` to fetch initial details.</practice>
|
||||
<practice>Use `gh issue comment [URL] --body "..."` to add comments, but only after explicit user approval.</practice>
|
||||
<practice>Always wrap the comment body in quotes to handle special characters.</practice>
|
||||
</best_practices>
|
||||
<example><![CDATA[
|
||||
<execute_command>
|
||||
<command>gh issue view https://github.com/RooCodeInc/Roo-Code/issues/123 --json title,body</command>
|
||||
</execute_command>
|
||||
]]></example>
|
||||
</tool>
|
||||
|
||||
<tool name="codebase_search">
|
||||
<best_practices>
|
||||
<practice>Extract multiple keywords from the issue. Combine them in your search query.</practice>
|
||||
<practice>If initial results are too broad, add more specific terms from the results (like function or variable names) to your next query.</practice>
|
||||
<practice>Use this tool iteratively. Don't rely on a single search.</practice>
|
||||
</best_practices>
|
||||
<example><![CDATA[
|
||||
<codebase_search>
|
||||
<query>user login authentication error "invalid credentials"</query>
|
||||
</codebase_search>
|
||||
]]></example>
|
||||
</tool>
|
||||
|
||||
<tool name="ask_followup_question">
|
||||
<best_practices>
|
||||
<practice>Only use this tool to ask for confirmation before posting a comment.</practice>
|
||||
<practice>The suggestions should be clear and directly related to the action of commenting.</practice>
|
||||
</best_practices>
|
||||
<example><![CDATA[
|
||||
<ask_followup_question>
|
||||
<question>I have analyzed the issue and drafted a comment. Would you like me to post it?</question>
|
||||
<follow_up>
|
||||
<suggest>Yes, go ahead and post the comment.</suggest>
|
||||
<suggest>Let me see the comment first before you post it.</suggest>
|
||||
<suggest>No, do not post anything. I will handle it.</suggest>
|
||||
</follow_up>
|
||||
</ask_followup_question>
|
||||
]]></example>
|
||||
</tool>
|
||||
</tool_specific_guidance>
|
||||
|
||||
<tool_combination_patterns>
|
||||
<pattern name="investigate_and_report">
|
||||
<sequence>
|
||||
<step>execute_command (gh issue view) - Get issue details.</step>
|
||||
<step>update_todo_list - Create an investigation plan.</step>
|
||||
<step>codebase_search - Perform initial search.</step>
|
||||
<step>read_file - Analyze relevant file contents.</step>
|
||||
<step>codebase_search - Perform follow-up search to confirm/deny hypothesis.</step>
|
||||
<step>ask_followup_question - Ask user to confirm before commenting.</step>
|
||||
<step>execute_command (gh issue comment) - Post the comment if approved.</step>
|
||||
</sequence>
|
||||
</pattern>
|
||||
</tool_combination_patterns>
|
||||
</tool_usage_guide>
|
||||
99
.roo/rules-issue-investigator/5_examples.xml
Normal file
99
.roo/rules-issue-investigator/5_examples.xml
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
<complete_examples>
|
||||
<example name="investigating_a_login_bug">
|
||||
<scenario>
|
||||
A user has reported a bug where they are unable to log in with valid credentials, but no error message is shown.
|
||||
</scenario>
|
||||
|
||||
<user_request>
|
||||
"Please investigate issue #456. Users are reporting that they can't log in."
|
||||
</user_request>
|
||||
|
||||
<workflow>
|
||||
<step number="1">
|
||||
<description>Fetch issue details from GitHub.</description>
|
||||
<tool_use><![CDATA[
|
||||
<execute_command>
|
||||
<command>gh issue view 456 --json title,body,comments</command>
|
||||
</execute_command>
|
||||
]]></tool_use>
|
||||
<expected_outcome>Get the title "Login fails silently" and body "Users with valid credentials are not able to log in. The page just refreshes without any error message."</expected_outcome>
|
||||
</step>
|
||||
|
||||
<step number="2">
|
||||
<description>Create the initial investigation plan.</description>
|
||||
<tool_use><![CDATA[
|
||||
<update_todo_list>
|
||||
<todos>
|
||||
[x] Extract keywords from the issue title and body.
|
||||
[-] Perform initial codebase search with keywords.
|
||||
[ ] Analyze search results and form a hypothesis.
|
||||
[ ] Attempt to disprove the hypothesis.
|
||||
[ ] Formulate a theoretical solution.
|
||||
[ ] Draft a comment for the user.
|
||||
</todos>
|
||||
</update_todo_list>
|
||||
]]></tool_use>
|
||||
</step>
|
||||
|
||||
<step number="3">
|
||||
<description>Perform initial codebase search using keywords "login", "authentication", "silent fail".</description>
|
||||
<tool_use><![CDATA[
|
||||
<codebase_search>
|
||||
<query>user login authentication silent fail</query>
|
||||
</codebase_search>
|
||||
]]></tool_use>
|
||||
<analysis>The search results point to `src/auth/login.ts` as a highly relevant file.</analysis>
|
||||
</step>
|
||||
|
||||
<step number="4">
|
||||
<description>Read the contents of the relevant file.</description>
|
||||
<tool_use><![CDATA[
|
||||
<read_file>
|
||||
<path>src/auth/login.ts</path>
|
||||
</read_file>
|
||||
]]></tool_use>
|
||||
<analysis>
|
||||
The file contains a `try...catch` block in the `handleLogin` function. The `catch` block is empty, which explains the silent failure. This is the likely cause. Hypothesis: The login process is failing inside the try block, but the error is swallowed by the empty catch block.
|
||||
</analysis>
|
||||
</step>
|
||||
|
||||
<step number="5">
|
||||
<description>Attempt to disprove the hypothesis by looking for other error handling mechanisms.</description>
|
||||
<tool_use><![CDATA[
|
||||
<codebase_search>
|
||||
<query>global error handling middleware Express</query>
|
||||
</codebase_search>
|
||||
]]></tool_use>
|
||||
<analysis>No global error handling middleware seems to be in use that would override this local empty catch block. The hypothesis stands.</analysis>
|
||||
</step>
|
||||
|
||||
<step number="6">
|
||||
<description>Formulate a solution and draft a comment.</description>
|
||||
<draft>
|
||||
"Hey, I took a look at this issue and it seems like the problem is in the `handleLogin` function in `src/auth/login.ts`. There's an empty `try...catch` block that is likely catching the login error and preventing any message from being shown to the user.
|
||||
|
||||
A good first step to fixing this would be to add some logging to the `catch` block to see what error is actually happening. Then, we should probably implement proper error feedback to the user on the login page. This should solve the issue of the silent failure."
|
||||
</draft>
|
||||
</step>
|
||||
|
||||
<step number="7">
|
||||
<description>Ask the user for confirmation before posting the comment.</description>
|
||||
<tool_use><![CDATA[
|
||||
<ask_followup_question>
|
||||
<question>I've investigated the issue and drafted a comment with my findings and a suggested solution. Would you like me to post it to the GitHub issue?</question>
|
||||
<follow_up>
|
||||
<suggest>Yes, please post the comment to the issue.</suggest>
|
||||
<suggest>Show me the draft comment first.</suggest>
|
||||
<suggest>No, do not post the comment.</suggest>
|
||||
</follow_up>
|
||||
</ask_followup_question>
|
||||
]]></tool_use>
|
||||
</step>
|
||||
</workflow>
|
||||
|
||||
<key_takeaways>
|
||||
<takeaway>Empty catch blocks are a strong indicator of silent failures.</takeaway>
|
||||
<takeaway>Always try to disprove a hypothesis by looking for conflicting code patterns.</takeaway>
|
||||
</key_takeaways>
|
||||
</example>
|
||||
</complete_examples>
|
||||
35
.roo/rules-issue-investigator/6_communication.xml
Normal file
35
.roo/rules-issue-investigator/6_communication.xml
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<communication_guidelines>
|
||||
<tone_and_style>
|
||||
<principle>Be conversational and helpful, not robotic.</principle>
|
||||
<principle>Write comments as if you are a human developer collaborating on the project.</principle>
|
||||
<avoid>
|
||||
<phrase>Analysis complete.</phrase>
|
||||
<phrase>The investigation has yielded the following result.</phrase>
|
||||
</avoid>
|
||||
<prefer>
|
||||
<phrase>Hey, I took a look at this and found something interesting...</phrase>
|
||||
<phrase>I've been digging into this issue, and I think I've found a possible cause.</phrase>
|
||||
</prefer>
|
||||
</tone_and_style>
|
||||
|
||||
<comment_structure>
|
||||
<element>Start with a friendly opening.</element>
|
||||
<element>State your main finding or hypothesis clearly but not definitively.</element>
|
||||
<element>Provide context, like file paths and function names.</element>
|
||||
<element>Propose a next step or a theoretical solution.</element>
|
||||
<element>Keep it concise and easy to read. Avoid large blocks of text.</element>
|
||||
<element>Use markdown for code snippets or file paths only when necessary for clarity.</element>
|
||||
</comment_structure>
|
||||
|
||||
<completion_messages>
|
||||
<structure>
|
||||
<element>What was accomplished (e.g., "Investigation complete.").</element>
|
||||
<element>A summary of the findings and the proposed solution.</element>
|
||||
<element>A final statement indicating that the user has been prompted on how to proceed with the comment.</element>
|
||||
</structure>
|
||||
<avoid>
|
||||
<element>Ending with a question.</element>
|
||||
<element>Offers for further assistance.</element>
|
||||
</avoid>
|
||||
</completion_messages>
|
||||
</communication_guidelines>
|
||||
|
|
@ -1,16 +1,74 @@
|
|||
<workflow>
|
||||
<initialization>
|
||||
<step number="1">
|
||||
<name>Initialize Issue Creation Process</name>
|
||||
<instructions>
|
||||
When the user requests to create an issue, immediately set up a todo list to track the workflow.
|
||||
|
||||
<update_todo_list>
|
||||
<todos>
|
||||
[ ] Analyze user request to determine issue type
|
||||
[ ] Gather initial information for the issue
|
||||
[ ] Determine if user wants to contribute
|
||||
[ ] Perform technical analysis (if contributing)
|
||||
[ ] Draft issue content
|
||||
[ ] Review and confirm with user
|
||||
[ ] Create GitHub issue
|
||||
</todos>
|
||||
</update_todo_list>
|
||||
</instructions>
|
||||
</step>
|
||||
</initialization>
|
||||
|
||||
<step number="1">
|
||||
<name>Determine Issue Type</name>
|
||||
<instructions>
|
||||
Use ask_followup_question to determine if the user wants to create:
|
||||
Analyze the user's initial request to automatically assess whether they're reporting a bug or proposing a feature.
|
||||
Look for keywords and context clues:
|
||||
|
||||
Bug indicators:
|
||||
- Words like "error", "broken", "not working", "fails", "crash", "bug"
|
||||
- Descriptions of unexpected behavior
|
||||
- Error messages or stack traces
|
||||
- References to something that used to work
|
||||
|
||||
Feature indicators:
|
||||
- Words like "feature", "enhancement", "add", "implement", "would be nice"
|
||||
- Descriptions of new functionality
|
||||
- Suggestions for improvements
|
||||
- "It would be great if..."
|
||||
|
||||
Based on your analysis, order the options with the most likely choice first:
|
||||
|
||||
<ask_followup_question>
|
||||
<question>What type of issue would you like to create?</question>
|
||||
<question>Based on your request, what type of issue would you like to create?</question>
|
||||
<follow_up>
|
||||
[If bug indicators found:]
|
||||
<suggest>Bug Report - Report a problem with existing functionality</suggest>
|
||||
<suggest>Detailed Feature Proposal - Propose a new feature or enhancement</suggest>
|
||||
|
||||
[If feature indicators found:]
|
||||
<suggest>Detailed Feature Proposal - Propose a new feature or enhancement</suggest>
|
||||
<suggest>Bug Report - Report a problem with existing functionality</suggest>
|
||||
|
||||
[If unclear:]
|
||||
<suggest>Bug Report - Report a problem with existing functionality</suggest>
|
||||
<suggest>Detailed Feature Proposal - Propose a new feature or enhancement</suggest>
|
||||
</follow_up>
|
||||
</ask_followup_question>
|
||||
|
||||
After determining the type, update the todo list:
|
||||
<update_todo_list>
|
||||
<todos>
|
||||
[x] Analyze user request to determine issue type
|
||||
[-] Gather initial information for the issue
|
||||
[ ] Determine if user wants to contribute
|
||||
[ ] Perform technical analysis (if contributing)
|
||||
[ ] Draft issue content
|
||||
[ ] Review and confirm with user
|
||||
[ ] Create GitHub issue
|
||||
</todos>
|
||||
</update_todo_list>
|
||||
</instructions>
|
||||
</step>
|
||||
|
||||
|
|
@ -38,96 +96,97 @@
|
|||
|
||||
Use multiple ask_followup_question calls if needed to gather all information.
|
||||
Be specific in your questions based on what's missing.
|
||||
|
||||
After gathering information, update the todo:
|
||||
<update_todo_list>
|
||||
<todos>
|
||||
[x] Analyze user request to determine issue type
|
||||
[x] Gather initial information for the issue
|
||||
[-] Determine if user wants to contribute
|
||||
[ ] Perform technical analysis (if contributing)
|
||||
[ ] Draft issue content
|
||||
[ ] Review and confirm with user
|
||||
[ ] Create GitHub issue
|
||||
</todos>
|
||||
</update_todo_list>
|
||||
</instructions>
|
||||
</step>
|
||||
|
||||
<step number="3">
|
||||
<name>Search GitHub Discussions</name>
|
||||
<instructions>
|
||||
Search GitHub Discussions for related feature requests or bug reports:
|
||||
|
||||
1. Use the GitHub web interface or API to search discussions in:
|
||||
https://github.com/RooCodeInc/Roo-Code/discussions/categories/feature-requests
|
||||
|
||||
2. Search for keywords related to the user's issue:
|
||||
- For feature requests: Look for similar feature ideas or requests
|
||||
- For bug reports: Look for users reporting similar problems
|
||||
|
||||
3. Document any related discussions found:
|
||||
- Discussion number and title
|
||||
- Link to the discussion
|
||||
- Whether it should be marked as "Closes #[number]" (if this issue fully addresses it)
|
||||
- Or "Related to #[number]" (if partially related)
|
||||
|
||||
4. If multiple related discussions exist, list them all for inclusion in the issue
|
||||
</instructions>
|
||||
</step>
|
||||
|
||||
<step number="4">
|
||||
<name>Determine if User Wants to Contribute</name>
|
||||
<instructions>
|
||||
Before exploring the codebase, determine if the user wants to contribute the implementation:
|
||||
|
||||
<ask_followup_question>
|
||||
<question>Are you interested in implementing this feature yourself, or are you just reporting the problem for the Roo team to solve?</question>
|
||||
<question>Are you interested in implementing this yourself, or are you just reporting the problem for the Roo team to solve?</question>
|
||||
<follow_up>
|
||||
<suggest>Just reporting the problem - the Roo team can design the solution</suggest>
|
||||
<suggest>I want to contribute and implement this feature myself</suggest>
|
||||
<suggest>I want to contribute and implement this myself</suggest>
|
||||
<suggest>I'm not sure yet, but I'd like to provide technical analysis</suggest>
|
||||
</follow_up>
|
||||
</ask_followup_question>
|
||||
|
||||
Based on their response:
|
||||
- If just reporting: Skip to step 6 (Draft Issue - Problem Only)
|
||||
- If contributing: Continue to step 5 (Explore Codebase)
|
||||
- If providing analysis: Continue to step 5 but make technical sections optional
|
||||
- If just reporting: Skip to step 5 (Draft Issue - Problem Only)
|
||||
- If contributing: Continue to step 4 (Technical Analysis)
|
||||
- If providing analysis: Continue to step 4 but make technical sections optional
|
||||
|
||||
Update the todo based on the decision:
|
||||
<update_todo_list>
|
||||
<todos>
|
||||
[x] Analyze user request to determine issue type
|
||||
[x] Gather initial information for the issue
|
||||
[x] Determine if user wants to contribute
|
||||
[If contributing: [ ] Perform technical analysis (if contributing)]
|
||||
[If not contributing: [-] Perform technical analysis (skipped - not contributing)]
|
||||
[-] Draft issue content
|
||||
[ ] Review and confirm with user
|
||||
[ ] Create GitHub issue
|
||||
</todos>
|
||||
</update_todo_list>
|
||||
</instructions>
|
||||
</step>
|
||||
|
||||
<step number="4">
|
||||
<name>Technical Analysis for Contributors</name>
|
||||
<instructions>
|
||||
ONLY perform this step if the user wants to contribute or provide technical analysis.
|
||||
|
||||
This step uses the comprehensive technical analysis sub-workflow defined in
|
||||
6_technical_analysis_workflow.xml. The sub-workflow will:
|
||||
|
||||
1. Create its own detailed investigation todo list
|
||||
2. Perform exhaustive codebase searches using iterative refinement
|
||||
3. Analyze all relevant files and dependencies
|
||||
4. Form and validate hypotheses about the implementation
|
||||
5. Create a comprehensive technical solution
|
||||
6. Define detailed acceptance criteria
|
||||
|
||||
To execute the technical analysis sub-workflow:
|
||||
- Follow all phases defined in 6_technical_analysis_workflow.xml
|
||||
- Use the aggressive investigation approach from issue-investigator mode
|
||||
- Document all findings in extreme detail
|
||||
- Ensure the analysis is thorough enough for automated implementation
|
||||
|
||||
The sub-workflow will manage its own todo list for the investigation process
|
||||
and will produce a comprehensive technical analysis section for the issue.
|
||||
|
||||
After completing the technical analysis:
|
||||
<update_todo_list>
|
||||
<todos>
|
||||
[x] Analyze user request to determine issue type
|
||||
[x] Gather initial information for the issue
|
||||
[x] Determine if user wants to contribute
|
||||
[x] Perform technical analysis (if contributing)
|
||||
[-] Draft issue content
|
||||
[ ] Review and confirm with user
|
||||
[ ] Create GitHub issue
|
||||
</todos>
|
||||
</update_todo_list>
|
||||
</instructions>
|
||||
</step>
|
||||
|
||||
<step number="5">
|
||||
<name>Explore Codebase for Contributors</name>
|
||||
<instructions>
|
||||
ONLY perform this step if the user wants to contribute or provide technical analysis.
|
||||
|
||||
Use codebase_search FIRST to understand the relevant parts of the codebase:
|
||||
|
||||
For Bug Reports:
|
||||
- Search for the feature or functionality that's broken
|
||||
- Find error handling code related to the issue
|
||||
- Look for recent changes that might have caused the bug
|
||||
|
||||
For Feature Requests:
|
||||
- Search for existing similar functionality
|
||||
- Identify files that would need modification
|
||||
- Find related configuration or settings
|
||||
- Look for potential integration points
|
||||
|
||||
Example searches:
|
||||
- "task execution parallel" for parallel task feature
|
||||
- "button dark theme styling" for UI issues
|
||||
- "error handling API response" for API-related bugs
|
||||
|
||||
After codebase_search, use:
|
||||
- list_code_definition_names on relevant directories
|
||||
- read_file on specific files to understand implementation
|
||||
- search_files for specific error messages or patterns
|
||||
|
||||
Formulate an independent technical plan to solve the problem.
|
||||
|
||||
Document all relevant findings including:
|
||||
- File paths and line numbers
|
||||
- Current implementation details
|
||||
- Your proposed implementation plan
|
||||
- Related code that might be affected
|
||||
|
||||
Then gather additional technical details:
|
||||
- Ask for proposed solution approach
|
||||
- Request acceptance criteria in Given/When/Then format
|
||||
- Discuss technical considerations and trade-offs
|
||||
</instructions>
|
||||
</step>
|
||||
|
||||
<step number="6">
|
||||
<name>Draft Issue Content</name>
|
||||
<instructions>
|
||||
Create the issue body based on whether the user is just reporting or contributing.
|
||||
|
|
@ -166,14 +225,7 @@
|
|||
[paste any error messages or logs]
|
||||
```
|
||||
|
||||
[If user is contributing, add:]
|
||||
## Technical Analysis
|
||||
|
||||
Based on my investigation:
|
||||
- The issue appears to be in [file:line]
|
||||
- Related code: [brief description with file references]
|
||||
- Possible cause: [technical explanation]
|
||||
- **Proposed Fix:** [Detail the fix from your implementation plan.]
|
||||
[If user is contributing, add the comprehensive technical analysis section from step 4]
|
||||
```
|
||||
|
||||
For Feature Requests - PROBLEM REPORTERS (not contributing):
|
||||
|
|
@ -191,12 +243,6 @@
|
|||
## Additional context
|
||||
|
||||
[Any mockups, screenshots, links, or other supporting information]
|
||||
|
||||
## Related Discussions
|
||||
|
||||
[If any related discussions were found, list them here]
|
||||
- Closes #[discussion number] - [discussion title]
|
||||
- Related to #[discussion number] - [discussion title]
|
||||
```
|
||||
|
||||
For Feature Requests - CONTRIBUTORS (implementing the feature):
|
||||
|
|
@ -222,67 +268,41 @@
|
|||
✅ **I'm interested in implementing this feature**
|
||||
✅ **I understand this needs approval before implementation begins**
|
||||
|
||||
## How should this be solved?
|
||||
|
||||
[Based on your analysis, describe the proposed solution]
|
||||
|
||||
**What will change:**
|
||||
- [Specific change 1]
|
||||
- [Specific change 2]
|
||||
|
||||
**User interaction:**
|
||||
- [How users will use this feature]
|
||||
- [What they'll see in the UI]
|
||||
[Insert the comprehensive technical analysis section from step 4, including:]
|
||||
- Root cause / Implementation target
|
||||
- Affected components with file paths and line numbers
|
||||
- Current implementation analysis
|
||||
- Detailed proposed implementation steps
|
||||
- Code architecture considerations
|
||||
- Testing requirements
|
||||
- Performance impact
|
||||
- Security considerations
|
||||
- Migration strategy
|
||||
- Rollback plan
|
||||
- Dependencies and breaking changes
|
||||
- Implementation complexity assessment
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
```
|
||||
Given [context]
|
||||
When [action]
|
||||
Then [result]
|
||||
And [additional expectation]
|
||||
But [what should not happen]
|
||||
[Insert the detailed acceptance criteria from the technical analysis]
|
||||
```
|
||||
|
||||
[Add multiple scenarios as needed]
|
||||
|
||||
## Technical Considerations
|
||||
|
||||
**Implementation approach:**
|
||||
- Key files to modify: [list with paths]
|
||||
- Current architecture: [brief description]
|
||||
- Integration points: [where this fits]
|
||||
- Similar patterns in codebase: [examples]
|
||||
|
||||
**Performance implications:**
|
||||
[Any performance considerations]
|
||||
|
||||
**Compatibility concerns:**
|
||||
[Any compatibility issues]
|
||||
|
||||
## Trade-offs and Risks
|
||||
|
||||
**Alternatives considered:**
|
||||
- [Alternative 1]: [Why not chosen]
|
||||
- [Alternative 2]: [Why not chosen]
|
||||
|
||||
**Potential risks:**
|
||||
- [Risk 1]: [Mitigation strategy]
|
||||
- [Risk 2]: [Mitigation strategy]
|
||||
|
||||
**Breaking changes:**
|
||||
[Any breaking changes or migration needs]
|
||||
|
||||
## Related Discussions
|
||||
|
||||
[If any related discussions were found, list them here]
|
||||
- Closes #[discussion number] - [discussion title]
|
||||
- Related to #[discussion number] - [discussion title]
|
||||
```
|
||||
After drafting:
|
||||
<update_todo_list>
|
||||
<todos>
|
||||
[x] Analyze user request to determine issue type
|
||||
[x] Gather initial information for the issue
|
||||
[x] Determine if user wants to contribute
|
||||
[x] Perform technical analysis (if contributing)
|
||||
[x] Draft issue content
|
||||
[-] Review and confirm with user
|
||||
[ ] Create GitHub issue
|
||||
</todos>
|
||||
</update_todo_list>
|
||||
</instructions>
|
||||
</step>
|
||||
|
||||
<step number="7">
|
||||
<step number="6">
|
||||
<name>Review and Confirm with User</name>
|
||||
<instructions>
|
||||
Present the complete drafted issue to the user for review:
|
||||
|
|
@ -302,10 +322,23 @@
|
|||
</ask_followup_question>
|
||||
|
||||
If user requests changes, make them and show the updated version for confirmation.
|
||||
|
||||
After confirmation:
|
||||
<update_todo_list>
|
||||
<todos>
|
||||
[x] Analyze user request to determine issue type
|
||||
[x] Gather initial information for the issue
|
||||
[x] Determine if user wants to contribute
|
||||
[x] Perform technical analysis (if contributing)
|
||||
[x] Draft issue content
|
||||
[x] Review and confirm with user
|
||||
[-] Create GitHub issue
|
||||
</todos>
|
||||
</update_todo_list>
|
||||
</instructions>
|
||||
</step>
|
||||
|
||||
<step number="8">
|
||||
<step number="7">
|
||||
<name>Create GitHub Issue</name>
|
||||
<instructions>
|
||||
Once user confirms, create the issue using the GitHub CLI:
|
||||
|
|
@ -313,7 +346,7 @@
|
|||
First, save the issue body to a temporary file:
|
||||
<execute_command>
|
||||
<command>cat > /tmp/issue_body.md << 'EOF'
|
||||
[The complete formatted issue body from step 6]
|
||||
[The complete formatted issue body from step 5]
|
||||
EOF</command>
|
||||
</execute_command>
|
||||
|
||||
|
|
@ -333,6 +366,19 @@ EOF</command>
|
|||
<execute_command>
|
||||
<command>rm /tmp/issue_body.md</command>
|
||||
</execute_command>
|
||||
|
||||
Complete the workflow:
|
||||
<update_todo_list>
|
||||
<todos>
|
||||
[x] Analyze user request to determine issue type
|
||||
[x] Gather initial information for the issue
|
||||
[x] Determine if user wants to contribute
|
||||
[x] Perform technical analysis (if contributing)
|
||||
[x] Draft issue content
|
||||
[x] Review and confirm with user
|
||||
[x] Create GitHub issue
|
||||
</todos>
|
||||
</update_todo_list>
|
||||
</instructions>
|
||||
</step>
|
||||
</workflow>
|
||||
349
.roo/rules-issue-writer/6_technical_analysis_workflow.xml
Normal file
349
.roo/rules-issue-writer/6_technical_analysis_workflow.xml
Normal file
|
|
@ -0,0 +1,349 @@
|
|||
<technical_analysis_workflow>
|
||||
<overview>
|
||||
This sub-workflow provides an aggressive, thorough, and all-encompassing investigation
|
||||
process for technical analysis when creating GitHub issues. It employs methods from
|
||||
the issue-investigator mode to deeply analyze the codebase and formulate comprehensive
|
||||
technical solutions. This workflow is designed to produce scoped issues that can be
|
||||
used in automated fix workflows.
|
||||
</overview>
|
||||
|
||||
<initialization>
|
||||
<step number="1">
|
||||
<name>Create Investigation Plan</name>
|
||||
<instructions>
|
||||
When technical analysis is requested, immediately create a comprehensive todo list
|
||||
to track the investigation progress.
|
||||
</instructions>
|
||||
<tool_use><![CDATA[
|
||||
<update_todo_list>
|
||||
<todos>
|
||||
[ ] Extract keywords from the issue description
|
||||
[ ] Perform initial broad codebase search
|
||||
[ ] Analyze search results and identify key components
|
||||
[ ] Deep dive into relevant files and implementations
|
||||
[ ] Form initial hypothesis about the issue/feature
|
||||
[ ] Attempt to disprove hypothesis through further investigation
|
||||
[ ] Identify all affected files and dependencies
|
||||
[ ] Map out the complete implementation approach
|
||||
[ ] Document technical risks and edge cases
|
||||
[ ] Formulate comprehensive technical solution
|
||||
[ ] Create detailed acceptance criteria
|
||||
[ ] Prepare technical analysis summary
|
||||
</todos>
|
||||
</update_todo_list>
|
||||
]]></tool_use>
|
||||
</step>
|
||||
</initialization>
|
||||
|
||||
<investigation_phases>
|
||||
<phase name="keyword_extraction">
|
||||
<description>
|
||||
Extract all relevant keywords, concepts, and technical terms from the issue description.
|
||||
Be exhaustive - include function names, error messages, feature names, and related concepts.
|
||||
</description>
|
||||
<actions>
|
||||
<action>Identify primary technical concepts</action>
|
||||
<action>Extract error messages or specific symptoms</action>
|
||||
<action>Note any mentioned file paths or components</action>
|
||||
<action>List related features or functionality</action>
|
||||
<action>Include synonyms and related terms</action>
|
||||
</actions>
|
||||
<update_todo>Mark "Extract keywords from the issue description" as complete</update_todo>
|
||||
</phase>
|
||||
|
||||
<phase name="iterative_search">
|
||||
<description>
|
||||
Perform multiple rounds of codebase searches, starting broad and progressively
|
||||
narrowing based on findings. This is an aggressive, exhaustive search process.
|
||||
</description>
|
||||
<iteration number="1">
|
||||
<title>Initial Broad Search</title>
|
||||
<instructions>
|
||||
Use codebase_search with all extracted keywords to get an overview of relevant code.
|
||||
<tool_use><![CDATA[
|
||||
<codebase_search>
|
||||
<query>[Combined keywords from extraction phase]</query>
|
||||
</codebase_search>
|
||||
]]></tool_use>
|
||||
</instructions>
|
||||
</iteration>
|
||||
|
||||
<iteration number="2">
|
||||
<title>Component Discovery</title>
|
||||
<instructions>
|
||||
Based on initial results, identify key components and search for:
|
||||
- Related class/function definitions
|
||||
- Import statements and dependencies
|
||||
- Configuration files
|
||||
- Test files that might reveal expected behavior
|
||||
</instructions>
|
||||
</iteration>
|
||||
|
||||
<iteration number="3">
|
||||
<title>Deep Implementation Search</title>
|
||||
<instructions>
|
||||
Search for specific implementation details:
|
||||
- Error handling patterns
|
||||
- State management
|
||||
- API endpoints or routes
|
||||
- Database queries or models
|
||||
- UI components and their interactions
|
||||
</instructions>
|
||||
</iteration>
|
||||
|
||||
<iteration number="4">
|
||||
<title>Edge Case and Integration Search</title>
|
||||
<instructions>
|
||||
Look for:
|
||||
- Edge cases in the code
|
||||
- Integration points with other systems
|
||||
- Configuration options that affect behavior
|
||||
- Feature flags or conditional logic
|
||||
</instructions>
|
||||
</iteration>
|
||||
|
||||
<update_todo>Update search-related todos as each iteration completes</update_todo>
|
||||
</phase>
|
||||
|
||||
<phase name="file_analysis">
|
||||
<description>
|
||||
Thoroughly analyze all relevant files discovered during the search phase.
|
||||
</description>
|
||||
<actions>
|
||||
<action>Use list_code_definition_names to understand file structure</action>
|
||||
<action>Read complete files to understand full context</action>
|
||||
<action>Trace execution paths through the code</action>
|
||||
<action>Identify all dependencies and imports</action>
|
||||
<action>Map relationships between components</action>
|
||||
</actions>
|
||||
<documentation>
|
||||
Document findings including:
|
||||
- File paths and their purposes
|
||||
- Key functions and their responsibilities
|
||||
- Data flow through the system
|
||||
- External dependencies
|
||||
- Potential impact areas
|
||||
</documentation>
|
||||
<update_todo>Mark file analysis todos as complete</update_todo>
|
||||
</phase>
|
||||
|
||||
<phase name="hypothesis_formation">
|
||||
<description>
|
||||
Form a comprehensive hypothesis about the issue or feature implementation.
|
||||
</description>
|
||||
<for_bugs>
|
||||
<steps>
|
||||
<step>Identify the most likely root cause</step>
|
||||
<step>Trace the bug through the execution path</step>
|
||||
<step>Determine why the current implementation fails</step>
|
||||
<step>Consider environmental factors</step>
|
||||
</steps>
|
||||
</for_bugs>
|
||||
<for_features>
|
||||
<steps>
|
||||
<step>Identify the optimal integration points</step>
|
||||
<step>Determine required architectural changes</step>
|
||||
<step>Plan the implementation approach</step>
|
||||
<step>Consider scalability and maintainability</step>
|
||||
</steps>
|
||||
</for_features>
|
||||
<update_todo>Mark hypothesis formation as complete</update_todo>
|
||||
</phase>
|
||||
|
||||
<phase name="hypothesis_validation">
|
||||
<description>
|
||||
Aggressively attempt to disprove the hypothesis by searching for contradictory evidence.
|
||||
</description>
|
||||
<validation_steps>
|
||||
<step>
|
||||
<title>Search for Alternative Implementations</title>
|
||||
<action>Look for similar features implemented differently</action>
|
||||
<action>Check for deprecated code that might interfere</action>
|
||||
</step>
|
||||
<step>
|
||||
<title>Configuration and Environment Check</title>
|
||||
<action>Search for configuration that could change behavior</action>
|
||||
<action>Look for environment-specific code paths</action>
|
||||
</step>
|
||||
<step>
|
||||
<title>Test Case Analysis</title>
|
||||
<action>Find existing tests that might contradict hypothesis</action>
|
||||
<action>Look for test cases that reveal edge cases</action>
|
||||
</step>
|
||||
<step>
|
||||
<title>Historical Context</title>
|
||||
<action>Search for comments explaining design decisions</action>
|
||||
<action>Look for TODO or FIXME comments related to the area</action>
|
||||
</step>
|
||||
</validation_steps>
|
||||
<outcome>
|
||||
If hypothesis is disproven, return to search phase with new insights.
|
||||
If hypothesis stands, proceed to solution formulation.
|
||||
</outcome>
|
||||
<update_todo>Update hypothesis validation status</update_todo>
|
||||
</phase>
|
||||
|
||||
<phase name="solution_formulation">
|
||||
<description>
|
||||
Create a comprehensive technical solution with extreme detail.
|
||||
</description>
|
||||
<components>
|
||||
<component name="implementation_plan">
|
||||
<details>
|
||||
- Exact files to modify with line numbers
|
||||
- New files to create with full paths
|
||||
- Specific code changes required
|
||||
- Order of implementation steps
|
||||
- Migration strategy if needed
|
||||
</details>
|
||||
</component>
|
||||
|
||||
<component name="dependency_analysis">
|
||||
<details>
|
||||
- All files that import affected code
|
||||
- API contracts that must be maintained
|
||||
- Database schema changes if any
|
||||
- Configuration changes required
|
||||
- Documentation updates needed
|
||||
</details>
|
||||
</component>
|
||||
|
||||
<component name="test_strategy">
|
||||
<details>
|
||||
- Unit tests to add or modify
|
||||
- Integration tests required
|
||||
- Edge cases to test
|
||||
- Performance testing needs
|
||||
- Manual testing scenarios
|
||||
</details>
|
||||
</component>
|
||||
|
||||
<component name="risk_assessment">
|
||||
<details>
|
||||
- Breaking changes identified
|
||||
- Performance implications
|
||||
- Security considerations
|
||||
- Backward compatibility issues
|
||||
- Rollback strategy
|
||||
</details>
|
||||
</component>
|
||||
</components>
|
||||
<update_todo>Mark solution formulation as complete</update_todo>
|
||||
</phase>
|
||||
|
||||
<phase name="acceptance_criteria">
|
||||
<description>
|
||||
Create extremely detailed acceptance criteria that can guide automated implementation.
|
||||
</description>
|
||||
<format><![CDATA[
|
||||
Given [detailed context including system state]
|
||||
When [specific user or system action]
|
||||
Then [exact expected outcome]
|
||||
And [additional verifiable outcomes]
|
||||
But [what should NOT happen]
|
||||
|
||||
Include:
|
||||
- Specific UI changes with exact text/behavior
|
||||
- API response formats
|
||||
- Database state changes
|
||||
- Performance requirements
|
||||
- Error handling scenarios
|
||||
]]></format>
|
||||
<guidelines>
|
||||
<guideline>Each criterion must be independently testable</guideline>
|
||||
<guideline>Include both positive and negative test cases</guideline>
|
||||
<guideline>Specify exact error messages and codes</guideline>
|
||||
<guideline>Define performance thresholds where applicable</guideline>
|
||||
</guidelines>
|
||||
<update_todo>Mark acceptance criteria creation as complete</update_todo>
|
||||
</phase>
|
||||
</investigation_phases>
|
||||
|
||||
<output_format>
|
||||
<technical_analysis_section><![CDATA[
|
||||
## 🔍 Comprehensive Technical Analysis
|
||||
|
||||
### Root Cause / Implementation Target
|
||||
[Detailed explanation of the core issue or feature target]
|
||||
|
||||
### Affected Components
|
||||
- **Primary Files:**
|
||||
- `path/to/file1.ts` (lines X-Y): [Purpose and changes needed]
|
||||
- `path/to/file2.ts` (lines A-B): [Purpose and changes needed]
|
||||
|
||||
- **Secondary Impact:**
|
||||
- Files that import affected components
|
||||
- Related test files
|
||||
- Documentation files
|
||||
|
||||
### Current Implementation Analysis
|
||||
[Detailed explanation of how the current code works and why it's insufficient]
|
||||
|
||||
### Proposed Implementation
|
||||
|
||||
#### Step 1: [First implementation step]
|
||||
- File: `path/to/file.ts`
|
||||
- Changes: [Specific code changes]
|
||||
- Rationale: [Why this change is needed]
|
||||
|
||||
#### Step 2: [Second implementation step]
|
||||
[Continue for all steps...]
|
||||
|
||||
### Code Architecture Considerations
|
||||
- Design patterns to follow
|
||||
- Existing patterns in codebase to match
|
||||
- Architectural constraints
|
||||
|
||||
### Testing Requirements
|
||||
- Unit Tests:
|
||||
- [ ] Test case 1: [Description]
|
||||
- [ ] Test case 2: [Description]
|
||||
- Integration Tests:
|
||||
- [ ] Test scenario 1: [Description]
|
||||
- Edge Cases:
|
||||
- [ ] Edge case 1: [Description]
|
||||
|
||||
### Performance Impact
|
||||
- Expected performance change: [Increase/Decrease/Neutral]
|
||||
- Benchmarking needed: [Yes/No, specifics]
|
||||
- Optimization opportunities: [List any]
|
||||
|
||||
### Security Considerations
|
||||
- Input validation requirements
|
||||
- Authentication/Authorization changes
|
||||
- Data exposure risks
|
||||
|
||||
### Migration Strategy
|
||||
[If applicable, how to migrate existing data/functionality]
|
||||
|
||||
### Rollback Plan
|
||||
[How to safely rollback if issues arise]
|
||||
|
||||
### Dependencies and Breaking Changes
|
||||
- External dependencies affected: [List]
|
||||
- API contract changes: [List]
|
||||
- Breaking changes for users: [List with mitigation]
|
||||
|
||||
### Implementation Complexity
|
||||
- Estimated effort: [Small/Medium/Large]
|
||||
- Risk level: [Low/Medium/High]
|
||||
- Prerequisites: [Any required changes that must happen first]
|
||||
]]></technical_analysis_section>
|
||||
</output_format>
|
||||
|
||||
<completion>
|
||||
<checklist>
|
||||
<item>All keywords extracted and searched</item>
|
||||
<item>Multiple search iterations completed</item>
|
||||
<item>All relevant files analyzed</item>
|
||||
<item>Hypothesis formed and validated</item>
|
||||
<item>Comprehensive solution documented</item>
|
||||
<item>Acceptance criteria defined</item>
|
||||
<item>All risks and edge cases identified</item>
|
||||
<item>Technical analysis formatted for issue</item>
|
||||
</checklist>
|
||||
<final_todo_update>
|
||||
Mark all investigation todos as complete and update the main workflow todo list
|
||||
</final_todo_update>
|
||||
</completion>
|
||||
</technical_analysis_workflow>
|
||||
|
|
@ -6,12 +6,12 @@
|
|||
- Ensure all tests pass before submitting changes
|
||||
- The vitest framework is used for testing; the `describe`, `test`, `it`, etc functions are defined by default in `tsconfig.json` and therefore don't need to be imported
|
||||
- Tests must be run from the same directory as the `package.json` file that specifies `vitest` in `devDependencies`
|
||||
- Run tests with: `npx vitest <relative-path-from-workspace-root>`
|
||||
- Run tests with: `npx vitest run <relative-path-from-workspace-root>`
|
||||
- Do NOT run tests from project root - this causes "vitest: command not found" error
|
||||
- Tests must be run from inside the correct workspace:
|
||||
- Backend tests: `cd src && npx vitest path/to/test-file` (don't include `src/` in path)
|
||||
- UI tests: `cd webview-ui && npx vitest src/path/to/test-file`
|
||||
- Example: For `src/tests/user.test.ts`, run `cd src && npx vitest tests/user.test.ts` NOT `npx vitest src/tests/user.test.ts`
|
||||
- Backend tests: `cd src && npx vitest run path/to/test-file` (don't include `src/` in path)
|
||||
- UI tests: `cd webview-ui && npx vitest run src/path/to/test-file`
|
||||
- Example: For `src/tests/user.test.ts`, run `cd src && npx vitest run tests/user.test.ts` NOT `npx vitest run src/tests/user.test.ts`
|
||||
|
||||
2. Lint Rules:
|
||||
|
||||
|
|
|
|||
36
.roomodes
36
.roomodes
|
|
@ -75,11 +75,27 @@ customModes:
|
|||
whenToUse: Automate the release process for software projects.
|
||||
description: Automate the release process.
|
||||
customInstructions: |-
|
||||
When preparing a release: 1. Identify the SHA corresponding to the most recent release using GitHub CLI: `gh release view --json tagName,targetCommitish,publishedAt ` 2. Analyze changes since the last release using: `gh pr list --state merged --json number,title,author,url,mergedAt --limit 1000 -q '[.[] | select(.mergedAt > "TIMESTAMP") | {number, title, author: .author.login, url, mergedAt}] | sort_by(.number)'` 3. Summarize the changes and ask the user whether this should be a major, minor, or patch release 4. Create a changeset in .changeset/v[version].md instead of directly modifying package.json. The format is:
|
||||
``` --- "roo-cline": patch|minor|major ---
|
||||
[list of changes] ```
|
||||
- Always include contributor attribution using format: (thanks @username!) - Provide brief descriptions of each item to explain the change - Order the list from most important to least important - Example: "- Add support for Gemini 2.5 Pro caching (thanks @contributor!)" - CRITICAL: Include EVERY SINGLE PR in the changeset - don't assume you know which ones are important. Count the total PRs to verify completeness and cross-reference the list to ensure nothing is missed.
|
||||
5. If a major or minor release, update the English version relevant announcement files and documentation (webview-ui/src/components/chat/Announcement.tsx, README.md, and the `latestAnnouncementId` in src/core/webview/ClineProvider.ts) 6. Ask the user to confirm the English version 7. Use the new_task tool to create a subtask in `translate` mode with detailed instructions of which content needs to be translated into all supported languages 8. Commit and push the changeset file to the repository 9. The GitHub Actions workflow will automatically:
|
||||
When preparing a release:
|
||||
1. Identify the SHA corresponding to the most recent release using GitHub CLI: `gh release view --json tagName,targetCommitish,publishedAt`
|
||||
2. Analyze changes since the last release using: `gh pr list --state merged --json number,title,author,url,mergedAt,closingIssuesReferences --limit 1000 -q '[.[] | select(.mergedAt > "TIMESTAMP") | {number, title, author: .author.login, url, mergedAt, issues: .closingIssuesReferences}] | sort_by(.number)'`
|
||||
3. For each PR with linked issues, fetch the issue details to get the issue reporter: `gh issue view ISSUE_NUMBER --json number,author -q '{number, reporter: .author.login}'`
|
||||
4. Summarize the changes and ask the user whether this should be a major, minor, or patch release
|
||||
5. Create a changeset in .changeset/v[version].md instead of directly modifying package.json. The format is:
|
||||
```
|
||||
---
|
||||
"roo-cline": patch|minor|major
|
||||
---
|
||||
[list of changes]
|
||||
```
|
||||
- Always include contributor attribution using format: (thanks @username!) - For PRs that close issues, also include the issue number and reporter: "- Fix: Description (#123 by @reporter, PR by @contributor)" - For PRs without linked issues, use the standard format: "- Add support for feature (thanks @contributor!)" - Provide brief descriptions of each item to explain the change - Order the list from most important to least important - Example formats:
|
||||
- With issue: "- Fix: Resolve memory leak in extension (#456 by @issueReporter, PR by @prAuthor)"
|
||||
- Without issue: "- Add support for Gemini 2.5 Pro caching (thanks @contributor!)"
|
||||
- CRITICAL: Include EVERY SINGLE PR in the changeset - don't assume you know which ones are important. Count the total PRs to verify completeness and cross-reference the list to ensure nothing is missed.
|
||||
6. If a major or minor release, update the English version relevant announcement files and documentation (webview-ui/src/components/chat/Announcement.tsx, README.md, and the `latestAnnouncementId` in src/core/webview/ClineProvider.ts)
|
||||
7. Ask the user to confirm the English version
|
||||
8. Use the new_task tool to create a subtask in `translate` mode with detailed instructions of which content needs to be translated into all supported languages
|
||||
9. Create a new branch for the release preparation: `git checkout -b release/v[version]`
|
||||
10. Commit and push the changeset file and any documentation updates to the repository: `git add . && git commit -m "chore: add changeset for v[version]" && git push origin release/v[version]` 11. Create a pull request for the release: `gh pr create --title "Release v[version]" --body "Release preparation for v[version]. This PR includes the changeset and any necessary documentation updates." --base main --head release/v[version]` 12. The GitHub Actions workflow will automatically:
|
||||
- Create a version bump PR when changesets are merged to main
|
||||
- Update the CHANGELOG.md with proper formatting
|
||||
- Publish the release when the version bump PR is merged
|
||||
|
|
@ -199,3 +215,13 @@ customModes:
|
|||
- edit
|
||||
- command
|
||||
- mcp
|
||||
- slug: issue-investigator
|
||||
name: 🕵️ Issue Investigator
|
||||
roleDefinition: You are Roo, a GitHub issue investigator. Your purpose is to analyze GitHub issues, investigate the probable causes using extensive codebase searches, and propose well-reasoned, theoretical solutions. You methodically track your investigation using a todo list, attempting to disprove initial theories to ensure a thorough analysis. Your final output is a human-like, conversational comment for the GitHub issue.
|
||||
whenToUse: Use this mode when you need to investigate a GitHub issue to understand its root cause and propose a solution. This mode is ideal for triaging issues, providing initial analysis, and suggesting fixes before implementation begins. It uses the `gh` CLI for issue interaction.
|
||||
description: Investigates GitHub issues
|
||||
groups:
|
||||
- read
|
||||
- command
|
||||
- mcp
|
||||
source: project
|
||||
|
|
|
|||
16
CHANGELOG.md
16
CHANGELOG.md
|
|
@ -1,5 +1,21 @@
|
|||
# Roo Code Changelog
|
||||
|
||||
## [3.23.16] - 2025-07-19
|
||||
|
||||
- Add global rate limiting for OpenAI-compatible embeddings (thanks @daniel-lxs!)
|
||||
- Add batch limiting to code indexer (thanks @daniel-lxs!)
|
||||
- Fix Docker port conflicts for evals services
|
||||
|
||||
## [3.23.15] - 2025-07-18
|
||||
|
||||
- Fix configurable delay for diagnostics to prevent premature error reporting
|
||||
- Add command timeout allowlist
|
||||
- Add description and whenToUse fields to custom modes in .roomodes (thanks @RandalSchwartz!)
|
||||
- Fix Claude model detection by name for API protocol selection (thanks @daniel-lxs!)
|
||||
- Move marketplace icon from overflow menu to top navigation
|
||||
- Optional setting to prevent completion with open todos
|
||||
- Added YouTube to website footer (thanks @thill2323!)
|
||||
|
||||
## [3.23.14] - 2025-07-17
|
||||
|
||||
- Log api-initiated tasks to a tmp directory
|
||||
|
|
|
|||
|
|
@ -22,9 +22,10 @@ import { CreateRun } from "@/lib/schemas"
|
|||
const EVALS_REPO_PATH = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../../../../evals")
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export async function createRun({ suite, exercises = [], systemPrompt, ...values }: CreateRun) {
|
||||
export async function createRun({ suite, exercises = [], systemPrompt, timeout, ...values }: CreateRun) {
|
||||
const run = await _createRun({
|
||||
...values,
|
||||
timeout,
|
||||
socketPath: "", // TODO: Get rid of this.
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@ import {
|
|||
CONCURRENCY_MIN,
|
||||
CONCURRENCY_MAX,
|
||||
CONCURRENCY_DEFAULT,
|
||||
TIMEOUT_MIN,
|
||||
TIMEOUT_MAX,
|
||||
TIMEOUT_DEFAULT,
|
||||
} from "@/lib/schemas"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { useOpenRouterModels } from "@/hooks/use-open-router-models"
|
||||
|
|
@ -77,6 +80,7 @@ export function NewRun() {
|
|||
exercises: [],
|
||||
settings: undefined,
|
||||
concurrency: CONCURRENCY_DEFAULT,
|
||||
timeout: TIMEOUT_DEFAULT,
|
||||
},
|
||||
})
|
||||
|
||||
|
|
@ -341,6 +345,29 @@ export function NewRun() {
|
|||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="timeout"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Timeout (minutes)</FormLabel>
|
||||
<FormControl>
|
||||
<div className="flex flex-row items-center gap-2">
|
||||
<Slider
|
||||
defaultValue={[field.value]}
|
||||
min={TIMEOUT_MIN}
|
||||
max={TIMEOUT_MAX}
|
||||
step={1}
|
||||
onValueChange={(value) => field.onChange(value[0])}
|
||||
/>
|
||||
<div>{field.value} min</div>
|
||||
</div>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="description"
|
||||
|
|
|
|||
|
|
@ -12,6 +12,10 @@ export const CONCURRENCY_MIN = 1
|
|||
export const CONCURRENCY_MAX = 25
|
||||
export const CONCURRENCY_DEFAULT = 1
|
||||
|
||||
export const TIMEOUT_MIN = 5
|
||||
export const TIMEOUT_MAX = 10
|
||||
export const TIMEOUT_DEFAULT = 5
|
||||
|
||||
export const createRunSchema = z
|
||||
.object({
|
||||
model: z.string().min(1, { message: "Model is required." }),
|
||||
|
|
@ -20,6 +24,7 @@ export const createRunSchema = z
|
|||
exercises: z.array(z.string()).optional(),
|
||||
settings: rooCodeSettingsSchema.optional(),
|
||||
concurrency: z.number().int().min(CONCURRENCY_MIN).max(CONCURRENCY_MAX),
|
||||
timeout: z.number().int().min(TIMEOUT_MIN).max(TIMEOUT_MAX),
|
||||
systemPrompt: z.string().optional(),
|
||||
})
|
||||
.refine((data) => data.suite === "full" || (data.exercises || []).length > 0, {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { useState, useRef, useEffect } from "react"
|
|||
import Link from "next/link"
|
||||
import Image from "next/image"
|
||||
import { ChevronDown } from "lucide-react"
|
||||
import { FaBluesky, FaDiscord, FaGithub, FaLinkedin, FaReddit, FaTiktok, FaXTwitter } from "react-icons/fa6"
|
||||
import { FaBluesky, FaDiscord, FaGithub, FaLinkedin, FaReddit, FaTiktok, FaXTwitter, FaYoutube } from "react-icons/fa6"
|
||||
|
||||
import { EXTERNAL_LINKS, INTERNAL_LINKS } from "@/lib/constants"
|
||||
import { useLogoSrc } from "@/lib/hooks/use-logo-src"
|
||||
|
|
@ -80,6 +80,14 @@ export function Footer() {
|
|||
<FaLinkedin className="h-6 w-6" />
|
||||
<span className="sr-only">LinkedIn</span>
|
||||
</a>
|
||||
<a
|
||||
href={EXTERNAL_LINKS.BLUESKY}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-muted-foreground transition-colors hover:text-foreground">
|
||||
<FaBluesky className="h-6 w-6" />
|
||||
<span className="sr-only">Bluesky</span>
|
||||
</a>
|
||||
<a
|
||||
href={EXTERNAL_LINKS.TIKTOK}
|
||||
target="_blank"
|
||||
|
|
@ -89,12 +97,12 @@ export function Footer() {
|
|||
<span className="sr-only">TikTok</span>
|
||||
</a>
|
||||
<a
|
||||
href={EXTERNAL_LINKS.BLUESKY}
|
||||
href={EXTERNAL_LINKS.YOUTUBE}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-muted-foreground transition-colors hover:text-foreground">
|
||||
<FaBluesky className="h-6 w-6" />
|
||||
<span className="sr-only">Bluesky</span>
|
||||
<FaYoutube className="h-6 w-6" />
|
||||
<span className="sr-only">YouTube</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ export const EXTERNAL_LINKS = {
|
|||
LINKEDIN: "https://www.linkedin.com/company/roo-code",
|
||||
TIKTOK: "https://www.tiktok.com/@roo.code",
|
||||
BLUESKY: "https://bsky.app/profile/roocode.bsky.social",
|
||||
YOUTUBE: "https://www.youtube.com/@RooCodeYT",
|
||||
DOCUMENTATION: "https://docs.roocode.com",
|
||||
CAREERS: "https://careers.roocode.com",
|
||||
ISSUES: "https://github.com/RooCodeInc/Roo-Code/issues",
|
||||
|
|
|
|||
|
|
@ -1 +1,3 @@
|
|||
DATABASE_URL=postgres://postgres:password@localhost:5432/evals_development
|
||||
DATABASE_URL=postgres://postgres:password@localhost:5433/evals_development
|
||||
EVALS_DB_PORT=5433
|
||||
EVALS_REDIS_PORT=6380
|
||||
|
|
|
|||
|
|
@ -1 +1,3 @@
|
|||
DATABASE_URL=postgres://postgres:password@localhost:5432/evals_test
|
||||
DATABASE_URL=postgres://postgres:password@localhost:5433/evals_test
|
||||
EVALS_DB_PORT=5433
|
||||
EVALS_REDIS_PORT=6380
|
||||
|
|
|
|||
|
|
@ -89,6 +89,46 @@ The setup script does the following:
|
|||
- Prompts for an OpenRouter API key to add to `.env.local`
|
||||
- Optionally builds and installs the Roo Code extension from source
|
||||
|
||||
## Port Configuration
|
||||
|
||||
By default, the evals system uses the following ports:
|
||||
|
||||
- **PostgreSQL**: 5433 (external) → 5432 (internal)
|
||||
- **Redis**: 6380 (external) → 6379 (internal)
|
||||
- **Web Service**: 3446 (external) → 3000 (internal)
|
||||
|
||||
These ports are configured to avoid conflicts with other services that might be running on the standard PostgreSQL (5432) and Redis (6379) ports.
|
||||
|
||||
### Customizing Ports
|
||||
|
||||
If you need to use different ports, you can customize them by creating a `.env.local` file in the `packages/evals/` directory:
|
||||
|
||||
```sh
|
||||
# Copy the example file and customize as needed
|
||||
cp packages/evals/.env.local.example packages/evals/.env.local
|
||||
```
|
||||
|
||||
Then edit `.env.local` to set your preferred ports:
|
||||
|
||||
```sh
|
||||
# Custom port configuration
|
||||
EVALS_DB_PORT=5434
|
||||
EVALS_REDIS_PORT=6381
|
||||
EVALS_WEB_PORT=3447
|
||||
|
||||
# Optional: Override database URL if needed
|
||||
DATABASE_URL=postgres://postgres:password@localhost:5434/evals_development
|
||||
```
|
||||
|
||||
### Port Conflict Resolution
|
||||
|
||||
If you encounter port conflicts when running `pnpm evals`, you have several options:
|
||||
|
||||
1. **Use the default configuration** (recommended): The system now uses non-standard ports by default
|
||||
2. **Stop conflicting services**: Temporarily stop other PostgreSQL/Redis services
|
||||
3. **Customize ports**: Use the `.env.local` file to set different ports
|
||||
4. **Use Docker networks**: Run services in isolated Docker networks
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
Here are some errors that you might encounter along with potential fixes:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
import { createClient, type RedisClientType } from "redis"
|
||||
|
||||
import { EVALS_TIMEOUT } from "@roo-code/types"
|
||||
|
||||
let redis: RedisClientType | undefined
|
||||
|
||||
export const redisClient = async () => {
|
||||
|
|
@ -18,11 +16,19 @@ export const getPubSubKey = (runId: number) => `evals:${runId}`
|
|||
export const getRunnersKey = (runId: number) => `runners:${runId}`
|
||||
export const getHeartbeatKey = (runId: number) => `heartbeat:${runId}`
|
||||
|
||||
export const registerRunner = async ({ runId, taskId }: { runId: number; taskId: number }) => {
|
||||
export const registerRunner = async ({
|
||||
runId,
|
||||
taskId,
|
||||
timeoutSeconds,
|
||||
}: {
|
||||
runId: number
|
||||
taskId: number
|
||||
timeoutSeconds: number
|
||||
}) => {
|
||||
const redis = await redisClient()
|
||||
const runnersKey = getRunnersKey(runId)
|
||||
await redis.sAdd(runnersKey, `task-${taskId}:${process.env.HOSTNAME ?? process.pid}`)
|
||||
await redis.expire(runnersKey, EVALS_TIMEOUT / 1_000)
|
||||
await redis.expire(runnersKey, timeoutSeconds)
|
||||
}
|
||||
|
||||
export const deregisterRunner = async ({ runId, taskId }: { runId: number; taskId: number }) => {
|
||||
|
|
|
|||
|
|
@ -5,14 +5,7 @@ import * as os from "node:os"
|
|||
import pWaitFor from "p-wait-for"
|
||||
import { execa } from "execa"
|
||||
|
||||
import {
|
||||
type TaskEvent,
|
||||
TaskCommandName,
|
||||
RooCodeEventName,
|
||||
IpcMessageType,
|
||||
EVALS_SETTINGS,
|
||||
EVALS_TIMEOUT,
|
||||
} from "@roo-code/types"
|
||||
import { type TaskEvent, TaskCommandName, RooCodeEventName, IpcMessageType, EVALS_SETTINGS } from "@roo-code/types"
|
||||
import { IpcClient } from "@roo-code/ipc"
|
||||
|
||||
import {
|
||||
|
|
@ -42,7 +35,7 @@ export const processTask = async ({ taskId, logger }: { taskId: number; logger?:
|
|||
const task = await findTask(taskId)
|
||||
const { language, exercise } = task
|
||||
const run = await findRun(task.runId)
|
||||
await registerRunner({ runId: run.id, taskId })
|
||||
await registerRunner({ runId: run.id, taskId, timeoutSeconds: (run.timeout || 5) * 60 })
|
||||
|
||||
const containerized = isDockerContainer()
|
||||
|
||||
|
|
@ -304,9 +297,10 @@ export const runTask = async ({ run, task, publish, logger }: RunTaskOptions) =>
|
|||
})
|
||||
|
||||
try {
|
||||
const timeoutMs = (run.timeout || 5) * 60 * 1_000 // Convert minutes to milliseconds
|
||||
await pWaitFor(() => !!taskFinishedAt || !!taskAbortedAt || isClientDisconnected, {
|
||||
interval: 1_000,
|
||||
timeout: EVALS_TIMEOUT,
|
||||
timeout: timeoutMs,
|
||||
})
|
||||
} catch (_error) {
|
||||
taskTimedOut = true
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE "runs" ADD COLUMN "timeout" integer DEFAULT 5 NOT NULL;
|
||||
|
|
@ -23,6 +23,7 @@ describe("copyRun", () => {
|
|||
socketPath: "/tmp/roo.sock",
|
||||
description: "Test run for copying",
|
||||
concurrency: 4,
|
||||
timeout: 5,
|
||||
})
|
||||
|
||||
sourceRunId = run.id
|
||||
|
|
@ -271,7 +272,7 @@ describe("copyRun", () => {
|
|||
})
|
||||
|
||||
it("should copy run without task metrics", async () => {
|
||||
const minimalRun = await createRun({ model: "gpt-3.5-turbo", socketPath: "/tmp/minimal.sock" })
|
||||
const minimalRun = await createRun({ model: "gpt-3.5-turbo", socketPath: "/tmp/minimal.sock", timeout: 5 })
|
||||
|
||||
const newRunId = await copyRun({ sourceDb: db, targetDb: db, runId: minimalRun.id })
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ export const runs = pgTable("runs", {
|
|||
pid: integer(),
|
||||
socketPath: text("socket_path").notNull(),
|
||||
concurrency: integer().default(2).notNull(),
|
||||
timeout: integer().default(5).notNull(),
|
||||
passed: integer().default(0).notNull(),
|
||||
failed: integer().default(0).notNull(),
|
||||
createdAt: timestamp("created_at").notNull(),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@roo-code/types",
|
||||
"version": "1.35.0",
|
||||
"version": "1.36.0",
|
||||
"description": "TypeScript type definitions for Roo Code.",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export const CODEBASE_INDEX_DEFAULTS = {
|
|||
export const codebaseIndexConfigSchema = z.object({
|
||||
codebaseIndexEnabled: z.boolean().optional(),
|
||||
codebaseIndexQdrantUrl: z.string().optional(),
|
||||
codebaseIndexEmbedderProvider: z.enum(["openai", "ollama", "openai-compatible", "gemini"]).optional(),
|
||||
codebaseIndexEmbedderProvider: z.enum(["openai", "ollama", "openai-compatible", "gemini", "mistral"]).optional(),
|
||||
codebaseIndexEmbedderBaseUrl: z.string().optional(),
|
||||
codebaseIndexEmbedderModelId: z.string().optional(),
|
||||
codebaseIndexEmbedderModelDimension: z.number().optional(),
|
||||
|
|
@ -47,6 +47,7 @@ export const codebaseIndexModelsSchema = z.object({
|
|||
ollama: z.record(z.string(), z.object({ dimension: z.number() })).optional(),
|
||||
"openai-compatible": z.record(z.string(), z.object({ dimension: z.number() })).optional(),
|
||||
gemini: z.record(z.string(), z.object({ dimension: z.number() })).optional(),
|
||||
mistral: z.record(z.string(), z.object({ dimension: z.number() })).optional(),
|
||||
})
|
||||
|
||||
export type CodebaseIndexModels = z.infer<typeof codebaseIndexModelsSchema>
|
||||
|
|
@ -62,6 +63,7 @@ export const codebaseIndexProviderSchema = z.object({
|
|||
codebaseIndexOpenAiCompatibleApiKey: z.string().optional(),
|
||||
codebaseIndexOpenAiCompatibleModelDimension: z.number().optional(),
|
||||
codebaseIndexGeminiApiKey: z.string().optional(),
|
||||
codebaseIndexMistralApiKey: z.string().optional(),
|
||||
})
|
||||
|
||||
export type CodebaseIndexProvider = z.infer<typeof codebaseIndexProviderSchema>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,20 @@ import { modeConfigSchema } from "./mode.js"
|
|||
import { customModePromptsSchema, customSupportPromptsSchema } from "./mode.js"
|
||||
import { languagesSchema } from "./vscode.js"
|
||||
|
||||
/**
|
||||
* Default delay in milliseconds after writes to allow diagnostics to detect potential problems.
|
||||
* This delay is particularly important for Go and other languages where tools like goimports
|
||||
* need time to automatically clean up unused imports.
|
||||
*/
|
||||
export const DEFAULT_WRITE_DELAY_MS = 1000
|
||||
|
||||
/**
|
||||
* Default terminal output character limit constant.
|
||||
* This provides a reasonable default that aligns with typical terminal usage
|
||||
* while preventing context window explosions from extremely long lines.
|
||||
*/
|
||||
export const DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT = 50_000
|
||||
|
||||
/**
|
||||
* GlobalSettings
|
||||
*/
|
||||
|
|
@ -37,7 +51,7 @@ export const globalSettingsSchema = z.object({
|
|||
alwaysAllowWrite: z.boolean().optional(),
|
||||
alwaysAllowWriteOutsideWorkspace: z.boolean().optional(),
|
||||
alwaysAllowWriteProtected: z.boolean().optional(),
|
||||
writeDelayMs: z.number().optional(),
|
||||
writeDelayMs: z.number().min(0).optional(),
|
||||
alwaysAllowBrowser: z.boolean().optional(),
|
||||
alwaysApproveResubmit: z.boolean().optional(),
|
||||
requestDelaySeconds: z.number().optional(),
|
||||
|
|
@ -51,6 +65,7 @@ export const globalSettingsSchema = z.object({
|
|||
allowedCommands: z.array(z.string()).optional(),
|
||||
deniedCommands: z.array(z.string()).optional(),
|
||||
commandExecutionTimeout: z.number().optional(),
|
||||
commandTimeoutAllowlist: z.array(z.string()).optional(),
|
||||
preventCompletionWithOpenTodos: z.boolean().optional(),
|
||||
allowedMaxRequests: z.number().nullish(),
|
||||
autoCondenseContext: z.boolean().optional(),
|
||||
|
|
@ -77,6 +92,7 @@ export const globalSettingsSchema = z.object({
|
|||
maxReadFileLine: z.number().optional(),
|
||||
|
||||
terminalOutputLineLimit: z.number().optional(),
|
||||
terminalOutputCharacterLimit: z.number().optional(),
|
||||
terminalShellIntegrationTimeout: z.number().optional(),
|
||||
terminalShellIntegrationDisabled: z.boolean().optional(),
|
||||
terminalCommandDelay: z.number().optional(),
|
||||
|
|
@ -87,6 +103,8 @@ export const globalSettingsSchema = z.object({
|
|||
terminalZdotdir: z.boolean().optional(),
|
||||
terminalCompressProgressBar: z.boolean().optional(),
|
||||
|
||||
diagnosticsEnabled: z.boolean().optional(),
|
||||
|
||||
rateLimitSeconds: z.number().optional(),
|
||||
diffEnabled: z.boolean().optional(),
|
||||
fuzzyMatchThreshold: z.number().optional(),
|
||||
|
|
@ -152,6 +170,7 @@ export const SECRET_STATE_KEYS = [
|
|||
"codeIndexQdrantApiKey",
|
||||
"codebaseIndexOpenAiCompatibleApiKey",
|
||||
"codebaseIndexGeminiApiKey",
|
||||
"codebaseIndexMistralApiKey",
|
||||
] as const satisfies readonly (keyof ProviderSettings)[]
|
||||
export type SecretState = Pick<ProviderSettings, (typeof SECRET_STATE_KEYS)[number]>
|
||||
|
||||
|
|
@ -203,6 +222,7 @@ export const EVALS_SETTINGS: RooCodeSettings = {
|
|||
followupAutoApproveTimeoutMs: 0,
|
||||
allowedCommands: ["*"],
|
||||
commandExecutionTimeout: 30_000,
|
||||
commandTimeoutAllowlist: [],
|
||||
preventCompletionWithOpenTodos: false,
|
||||
|
||||
browserToolEnabled: false,
|
||||
|
|
@ -216,6 +236,7 @@ export const EVALS_SETTINGS: RooCodeSettings = {
|
|||
soundVolume: 0.5,
|
||||
|
||||
terminalOutputLineLimit: 500,
|
||||
terminalOutputCharacterLimit: DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT,
|
||||
terminalShellIntegrationTimeout: 30000,
|
||||
terminalCommandDelay: 0,
|
||||
terminalPowershellCounter: false,
|
||||
|
|
@ -226,6 +247,8 @@ export const EVALS_SETTINGS: RooCodeSettings = {
|
|||
terminalCompressProgressBar: true,
|
||||
terminalShellIntegrationDisabled: true,
|
||||
|
||||
diagnosticsEnabled: true,
|
||||
|
||||
diffEnabled: true,
|
||||
fuzzyMatchThreshold: 1,
|
||||
|
||||
|
|
|
|||
|
|
@ -558,48 +558,54 @@ export class CustomModesManager {
|
|||
*/
|
||||
public async checkRulesDirectoryHasContent(slug: string): Promise<boolean> {
|
||||
try {
|
||||
// Get workspace path
|
||||
const workspacePath = getWorkspacePath()
|
||||
if (!workspacePath) {
|
||||
return false
|
||||
}
|
||||
// First, find the mode to determine its source
|
||||
const allModes = await this.getCustomModes()
|
||||
const mode = allModes.find((m) => m.slug === slug)
|
||||
|
||||
// Check if .roomodes file exists and contains this mode
|
||||
// This ensures we can only consolidate rules for modes that have been customized
|
||||
const roomodesPath = path.join(workspacePath, ROOMODES_FILENAME)
|
||||
try {
|
||||
const roomodesExists = await fileExistsAtPath(roomodesPath)
|
||||
if (roomodesExists) {
|
||||
const roomodesContent = await fs.readFile(roomodesPath, "utf-8")
|
||||
const roomodesData = yaml.parse(roomodesContent)
|
||||
const roomodesModes = roomodesData?.customModes || []
|
||||
|
||||
// Check if this specific mode exists in .roomodes
|
||||
const modeInRoomodes = roomodesModes.find((m: any) => m.slug === slug)
|
||||
if (!modeInRoomodes) {
|
||||
return false // Mode not customized in .roomodes, cannot consolidate
|
||||
}
|
||||
} else {
|
||||
// If no .roomodes file exists, check if it's in global custom modes
|
||||
const allModes = await this.getCustomModes()
|
||||
const mode = allModes.find((m) => m.slug === slug)
|
||||
|
||||
if (!mode) {
|
||||
return false // Not a custom mode, cannot consolidate
|
||||
}
|
||||
if (!mode) {
|
||||
// If not in custom modes, check if it's in .roomodes (project-specific)
|
||||
const workspacePath = getWorkspacePath()
|
||||
if (!workspacePath) {
|
||||
return false
|
||||
}
|
||||
} catch (error) {
|
||||
// If we can't read .roomodes, fall back to checking custom modes
|
||||
const allModes = await this.getCustomModes()
|
||||
const mode = allModes.find((m) => m.slug === slug)
|
||||
|
||||
if (!mode) {
|
||||
return false // Not a custom mode, cannot consolidate
|
||||
const roomodesPath = path.join(workspacePath, ROOMODES_FILENAME)
|
||||
try {
|
||||
const roomodesExists = await fileExistsAtPath(roomodesPath)
|
||||
if (roomodesExists) {
|
||||
const roomodesContent = await fs.readFile(roomodesPath, "utf-8")
|
||||
const roomodesData = yaml.parse(roomodesContent)
|
||||
const roomodesModes = roomodesData?.customModes || []
|
||||
|
||||
// Check if this specific mode exists in .roomodes
|
||||
const modeInRoomodes = roomodesModes.find((m: any) => m.slug === slug)
|
||||
if (!modeInRoomodes) {
|
||||
return false // Mode not found anywhere
|
||||
}
|
||||
} else {
|
||||
return false // No .roomodes file and not in custom modes
|
||||
}
|
||||
} catch (error) {
|
||||
return false // Cannot read .roomodes and not in custom modes
|
||||
}
|
||||
}
|
||||
|
||||
// Check for .roo/rules-{slug}/ directory
|
||||
const modeRulesDir = path.join(workspacePath, ".roo", `rules-${slug}`)
|
||||
// Determine the correct rules directory based on mode source
|
||||
let modeRulesDir: string
|
||||
const isGlobalMode = mode?.source === "global"
|
||||
|
||||
if (isGlobalMode) {
|
||||
// For global modes, check in global .roo directory
|
||||
const globalRooDir = getGlobalRooDirectory()
|
||||
modeRulesDir = path.join(globalRooDir, `rules-${slug}`)
|
||||
} else {
|
||||
// For project modes, check in workspace .roo directory
|
||||
const workspacePath = getWorkspacePath()
|
||||
if (!workspacePath) {
|
||||
return false
|
||||
}
|
||||
modeRulesDir = path.join(workspacePath, ".roo", `rules-${slug}`)
|
||||
}
|
||||
|
||||
try {
|
||||
const stats = await fs.stat(modeRulesDir)
|
||||
|
|
@ -655,24 +661,23 @@ export class CustomModesManager {
|
|||
|
||||
// If mode not found in custom modes, check if it's a built-in mode that has been customized
|
||||
if (!mode) {
|
||||
// Only check workspace-based modes if workspace is available
|
||||
const workspacePath = getWorkspacePath()
|
||||
if (!workspacePath) {
|
||||
return { success: false, error: "No workspace found" }
|
||||
}
|
||||
if (workspacePath) {
|
||||
const roomodesPath = path.join(workspacePath, ROOMODES_FILENAME)
|
||||
try {
|
||||
const roomodesExists = await fileExistsAtPath(roomodesPath)
|
||||
if (roomodesExists) {
|
||||
const roomodesContent = await fs.readFile(roomodesPath, "utf-8")
|
||||
const roomodesData = yaml.parse(roomodesContent)
|
||||
const roomodesModes = roomodesData?.customModes || []
|
||||
|
||||
const roomodesPath = path.join(workspacePath, ROOMODES_FILENAME)
|
||||
try {
|
||||
const roomodesExists = await fileExistsAtPath(roomodesPath)
|
||||
if (roomodesExists) {
|
||||
const roomodesContent = await fs.readFile(roomodesPath, "utf-8")
|
||||
const roomodesData = yaml.parse(roomodesContent)
|
||||
const roomodesModes = roomodesData?.customModes || []
|
||||
|
||||
// Find the mode in .roomodes
|
||||
mode = roomodesModes.find((m: any) => m.slug === slug)
|
||||
// Find the mode in .roomodes
|
||||
mode = roomodesModes.find((m: any) => m.slug === slug)
|
||||
}
|
||||
} catch (error) {
|
||||
// Continue to check built-in modes
|
||||
}
|
||||
} catch (error) {
|
||||
// Continue to check built-in modes
|
||||
}
|
||||
|
||||
// If still not found, check if it's a built-in mode
|
||||
|
|
@ -687,14 +692,25 @@ export class CustomModesManager {
|
|||
}
|
||||
}
|
||||
|
||||
// Get workspace path
|
||||
const workspacePath = getWorkspacePath()
|
||||
if (!workspacePath) {
|
||||
return { success: false, error: "No workspace found" }
|
||||
// Determine the base directory based on mode source
|
||||
const isGlobalMode = mode.source === "global"
|
||||
let baseDir: string
|
||||
if (isGlobalMode) {
|
||||
// For global modes, use the global .roo directory
|
||||
baseDir = getGlobalRooDirectory()
|
||||
} else {
|
||||
// For project modes, use the workspace directory
|
||||
const workspacePath = getWorkspacePath()
|
||||
if (!workspacePath) {
|
||||
return { success: false, error: "No workspace found" }
|
||||
}
|
||||
baseDir = workspacePath
|
||||
}
|
||||
|
||||
// Check for .roo/rules-{slug}/ directory
|
||||
const modeRulesDir = path.join(workspacePath, ".roo", `rules-${slug}`)
|
||||
// Check for .roo/rules-{slug}/ directory (or rules-{slug}/ for global)
|
||||
const modeRulesDir = isGlobalMode
|
||||
? path.join(baseDir, `rules-${slug}`)
|
||||
: path.join(baseDir, ".roo", `rules-${slug}`)
|
||||
|
||||
let rulesFiles: RuleFile[] = []
|
||||
try {
|
||||
|
|
@ -709,8 +725,10 @@ export class CustomModesManager {
|
|||
const filePath = path.join(modeRulesDir, entry.name)
|
||||
const content = await fs.readFile(filePath, "utf-8")
|
||||
if (content.trim()) {
|
||||
// Calculate relative path from .roo directory
|
||||
const relativePath = path.relative(path.join(workspacePath, ".roo"), filePath)
|
||||
// Calculate relative path based on mode source
|
||||
const relativePath = isGlobalMode
|
||||
? path.relative(baseDir, filePath)
|
||||
: path.relative(path.join(baseDir, ".roo"), filePath)
|
||||
rulesFiles.push({ relativePath, content: content.trim() })
|
||||
}
|
||||
}
|
||||
|
|
@ -755,6 +773,77 @@ export class CustomModesManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to import rules files for a mode
|
||||
* @param importMode - The mode being imported
|
||||
* @param rulesFiles - The rules files to import
|
||||
* @param source - The import source ("global" or "project")
|
||||
*/
|
||||
private async importRulesFiles(
|
||||
importMode: ExportedModeConfig,
|
||||
rulesFiles: RuleFile[],
|
||||
source: "global" | "project",
|
||||
): Promise<void> {
|
||||
// Determine base directory and rules folder path based on source
|
||||
let baseDir: string
|
||||
let rulesFolderPath: string
|
||||
|
||||
if (source === "global") {
|
||||
baseDir = getGlobalRooDirectory()
|
||||
rulesFolderPath = path.join(baseDir, `rules-${importMode.slug}`)
|
||||
} else {
|
||||
const workspacePath = getWorkspacePath()
|
||||
baseDir = path.join(workspacePath, ".roo")
|
||||
rulesFolderPath = path.join(baseDir, `rules-${importMode.slug}`)
|
||||
}
|
||||
|
||||
// Always remove the existing rules folder for this mode if it exists
|
||||
// This ensures that if the imported mode has no rules, the folder is cleaned up
|
||||
try {
|
||||
await fs.rm(rulesFolderPath, { recursive: true, force: true })
|
||||
logger.info(`Removed existing ${source} rules folder for mode ${importMode.slug}`)
|
||||
} catch (error) {
|
||||
// It's okay if the folder doesn't exist
|
||||
logger.debug(`No existing ${source} rules folder to remove for mode ${importMode.slug}`)
|
||||
}
|
||||
|
||||
// Only proceed with file creation if there are rules files to import
|
||||
if (!rulesFiles || !Array.isArray(rulesFiles) || rulesFiles.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
// Import the new rules files with path validation
|
||||
for (const ruleFile of rulesFiles) {
|
||||
if (ruleFile.relativePath && ruleFile.content) {
|
||||
// Validate the relative path to prevent path traversal attacks
|
||||
const normalizedRelativePath = path.normalize(ruleFile.relativePath)
|
||||
|
||||
// Ensure the path doesn't contain traversal sequences
|
||||
if (normalizedRelativePath.includes("..") || path.isAbsolute(normalizedRelativePath)) {
|
||||
logger.error(`Invalid file path detected: ${ruleFile.relativePath}`)
|
||||
continue // Skip this file but continue with others
|
||||
}
|
||||
|
||||
const targetPath = path.join(baseDir, normalizedRelativePath)
|
||||
const normalizedTargetPath = path.normalize(targetPath)
|
||||
const expectedBasePath = path.normalize(baseDir)
|
||||
|
||||
// Ensure the resolved path stays within the base directory
|
||||
if (!normalizedTargetPath.startsWith(expectedBasePath)) {
|
||||
logger.error(`Path traversal attempt detected: ${ruleFile.relativePath}`)
|
||||
continue // Skip this file but continue with others
|
||||
}
|
||||
|
||||
// Ensure directory exists
|
||||
const targetDir = path.dirname(targetPath)
|
||||
await fs.mkdir(targetDir, { recursive: true })
|
||||
|
||||
// Write the file
|
||||
await fs.writeFile(targetPath, ruleFile.content, "utf-8")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Imports modes from YAML content, including their associated rules files
|
||||
* @param yamlContent - The YAML content containing mode configurations
|
||||
|
|
@ -821,100 +910,8 @@ export class CustomModesManager {
|
|||
source: source, // Use the provided source parameter
|
||||
})
|
||||
|
||||
// Handle project-level imports
|
||||
if (source === "project") {
|
||||
const workspacePath = getWorkspacePath()
|
||||
|
||||
// Always remove the existing rules folder for this mode if it exists
|
||||
// This ensures that if the imported mode has no rules, the folder is cleaned up
|
||||
const rulesFolderPath = path.join(workspacePath, ".roo", `rules-${importMode.slug}`)
|
||||
try {
|
||||
await fs.rm(rulesFolderPath, { recursive: true, force: true })
|
||||
logger.info(`Removed existing rules folder for mode ${importMode.slug}`)
|
||||
} catch (error) {
|
||||
// It's okay if the folder doesn't exist
|
||||
logger.debug(`No existing rules folder to remove for mode ${importMode.slug}`)
|
||||
}
|
||||
|
||||
// Only create new rules files if they exist in the import
|
||||
if (rulesFiles && Array.isArray(rulesFiles) && rulesFiles.length > 0) {
|
||||
// Import the new rules files with path validation
|
||||
for (const ruleFile of rulesFiles) {
|
||||
if (ruleFile.relativePath && ruleFile.content) {
|
||||
// Validate the relative path to prevent path traversal attacks
|
||||
const normalizedRelativePath = path.normalize(ruleFile.relativePath)
|
||||
|
||||
// Ensure the path doesn't contain traversal sequences
|
||||
if (normalizedRelativePath.includes("..") || path.isAbsolute(normalizedRelativePath)) {
|
||||
logger.error(`Invalid file path detected: ${ruleFile.relativePath}`)
|
||||
continue // Skip this file but continue with others
|
||||
}
|
||||
|
||||
const targetPath = path.join(workspacePath, ".roo", normalizedRelativePath)
|
||||
const normalizedTargetPath = path.normalize(targetPath)
|
||||
const expectedBasePath = path.normalize(path.join(workspacePath, ".roo"))
|
||||
|
||||
// Ensure the resolved path stays within the .roo directory
|
||||
if (!normalizedTargetPath.startsWith(expectedBasePath)) {
|
||||
logger.error(`Path traversal attempt detected: ${ruleFile.relativePath}`)
|
||||
continue // Skip this file but continue with others
|
||||
}
|
||||
|
||||
// Ensure directory exists
|
||||
const targetDir = path.dirname(targetPath)
|
||||
await fs.mkdir(targetDir, { recursive: true })
|
||||
|
||||
// Write the file
|
||||
await fs.writeFile(targetPath, ruleFile.content, "utf-8")
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (source === "global" && rulesFiles && Array.isArray(rulesFiles)) {
|
||||
// For global imports, preserve the rules files structure in the global .roo directory
|
||||
const globalRooDir = getGlobalRooDirectory()
|
||||
|
||||
// Always remove the existing rules folder for this mode if it exists
|
||||
// This ensures that if the imported mode has no rules, the folder is cleaned up
|
||||
const rulesFolderPath = path.join(globalRooDir, `rules-${importMode.slug}`)
|
||||
try {
|
||||
await fs.rm(rulesFolderPath, { recursive: true, force: true })
|
||||
logger.info(`Removed existing global rules folder for mode ${importMode.slug}`)
|
||||
} catch (error) {
|
||||
// It's okay if the folder doesn't exist
|
||||
logger.debug(`No existing global rules folder to remove for mode ${importMode.slug}`)
|
||||
}
|
||||
|
||||
// Import the new rules files with path validation
|
||||
for (const ruleFile of rulesFiles) {
|
||||
if (ruleFile.relativePath && ruleFile.content) {
|
||||
// Validate the relative path to prevent path traversal attacks
|
||||
const normalizedRelativePath = path.normalize(ruleFile.relativePath)
|
||||
|
||||
// Ensure the path doesn't contain traversal sequences
|
||||
if (normalizedRelativePath.includes("..") || path.isAbsolute(normalizedRelativePath)) {
|
||||
logger.error(`Invalid file path detected: ${ruleFile.relativePath}`)
|
||||
continue // Skip this file but continue with others
|
||||
}
|
||||
|
||||
const targetPath = path.join(globalRooDir, normalizedRelativePath)
|
||||
const normalizedTargetPath = path.normalize(targetPath)
|
||||
const expectedBasePath = path.normalize(globalRooDir)
|
||||
|
||||
// Ensure the resolved path stays within the global .roo directory
|
||||
if (!normalizedTargetPath.startsWith(expectedBasePath)) {
|
||||
logger.error(`Path traversal attempt detected: ${ruleFile.relativePath}`)
|
||||
continue // Skip this file but continue with others
|
||||
}
|
||||
|
||||
// Ensure directory exists
|
||||
const targetDir = path.dirname(targetPath)
|
||||
await fs.mkdir(targetDir, { recursive: true })
|
||||
|
||||
// Write the file
|
||||
await fs.writeFile(targetPath, ruleFile.content, "utf-8")
|
||||
}
|
||||
}
|
||||
}
|
||||
// Import rules files (this also handles cleanup of existing rules folders)
|
||||
await this.importRulesFiles(importMode, rulesFiles || [], source)
|
||||
}
|
||||
|
||||
// Refresh the modes after import
|
||||
|
|
|
|||
|
|
@ -1373,7 +1373,7 @@ describe("CustomModesManager", () => {
|
|||
})
|
||||
|
||||
describe("exportModeWithRules", () => {
|
||||
it("should return error when no workspace is available", async () => {
|
||||
it("should return error when mode is not found and no workspace is available", async () => {
|
||||
// Create a fresh manager instance to avoid cache issues
|
||||
const freshManager = new CustomModesManager(mockContext, mockOnUpdate)
|
||||
|
||||
|
|
@ -1391,7 +1391,7 @@ describe("CustomModesManager", () => {
|
|||
const result = await freshManager.exportModeWithRules("test-mode")
|
||||
|
||||
expect(result.success).toBe(false)
|
||||
expect(result.error).toBe("No workspace found")
|
||||
expect(result.error).toBe("Mode not found")
|
||||
})
|
||||
|
||||
it("should return error when mode is not found", async () => {
|
||||
|
|
@ -1571,5 +1571,133 @@ describe("CustomModesManager", () => {
|
|||
expect(result.success).toBe(true)
|
||||
expect(result.yaml).toContain("test-mode")
|
||||
})
|
||||
|
||||
it("should successfully export global mode with rules from global .roo directory", async () => {
|
||||
// Mock a global mode
|
||||
const globalMode = {
|
||||
slug: "global-test-mode",
|
||||
name: "Global Test Mode",
|
||||
roleDefinition: "Global Test Role",
|
||||
groups: ["read"],
|
||||
source: "global",
|
||||
}
|
||||
|
||||
// Create a fresh manager instance to avoid cache issues
|
||||
const freshManager = new CustomModesManager(mockContext, mockOnUpdate)
|
||||
|
||||
;(fs.readFile as Mock).mockImplementation(async (path: string) => {
|
||||
if (path === mockSettingsPath) {
|
||||
return yaml.stringify({ customModes: [globalMode] })
|
||||
}
|
||||
if (path.includes("rules-global-test-mode") && path.includes("rule1.md")) {
|
||||
return "Global rule content"
|
||||
}
|
||||
throw new Error("File not found")
|
||||
})
|
||||
;(fileExistsAtPath as Mock).mockImplementation(async (path: string) => {
|
||||
return path === mockSettingsPath
|
||||
})
|
||||
;(fs.stat as Mock).mockImplementation(async (path: string) => {
|
||||
if (path.includes("rules-global-test-mode")) {
|
||||
return { isDirectory: () => true }
|
||||
}
|
||||
throw new Error("Directory not found")
|
||||
})
|
||||
;(fs.readdir as Mock).mockImplementation(async (path: string) => {
|
||||
if (path.includes("rules-global-test-mode")) {
|
||||
return [{ name: "rule1.md", isFile: () => true }]
|
||||
}
|
||||
return []
|
||||
})
|
||||
|
||||
const result = await freshManager.exportModeWithRules("global-test-mode")
|
||||
|
||||
expect(result.success).toBe(true)
|
||||
expect(result.yaml).toContain("global-test-mode")
|
||||
expect(result.yaml).toContain("Global Test Mode")
|
||||
expect(result.yaml).toContain("Global rule content")
|
||||
})
|
||||
|
||||
it("should successfully export global mode without rules when global rules directory doesn't exist", async () => {
|
||||
// Mock a global mode
|
||||
const globalMode = {
|
||||
slug: "global-test-mode",
|
||||
name: "Global Test Mode",
|
||||
roleDefinition: "Global Test Role",
|
||||
groups: ["read"],
|
||||
source: "global",
|
||||
}
|
||||
|
||||
// Create a fresh manager instance to avoid cache issues
|
||||
const freshManager = new CustomModesManager(mockContext, mockOnUpdate)
|
||||
|
||||
;(fs.readFile as Mock).mockImplementation(async (path: string) => {
|
||||
if (path === mockSettingsPath) {
|
||||
return yaml.stringify({ customModes: [globalMode] })
|
||||
}
|
||||
throw new Error("File not found")
|
||||
})
|
||||
;(fileExistsAtPath as Mock).mockImplementation(async (path: string) => {
|
||||
return path === mockSettingsPath
|
||||
})
|
||||
;(fs.stat as Mock).mockRejectedValue(new Error("Directory not found"))
|
||||
|
||||
const result = await freshManager.exportModeWithRules("global-test-mode")
|
||||
|
||||
expect(result.success).toBe(true)
|
||||
expect(result.yaml).toContain("global-test-mode")
|
||||
expect(result.yaml).toContain("Global Test Mode")
|
||||
// Should not contain rulesFiles since no rules directory exists
|
||||
expect(result.yaml).not.toContain("rulesFiles")
|
||||
})
|
||||
|
||||
it("should handle global mode export when workspace is not available", async () => {
|
||||
// Mock a global mode
|
||||
const globalMode = {
|
||||
slug: "global-test-mode",
|
||||
name: "Global Test Mode",
|
||||
roleDefinition: "Global Test Role",
|
||||
groups: ["read"],
|
||||
source: "global",
|
||||
}
|
||||
|
||||
// Create a fresh manager instance to avoid cache issues
|
||||
const freshManager = new CustomModesManager(mockContext, mockOnUpdate)
|
||||
|
||||
// Mock no workspace folders
|
||||
;(vscode.workspace as any).workspaceFolders = []
|
||||
;(getWorkspacePath as Mock).mockReturnValue(null)
|
||||
;(fs.readFile as Mock).mockImplementation(async (path: string) => {
|
||||
if (path === mockSettingsPath) {
|
||||
return yaml.stringify({ customModes: [globalMode] })
|
||||
}
|
||||
if (path.includes("rules-global-test-mode") && path.includes("rule1.md")) {
|
||||
return "Global rule content"
|
||||
}
|
||||
throw new Error("File not found")
|
||||
})
|
||||
;(fileExistsAtPath as Mock).mockImplementation(async (path: string) => {
|
||||
return path === mockSettingsPath
|
||||
})
|
||||
;(fs.stat as Mock).mockImplementation(async (path: string) => {
|
||||
if (path.includes("rules-global-test-mode")) {
|
||||
return { isDirectory: () => true }
|
||||
}
|
||||
throw new Error("Directory not found")
|
||||
})
|
||||
;(fs.readdir as Mock).mockImplementation(async (path: string) => {
|
||||
if (path.includes("rules-global-test-mode")) {
|
||||
return [{ name: "rule1.md", isFile: () => true }]
|
||||
}
|
||||
return []
|
||||
})
|
||||
|
||||
const result = await freshManager.exportModeWithRules("global-test-mode")
|
||||
|
||||
// Should succeed even without workspace since it's a global mode
|
||||
expect(result.success).toBe(true)
|
||||
expect(result.yaml).toContain("global-test-mode")
|
||||
expect(result.yaml).toContain("Global rule content")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import pWaitFor from "p-wait-for"
|
|||
import delay from "delay"
|
||||
|
||||
import type { ExperimentId } from "@roo-code/types"
|
||||
import { DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT } from "@roo-code/types"
|
||||
|
||||
import { EXPERIMENT_IDS, experiments as Experiments } from "../../shared/experiments"
|
||||
import { formatLanguage } from "../../shared/language"
|
||||
|
|
@ -25,7 +26,11 @@ export async function getEnvironmentDetails(cline: Task, includeFileDetails: boo
|
|||
|
||||
const clineProvider = cline.providerRef.deref()
|
||||
const state = await clineProvider?.getState()
|
||||
const { terminalOutputLineLimit = 500, maxWorkspaceFiles = 200 } = state ?? {}
|
||||
const {
|
||||
terminalOutputLineLimit = 500,
|
||||
terminalOutputCharacterLimit = DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT,
|
||||
maxWorkspaceFiles = 200,
|
||||
} = state ?? {}
|
||||
|
||||
// It could be useful for cline to know if the user went from one or no
|
||||
// file to another between messages, so we always include this context.
|
||||
|
|
@ -111,7 +116,11 @@ export async function getEnvironmentDetails(cline: Task, includeFileDetails: boo
|
|||
let newOutput = TerminalRegistry.getUnretrievedOutput(busyTerminal.id)
|
||||
|
||||
if (newOutput) {
|
||||
newOutput = Terminal.compressTerminalOutput(newOutput, terminalOutputLineLimit)
|
||||
newOutput = Terminal.compressTerminalOutput(
|
||||
newOutput,
|
||||
terminalOutputLineLimit,
|
||||
terminalOutputCharacterLimit,
|
||||
)
|
||||
terminalDetails += `\n### New Output\n${newOutput}`
|
||||
}
|
||||
}
|
||||
|
|
@ -139,7 +148,11 @@ export async function getEnvironmentDetails(cline: Task, includeFileDetails: boo
|
|||
let output = process.getUnretrievedOutput()
|
||||
|
||||
if (output) {
|
||||
output = Terminal.compressTerminalOutput(output, terminalOutputLineLimit)
|
||||
output = Terminal.compressTerminalOutput(
|
||||
output,
|
||||
terminalOutputLineLimit,
|
||||
terminalOutputCharacterLimit,
|
||||
)
|
||||
terminalOutputs.push(`Command: \`${process.command}\`\n${output}`)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -269,55 +269,6 @@ Examples:
|
|||
<ignore_case>true</ignore_case>
|
||||
</search_and_replace>
|
||||
|
||||
## use_mcp_tool
|
||||
Description: Request to use a tool provided by a connected MCP server. Each MCP server can provide multiple tools with different capabilities. Tools have defined input schemas that specify required and optional parameters.
|
||||
Parameters:
|
||||
- server_name: (required) The name of the MCP server providing the tool
|
||||
- tool_name: (required) The name of the tool to execute
|
||||
- arguments: (required) A JSON object containing the tool's input parameters, following the tool's input schema
|
||||
Usage:
|
||||
<use_mcp_tool>
|
||||
<server_name>server name here</server_name>
|
||||
<tool_name>tool name here</tool_name>
|
||||
<arguments>
|
||||
{
|
||||
"param1": "value1",
|
||||
"param2": "value2"
|
||||
}
|
||||
</arguments>
|
||||
</use_mcp_tool>
|
||||
|
||||
Example: Requesting to use an MCP tool
|
||||
|
||||
<use_mcp_tool>
|
||||
<server_name>weather-server</server_name>
|
||||
<tool_name>get_forecast</tool_name>
|
||||
<arguments>
|
||||
{
|
||||
"city": "San Francisco",
|
||||
"days": 5
|
||||
}
|
||||
</arguments>
|
||||
</use_mcp_tool>
|
||||
|
||||
## access_mcp_resource
|
||||
Description: Request to access a resource provided by a connected MCP server. Resources represent data sources that can be used as context, such as files, API responses, or system information.
|
||||
Parameters:
|
||||
- server_name: (required) The name of the MCP server providing the resource
|
||||
- uri: (required) The URI identifying the specific resource to access
|
||||
Usage:
|
||||
<access_mcp_resource>
|
||||
<server_name>server name here</server_name>
|
||||
<uri>resource URI here</uri>
|
||||
</access_mcp_resource>
|
||||
|
||||
Example: Requesting to access an MCP resource
|
||||
|
||||
<access_mcp_resource>
|
||||
<server_name>weather-server</server_name>
|
||||
<uri>weather://san-francisco/current</uri>
|
||||
</access_mcp_resource>
|
||||
|
||||
## ask_followup_question
|
||||
Description: Ask the user a question to gather additional information needed to complete the task. This tool should be used when you encounter ambiguities, need clarification, or require more details to proceed effectively. It allows for interactive problem-solving by enabling direct communication with the user. Use this tool judiciously to maintain a balance between gathering necessary information and avoiding excessive back-and-forth.
|
||||
Parameters:
|
||||
|
|
@ -508,18 +459,7 @@ It is crucial to proceed step-by-step, waiting for the user's message after each
|
|||
|
||||
By waiting for and carefully considering the user's response after each tool use, you can react accordingly and make informed decisions about how to proceed with the task. This iterative process helps ensure the overall success and accuracy of your work.
|
||||
|
||||
MCP SERVERS
|
||||
|
||||
The Model Context Protocol (MCP) enables communication between the system and MCP servers that provide additional tools and resources to extend your capabilities. MCP servers can be one of two types:
|
||||
|
||||
1. Local (Stdio-based) servers: These run locally on the user's machine and communicate via standard input/output
|
||||
2. Remote (SSE-based) servers: These run on remote machines and communicate via Server-Sent Events (SSE) over HTTP/HTTPS
|
||||
|
||||
# Connected MCP Servers
|
||||
|
||||
When a server is connected, you can use the server's tools via the `use_mcp_tool` tool, and access the server's resources via the `access_mcp_resource` tool.
|
||||
|
||||
(No MCP servers currently connected)
|
||||
|
||||
====
|
||||
|
||||
|
|
@ -531,8 +471,6 @@ CAPABILITIES
|
|||
- You can use the list_code_definition_names tool to get an overview of source code definitions for all files at the top level of a specified directory. This can be particularly useful when you need to understand the broader context and relationships between certain parts of the code. You may need to call this tool multiple times to understand various parts of the codebase related to the task.
|
||||
- For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the write_to_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
|
||||
- You can use the execute_command tool to run commands on the user's computer whenever you feel it can help accomplish the user's task. When you need to execute a CLI command, you must provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, since they are more flexible and easier to run. Interactive and long-running commands are allowed, since the commands are run in the user's VSCode terminal. The user may keep commands running in the background and you will be kept updated on their status along the way. Each command you execute is run in a new terminal instance.
|
||||
- You have access to MCP servers that may provide additional tools and resources. Each server may provide different capabilities that you can use to accomplish tasks more effectively.
|
||||
|
||||
|
||||
====
|
||||
|
||||
|
|
|
|||
|
|
@ -519,7 +519,7 @@ The Model Context Protocol (MCP) enables communication between the system and MC
|
|||
|
||||
When a server is connected, you can use the server's tools via the `use_mcp_tool` tool, and access the server's resources via the `access_mcp_resource` tool.
|
||||
|
||||
(No MCP servers currently connected)
|
||||
|
||||
## Creating an MCP Server
|
||||
|
||||
The user may ask you something along the lines of "add a tool" that does some function, in other words to create an MCP server that provides tools and resources that may connect to external APIs for example. If they do, you should obtain detailed instructions on this topic using the fetch_instructions tool, like this:
|
||||
|
|
|
|||
|
|
@ -519,7 +519,7 @@ The Model Context Protocol (MCP) enables communication between the system and MC
|
|||
|
||||
When a server is connected, you can use the server's tools via the `use_mcp_tool` tool, and access the server's resources via the `access_mcp_resource` tool.
|
||||
|
||||
(No MCP servers currently connected)
|
||||
|
||||
## Creating an MCP Server
|
||||
|
||||
The user may ask you something along the lines of "add a tool" that does some function, in other words to create an MCP server that provides tools and resources that may connect to external APIs for example. If they do, you should obtain detailed instructions on this topic using the fetch_instructions tool, like this:
|
||||
|
|
|
|||
|
|
@ -168,9 +168,9 @@ const mockContext = {
|
|||
} as unknown as vscode.ExtensionContext
|
||||
|
||||
// Instead of extending McpHub, create a mock that implements just what we need
|
||||
const createMockMcpHub = (): McpHub =>
|
||||
const createMockMcpHub = (withServers: boolean = false): McpHub =>
|
||||
({
|
||||
getServers: () => [],
|
||||
getServers: () => (withServers ? [{ name: "test-server", disabled: false }] : []),
|
||||
getMcpServersPath: async () => "/mock/mcp/path",
|
||||
getMcpSettingsFilePath: async () => "/mock/settings/path",
|
||||
dispose: async () => {},
|
||||
|
|
@ -236,7 +236,7 @@ describe("addCustomInstructions", () => {
|
|||
})
|
||||
|
||||
it("should include MCP server creation info when enabled", async () => {
|
||||
const mockMcpHub = createMockMcpHub()
|
||||
const mockMcpHub = createMockMcpHub(true)
|
||||
|
||||
const prompt = await SYSTEM_PROMPT(
|
||||
mockContext,
|
||||
|
|
@ -262,7 +262,7 @@ describe("addCustomInstructions", () => {
|
|||
})
|
||||
|
||||
it("should exclude MCP server creation info when disabled", async () => {
|
||||
const mockMcpHub = createMockMcpHub()
|
||||
const mockMcpHub = createMockMcpHub(false)
|
||||
|
||||
const prompt = await SYSTEM_PROMPT(
|
||||
mockContext,
|
||||
|
|
|
|||
|
|
@ -168,9 +168,9 @@ const mockContext = {
|
|||
} as unknown as vscode.ExtensionContext
|
||||
|
||||
// Instead of extending McpHub, create a mock that implements just what we need
|
||||
const createMockMcpHub = (): McpHub =>
|
||||
const createMockMcpHub = (withServers: boolean = false): McpHub =>
|
||||
({
|
||||
getServers: () => [],
|
||||
getServers: () => (withServers ? [{ name: "test-server", disabled: false }] : []),
|
||||
getMcpServersPath: async () => "/mock/mcp/path",
|
||||
getMcpSettingsFilePath: async () => "/mock/settings/path",
|
||||
dispose: async () => {},
|
||||
|
|
@ -250,7 +250,7 @@ describe("SYSTEM_PROMPT", () => {
|
|||
})
|
||||
|
||||
it("should include MCP server info when mcpHub is provided", async () => {
|
||||
mockMcpHub = createMockMcpHub()
|
||||
mockMcpHub = createMockMcpHub(true)
|
||||
|
||||
const prompt = await SYSTEM_PROMPT(
|
||||
mockContext,
|
||||
|
|
|
|||
|
|
@ -71,9 +71,14 @@ async function generatePrompt(
|
|||
const modeConfig = getModeBySlug(mode, customModeConfigs) || modes.find((m) => m.slug === mode) || modes[0]
|
||||
const { roleDefinition, baseInstructions } = getModeSelection(mode, promptComponent, customModeConfigs)
|
||||
|
||||
// Check if MCP functionality should be included
|
||||
const hasMcpGroup = modeConfig.groups.some((groupEntry) => getGroupName(groupEntry) === "mcp")
|
||||
const hasMcpServers = mcpHub && mcpHub.getServers().length > 0
|
||||
const shouldIncludeMcp = hasMcpGroup && hasMcpServers
|
||||
|
||||
const [modesSection, mcpServersSection] = await Promise.all([
|
||||
getModesSection(context),
|
||||
modeConfig.groups.some((groupEntry) => getGroupName(groupEntry) === "mcp")
|
||||
shouldIncludeMcp
|
||||
? getMcpServersSection(mcpHub, effectiveDiffStrategy, enableMcpServerCreation)
|
||||
: Promise.resolve(""),
|
||||
])
|
||||
|
|
@ -93,7 +98,7 @@ ${getToolDescriptionsForMode(
|
|||
codeIndexManager,
|
||||
effectiveDiffStrategy,
|
||||
browserViewportSize,
|
||||
mcpHub,
|
||||
shouldIncludeMcp ? mcpHub : undefined,
|
||||
customModeConfigs,
|
||||
experiments,
|
||||
partialReadsEnabled,
|
||||
|
|
@ -104,7 +109,7 @@ ${getToolUseGuidelinesSection(codeIndexManager)}
|
|||
|
||||
${mcpServersSection}
|
||||
|
||||
${getCapabilitiesSection(cwd, supportsComputerUse, mcpHub, effectiveDiffStrategy, codeIndexManager)}
|
||||
${getCapabilitiesSection(cwd, supportsComputerUse, shouldIncludeMcp ? mcpHub : undefined, effectiveDiffStrategy, codeIndexManager)}
|
||||
|
||||
${modesSection}
|
||||
|
||||
|
|
|
|||
|
|
@ -1442,16 +1442,18 @@ export class Task extends EventEmitter<ClineEvents> {
|
|||
// could be in (i.e. could have streamed some tools the user
|
||||
// may have executed), so we just resort to replicating a
|
||||
// cancel task.
|
||||
this.abortTask()
|
||||
|
||||
// Check if this was a user-initiated cancellation
|
||||
// If this.abort is true, it means the user clicked cancel, so we should
|
||||
// Check if this was a user-initiated cancellation BEFORE calling abortTask
|
||||
// If this.abort is already true, it means the user clicked cancel, so we should
|
||||
// treat this as "user_cancelled" rather than "streaming_failed"
|
||||
const cancelReason = this.abort ? "user_cancelled" : "streaming_failed"
|
||||
const streamingFailedMessage = this.abort
|
||||
? undefined
|
||||
: (error.message ?? JSON.stringify(serializeError(error), null, 2))
|
||||
|
||||
// Now call abortTask after determining the cancel reason
|
||||
await this.abortTask()
|
||||
|
||||
await abortStream(cancelReason, streamingFailedMessage)
|
||||
|
||||
const history = await provider?.getTaskWithId(this.taskId)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import * as vscode from "vscode"
|
||||
import * as fs from "fs/promises"
|
||||
import { executeCommand, ExecuteCommandOptions } from "../executeCommandTool"
|
||||
import { executeCommand, executeCommandTool, ExecuteCommandOptions } from "../executeCommandTool"
|
||||
import { Task } from "../../task/Task"
|
||||
import { TerminalRegistry } from "../../../integrations/terminal/TerminalRegistry"
|
||||
|
||||
|
|
@ -17,6 +17,20 @@ vitest.mock("vscode", () => ({
|
|||
vitest.mock("fs/promises")
|
||||
vitest.mock("../../../integrations/terminal/TerminalRegistry")
|
||||
vitest.mock("../../task/Task")
|
||||
vitest.mock("../../prompts/responses", () => ({
|
||||
formatResponse: {
|
||||
toolError: vitest.fn((msg) => `Tool Error: ${msg}`),
|
||||
rooIgnoreError: vitest.fn((msg) => `RooIgnore Error: ${msg}`),
|
||||
},
|
||||
}))
|
||||
vitest.mock("../../../utils/text-normalization", () => ({
|
||||
unescapeHtmlEntities: vitest.fn((text) => text),
|
||||
}))
|
||||
vitest.mock("../../../shared/package", () => ({
|
||||
Package: {
|
||||
name: "roo-cline",
|
||||
},
|
||||
}))
|
||||
|
||||
describe("Command Execution Timeout Integration", () => {
|
||||
let mockTask: any
|
||||
|
|
@ -186,4 +200,213 @@ describe("Command Execution Timeout Integration", () => {
|
|||
expect(result[0]).toBe(false) // Not rejected
|
||||
expect(result[1]).not.toContain("terminated after exceeding")
|
||||
})
|
||||
|
||||
describe("Command Timeout Allowlist", () => {
|
||||
let mockBlock: any
|
||||
let mockAskApproval: any
|
||||
let mockHandleError: any
|
||||
let mockPushToolResult: any
|
||||
let mockRemoveClosingTag: any
|
||||
|
||||
beforeEach(() => {
|
||||
// Reset mocks for allowlist tests
|
||||
vitest.clearAllMocks()
|
||||
;(fs.access as any).mockResolvedValue(undefined)
|
||||
;(TerminalRegistry.getOrCreateTerminal as any).mockResolvedValue(mockTerminal)
|
||||
|
||||
// Mock the executeCommandTool parameters
|
||||
mockBlock = {
|
||||
params: {
|
||||
command: "",
|
||||
cwd: undefined,
|
||||
},
|
||||
partial: false,
|
||||
}
|
||||
|
||||
mockAskApproval = vitest.fn().mockResolvedValue(true) // Always approve
|
||||
mockHandleError = vitest.fn()
|
||||
mockPushToolResult = vitest.fn()
|
||||
mockRemoveClosingTag = vitest.fn()
|
||||
|
||||
// Mock task with additional properties needed by executeCommandTool
|
||||
mockTask = {
|
||||
cwd: "/test/directory",
|
||||
terminalProcess: undefined,
|
||||
providerRef: {
|
||||
deref: vitest.fn().mockResolvedValue({
|
||||
postMessageToWebview: vitest.fn(),
|
||||
getState: vitest.fn().mockResolvedValue({
|
||||
terminalOutputLineLimit: 500,
|
||||
terminalShellIntegrationDisabled: false,
|
||||
}),
|
||||
}),
|
||||
},
|
||||
say: vitest.fn().mockResolvedValue(undefined),
|
||||
consecutiveMistakeCount: 0,
|
||||
recordToolError: vitest.fn(),
|
||||
sayAndCreateMissingParamError: vitest.fn(),
|
||||
rooIgnoreController: {
|
||||
validateCommand: vitest.fn().mockReturnValue(null),
|
||||
},
|
||||
lastMessageTs: Date.now(),
|
||||
ask: vitest.fn(),
|
||||
didRejectTool: false,
|
||||
}
|
||||
})
|
||||
|
||||
it("should skip timeout for commands in allowlist", async () => {
|
||||
// Mock VSCode configuration with timeout and allowlist
|
||||
const mockGetConfiguration = vitest.fn().mockReturnValue({
|
||||
get: vitest.fn().mockImplementation((key: string) => {
|
||||
if (key === "commandExecutionTimeout") return 1 // 1 second timeout
|
||||
if (key === "commandTimeoutAllowlist") return ["npm", "git"]
|
||||
return undefined
|
||||
}),
|
||||
})
|
||||
;(vscode.workspace.getConfiguration as any).mockReturnValue(mockGetConfiguration())
|
||||
|
||||
mockBlock.params.command = "npm install"
|
||||
|
||||
// Create a process that would timeout if not allowlisted
|
||||
const longRunningProcess = new Promise((resolve) => {
|
||||
setTimeout(resolve, 2000) // 2 seconds, longer than 1 second timeout
|
||||
})
|
||||
mockTerminal.runCommand.mockReturnValue(longRunningProcess)
|
||||
|
||||
await executeCommandTool(
|
||||
mockTask as Task,
|
||||
mockBlock,
|
||||
mockAskApproval,
|
||||
mockHandleError,
|
||||
mockPushToolResult,
|
||||
mockRemoveClosingTag,
|
||||
)
|
||||
|
||||
// Should complete successfully without timeout because "npm" is in allowlist
|
||||
expect(mockPushToolResult).toHaveBeenCalled()
|
||||
const result = mockPushToolResult.mock.calls[0][0]
|
||||
expect(result).not.toContain("terminated after exceeding")
|
||||
}, 3000)
|
||||
|
||||
it("should apply timeout for commands not in allowlist", async () => {
|
||||
// Mock VSCode configuration with timeout and allowlist
|
||||
const mockGetConfiguration = vitest.fn().mockReturnValue({
|
||||
get: vitest.fn().mockImplementation((key: string) => {
|
||||
if (key === "commandExecutionTimeout") return 1 // 1 second timeout
|
||||
if (key === "commandTimeoutAllowlist") return ["npm", "git"]
|
||||
return undefined
|
||||
}),
|
||||
})
|
||||
;(vscode.workspace.getConfiguration as any).mockReturnValue(mockGetConfiguration())
|
||||
|
||||
mockBlock.params.command = "sleep 10" // Not in allowlist
|
||||
|
||||
// Create a process that never resolves
|
||||
const neverResolvingProcess = new Promise(() => {})
|
||||
;(neverResolvingProcess as any).abort = vitest.fn()
|
||||
mockTerminal.runCommand.mockReturnValue(neverResolvingProcess)
|
||||
|
||||
await executeCommandTool(
|
||||
mockTask as Task,
|
||||
mockBlock,
|
||||
mockAskApproval,
|
||||
mockHandleError,
|
||||
mockPushToolResult,
|
||||
mockRemoveClosingTag,
|
||||
)
|
||||
|
||||
// Should timeout because "sleep" is not in allowlist
|
||||
expect(mockPushToolResult).toHaveBeenCalled()
|
||||
const result = mockPushToolResult.mock.calls[0][0]
|
||||
expect(result).toContain("terminated after exceeding")
|
||||
}, 3000)
|
||||
|
||||
it("should handle empty allowlist", async () => {
|
||||
// Mock VSCode configuration with timeout and empty allowlist
|
||||
const mockGetConfiguration = vitest.fn().mockReturnValue({
|
||||
get: vitest.fn().mockImplementation((key: string) => {
|
||||
if (key === "commandExecutionTimeout") return 1 // 1 second timeout
|
||||
if (key === "commandTimeoutAllowlist") return []
|
||||
return undefined
|
||||
}),
|
||||
})
|
||||
;(vscode.workspace.getConfiguration as any).mockReturnValue(mockGetConfiguration())
|
||||
|
||||
mockBlock.params.command = "npm install"
|
||||
|
||||
// Create a process that never resolves
|
||||
const neverResolvingProcess = new Promise(() => {})
|
||||
;(neverResolvingProcess as any).abort = vitest.fn()
|
||||
mockTerminal.runCommand.mockReturnValue(neverResolvingProcess)
|
||||
|
||||
await executeCommandTool(
|
||||
mockTask as Task,
|
||||
mockBlock,
|
||||
mockAskApproval,
|
||||
mockHandleError,
|
||||
mockPushToolResult,
|
||||
mockRemoveClosingTag,
|
||||
)
|
||||
|
||||
// Should timeout because allowlist is empty
|
||||
expect(mockPushToolResult).toHaveBeenCalled()
|
||||
const result = mockPushToolResult.mock.calls[0][0]
|
||||
expect(result).toContain("terminated after exceeding")
|
||||
}, 3000)
|
||||
|
||||
it("should match command prefixes correctly", async () => {
|
||||
// Mock VSCode configuration with timeout and allowlist
|
||||
const mockGetConfiguration = vitest.fn().mockReturnValue({
|
||||
get: vitest.fn().mockImplementation((key: string) => {
|
||||
if (key === "commandExecutionTimeout") return 1 // 1 second timeout
|
||||
if (key === "commandTimeoutAllowlist") return ["git log", "npm run"]
|
||||
return undefined
|
||||
}),
|
||||
})
|
||||
;(vscode.workspace.getConfiguration as any).mockReturnValue(mockGetConfiguration())
|
||||
|
||||
const longRunningProcess = new Promise((resolve) => {
|
||||
setTimeout(resolve, 2000) // 2 seconds
|
||||
})
|
||||
const neverResolvingProcess = new Promise(() => {})
|
||||
;(neverResolvingProcess as any).abort = vitest.fn()
|
||||
|
||||
// Test exact prefix match - should not timeout
|
||||
mockBlock.params.command = "git log --oneline"
|
||||
mockTerminal.runCommand.mockReturnValueOnce(longRunningProcess)
|
||||
|
||||
await executeCommandTool(
|
||||
mockTask as Task,
|
||||
mockBlock,
|
||||
mockAskApproval,
|
||||
mockHandleError,
|
||||
mockPushToolResult,
|
||||
mockRemoveClosingTag,
|
||||
)
|
||||
|
||||
expect(mockPushToolResult).toHaveBeenCalled()
|
||||
const result1 = mockPushToolResult.mock.calls[0][0]
|
||||
expect(result1).not.toContain("terminated after exceeding")
|
||||
|
||||
// Reset mocks for second test
|
||||
mockPushToolResult.mockClear()
|
||||
|
||||
// Test partial prefix match (should not match) - should timeout
|
||||
mockBlock.params.command = "git status" // "git" alone is not in allowlist, only "git log"
|
||||
mockTerminal.runCommand.mockReturnValueOnce(neverResolvingProcess)
|
||||
|
||||
await executeCommandTool(
|
||||
mockTask as Task,
|
||||
mockBlock,
|
||||
mockAskApproval,
|
||||
mockHandleError,
|
||||
mockPushToolResult,
|
||||
mockRemoveClosingTag,
|
||||
)
|
||||
|
||||
expect(mockPushToolResult).toHaveBeenCalled()
|
||||
const result2 = mockPushToolResult.mock.calls[0][0]
|
||||
expect(result2).toContain("terminated after exceeding")
|
||||
}, 5000)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -71,6 +71,14 @@ describe("insertContentTool", () => {
|
|||
cwd: "/",
|
||||
consecutiveMistakeCount: 0,
|
||||
didEditFile: false,
|
||||
providerRef: {
|
||||
deref: vi.fn().mockReturnValue({
|
||||
getState: vi.fn().mockResolvedValue({
|
||||
diagnosticsEnabled: true,
|
||||
writeDelayMs: 1000,
|
||||
}),
|
||||
}),
|
||||
},
|
||||
rooIgnoreController: {
|
||||
validateAccess: vi.fn().mockReturnValue(true),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -132,6 +132,14 @@ describe("writeToFileTool", () => {
|
|||
mockCline.consecutiveMistakeCount = 0
|
||||
mockCline.didEditFile = false
|
||||
mockCline.diffStrategy = undefined
|
||||
mockCline.providerRef = {
|
||||
deref: vi.fn().mockReturnValue({
|
||||
getState: vi.fn().mockResolvedValue({
|
||||
diagnosticsEnabled: true,
|
||||
writeDelayMs: 1000,
|
||||
}),
|
||||
}),
|
||||
}
|
||||
mockCline.rooIgnoreController = {
|
||||
validateAccess: vi.fn().mockReturnValue(true),
|
||||
}
|
||||
|
|
@ -376,7 +384,7 @@ describe("writeToFileTool", () => {
|
|||
userEdits: userEditsValue,
|
||||
finalContent: "modified content",
|
||||
})
|
||||
// Manually set the property on the mock instance because the original saveChanges is not called
|
||||
// Set the userEdits property on the diffViewProvider mock to simulate user edits
|
||||
mockCline.diffViewProvider.userEdits = userEditsValue
|
||||
|
||||
await executeWriteFileTool({}, { fileExists: true })
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import path from "path"
|
|||
import fs from "fs/promises"
|
||||
|
||||
import { TelemetryService } from "@roo-code/telemetry"
|
||||
import { DEFAULT_WRITE_DELAY_MS } from "@roo-code/types"
|
||||
|
||||
import { ClineSayTool } from "../../shared/ExtensionMessage"
|
||||
import { getReadablePath } from "../../utils/path"
|
||||
|
|
@ -170,7 +171,11 @@ export async function applyDiffToolLegacy(
|
|||
}
|
||||
|
||||
// Call saveChanges to update the DiffViewProvider properties
|
||||
await cline.diffViewProvider.saveChanges()
|
||||
const provider = cline.providerRef.deref()
|
||||
const state = await provider?.getState()
|
||||
const diagnosticsEnabled = state?.diagnosticsEnabled ?? true
|
||||
const writeDelayMs = state?.writeDelayMs ?? DEFAULT_WRITE_DELAY_MS
|
||||
await cline.diffViewProvider.saveChanges(diagnosticsEnabled, writeDelayMs)
|
||||
|
||||
// Track file edit operation
|
||||
if (relPath) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import * as vscode from "vscode"
|
|||
|
||||
import delay from "delay"
|
||||
|
||||
import { CommandExecutionStatus } from "@roo-code/types"
|
||||
import { CommandExecutionStatus, DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT } from "@roo-code/types"
|
||||
import { TelemetryService } from "@roo-code/telemetry"
|
||||
|
||||
import { Task } from "../task/Task"
|
||||
|
|
@ -63,15 +63,27 @@ export async function executeCommandTool(
|
|||
const executionId = cline.lastMessageTs?.toString() ?? Date.now().toString()
|
||||
const clineProvider = await cline.providerRef.deref()
|
||||
const clineProviderState = await clineProvider?.getState()
|
||||
const { terminalOutputLineLimit = 500, terminalShellIntegrationDisabled = false } = clineProviderState ?? {}
|
||||
const {
|
||||
terminalOutputLineLimit = 500,
|
||||
terminalOutputCharacterLimit = DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT,
|
||||
terminalShellIntegrationDisabled = false,
|
||||
} = clineProviderState ?? {}
|
||||
|
||||
// Get command execution timeout from VSCode configuration (in seconds)
|
||||
const commandExecutionTimeoutSeconds = vscode.workspace
|
||||
.getConfiguration(Package.name)
|
||||
.get<number>("commandExecutionTimeout", 0)
|
||||
|
||||
// Convert seconds to milliseconds for internal use
|
||||
const commandExecutionTimeout = commandExecutionTimeoutSeconds * 1000
|
||||
// Get command timeout allowlist from VSCode configuration
|
||||
const commandTimeoutAllowlist = vscode.workspace
|
||||
.getConfiguration(Package.name)
|
||||
.get<string[]>("commandTimeoutAllowlist", [])
|
||||
|
||||
// Check if command matches any prefix in the allowlist
|
||||
const isCommandAllowlisted = commandTimeoutAllowlist.some((prefix) => command!.startsWith(prefix.trim()))
|
||||
|
||||
// Convert seconds to milliseconds for internal use, but skip timeout if command is allowlisted
|
||||
const commandExecutionTimeout = isCommandAllowlisted ? 0 : commandExecutionTimeoutSeconds * 1000
|
||||
|
||||
const options: ExecuteCommandOptions = {
|
||||
executionId,
|
||||
|
|
@ -79,6 +91,7 @@ export async function executeCommandTool(
|
|||
customCwd,
|
||||
terminalShellIntegrationDisabled,
|
||||
terminalOutputLineLimit,
|
||||
terminalOutputCharacterLimit,
|
||||
commandExecutionTimeout,
|
||||
}
|
||||
|
||||
|
|
@ -125,6 +138,7 @@ export type ExecuteCommandOptions = {
|
|||
customCwd?: string
|
||||
terminalShellIntegrationDisabled?: boolean
|
||||
terminalOutputLineLimit?: number
|
||||
terminalOutputCharacterLimit?: number
|
||||
commandExecutionTimeout?: number
|
||||
}
|
||||
|
||||
|
|
@ -136,6 +150,7 @@ export async function executeCommand(
|
|||
customCwd,
|
||||
terminalShellIntegrationDisabled = false,
|
||||
terminalOutputLineLimit = 500,
|
||||
terminalOutputCharacterLimit = DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT,
|
||||
commandExecutionTimeout = 0,
|
||||
}: ExecuteCommandOptions,
|
||||
): Promise<[boolean, ToolResponse]> {
|
||||
|
|
@ -171,7 +186,11 @@ export async function executeCommand(
|
|||
const callbacks: RooTerminalCallbacks = {
|
||||
onLine: async (lines: string, process: RooTerminalProcess) => {
|
||||
accumulatedOutput += lines
|
||||
const compressedOutput = Terminal.compressTerminalOutput(accumulatedOutput, terminalOutputLineLimit)
|
||||
const compressedOutput = Terminal.compressTerminalOutput(
|
||||
accumulatedOutput,
|
||||
terminalOutputLineLimit,
|
||||
terminalOutputCharacterLimit,
|
||||
)
|
||||
const status: CommandExecutionStatus = { executionId, status: "output", output: compressedOutput }
|
||||
clineProvider?.postMessageToWebview({ type: "commandExecutionStatus", text: JSON.stringify(status) })
|
||||
|
||||
|
|
@ -190,7 +209,11 @@ export async function executeCommand(
|
|||
} catch (_error) {}
|
||||
},
|
||||
onCompleted: (output: string | undefined) => {
|
||||
result = Terminal.compressTerminalOutput(output ?? "", terminalOutputLineLimit)
|
||||
result = Terminal.compressTerminalOutput(
|
||||
output ?? "",
|
||||
terminalOutputLineLimit,
|
||||
terminalOutputCharacterLimit,
|
||||
)
|
||||
cline.say("command_output", result)
|
||||
completed = true
|
||||
},
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { ClineSayTool } from "../../shared/ExtensionMessage"
|
|||
import { RecordSource } from "../context-tracking/FileContextTrackerTypes"
|
||||
import { fileExistsAtPath } from "../../utils/fs"
|
||||
import { insertGroups } from "../diff/insert-groups"
|
||||
import { DEFAULT_WRITE_DELAY_MS } from "@roo-code/types"
|
||||
|
||||
export async function insertContentTool(
|
||||
cline: Task,
|
||||
|
|
@ -155,7 +156,11 @@ export async function insertContentTool(
|
|||
}
|
||||
|
||||
// Call saveChanges to update the DiffViewProvider properties
|
||||
await cline.diffViewProvider.saveChanges()
|
||||
const provider = cline.providerRef.deref()
|
||||
const state = await provider?.getState()
|
||||
const diagnosticsEnabled = state?.diagnosticsEnabled ?? true
|
||||
const writeDelayMs = state?.writeDelayMs ?? DEFAULT_WRITE_DELAY_MS
|
||||
await cline.diffViewProvider.saveChanges(diagnosticsEnabled, writeDelayMs)
|
||||
|
||||
// Track file edit operation
|
||||
if (relPath) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import path from "path"
|
|||
import fs from "fs/promises"
|
||||
|
||||
import { TelemetryService } from "@roo-code/telemetry"
|
||||
import { DEFAULT_WRITE_DELAY_MS } from "@roo-code/types"
|
||||
|
||||
import { ClineSayTool } from "../../shared/ExtensionMessage"
|
||||
import { getReadablePath } from "../../utils/path"
|
||||
|
|
@ -553,7 +554,11 @@ ${errorDetails ? `\nTechnical details:\n${errorDetails}\n` : ""}
|
|||
}
|
||||
|
||||
// Call saveChanges to update the DiffViewProvider properties
|
||||
await cline.diffViewProvider.saveChanges()
|
||||
const provider = cline.providerRef.deref()
|
||||
const state = await provider?.getState()
|
||||
const diagnosticsEnabled = state?.diagnosticsEnabled ?? true
|
||||
const writeDelayMs = state?.writeDelayMs ?? DEFAULT_WRITE_DELAY_MS
|
||||
await cline.diffViewProvider.saveChanges(diagnosticsEnabled, writeDelayMs)
|
||||
|
||||
// Track file edit operation
|
||||
await cline.fileContextTracker.trackFileContext(relPath, "roo_edited" as RecordSource)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import { ClineSayTool } from "../../shared/ExtensionMessage"
|
|||
import { getReadablePath } from "../../utils/path"
|
||||
import { fileExistsAtPath } from "../../utils/fs"
|
||||
import { RecordSource } from "../context-tracking/FileContextTrackerTypes"
|
||||
import { DEFAULT_WRITE_DELAY_MS } from "@roo-code/types"
|
||||
|
||||
/**
|
||||
* Tool for performing search and replace operations on files
|
||||
|
|
@ -227,7 +228,11 @@ export async function searchAndReplaceTool(
|
|||
}
|
||||
|
||||
// Call saveChanges to update the DiffViewProvider properties
|
||||
await cline.diffViewProvider.saveChanges()
|
||||
const provider = cline.providerRef.deref()
|
||||
const state = await provider?.getState()
|
||||
const diagnosticsEnabled = state?.diagnosticsEnabled ?? true
|
||||
const writeDelayMs = state?.writeDelayMs ?? DEFAULT_WRITE_DELAY_MS
|
||||
await cline.diffViewProvider.saveChanges(diagnosticsEnabled, writeDelayMs)
|
||||
|
||||
// Track file edit operation
|
||||
if (relPath) {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import { getReadablePath } from "../../utils/path"
|
|||
import { isPathOutsideWorkspace } from "../../utils/pathUtils"
|
||||
import { detectCodeOmission } from "../../integrations/editor/detect-omission"
|
||||
import { unescapeHtmlEntities } from "../../utils/text-normalization"
|
||||
import { DEFAULT_WRITE_DELAY_MS } from "@roo-code/types"
|
||||
|
||||
export async function writeToFileTool(
|
||||
cline: Task,
|
||||
|
|
@ -213,7 +214,11 @@ export async function writeToFileTool(
|
|||
}
|
||||
|
||||
// Call saveChanges to update the DiffViewProvider properties
|
||||
await cline.diffViewProvider.saveChanges()
|
||||
const provider = cline.providerRef.deref()
|
||||
const state = await provider?.getState()
|
||||
const diagnosticsEnabled = state?.diagnosticsEnabled ?? true
|
||||
const writeDelayMs = state?.writeDelayMs ?? DEFAULT_WRITE_DELAY_MS
|
||||
await cline.diffViewProvider.saveChanges(diagnosticsEnabled, writeDelayMs)
|
||||
|
||||
// Track file edit operation
|
||||
if (relPath) {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import {
|
|||
openRouterDefaultModelId,
|
||||
glamaDefaultModelId,
|
||||
ORGANIZATION_ALLOW_ALL,
|
||||
DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT,
|
||||
} from "@roo-code/types"
|
||||
import { TelemetryService } from "@roo-code/telemetry"
|
||||
import { CloudService, getRooCodeApiUrl } from "@roo-code/cloud"
|
||||
|
|
@ -42,6 +43,7 @@ import { ExtensionMessage, MarketplaceInstalledMetadata } from "../../shared/Ext
|
|||
import { Mode, defaultModeSlug } from "../../shared/modes"
|
||||
import { experimentDefault, experiments, EXPERIMENT_IDS } from "../../shared/experiments"
|
||||
import { formatLanguage } from "../../shared/language"
|
||||
import { DEFAULT_WRITE_DELAY_MS } from "@roo-code/types"
|
||||
import { Terminal } from "../../integrations/terminal/Terminal"
|
||||
import { downloadTask } from "../../integrations/misc/export-markdown"
|
||||
import { getTheme } from "../../integrations/theme/getTheme"
|
||||
|
|
@ -1392,6 +1394,7 @@ export class ClineProvider
|
|||
cachedChromeHostUrl,
|
||||
writeDelayMs,
|
||||
terminalOutputLineLimit,
|
||||
terminalOutputCharacterLimit,
|
||||
terminalShellIntegrationTimeout,
|
||||
terminalShellIntegrationDisabled,
|
||||
terminalCommandDelay,
|
||||
|
|
@ -1436,6 +1439,7 @@ export class ClineProvider
|
|||
profileThresholds,
|
||||
alwaysAllowFollowupQuestions,
|
||||
followupAutoApproveTimeoutMs,
|
||||
diagnosticsEnabled,
|
||||
} = await this.getState()
|
||||
|
||||
const telemetryKey = process.env.POSTHOG_API_KEY
|
||||
|
|
@ -1489,8 +1493,9 @@ export class ClineProvider
|
|||
remoteBrowserHost,
|
||||
remoteBrowserEnabled: remoteBrowserEnabled ?? false,
|
||||
cachedChromeHostUrl: cachedChromeHostUrl,
|
||||
writeDelayMs: writeDelayMs ?? 1000,
|
||||
writeDelayMs: writeDelayMs ?? DEFAULT_WRITE_DELAY_MS,
|
||||
terminalOutputLineLimit: terminalOutputLineLimit ?? 500,
|
||||
terminalOutputCharacterLimit: terminalOutputCharacterLimit ?? DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT,
|
||||
terminalShellIntegrationTimeout: terminalShellIntegrationTimeout ?? Terminal.defaultShellIntegrationTimeout,
|
||||
terminalShellIntegrationDisabled: terminalShellIntegrationDisabled ?? false,
|
||||
terminalCommandDelay: terminalCommandDelay ?? 0,
|
||||
|
|
@ -1555,6 +1560,7 @@ export class ClineProvider
|
|||
hasOpenedModeSelector: this.getGlobalState("hasOpenedModeSelector") ?? false,
|
||||
alwaysAllowFollowupQuestions: alwaysAllowFollowupQuestions ?? false,
|
||||
followupAutoApproveTimeoutMs: followupAutoApproveTimeoutMs ?? 60000,
|
||||
diagnosticsEnabled: diagnosticsEnabled ?? true,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1638,6 +1644,7 @@ export class ClineProvider
|
|||
alwaysAllowFollowupQuestions: stateValues.alwaysAllowFollowupQuestions ?? false,
|
||||
alwaysAllowUpdateTodoList: stateValues.alwaysAllowUpdateTodoList ?? false,
|
||||
followupAutoApproveTimeoutMs: stateValues.followupAutoApproveTimeoutMs ?? 60000,
|
||||
diagnosticsEnabled: stateValues.diagnosticsEnabled ?? true,
|
||||
allowedMaxRequests: stateValues.allowedMaxRequests,
|
||||
autoCondenseContext: stateValues.autoCondenseContext ?? true,
|
||||
autoCondenseContextPercent: stateValues.autoCondenseContextPercent ?? 100,
|
||||
|
|
@ -1656,8 +1663,10 @@ export class ClineProvider
|
|||
remoteBrowserEnabled: stateValues.remoteBrowserEnabled ?? false,
|
||||
cachedChromeHostUrl: stateValues.cachedChromeHostUrl as string | undefined,
|
||||
fuzzyMatchThreshold: stateValues.fuzzyMatchThreshold ?? 1.0,
|
||||
writeDelayMs: stateValues.writeDelayMs ?? 1000,
|
||||
writeDelayMs: stateValues.writeDelayMs ?? DEFAULT_WRITE_DELAY_MS,
|
||||
terminalOutputLineLimit: stateValues.terminalOutputLineLimit ?? 500,
|
||||
terminalOutputCharacterLimit:
|
||||
stateValues.terminalOutputCharacterLimit ?? DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT,
|
||||
terminalShellIntegrationTimeout:
|
||||
stateValues.terminalShellIntegrationTimeout ?? Terminal.defaultShellIntegrationTimeout,
|
||||
terminalShellIntegrationDisabled: stateValues.terminalShellIntegrationDisabled ?? false,
|
||||
|
|
|
|||
|
|
@ -540,6 +540,7 @@ describe("ClineProvider", () => {
|
|||
sharingEnabled: false,
|
||||
profileThresholds: {},
|
||||
hasOpenedModeSelector: false,
|
||||
diagnosticsEnabled: true,
|
||||
}
|
||||
|
||||
const message: ExtensionMessage = {
|
||||
|
|
|
|||
|
|
@ -1044,10 +1044,35 @@ export const webviewMessageHandler = async (
|
|||
await updateGlobalState("writeDelayMs", message.value)
|
||||
await provider.postStateToWebview()
|
||||
break
|
||||
case "terminalOutputLineLimit":
|
||||
await updateGlobalState("terminalOutputLineLimit", message.value)
|
||||
case "diagnosticsEnabled":
|
||||
await updateGlobalState("diagnosticsEnabled", message.bool ?? true)
|
||||
await provider.postStateToWebview()
|
||||
break
|
||||
case "terminalOutputLineLimit":
|
||||
// Validate that the line limit is a positive number
|
||||
const lineLimit = message.value
|
||||
if (typeof lineLimit === "number" && lineLimit > 0) {
|
||||
await updateGlobalState("terminalOutputLineLimit", lineLimit)
|
||||
await provider.postStateToWebview()
|
||||
} else {
|
||||
vscode.window.showErrorMessage(
|
||||
t("common:errors.invalid_line_limit") || "Terminal output line limit must be a positive number",
|
||||
)
|
||||
}
|
||||
break
|
||||
case "terminalOutputCharacterLimit":
|
||||
// Validate that the character limit is a positive number
|
||||
const charLimit = message.value
|
||||
if (typeof charLimit === "number" && charLimit > 0) {
|
||||
await updateGlobalState("terminalOutputCharacterLimit", charLimit)
|
||||
await provider.postStateToWebview()
|
||||
} else {
|
||||
vscode.window.showErrorMessage(
|
||||
t("common:errors.invalid_character_limit") ||
|
||||
"Terminal output character limit must be a positive number",
|
||||
)
|
||||
}
|
||||
break
|
||||
case "terminalShellIntegrationTimeout":
|
||||
await updateGlobalState("terminalShellIntegrationTimeout", message.value)
|
||||
await provider.postStateToWebview()
|
||||
|
|
@ -1257,6 +1282,11 @@ export const webviewMessageHandler = async (
|
|||
await provider.postStateToWebview()
|
||||
break
|
||||
case "updateCondensingPrompt":
|
||||
// Store the condensing prompt in customSupportPrompts["CONDENSE"] instead of customCondensingPrompt
|
||||
const currentSupportPrompts = getGlobalState("customSupportPrompts") ?? {}
|
||||
const updatedSupportPrompts = { ...currentSupportPrompts, CONDENSE: message.text }
|
||||
await updateGlobalState("customSupportPrompts", updatedSupportPrompts)
|
||||
// Also update the old field for backward compatibility during migration
|
||||
await updateGlobalState("customCondensingPrompt", message.text)
|
||||
await provider.postStateToWebview()
|
||||
break
|
||||
|
|
@ -2051,6 +2081,12 @@ export const webviewMessageHandler = async (
|
|||
settings.codebaseIndexGeminiApiKey,
|
||||
)
|
||||
}
|
||||
if (settings.codebaseIndexMistralApiKey !== undefined) {
|
||||
await provider.contextProxy.storeSecret(
|
||||
"codebaseIndexMistralApiKey",
|
||||
settings.codebaseIndexMistralApiKey,
|
||||
)
|
||||
}
|
||||
|
||||
// Send success response first - settings are saved regardless of validation
|
||||
await provider.postMessageToWebview({
|
||||
|
|
@ -2143,6 +2179,7 @@ export const webviewMessageHandler = async (
|
|||
"codebaseIndexOpenAiCompatibleApiKey",
|
||||
))
|
||||
const hasGeminiApiKey = !!(await provider.context.secrets.get("codebaseIndexGeminiApiKey"))
|
||||
const hasMistralApiKey = !!(await provider.context.secrets.get("codebaseIndexMistralApiKey"))
|
||||
|
||||
provider.postMessageToWebview({
|
||||
type: "codeIndexSecretStatus",
|
||||
|
|
@ -2151,6 +2188,7 @@ export const webviewMessageHandler = async (
|
|||
hasQdrantApiKey,
|
||||
hasOpenAiCompatibleApiKey,
|
||||
hasGeminiApiKey,
|
||||
hasMistralApiKey,
|
||||
},
|
||||
})
|
||||
break
|
||||
|
|
|
|||
1
src/i18n/locales/ca/embeddings.json
generated
1
src/i18n/locales/ca/embeddings.json
generated
|
|
@ -46,6 +46,7 @@
|
|||
"ollamaConfigMissing": "Falta la configuració d'Ollama per crear l'embedder",
|
||||
"openAiCompatibleConfigMissing": "Falta la configuració compatible amb OpenAI per crear l'embedder",
|
||||
"geminiConfigMissing": "Falta la configuració de Gemini per crear l'embedder",
|
||||
"mistralConfigMissing": "Falta la configuració de Mistral per crear l'embedder",
|
||||
"invalidEmbedderType": "Tipus d'embedder configurat no vàlid: {{embedderProvider}}",
|
||||
"vectorDimensionNotDeterminedOpenAiCompatible": "No s'ha pogut determinar la dimensió del vector per al model '{{modelId}}' amb el proveïdor '{{provider}}'. Assegura't que la 'Dimensió d'incrustació' estigui configurada correctament als paràmetres del proveïdor compatible amb OpenAI.",
|
||||
"vectorDimensionNotDetermined": "No s'ha pogut determinar la dimensió del vector per al model '{{modelId}}' amb el proveïdor '{{provider}}'. Comprova els perfils del model o la configuració.",
|
||||
|
|
|
|||
1
src/i18n/locales/de/embeddings.json
generated
1
src/i18n/locales/de/embeddings.json
generated
|
|
@ -46,6 +46,7 @@
|
|||
"ollamaConfigMissing": "Ollama-Konfiguration fehlt für die Erstellung des Embedders",
|
||||
"openAiCompatibleConfigMissing": "OpenAI-kompatible Konfiguration fehlt für die Erstellung des Embedders",
|
||||
"geminiConfigMissing": "Gemini-Konfiguration fehlt für die Erstellung des Embedders",
|
||||
"mistralConfigMissing": "Mistral-Konfiguration fehlt für die Erstellung des Embedders",
|
||||
"invalidEmbedderType": "Ungültiger Embedder-Typ konfiguriert: {{embedderProvider}}",
|
||||
"vectorDimensionNotDeterminedOpenAiCompatible": "Konnte die Vektordimension für Modell '{{modelId}}' mit Anbieter '{{provider}}' nicht bestimmen. Stelle sicher, dass die 'Embedding-Dimension' in den OpenAI-kompatiblen Anbietereinstellungen korrekt eingestellt ist.",
|
||||
"vectorDimensionNotDetermined": "Konnte die Vektordimension für Modell '{{modelId}}' mit Anbieter '{{provider}}' nicht bestimmen. Überprüfe die Modellprofile oder Konfiguration.",
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@
|
|||
"ollamaConfigMissing": "Ollama configuration missing for embedder creation",
|
||||
"openAiCompatibleConfigMissing": "OpenAI Compatible configuration missing for embedder creation",
|
||||
"geminiConfigMissing": "Gemini configuration missing for embedder creation",
|
||||
"mistralConfigMissing": "Mistral configuration missing for embedder creation",
|
||||
"invalidEmbedderType": "Invalid embedder type configured: {{embedderProvider}}",
|
||||
"vectorDimensionNotDeterminedOpenAiCompatible": "Could not determine vector dimension for model '{{modelId}}' with provider '{{provider}}'. Please ensure the 'Embedding Dimension' is correctly set in the OpenAI-Compatible provider settings.",
|
||||
"vectorDimensionNotDetermined": "Could not determine vector dimension for model '{{modelId}}' with provider '{{provider}}'. Check model profiles or configuration.",
|
||||
|
|
|
|||
1
src/i18n/locales/es/embeddings.json
generated
1
src/i18n/locales/es/embeddings.json
generated
|
|
@ -46,6 +46,7 @@
|
|||
"ollamaConfigMissing": "Falta la configuración de Ollama para crear el incrustador",
|
||||
"openAiCompatibleConfigMissing": "Falta la configuración compatible con OpenAI para crear el incrustador",
|
||||
"geminiConfigMissing": "Falta la configuración de Gemini para crear el incrustador",
|
||||
"mistralConfigMissing": "Falta la configuración de Mistral para la creación del incrustador",
|
||||
"invalidEmbedderType": "Tipo de incrustador configurado inválido: {{embedderProvider}}",
|
||||
"vectorDimensionNotDeterminedOpenAiCompatible": "No se pudo determinar la dimensión del vector para el modelo '{{modelId}}' con el proveedor '{{provider}}'. Asegúrate de que la 'Dimensión de incrustación' esté configurada correctamente en los ajustes del proveedor compatible con OpenAI.",
|
||||
"vectorDimensionNotDetermined": "No se pudo determinar la dimensión del vector para el modelo '{{modelId}}' con el proveedor '{{provider}}'. Verifica los perfiles del modelo o la configuración.",
|
||||
|
|
|
|||
1
src/i18n/locales/fr/embeddings.json
generated
1
src/i18n/locales/fr/embeddings.json
generated
|
|
@ -46,6 +46,7 @@
|
|||
"ollamaConfigMissing": "Configuration Ollama manquante pour la création de l'embedder",
|
||||
"openAiCompatibleConfigMissing": "Configuration compatible OpenAI manquante pour la création de l'embedder",
|
||||
"geminiConfigMissing": "Configuration Gemini manquante pour la création de l'embedder",
|
||||
"mistralConfigMissing": "Configuration Mistral manquante pour la création de l'embedder",
|
||||
"invalidEmbedderType": "Type d'embedder configuré invalide : {{embedderProvider}}",
|
||||
"vectorDimensionNotDeterminedOpenAiCompatible": "Impossible de déterminer la dimension du vecteur pour le modèle '{{modelId}}' avec le fournisseur '{{provider}}'. Assure-toi que la 'Dimension d'embedding' est correctement définie dans les paramètres du fournisseur compatible OpenAI.",
|
||||
"vectorDimensionNotDetermined": "Impossible de déterminer la dimension du vecteur pour le modèle '{{modelId}}' avec le fournisseur '{{provider}}'. Vérifie les profils du modèle ou la configuration.",
|
||||
|
|
|
|||
1
src/i18n/locales/hi/embeddings.json
generated
1
src/i18n/locales/hi/embeddings.json
generated
|
|
@ -46,6 +46,7 @@
|
|||
"ollamaConfigMissing": "एम्बेडर बनाने के लिए Ollama कॉन्फ़िगरेशन गायब है",
|
||||
"openAiCompatibleConfigMissing": "एम्बेडर बनाने के लिए OpenAI संगत कॉन्फ़िगरेशन गायब है",
|
||||
"geminiConfigMissing": "एम्बेडर बनाने के लिए Gemini कॉन्फ़िगरेशन गायब है",
|
||||
"mistralConfigMissing": "एम्बेडर निर्माण के लिए मिस्ट्रल कॉन्फ़िगरेशन गायब है",
|
||||
"invalidEmbedderType": "अमान्य एम्बेडर प्रकार कॉन्फ़िगर किया गया: {{embedderProvider}}",
|
||||
"vectorDimensionNotDeterminedOpenAiCompatible": "प्रदाता '{{provider}}' के साथ मॉडल '{{modelId}}' के लिए वेक्टर आयाम निर्धारित नहीं कर सका। कृपया सुनिश्चित करें कि OpenAI-संगत प्रदाता सेटिंग्स में 'एम्बेडिंग आयाम' सही तरीके से सेट है।",
|
||||
"vectorDimensionNotDetermined": "प्रदाता '{{provider}}' के साथ मॉडल '{{modelId}}' के लिए वेक्टर आयाम निर्धारित नहीं कर सका। मॉडल प्रोफ़ाइल या कॉन्फ़िगरेशन की जांच करें।",
|
||||
|
|
|
|||
1
src/i18n/locales/id/embeddings.json
generated
1
src/i18n/locales/id/embeddings.json
generated
|
|
@ -46,6 +46,7 @@
|
|||
"ollamaConfigMissing": "Konfigurasi Ollama tidak ada untuk membuat embedder",
|
||||
"openAiCompatibleConfigMissing": "Konfigurasi yang kompatibel dengan OpenAI tidak ada untuk membuat embedder",
|
||||
"geminiConfigMissing": "Konfigurasi Gemini tidak ada untuk membuat embedder",
|
||||
"mistralConfigMissing": "Konfigurasi Mistral hilang untuk pembuatan embedder",
|
||||
"invalidEmbedderType": "Tipe embedder yang dikonfigurasi tidak valid: {{embedderProvider}}",
|
||||
"vectorDimensionNotDeterminedOpenAiCompatible": "Tidak dapat menentukan dimensi vektor untuk model '{{modelId}}' dengan penyedia '{{provider}}'. Pastikan 'Dimensi Embedding' diatur dengan benar di pengaturan penyedia yang kompatibel dengan OpenAI.",
|
||||
"vectorDimensionNotDetermined": "Tidak dapat menentukan dimensi vektor untuk model '{{modelId}}' dengan penyedia '{{provider}}'. Periksa profil model atau konfigurasi.",
|
||||
|
|
|
|||
1
src/i18n/locales/it/embeddings.json
generated
1
src/i18n/locales/it/embeddings.json
generated
|
|
@ -46,6 +46,7 @@
|
|||
"ollamaConfigMissing": "Configurazione Ollama mancante per la creazione dell'embedder",
|
||||
"openAiCompatibleConfigMissing": "Configurazione compatibile con OpenAI mancante per la creazione dell'embedder",
|
||||
"geminiConfigMissing": "Configurazione Gemini mancante per la creazione dell'embedder",
|
||||
"mistralConfigMissing": "Configurazione di Mistral mancante per la creazione dell'embedder",
|
||||
"invalidEmbedderType": "Tipo di embedder configurato non valido: {{embedderProvider}}",
|
||||
"vectorDimensionNotDeterminedOpenAiCompatible": "Impossibile determinare la dimensione del vettore per il modello '{{modelId}}' con il provider '{{provider}}'. Assicurati che la 'Dimensione di embedding' sia impostata correttamente nelle impostazioni del provider compatibile con OpenAI.",
|
||||
"vectorDimensionNotDetermined": "Impossibile determinare la dimensione del vettore per il modello '{{modelId}}' con il provider '{{provider}}'. Controlla i profili del modello o la configurazione.",
|
||||
|
|
|
|||
1
src/i18n/locales/ja/embeddings.json
generated
1
src/i18n/locales/ja/embeddings.json
generated
|
|
@ -46,6 +46,7 @@
|
|||
"ollamaConfigMissing": "エンベッダー作成のためのOllama設定がありません",
|
||||
"openAiCompatibleConfigMissing": "エンベッダー作成のためのOpenAI互換設定がありません",
|
||||
"geminiConfigMissing": "エンベッダー作成のためのGemini設定がありません",
|
||||
"mistralConfigMissing": "エンベッダー作成のためのMistral設定がありません",
|
||||
"invalidEmbedderType": "無効なエンベッダータイプが設定されています: {{embedderProvider}}",
|
||||
"vectorDimensionNotDeterminedOpenAiCompatible": "プロバイダー '{{provider}}' のモデル '{{modelId}}' の埋め込み次元を決定できませんでした。OpenAI互換プロバイダー設定で「埋め込み次元」が正しく設定されていることを確認してください。",
|
||||
"vectorDimensionNotDetermined": "プロバイダー '{{provider}}' のモデル '{{modelId}}' の埋め込み次元を決定できませんでした。モデルプロファイルまたは設定を確認してください。",
|
||||
|
|
|
|||
1
src/i18n/locales/ko/embeddings.json
generated
1
src/i18n/locales/ko/embeddings.json
generated
|
|
@ -46,6 +46,7 @@
|
|||
"ollamaConfigMissing": "임베더 생성을 위한 Ollama 구성이 누락되었습니다",
|
||||
"openAiCompatibleConfigMissing": "임베더 생성을 위한 OpenAI 호환 구성이 누락되었습니다",
|
||||
"geminiConfigMissing": "임베더 생성을 위한 Gemini 구성이 누락되었습니다",
|
||||
"mistralConfigMissing": "임베더 생성을 위한 Mistral 구성이 없습니다",
|
||||
"invalidEmbedderType": "잘못된 임베더 유형이 구성되었습니다: {{embedderProvider}}",
|
||||
"vectorDimensionNotDeterminedOpenAiCompatible": "프로바이더 '{{provider}}'의 모델 '{{modelId}}'에 대한 벡터 차원을 결정할 수 없습니다. OpenAI 호환 프로바이더 설정에서 '임베딩 차원'이 올바르게 설정되어 있는지 확인하세요.",
|
||||
"vectorDimensionNotDetermined": "프로바이더 '{{provider}}'의 모델 '{{modelId}}'에 대한 벡터 차원을 결정할 수 없습니다. 모델 프로필 또는 구성을 확인하세요.",
|
||||
|
|
|
|||
1
src/i18n/locales/nl/embeddings.json
generated
1
src/i18n/locales/nl/embeddings.json
generated
|
|
@ -46,6 +46,7 @@
|
|||
"ollamaConfigMissing": "Ollama-configuratie ontbreekt voor het maken van embedder",
|
||||
"openAiCompatibleConfigMissing": "OpenAI-compatibele configuratie ontbreekt voor het maken van embedder",
|
||||
"geminiConfigMissing": "Gemini-configuratie ontbreekt voor het maken van embedder",
|
||||
"mistralConfigMissing": "Mistral-configuratie ontbreekt voor het maken van de embedder",
|
||||
"invalidEmbedderType": "Ongeldig embedder-type geconfigureerd: {{embedderProvider}}",
|
||||
"vectorDimensionNotDeterminedOpenAiCompatible": "Kan de vectordimensie voor model '{{modelId}}' met provider '{{provider}}' niet bepalen. Zorg ervoor dat de 'Embedding Dimensie' correct is ingesteld in de OpenAI-compatibele provider-instellingen.",
|
||||
"vectorDimensionNotDetermined": "Kan de vectordimensie voor model '{{modelId}}' met provider '{{provider}}' niet bepalen. Controleer modelprofielen of configuratie.",
|
||||
|
|
|
|||
1
src/i18n/locales/pl/embeddings.json
generated
1
src/i18n/locales/pl/embeddings.json
generated
|
|
@ -46,6 +46,7 @@
|
|||
"ollamaConfigMissing": "Brak konfiguracji Ollama do utworzenia embeddera",
|
||||
"openAiCompatibleConfigMissing": "Brak konfiguracji kompatybilnej z OpenAI do utworzenia embeddera",
|
||||
"geminiConfigMissing": "Brak konfiguracji Gemini do utworzenia embeddera",
|
||||
"mistralConfigMissing": "Brak konfiguracji Mistral do utworzenia embeddera",
|
||||
"invalidEmbedderType": "Skonfigurowano nieprawidłowy typ embeddera: {{embedderProvider}}",
|
||||
"vectorDimensionNotDeterminedOpenAiCompatible": "Nie można określić wymiaru wektora dla modelu '{{modelId}}' z dostawcą '{{provider}}'. Upewnij się, że 'Wymiar osadzania' jest poprawnie ustawiony w ustawieniach dostawcy kompatybilnego z OpenAI.",
|
||||
"vectorDimensionNotDetermined": "Nie można określić wymiaru wektora dla modelu '{{modelId}}' z dostawcą '{{provider}}'. Sprawdź profile modelu lub konfigurację.",
|
||||
|
|
|
|||
1
src/i18n/locales/pt-BR/embeddings.json
generated
1
src/i18n/locales/pt-BR/embeddings.json
generated
|
|
@ -46,6 +46,7 @@
|
|||
"ollamaConfigMissing": "Configuração do Ollama ausente para criação do embedder",
|
||||
"openAiCompatibleConfigMissing": "Configuração compatível com OpenAI ausente para criação do embedder",
|
||||
"geminiConfigMissing": "Configuração do Gemini ausente para criação do embedder",
|
||||
"mistralConfigMissing": "Configuração do Mistral ausente para a criação do embedder",
|
||||
"invalidEmbedderType": "Tipo de embedder configurado inválido: {{embedderProvider}}",
|
||||
"vectorDimensionNotDeterminedOpenAiCompatible": "Não foi possível determinar a dimensão do vetor para o modelo '{{modelId}}' com o provedor '{{provider}}'. Certifique-se de que a 'Dimensão de Embedding' esteja configurada corretamente nas configurações do provedor compatível com OpenAI.",
|
||||
"vectorDimensionNotDetermined": "Não foi possível determinar a dimensão do vetor para o modelo '{{modelId}}' com o provedor '{{provider}}'. Verifique os perfis do modelo ou a configuração.",
|
||||
|
|
|
|||
1
src/i18n/locales/ru/embeddings.json
generated
1
src/i18n/locales/ru/embeddings.json
generated
|
|
@ -46,6 +46,7 @@
|
|||
"ollamaConfigMissing": "Отсутствует конфигурация Ollama для создания эмбеддера",
|
||||
"openAiCompatibleConfigMissing": "Отсутствует конфигурация, совместимая с OpenAI, для создания эмбеддера",
|
||||
"geminiConfigMissing": "Отсутствует конфигурация Gemini для создания эмбеддера",
|
||||
"mistralConfigMissing": "Конфигурация Mistral отсутствует для создания эмбеддера",
|
||||
"invalidEmbedderType": "Настроен недопустимый тип эмбеддера: {{embedderProvider}}",
|
||||
"vectorDimensionNotDeterminedOpenAiCompatible": "Не удалось определить размерность вектора для модели '{{modelId}}' с провайдером '{{provider}}'. Убедитесь, что 'Размерность эмбеддинга' правильно установлена в настройках провайдера, совместимого с OpenAI.",
|
||||
"vectorDimensionNotDetermined": "Не удалось определить размерность вектора для модели '{{modelId}}' с провайдером '{{provider}}'. Проверьте профили модели или конфигурацию.",
|
||||
|
|
|
|||
1
src/i18n/locales/tr/embeddings.json
generated
1
src/i18n/locales/tr/embeddings.json
generated
|
|
@ -46,6 +46,7 @@
|
|||
"ollamaConfigMissing": "Gömücü oluşturmak için Ollama yapılandırması eksik",
|
||||
"openAiCompatibleConfigMissing": "Gömücü oluşturmak için OpenAI uyumlu yapılandırması eksik",
|
||||
"geminiConfigMissing": "Gömücü oluşturmak için Gemini yapılandırması eksik",
|
||||
"mistralConfigMissing": "Gömücü oluşturmak için Mistral yapılandırması eksik",
|
||||
"invalidEmbedderType": "Geçersiz gömücü türü yapılandırıldı: {{embedderProvider}}",
|
||||
"vectorDimensionNotDeterminedOpenAiCompatible": "'{{provider}}' sağlayıcısı ile '{{modelId}}' modeli için vektör boyutu belirlenemedi. OpenAI uyumlu sağlayıcı ayarlarında 'Gömme Boyutu'nun doğru ayarlandığından emin ol.",
|
||||
"vectorDimensionNotDetermined": "'{{provider}}' sağlayıcısı ile '{{modelId}}' modeli için vektör boyutu belirlenemedi. Model profillerini veya yapılandırmayı kontrol et.",
|
||||
|
|
|
|||
1
src/i18n/locales/vi/embeddings.json
generated
1
src/i18n/locales/vi/embeddings.json
generated
|
|
@ -46,6 +46,7 @@
|
|||
"ollamaConfigMissing": "Thiếu cấu hình Ollama để tạo embedder",
|
||||
"openAiCompatibleConfigMissing": "Thiếu cấu hình tương thích OpenAI để tạo embedder",
|
||||
"geminiConfigMissing": "Thiếu cấu hình Gemini để tạo embedder",
|
||||
"mistralConfigMissing": "Thiếu cấu hình Mistral để tạo trình nhúng",
|
||||
"invalidEmbedderType": "Loại embedder được cấu hình không hợp lệ: {{embedderProvider}}",
|
||||
"vectorDimensionNotDeterminedOpenAiCompatible": "Không thể xác định kích thước vector cho mô hình '{{modelId}}' với nhà cung cấp '{{provider}}'. Hãy đảm bảo 'Kích thước Embedding' được cài đặt đúng trong cài đặt nhà cung cấp tương thích OpenAI.",
|
||||
"vectorDimensionNotDetermined": "Không thể xác định kích thước vector cho mô hình '{{modelId}}' với nhà cung cấp '{{provider}}'. Kiểm tra hồ sơ mô hình hoặc cấu hình.",
|
||||
|
|
|
|||
1
src/i18n/locales/zh-CN/embeddings.json
generated
1
src/i18n/locales/zh-CN/embeddings.json
generated
|
|
@ -46,6 +46,7 @@
|
|||
"ollamaConfigMissing": "创建嵌入器缺少 Ollama 配置",
|
||||
"openAiCompatibleConfigMissing": "创建嵌入器缺少 OpenAI 兼容配置",
|
||||
"geminiConfigMissing": "创建嵌入器缺少 Gemini 配置",
|
||||
"mistralConfigMissing": "创建嵌入器时缺少 Mistral 配置",
|
||||
"invalidEmbedderType": "配置的嵌入器类型无效:{{embedderProvider}}",
|
||||
"vectorDimensionNotDeterminedOpenAiCompatible": "无法确定提供商 '{{provider}}' 的模型 '{{modelId}}' 的向量维度。请确保在 OpenAI 兼容提供商设置中正确设置了「嵌入维度」。",
|
||||
"vectorDimensionNotDetermined": "无法确定提供商 '{{provider}}' 的模型 '{{modelId}}' 的向量维度。请检查模型配置文件或配置。",
|
||||
|
|
|
|||
1
src/i18n/locales/zh-TW/embeddings.json
generated
1
src/i18n/locales/zh-TW/embeddings.json
generated
|
|
@ -46,6 +46,7 @@
|
|||
"ollamaConfigMissing": "建立嵌入器缺少 Ollama 設定",
|
||||
"openAiCompatibleConfigMissing": "建立嵌入器缺少 OpenAI 相容設定",
|
||||
"geminiConfigMissing": "建立嵌入器缺少 Gemini 設定",
|
||||
"mistralConfigMissing": "建立嵌入器時缺少 Mistral 設定",
|
||||
"invalidEmbedderType": "設定的嵌入器類型無效:{{embedderProvider}}",
|
||||
"vectorDimensionNotDeterminedOpenAiCompatible": "無法確定提供商 '{{provider}}' 的模型 '{{modelId}}' 的向量維度。請確保在 OpenAI 相容提供商設定中正確設定了「嵌入維度」。",
|
||||
"vectorDimensionNotDetermined": "無法確定提供商 '{{provider}}' 的模型 '{{modelId}}' 的向量維度。請檢查模型設定檔或設定。",
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import * as fs from "fs/promises"
|
|||
import * as diff from "diff"
|
||||
import stripBom from "strip-bom"
|
||||
import { XMLBuilder } from "fast-xml-parser"
|
||||
import delay from "delay"
|
||||
|
||||
import { createDirectoriesForFile } from "../../utils/fs"
|
||||
import { arePathsEqual, getReadablePath } from "../../utils/path"
|
||||
|
|
@ -11,6 +12,7 @@ import { formatResponse } from "../../core/prompts/responses"
|
|||
import { diagnosticsToProblemsString, getNewDiagnostics } from "../diagnostics"
|
||||
import { ClineSayTool } from "../../shared/ExtensionMessage"
|
||||
import { Task } from "../../core/task/Task"
|
||||
import { DEFAULT_WRITE_DELAY_MS } from "@roo-code/types"
|
||||
|
||||
import { DecorationController } from "./DecorationController"
|
||||
|
||||
|
|
@ -179,7 +181,7 @@ export class DiffViewProvider {
|
|||
}
|
||||
}
|
||||
|
||||
async saveChanges(): Promise<{
|
||||
async saveChanges(diagnosticsEnabled: boolean = true, writeDelayMs: number = DEFAULT_WRITE_DELAY_MS): Promise<{
|
||||
newProblemsMessage: string | undefined
|
||||
userEdits: string | undefined
|
||||
finalContent: string | undefined
|
||||
|
|
@ -214,18 +216,35 @@ export class DiffViewProvider {
|
|||
// and can address them accordingly. If problems don't change immediately after
|
||||
// applying a fix, won't be notified, which is generally fine since the
|
||||
// initial fix is usually correct and it may just take time for linters to catch up.
|
||||
const postDiagnostics = vscode.languages.getDiagnostics()
|
||||
|
||||
let newProblemsMessage = ""
|
||||
|
||||
if (diagnosticsEnabled) {
|
||||
// Add configurable delay to allow linters time to process and clean up issues
|
||||
// like unused imports (especially important for Go and other languages)
|
||||
// Ensure delay is non-negative
|
||||
const safeDelayMs = Math.max(0, writeDelayMs)
|
||||
|
||||
try {
|
||||
await delay(safeDelayMs)
|
||||
} catch (error) {
|
||||
// Log error but continue - delay failure shouldn't break the save operation
|
||||
console.warn(`Failed to apply write delay: ${error}`)
|
||||
}
|
||||
|
||||
const postDiagnostics = vscode.languages.getDiagnostics()
|
||||
|
||||
const newProblems = await diagnosticsToProblemsString(
|
||||
getNewDiagnostics(this.preDiagnostics, postDiagnostics),
|
||||
[
|
||||
vscode.DiagnosticSeverity.Error, // only including errors since warnings can be distracting (if user wants to fix warnings they can use the @problems mention)
|
||||
],
|
||||
this.cwd,
|
||||
) // Will be empty string if no errors.
|
||||
const newProblems = await diagnosticsToProblemsString(
|
||||
getNewDiagnostics(this.preDiagnostics, postDiagnostics),
|
||||
[
|
||||
vscode.DiagnosticSeverity.Error, // only including errors since warnings can be distracting (if user wants to fix warnings they can use the @problems mention)
|
||||
],
|
||||
this.cwd,
|
||||
) // Will be empty string if no errors.
|
||||
|
||||
const newProblemsMessage =
|
||||
newProblems.length > 0 ? `\n\nNew problems detected after saving the file:\n${newProblems}` : ""
|
||||
newProblemsMessage =
|
||||
newProblems.length > 0 ? `\n\nNew problems detected after saving the file:\n${newProblems}` : ""
|
||||
}
|
||||
|
||||
// If the edited content has different EOL characters, we don't want to
|
||||
// show a diff with all the EOL differences.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
import { DiffViewProvider, DIFF_VIEW_URI_SCHEME, DIFF_VIEW_LABEL_CHANGES } from "../DiffViewProvider"
|
||||
import * as vscode from "vscode"
|
||||
import * as path from "path"
|
||||
import delay from "delay"
|
||||
|
||||
// Mock delay
|
||||
vi.mock("delay", () => ({
|
||||
default: vi.fn().mockResolvedValue(undefined),
|
||||
}))
|
||||
|
||||
// Mock fs/promises
|
||||
vi.mock("fs/promises", () => ({
|
||||
|
|
@ -45,6 +51,12 @@ vi.mock("vscode", () => ({
|
|||
languages: {
|
||||
getDiagnostics: vi.fn(() => []),
|
||||
},
|
||||
DiagnosticSeverity: {
|
||||
Error: 0,
|
||||
Warning: 1,
|
||||
Information: 2,
|
||||
Hint: 3,
|
||||
},
|
||||
WorkspaceEdit: vi.fn().mockImplementation(() => ({
|
||||
replace: vi.fn(),
|
||||
delete: vi.fn(),
|
||||
|
|
@ -327,4 +339,83 @@ describe("DiffViewProvider", () => {
|
|||
).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe("saveChanges method with diagnostic settings", () => {
|
||||
beforeEach(() => {
|
||||
// Setup common mocks for saveChanges tests
|
||||
;(diffViewProvider as any).relPath = "test.ts"
|
||||
;(diffViewProvider as any).newContent = "new content"
|
||||
;(diffViewProvider as any).activeDiffEditor = {
|
||||
document: {
|
||||
getText: vi.fn().mockReturnValue("new content"),
|
||||
isDirty: false,
|
||||
save: vi.fn().mockResolvedValue(undefined),
|
||||
},
|
||||
}
|
||||
;(diffViewProvider as any).preDiagnostics = []
|
||||
|
||||
// Mock vscode functions
|
||||
vi.mocked(vscode.window.showTextDocument).mockResolvedValue({} as any)
|
||||
vi.mocked(vscode.languages.getDiagnostics).mockReturnValue([])
|
||||
})
|
||||
|
||||
it("should apply diagnostic delay when diagnosticsEnabled is true", async () => {
|
||||
const mockDelay = vi.mocked(delay)
|
||||
mockDelay.mockClear()
|
||||
|
||||
// Mock closeAllDiffViews
|
||||
;(diffViewProvider as any).closeAllDiffViews = vi.fn().mockResolvedValue(undefined)
|
||||
|
||||
const result = await diffViewProvider.saveChanges(true, 3000)
|
||||
|
||||
// Verify delay was called with correct duration
|
||||
expect(mockDelay).toHaveBeenCalledWith(3000)
|
||||
expect(vscode.languages.getDiagnostics).toHaveBeenCalled()
|
||||
expect(result.newProblemsMessage).toBe("")
|
||||
})
|
||||
|
||||
it("should skip diagnostics when diagnosticsEnabled is false", async () => {
|
||||
const mockDelay = vi.mocked(delay)
|
||||
mockDelay.mockClear()
|
||||
|
||||
// Mock closeAllDiffViews
|
||||
;(diffViewProvider as any).closeAllDiffViews = vi.fn().mockResolvedValue(undefined)
|
||||
|
||||
const result = await diffViewProvider.saveChanges(false, 2000)
|
||||
|
||||
// Verify delay was NOT called and diagnostics were NOT checked
|
||||
expect(mockDelay).not.toHaveBeenCalled()
|
||||
expect(vscode.languages.getDiagnostics).not.toHaveBeenCalled()
|
||||
expect(result.newProblemsMessage).toBe("")
|
||||
})
|
||||
|
||||
it("should use default values when no parameters provided", async () => {
|
||||
const mockDelay = vi.mocked(delay)
|
||||
mockDelay.mockClear()
|
||||
|
||||
// Mock closeAllDiffViews
|
||||
;(diffViewProvider as any).closeAllDiffViews = vi.fn().mockResolvedValue(undefined)
|
||||
|
||||
const result = await diffViewProvider.saveChanges()
|
||||
|
||||
// Verify default behavior (enabled=true, delay=2000ms)
|
||||
expect(mockDelay).toHaveBeenCalledWith(1000)
|
||||
expect(vscode.languages.getDiagnostics).toHaveBeenCalled()
|
||||
expect(result.newProblemsMessage).toBe("")
|
||||
})
|
||||
|
||||
it("should handle custom delay values", async () => {
|
||||
const mockDelay = vi.mocked(delay)
|
||||
mockDelay.mockClear()
|
||||
|
||||
// Mock closeAllDiffViews
|
||||
;(diffViewProvider as any).closeAllDiffViews = vi.fn().mockResolvedValue(undefined)
|
||||
|
||||
const result = await diffViewProvider.saveChanges(true, 5000)
|
||||
|
||||
// Verify custom delay was used
|
||||
expect(mockDelay).toHaveBeenCalledWith(5000)
|
||||
expect(vscode.languages.getDiagnostics).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -306,6 +306,197 @@ describe("truncateOutput", () => {
|
|||
const expectedLines = ["line1", "", "[...10 lines omitted...]", "", "line12", "line13", "line14", "line15"]
|
||||
expect(resultLines).toEqual(expectedLines)
|
||||
})
|
||||
|
||||
describe("character limit functionality", () => {
|
||||
it("returns original content when no character limit provided", () => {
|
||||
const content = "a".repeat(1000)
|
||||
expect(truncateOutput(content, undefined, undefined)).toBe(content)
|
||||
})
|
||||
|
||||
it("returns original content when characters are under limit", () => {
|
||||
const content = "a".repeat(100)
|
||||
expect(truncateOutput(content, undefined, 200)).toBe(content)
|
||||
})
|
||||
|
||||
it("truncates content by character limit with 20/80 split", () => {
|
||||
// Create content with 1000 characters
|
||||
const content = "a".repeat(1000)
|
||||
|
||||
// Set character limit to 100
|
||||
const result = truncateOutput(content, undefined, 100)
|
||||
|
||||
// Should keep:
|
||||
// - First 20 characters (20% of 100)
|
||||
// - Last 80 characters (80% of 100)
|
||||
// - Omission indicator in between
|
||||
const expectedStart = "a".repeat(20)
|
||||
const expectedEnd = "a".repeat(80)
|
||||
const expected = expectedStart + "\n[...900 characters omitted...]\n" + expectedEnd
|
||||
|
||||
expect(result).toBe(expected)
|
||||
})
|
||||
|
||||
it("prioritizes character limit over line limit", () => {
|
||||
// Create content with few lines but many characters per line
|
||||
const longLine = "a".repeat(500)
|
||||
const content = `${longLine}\n${longLine}\n${longLine}`
|
||||
|
||||
// Set both limits - character limit should take precedence
|
||||
const result = truncateOutput(content, 10, 100)
|
||||
|
||||
// Should truncate by character limit, not line limit
|
||||
const expectedStart = "a".repeat(20)
|
||||
const expectedEnd = "a".repeat(80)
|
||||
// Total content: 1502 chars, limit: 100, so 1402 chars omitted
|
||||
const expected = expectedStart + "\n[...1402 characters omitted...]\n" + expectedEnd
|
||||
|
||||
expect(result).toBe(expected)
|
||||
})
|
||||
|
||||
it("falls back to line limit when character limit is satisfied", () => {
|
||||
// Create content with many short lines
|
||||
const lines = Array.from({ length: 25 }, (_, i) => `line${i + 1}`)
|
||||
const content = lines.join("\n")
|
||||
|
||||
// Character limit is high enough, so line limit should apply
|
||||
const result = truncateOutput(content, 10, 10000)
|
||||
|
||||
// Should truncate by line limit
|
||||
const expectedLines = [
|
||||
"line1",
|
||||
"line2",
|
||||
"",
|
||||
"[...15 lines omitted...]",
|
||||
"",
|
||||
"line18",
|
||||
"line19",
|
||||
"line20",
|
||||
"line21",
|
||||
"line22",
|
||||
"line23",
|
||||
"line24",
|
||||
"line25",
|
||||
]
|
||||
expect(result).toBe(expectedLines.join("\n"))
|
||||
})
|
||||
|
||||
it("handles edge case where character limit equals content length", () => {
|
||||
const content = "exactly100chars".repeat(6) + "1234" // exactly 100 chars
|
||||
const result = truncateOutput(content, undefined, 100)
|
||||
expect(result).toBe(content)
|
||||
})
|
||||
|
||||
it("handles very small character limits", () => {
|
||||
const content = "a".repeat(1000)
|
||||
const result = truncateOutput(content, undefined, 10)
|
||||
|
||||
// 20% of 10 = 2, 80% of 10 = 8
|
||||
const expected = "aa\n[...990 characters omitted...]\n" + "a".repeat(8)
|
||||
expect(result).toBe(expected)
|
||||
})
|
||||
|
||||
it("handles character limit with mixed content", () => {
|
||||
const content = "Hello world! This is a test with mixed content including numbers 123 and symbols @#$%"
|
||||
const result = truncateOutput(content, undefined, 50)
|
||||
|
||||
// 20% of 50 = 10, 80% of 50 = 40
|
||||
const expectedStart = content.slice(0, 10) // "Hello worl"
|
||||
const expectedEnd = content.slice(-40) // last 40 chars
|
||||
const omittedChars = content.length - 50
|
||||
const expected = expectedStart + `\n[...${omittedChars} characters omitted...]\n` + expectedEnd
|
||||
|
||||
expect(result).toBe(expected)
|
||||
})
|
||||
|
||||
describe("edge cases with very small character limits", () => {
|
||||
it("handles character limit of 1", () => {
|
||||
const content = "abcdefghijklmnopqrstuvwxyz"
|
||||
const result = truncateOutput(content, undefined, 1)
|
||||
|
||||
// 20% of 1 = 0.2 (floor = 0), so beforeLimit = 0
|
||||
// afterLimit = 1 - 0 = 1
|
||||
// Should keep 0 chars from start and 1 char from end
|
||||
const expected = "\n[...25 characters omitted...]\nz"
|
||||
expect(result).toBe(expected)
|
||||
})
|
||||
|
||||
it("handles character limit of 2", () => {
|
||||
const content = "abcdefghijklmnopqrstuvwxyz"
|
||||
const result = truncateOutput(content, undefined, 2)
|
||||
|
||||
// 20% of 2 = 0.4 (floor = 0), so beforeLimit = 0
|
||||
// afterLimit = 2 - 0 = 2
|
||||
// Should keep 0 chars from start and 2 chars from end
|
||||
const expected = "\n[...24 characters omitted...]\nyz"
|
||||
expect(result).toBe(expected)
|
||||
})
|
||||
|
||||
it("handles character limit of 5", () => {
|
||||
const content = "abcdefghijklmnopqrstuvwxyz"
|
||||
const result = truncateOutput(content, undefined, 5)
|
||||
|
||||
// 20% of 5 = 1, so beforeLimit = 1
|
||||
// afterLimit = 5 - 1 = 4
|
||||
// Should keep 1 char from start and 4 chars from end
|
||||
const expected = "a\n[...21 characters omitted...]\nwxyz"
|
||||
expect(result).toBe(expected)
|
||||
})
|
||||
|
||||
it("handles character limit with multi-byte characters", () => {
|
||||
const content = "🚀🎉🔥💻🌟🎨🎯🎪🎭🎬" // 10 emojis, each is multi-byte
|
||||
const result = truncateOutput(content, undefined, 10)
|
||||
|
||||
// Character limit works on string length, not byte count
|
||||
// 20% of 10 = 2, 80% of 10 = 8
|
||||
// Note: In JavaScript, each emoji is actually 2 characters (surrogate pair)
|
||||
// So the content is actually 20 characters long, not 10
|
||||
const expected = "🚀\n[...10 characters omitted...]\n🎯🎪🎭🎬"
|
||||
expect(result).toBe(expected)
|
||||
})
|
||||
|
||||
it("handles character limit with newlines in content", () => {
|
||||
const content = "line1\nline2\nline3\nline4\nline5"
|
||||
const result = truncateOutput(content, undefined, 15)
|
||||
|
||||
// Total length is 29 chars (including newlines)
|
||||
// 20% of 15 = 3, 80% of 15 = 12
|
||||
// The slice will take first 3 chars: "lin"
|
||||
// And last 12 chars: "e4\nline5" (counting backwards)
|
||||
const expected = "lin\n[...14 characters omitted...]\n\nline4\nline5"
|
||||
expect(result).toBe(expected)
|
||||
})
|
||||
|
||||
it("handles character limit exactly matching content with omission message", () => {
|
||||
// Edge case: when the omission message would make output longer than original
|
||||
const content = "short"
|
||||
const result = truncateOutput(content, undefined, 10)
|
||||
|
||||
// Content is 5 chars, limit is 10, so no truncation needed
|
||||
expect(result).toBe(content)
|
||||
})
|
||||
|
||||
it("handles character limit smaller than omission message", () => {
|
||||
const content = "a".repeat(100)
|
||||
const result = truncateOutput(content, undefined, 3)
|
||||
|
||||
// 20% of 3 = 0.6 (floor = 0), so beforeLimit = 0
|
||||
// afterLimit = 3 - 0 = 3
|
||||
const expected = "\n[...97 characters omitted...]\naaa"
|
||||
expect(result).toBe(expected)
|
||||
})
|
||||
|
||||
it("prioritizes character limit even with very high line limit", () => {
|
||||
const content = "a".repeat(1000)
|
||||
const result = truncateOutput(content, 999999, 50)
|
||||
|
||||
// Character limit should still apply despite high line limit
|
||||
const expectedStart = "a".repeat(10) // 20% of 50
|
||||
const expectedEnd = "a".repeat(40) // 80% of 50
|
||||
const expected = expectedStart + "\n[...950 characters omitted...]\n" + expectedEnd
|
||||
expect(result).toBe(expected)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("applyRunLengthEncoding", () => {
|
||||
|
|
|
|||
|
|
@ -135,17 +135,58 @@ export function stripLineNumbers(content: string, aggressive: boolean = false):
|
|||
* When truncation is needed, it keeps 20% of the lines from the start and 80% from the end,
|
||||
* with a clear indicator of how many lines were omitted in between.
|
||||
*
|
||||
* IMPORTANT: Character limit takes precedence over line limit. This is because:
|
||||
* 1. Character limit provides a hard cap on memory usage and context window consumption
|
||||
* 2. A single line with millions of characters could bypass line limits and cause issues
|
||||
* 3. Character limit ensures consistent behavior regardless of line structure
|
||||
*
|
||||
* When both limits are specified:
|
||||
* - If content exceeds character limit, character-based truncation is applied (regardless of line count)
|
||||
* - If content is within character limit but exceeds line limit, line-based truncation is applied
|
||||
* - This prevents edge cases where extremely long lines could consume excessive resources
|
||||
*
|
||||
* @param content The multi-line string to truncate
|
||||
* @param lineLimit Optional maximum number of lines to keep. If not provided or 0, returns the original content
|
||||
* @returns The truncated string with an indicator of omitted lines, or the original content if no truncation needed
|
||||
* @param lineLimit Optional maximum number of lines to keep. If not provided or 0, no line limit is applied
|
||||
* @param characterLimit Optional maximum number of characters to keep. If not provided or 0, no character limit is applied
|
||||
* @returns The truncated string with an indicator of omitted content, or the original content if no truncation needed
|
||||
*
|
||||
* @example
|
||||
* // With 10 line limit on 25 lines of content:
|
||||
* // - Keeps first 2 lines (20% of 10)
|
||||
* // - Keeps last 8 lines (80% of 10)
|
||||
* // - Adds "[...15 lines omitted...]" in between
|
||||
*
|
||||
* @example
|
||||
* // With character limit on long single line:
|
||||
* // - Keeps first 20% of characters
|
||||
* // - Keeps last 80% of characters
|
||||
* // - Adds "[...X characters omitted...]" in between
|
||||
*
|
||||
* @example
|
||||
* // Character limit takes precedence:
|
||||
* // content = "A".repeat(50000) + "\n" + "B".repeat(50000) // 2 lines, 100,002 chars
|
||||
* // truncateOutput(content, 10, 40000) // Uses character limit, not line limit
|
||||
* // Result: First ~8000 chars + "[...60002 characters omitted...]" + Last ~32000 chars
|
||||
*/
|
||||
export function truncateOutput(content: string, lineLimit?: number): string {
|
||||
export function truncateOutput(content: string, lineLimit?: number, characterLimit?: number): string {
|
||||
// If no limits are specified, return original content
|
||||
if (!lineLimit && !characterLimit) {
|
||||
return content
|
||||
}
|
||||
|
||||
// Character limit takes priority over line limit
|
||||
if (characterLimit && content.length > characterLimit) {
|
||||
const beforeLimit = Math.floor(characterLimit * 0.2) // 20% of characters before
|
||||
const afterLimit = characterLimit - beforeLimit // remaining 80% after
|
||||
|
||||
const startSection = content.slice(0, beforeLimit)
|
||||
const endSection = content.slice(-afterLimit)
|
||||
const omittedChars = content.length - characterLimit
|
||||
|
||||
return startSection + `\n[...${omittedChars} characters omitted...]\n` + endSection
|
||||
}
|
||||
|
||||
// If character limit is not exceeded or not specified, check line limit
|
||||
if (!lineLimit) {
|
||||
return content
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { truncateOutput, applyRunLengthEncoding, processBackspaces, processCarriageReturns } from "../misc/extract-text"
|
||||
import { DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT } from "@roo-code/types"
|
||||
|
||||
import type {
|
||||
RooTerminalProvider,
|
||||
|
|
@ -262,11 +263,13 @@ export abstract class BaseTerminal implements RooTerminal {
|
|||
}
|
||||
|
||||
/**
|
||||
* Compresses terminal output by applying run-length encoding and truncating to line limit
|
||||
* Compresses terminal output by applying run-length encoding and truncating to line and character limits
|
||||
* @param input The terminal output to compress
|
||||
* @param lineLimit Maximum number of lines to keep
|
||||
* @param characterLimit Optional maximum number of characters to keep (defaults to DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT)
|
||||
* @returns The compressed terminal output
|
||||
*/
|
||||
public static compressTerminalOutput(input: string, lineLimit: number): string {
|
||||
public static compressTerminalOutput(input: string, lineLimit: number, characterLimit?: number): string {
|
||||
let processedInput = input
|
||||
|
||||
if (BaseTerminal.compressProgressBar) {
|
||||
|
|
@ -274,7 +277,10 @@ export abstract class BaseTerminal implements RooTerminal {
|
|||
processedInput = processBackspaces(processedInput)
|
||||
}
|
||||
|
||||
return truncateOutput(applyRunLengthEncoding(processedInput), lineLimit)
|
||||
// Default character limit to prevent context window explosion
|
||||
const effectiveCharLimit = characterLimit ?? DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT
|
||||
|
||||
return truncateOutput(applyRunLengthEncoding(processedInput), lineLimit, effectiveCharLimit)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"displayName": "%extension.displayName%",
|
||||
"description": "%extension.description%",
|
||||
"publisher": "RooVeterinaryInc",
|
||||
"version": "3.23.14",
|
||||
"version": "3.23.16",
|
||||
"icon": "assets/icons/icon.png",
|
||||
"galleryBanner": {
|
||||
"color": "#617A91",
|
||||
|
|
@ -345,6 +345,14 @@
|
|||
"maximum": 600,
|
||||
"description": "%commands.commandExecutionTimeout.description%"
|
||||
},
|
||||
"roo-cline.commandTimeoutAllowlist": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"default": [],
|
||||
"description": "%commands.commandTimeoutAllowlist.description%"
|
||||
},
|
||||
"roo-cline.preventCompletionWithOpenTodos": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
"commands.allowedCommands.description": "Ordres que es poden executar automàticament quan 'Aprova sempre les operacions d'execució' està activat",
|
||||
"commands.deniedCommands.description": "Prefixos d'ordres que seran automàticament denegats sense demanar aprovació. En cas de conflictes amb ordres permeses, la coincidència de prefix més llarga té prioritat. Afegeix * per denegar totes les ordres.",
|
||||
"commands.commandExecutionTimeout.description": "Temps màxim en segons per esperar que l'execució de l'ordre es completi abans d'esgotar el temps (0 = sense temps límit, 1-600s, per defecte: 0s)",
|
||||
"commands.commandTimeoutAllowlist.description": "Prefixos d'ordres que estan exclosos del temps límit d'execució d'ordres. Les ordres que coincideixin amb aquests prefixos s'executaran sense restriccions de temps límit.",
|
||||
"settings.vsCodeLmModelSelector.description": "Configuració per a l'API del model de llenguatge VSCode",
|
||||
"settings.vsCodeLmModelSelector.vendor.description": "El proveïdor del model de llenguatge (p. ex. copilot)",
|
||||
"settings.vsCodeLmModelSelector.family.description": "La família del model de llenguatge (p. ex. gpt-4)",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
"commands.allowedCommands.description": "Befehle, die automatisch ausgeführt werden können, wenn 'Ausführungsoperationen immer genehmigen' aktiviert ist",
|
||||
"commands.deniedCommands.description": "Befehlspräfixe, die automatisch abgelehnt werden, ohne nach Genehmigung zu fragen. Bei Konflikten mit erlaubten Befehlen hat die längste Präfix-Übereinstimmung Vorrang. Füge * hinzu, um alle Befehle abzulehnen.",
|
||||
"commands.commandExecutionTimeout.description": "Maximale Zeit in Sekunden, die auf den Abschluss der Befehlsausführung gewartet wird, bevor ein Timeout auftritt (0 = kein Timeout, 1-600s, Standard: 0s)",
|
||||
"commands.commandTimeoutAllowlist.description": "Befehlspräfixe, die vom Timeout der Befehlsausführung ausgeschlossen sind. Befehle, die diesen Präfixen entsprechen, werden ohne Timeout-Beschränkungen ausgeführt.",
|
||||
"settings.vsCodeLmModelSelector.description": "Einstellungen für die VSCode-Sprachmodell-API",
|
||||
"settings.vsCodeLmModelSelector.vendor.description": "Der Anbieter des Sprachmodells (z.B. copilot)",
|
||||
"settings.vsCodeLmModelSelector.family.description": "Die Familie des Sprachmodells (z.B. gpt-4)",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
"commands.allowedCommands.description": "Comandos que pueden ejecutarse automáticamente cuando 'Aprobar siempre operaciones de ejecución' está activado",
|
||||
"commands.deniedCommands.description": "Prefijos de comandos que serán automáticamente denegados sin solicitar aprobación. En caso de conflictos con comandos permitidos, la coincidencia de prefijo más larga tiene prioridad. Añade * para denegar todos los comandos.",
|
||||
"commands.commandExecutionTimeout.description": "Tiempo máximo en segundos para esperar que se complete la ejecución del comando antes de que expire (0 = sin tiempo límite, 1-600s, predeterminado: 0s)",
|
||||
"commands.commandTimeoutAllowlist.description": "Prefijos de comandos que están excluidos del tiempo límite de ejecución de comandos. Los comandos que coincidan con estos prefijos se ejecutarán sin restricciones de tiempo límite.",
|
||||
"settings.vsCodeLmModelSelector.description": "Configuración para la API del modelo de lenguaje VSCode",
|
||||
"settings.vsCodeLmModelSelector.vendor.description": "El proveedor del modelo de lenguaje (ej. copilot)",
|
||||
"settings.vsCodeLmModelSelector.family.description": "La familia del modelo de lenguaje (ej. gpt-4)",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
"commands.allowedCommands.description": "Commandes pouvant être exécutées automatiquement lorsque 'Toujours approuver les opérations d'exécution' est activé",
|
||||
"commands.deniedCommands.description": "Préfixes de commandes qui seront automatiquement refusés sans demander d'approbation. En cas de conflit avec les commandes autorisées, la correspondance de préfixe la plus longue a la priorité. Ajouter * pour refuser toutes les commandes.",
|
||||
"commands.commandExecutionTimeout.description": "Temps maximum en secondes pour attendre que l'exécution de la commande se termine avant expiration (0 = pas de délai, 1-600s, défaut : 0s)",
|
||||
"commands.commandTimeoutAllowlist.description": "Préfixes de commandes qui sont exclus du délai d'exécution des commandes. Les commandes correspondant à ces préfixes s'exécuteront sans restrictions de délai.",
|
||||
"settings.vsCodeLmModelSelector.description": "Paramètres pour l'API du modèle de langage VSCode",
|
||||
"settings.vsCodeLmModelSelector.vendor.description": "Le fournisseur du modèle de langage (ex: copilot)",
|
||||
"settings.vsCodeLmModelSelector.family.description": "La famille du modèle de langage (ex: gpt-4)",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
"commands.allowedCommands.description": "वे कमांड जो स्वचालित रूप से निष्पादित की जा सकती हैं जब 'हमेशा निष्पादन संचालन को स्वीकृत करें' सक्रिय हो",
|
||||
"commands.deniedCommands.description": "कमांड प्रीफिक्स जो स्वचालित रूप से अस्वीकार कर दिए जाएंगे बिना अनुमोदन मांगे। अनुमतित कमांड के साथ संघर्ष की स्थिति में, सबसे लंबा प्रीफिक्स मैच प्राथमिकता लेता है। सभी कमांड को अस्वीकार करने के लिए * जोड़ें।",
|
||||
"commands.commandExecutionTimeout.description": "कमांड निष्पादन पूरा होने का इंतजार करने के लिए अधिकतम समय सेकंड में, समय समाप्त होने से पहले (0 = कोई समय सीमा नहीं, 1-600s, डिफ़ॉल्ट: 0s)",
|
||||
"commands.commandTimeoutAllowlist.description": "कमांड प्रीफिक्स जो कमांड निष्पादन टाइमआउट से बाहर रखे गए हैं। इन प्रीफिक्स से मेल खाने वाले कमांड बिना टाइमआउट प्रतिबंधों के चलेंगे।",
|
||||
"settings.vsCodeLmModelSelector.description": "VSCode भाषा मॉडल API के लिए सेटिंग्स",
|
||||
"settings.vsCodeLmModelSelector.vendor.description": "भाषा मॉडल का विक्रेता (उदा. copilot)",
|
||||
"settings.vsCodeLmModelSelector.family.description": "भाषा मॉडल का परिवार (उदा. gpt-4)",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
"commands.allowedCommands.description": "Perintah yang dapat dijalankan secara otomatis ketika 'Selalu setujui operasi eksekusi' diaktifkan",
|
||||
"commands.deniedCommands.description": "Awalan perintah yang akan otomatis ditolak tanpa meminta persetujuan. Jika terjadi konflik dengan perintah yang diizinkan, pencocokan awalan terpanjang akan diprioritaskan. Tambahkan * untuk menolak semua perintah.",
|
||||
"commands.commandExecutionTimeout.description": "Waktu maksimum dalam detik untuk menunggu eksekusi perintah selesai sebelum timeout (0 = tanpa timeout, 1-600s, default: 0s)",
|
||||
"commands.commandTimeoutAllowlist.description": "Awalan perintah yang dikecualikan dari timeout eksekusi perintah. Perintah yang cocok dengan awalan ini akan berjalan tanpa batasan timeout.",
|
||||
"settings.vsCodeLmModelSelector.description": "Pengaturan untuk API Model Bahasa VSCode",
|
||||
"settings.vsCodeLmModelSelector.vendor.description": "Vendor dari model bahasa (misalnya copilot)",
|
||||
"settings.vsCodeLmModelSelector.family.description": "Keluarga dari model bahasa (misalnya gpt-4)",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
"commands.allowedCommands.description": "Comandi che possono essere eseguiti automaticamente quando 'Approva sempre le operazioni di esecuzione' è attivato",
|
||||
"commands.deniedCommands.description": "Prefissi di comandi che verranno automaticamente rifiutati senza richiedere approvazione. In caso di conflitti con comandi consentiti, la corrispondenza del prefisso più lungo ha la precedenza. Aggiungi * per rifiutare tutti i comandi.",
|
||||
"commands.commandExecutionTimeout.description": "Tempo massimo in secondi per attendere il completamento dell'esecuzione del comando prima del timeout (0 = nessun timeout, 1-600s, predefinito: 0s)",
|
||||
"commands.commandTimeoutAllowlist.description": "Prefissi di comandi che sono esclusi dal timeout di esecuzione dei comandi. I comandi che corrispondono a questi prefissi verranno eseguiti senza restrizioni di timeout.",
|
||||
"settings.vsCodeLmModelSelector.description": "Impostazioni per l'API del modello linguistico VSCode",
|
||||
"settings.vsCodeLmModelSelector.vendor.description": "Il fornitore del modello linguistico (es. copilot)",
|
||||
"settings.vsCodeLmModelSelector.family.description": "La famiglia del modello linguistico (es. gpt-4)",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
"commands.allowedCommands.description": "'常に実行操作を承認する'が有効な場合に自動実行できるコマンド",
|
||||
"commands.deniedCommands.description": "承認を求めずに自動的に拒否されるコマンドプレフィックス。許可されたコマンドとの競合がある場合、最長プレフィックスマッチが優先されます。すべてのコマンドを拒否するには * を追加してください。",
|
||||
"commands.commandExecutionTimeout.description": "コマンド実行の完了を待つ最大時間(秒)、タイムアウトまで(0 = タイムアウトなし、1-600秒、デフォルト: 0秒)",
|
||||
"commands.commandTimeoutAllowlist.description": "コマンド実行タイムアウトから除外されるコマンドプレフィックス。これらのプレフィックスに一致するコマンドは、タイムアウト制限なしで実行されます。",
|
||||
"settings.vsCodeLmModelSelector.description": "VSCode 言語モデル API の設定",
|
||||
"settings.vsCodeLmModelSelector.vendor.description": "言語モデルのベンダー(例:copilot)",
|
||||
"settings.vsCodeLmModelSelector.family.description": "言語モデルのファミリー(例:gpt-4)",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
"commands.allowedCommands.description": "Commands that can be auto-executed when 'Always approve execute operations' is enabled",
|
||||
"commands.deniedCommands.description": "Command prefixes that will be automatically denied without asking for approval. In case of conflicts with allowed commands, the longest prefix match takes precedence. Add * to deny all commands.",
|
||||
"commands.commandExecutionTimeout.description": "Maximum time in seconds to wait for command execution to complete before timing out (0 = no timeout, 1-600s, default: 0s)",
|
||||
"commands.commandTimeoutAllowlist.description": "Command prefixes that are excluded from the command execution timeout. Commands matching these prefixes will run without timeout restrictions.",
|
||||
"commands.preventCompletionWithOpenTodos.description": "Prevent task completion when there are incomplete todos in the todo list",
|
||||
"settings.vsCodeLmModelSelector.description": "Settings for VSCode Language Model API",
|
||||
"settings.vsCodeLmModelSelector.vendor.description": "The vendor of the language model (e.g. copilot)",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
"commands.allowedCommands.description": "'항상 실행 작업 승인' 이 활성화되어 있을 때 자동으로 실행할 수 있는 명령어",
|
||||
"commands.deniedCommands.description": "승인을 요청하지 않고 자동으로 거부될 명령어 접두사. 허용된 명령어와 충돌하는 경우 가장 긴 접두사 일치가 우선됩니다. 모든 명령어를 거부하려면 *를 추가하세요.",
|
||||
"commands.commandExecutionTimeout.description": "명령어 실행이 완료되기를 기다리는 최대 시간(초), 타임아웃 전까지 (0 = 타임아웃 없음, 1-600초, 기본값: 0초)",
|
||||
"commands.commandTimeoutAllowlist.description": "명령어 실행 타임아웃에서 제외되는 명령어 접두사. 이러한 접두사와 일치하는 명령어는 타임아웃 제한 없이 실행됩니다.",
|
||||
"settings.vsCodeLmModelSelector.description": "VSCode 언어 모델 API 설정",
|
||||
"settings.vsCodeLmModelSelector.vendor.description": "언어 모델 공급자 (예: copilot)",
|
||||
"settings.vsCodeLmModelSelector.family.description": "언어 모델 계열 (예: gpt-4)",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
"commands.allowedCommands.description": "Commando's die automatisch kunnen worden uitgevoerd wanneer 'Altijd goedkeuren uitvoerbewerkingen' is ingeschakeld",
|
||||
"commands.deniedCommands.description": "Commando-prefixen die automatisch worden geweigerd zonder om goedkeuring te vragen. Bij conflicten met toegestane commando's heeft de langste prefix-match voorrang. Voeg * toe om alle commando's te weigeren.",
|
||||
"commands.commandExecutionTimeout.description": "Maximale tijd in seconden om te wachten tot commando-uitvoering voltooid is voordat er een timeout optreedt (0 = geen timeout, 1-600s, standaard: 0s)",
|
||||
"commands.commandTimeoutAllowlist.description": "Commando-prefixen die zijn uitgesloten van de commando-uitvoering timeout. Commando's die overeenkomen met deze prefixen worden uitgevoerd zonder timeout-beperkingen.",
|
||||
"settings.vsCodeLmModelSelector.description": "Instellingen voor VSCode Language Model API",
|
||||
"settings.vsCodeLmModelSelector.vendor.description": "De leverancier van het taalmodel (bijv. copilot)",
|
||||
"settings.vsCodeLmModelSelector.family.description": "De familie van het taalmodel (bijv. gpt-4)",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
"commands.allowedCommands.description": "Polecenia, które mogą być wykonywane automatycznie, gdy włączona jest opcja 'Zawsze zatwierdzaj operacje wykonania'",
|
||||
"commands.deniedCommands.description": "Prefiksy poleceń, które będą automatycznie odrzucane bez pytania o zatwierdzenie. W przypadku konfliktów z dozwolonymi poleceniami, najdłuższe dopasowanie prefiksu ma pierwszeństwo. Dodaj * aby odrzucić wszystkie polecenia.",
|
||||
"commands.commandExecutionTimeout.description": "Maksymalny czas w sekundach oczekiwania na zakończenie wykonania polecenia przed przekroczeniem limitu czasu (0 = brak limitu czasu, 1-600s, domyślnie: 0s)",
|
||||
"commands.commandTimeoutAllowlist.description": "Prefiksy poleceń, które są wykluczone z limitu czasu wykonania poleceń. Polecenia pasujące do tych prefiksów będą wykonywane bez ograniczeń czasowych.",
|
||||
"settings.vsCodeLmModelSelector.description": "Ustawienia dla API modelu językowego VSCode",
|
||||
"settings.vsCodeLmModelSelector.vendor.description": "Dostawca modelu językowego (np. copilot)",
|
||||
"settings.vsCodeLmModelSelector.family.description": "Rodzina modelu językowego (np. gpt-4)",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
"commands.allowedCommands.description": "Comandos que podem ser executados automaticamente quando 'Sempre aprovar operações de execução' está ativado",
|
||||
"commands.deniedCommands.description": "Prefixos de comandos que serão automaticamente negados sem solicitar aprovação. Em caso de conflitos com comandos permitidos, a correspondência de prefixo mais longa tem precedência. Adicione * para negar todos os comandos.",
|
||||
"commands.commandExecutionTimeout.description": "Tempo máximo em segundos para aguardar a conclusão da execução do comando antes do timeout (0 = sem timeout, 1-600s, padrão: 0s)",
|
||||
"commands.commandTimeoutAllowlist.description": "Prefixos de comandos que são excluídos do timeout de execução de comandos. Comandos que correspondem a esses prefixos serão executados sem restrições de timeout.",
|
||||
"settings.vsCodeLmModelSelector.description": "Configurações para a API do modelo de linguagem do VSCode",
|
||||
"settings.vsCodeLmModelSelector.vendor.description": "O fornecedor do modelo de linguagem (ex: copilot)",
|
||||
"settings.vsCodeLmModelSelector.family.description": "A família do modelo de linguagem (ex: gpt-4)",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
"commands.allowedCommands.description": "Команды, которые могут быть автоматически выполнены, когда включена опция 'Всегда подтверждать операции выполнения'",
|
||||
"commands.deniedCommands.description": "Префиксы команд, которые будут автоматически отклонены без запроса подтверждения. В случае конфликтов с разрешенными командами приоритет имеет самое длинное совпадение префикса. Добавьте * чтобы отклонить все команды.",
|
||||
"commands.commandExecutionTimeout.description": "Максимальное время в секундах для ожидания завершения выполнения команды до истечения времени ожидания (0 = без тайм-аута, 1-600с, по умолчанию: 0с)",
|
||||
"commands.commandTimeoutAllowlist.description": "Префиксы команд, которые исключены из тайм-аута выполнения команд. Команды, соответствующие этим префиксам, будут выполняться без ограничений по времени.",
|
||||
"settings.vsCodeLmModelSelector.description": "Настройки для VSCode Language Model API",
|
||||
"settings.vsCodeLmModelSelector.vendor.description": "Поставщик языковой модели (например, copilot)",
|
||||
"settings.vsCodeLmModelSelector.family.description": "Семейство языковой модели (например, gpt-4)",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
"commands.allowedCommands.description": "'Her zaman yürütme işlemlerini onayla' etkinleştirildiğinde otomatik olarak yürütülebilen komutlar",
|
||||
"commands.deniedCommands.description": "Onay istenmeden otomatik olarak reddedilecek komut önekleri. İzin verilen komutlarla çakışma durumunda en uzun önek eşleşmesi öncelik alır. Tüm komutları reddetmek için * ekleyin.",
|
||||
"commands.commandExecutionTimeout.description": "Komut yürütmesinin tamamlanmasını beklemek için maksimum süre (saniye), zaman aşımından önce (0 = zaman aşımı yok, 1-600s, varsayılan: 0s)",
|
||||
"commands.commandTimeoutAllowlist.description": "Komut yürütme zaman aşımından hariç tutulan komut önekleri. Bu öneklerle eşleşen komutlar zaman aşımı kısıtlamaları olmadan çalışacaktır.",
|
||||
"settings.vsCodeLmModelSelector.description": "VSCode dil modeli API'si için ayarlar",
|
||||
"settings.vsCodeLmModelSelector.vendor.description": "Dil modelinin sağlayıcısı (örn: copilot)",
|
||||
"settings.vsCodeLmModelSelector.family.description": "Dil modelinin ailesi (örn: gpt-4)",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
"commands.allowedCommands.description": "Các lệnh có thể được thực thi tự động khi 'Luôn phê duyệt các thao tác thực thi' được bật",
|
||||
"commands.deniedCommands.description": "Các tiền tố lệnh sẽ được tự động từ chối mà không yêu cầu phê duyệt. Trong trường hợp xung đột với các lệnh được phép, việc khớp tiền tố dài nhất sẽ được ưu tiên. Thêm * để từ chối tất cả các lệnh.",
|
||||
"commands.commandExecutionTimeout.description": "Thời gian tối đa tính bằng giây để chờ việc thực thi lệnh hoàn thành trước khi hết thời gian chờ (0 = không có thời gian chờ, 1-600s, mặc định: 0s)",
|
||||
"commands.commandTimeoutAllowlist.description": "Các tiền tố lệnh được loại trừ khỏi thời gian chờ thực thi lệnh. Các lệnh khớp với những tiền tố này sẽ chạy mà không có giới hạn thời gian chờ.",
|
||||
"settings.vsCodeLmModelSelector.description": "Cài đặt cho API mô hình ngôn ngữ VSCode",
|
||||
"settings.vsCodeLmModelSelector.vendor.description": "Nhà cung cấp mô hình ngôn ngữ (ví dụ: copilot)",
|
||||
"settings.vsCodeLmModelSelector.family.description": "Họ mô hình ngôn ngữ (ví dụ: gpt-4)",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
"commands.allowedCommands.description": "当启用'始终批准执行操作'时可以自动执行的命令",
|
||||
"commands.deniedCommands.description": "将自动拒绝而无需请求批准的命令前缀。与允许命令冲突时,最长前缀匹配优先。添加 * 拒绝所有命令。",
|
||||
"commands.commandExecutionTimeout.description": "等待命令执行完成的最大时间(秒),超时前(0 = 无超时,1-600秒,默认:0秒)",
|
||||
"commands.commandTimeoutAllowlist.description": "从命令执行超时中排除的命令前缀。匹配这些前缀的命令将在没有超时限制的情况下运行。",
|
||||
"settings.vsCodeLmModelSelector.description": "VSCode 语言模型 API 的设置",
|
||||
"settings.vsCodeLmModelSelector.vendor.description": "语言模型的供应商(例如:copilot)",
|
||||
"settings.vsCodeLmModelSelector.family.description": "语言模型的系列(例如:gpt-4)",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
"commands.allowedCommands.description": "當啟用'始終批准執行操作'時可以自動執行的命令",
|
||||
"commands.deniedCommands.description": "將自動拒絕而無需請求批准的命令前綴。與允許命令衝突時,最長前綴匹配優先。新增 * 拒絕所有命令。",
|
||||
"commands.commandExecutionTimeout.description": "等待命令執行完成的最大時間(秒),逾時前(0 = 無逾時,1-600秒,預設:0秒)",
|
||||
"commands.commandTimeoutAllowlist.description": "從命令執行逾時中排除的命令前綴。符合這些前綴的命令將在沒有逾時限制的情況下執行。",
|
||||
"settings.vsCodeLmModelSelector.description": "VSCode 語言模型 API 的設定",
|
||||
"settings.vsCodeLmModelSelector.vendor.description": "語言模型供應商(例如:copilot)",
|
||||
"settings.vsCodeLmModelSelector.family.description": "語言模型系列(例如:gpt-4)",
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ export class CodeIndexConfigManager {
|
|||
private ollamaOptions?: ApiHandlerOptions
|
||||
private openAiCompatibleOptions?: { baseUrl: string; apiKey: string }
|
||||
private geminiOptions?: { apiKey: string }
|
||||
private mistralOptions?: { apiKey: string }
|
||||
private qdrantUrl?: string = "http://localhost:6333"
|
||||
private qdrantApiKey?: string
|
||||
private searchMinScore?: number
|
||||
|
|
@ -67,6 +68,7 @@ export class CodeIndexConfigManager {
|
|||
const openAiCompatibleBaseUrl = codebaseIndexConfig.codebaseIndexOpenAiCompatibleBaseUrl ?? ""
|
||||
const openAiCompatibleApiKey = this.contextProxy?.getSecret("codebaseIndexOpenAiCompatibleApiKey") ?? ""
|
||||
const geminiApiKey = this.contextProxy?.getSecret("codebaseIndexGeminiApiKey") ?? ""
|
||||
const mistralApiKey = this.contextProxy?.getSecret("codebaseIndexMistralApiKey") ?? ""
|
||||
|
||||
// Update instance variables with configuration
|
||||
this.codebaseIndexEnabled = codebaseIndexEnabled ?? true
|
||||
|
|
@ -100,6 +102,8 @@ export class CodeIndexConfigManager {
|
|||
this.embedderProvider = "openai-compatible"
|
||||
} else if (codebaseIndexEmbedderProvider === "gemini") {
|
||||
this.embedderProvider = "gemini"
|
||||
} else if (codebaseIndexEmbedderProvider === "mistral") {
|
||||
this.embedderProvider = "mistral"
|
||||
} else {
|
||||
this.embedderProvider = "openai"
|
||||
}
|
||||
|
|
@ -119,6 +123,7 @@ export class CodeIndexConfigManager {
|
|||
: undefined
|
||||
|
||||
this.geminiOptions = geminiApiKey ? { apiKey: geminiApiKey } : undefined
|
||||
this.mistralOptions = mistralApiKey ? { apiKey: mistralApiKey } : undefined
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -135,6 +140,7 @@ export class CodeIndexConfigManager {
|
|||
ollamaOptions?: ApiHandlerOptions
|
||||
openAiCompatibleOptions?: { baseUrl: string; apiKey: string }
|
||||
geminiOptions?: { apiKey: string }
|
||||
mistralOptions?: { apiKey: string }
|
||||
qdrantUrl?: string
|
||||
qdrantApiKey?: string
|
||||
searchMinScore?: number
|
||||
|
|
@ -153,6 +159,7 @@ export class CodeIndexConfigManager {
|
|||
openAiCompatibleBaseUrl: this.openAiCompatibleOptions?.baseUrl ?? "",
|
||||
openAiCompatibleApiKey: this.openAiCompatibleOptions?.apiKey ?? "",
|
||||
geminiApiKey: this.geminiOptions?.apiKey ?? "",
|
||||
mistralApiKey: this.mistralOptions?.apiKey ?? "",
|
||||
qdrantUrl: this.qdrantUrl ?? "",
|
||||
qdrantApiKey: this.qdrantApiKey ?? "",
|
||||
}
|
||||
|
|
@ -176,6 +183,7 @@ export class CodeIndexConfigManager {
|
|||
ollamaOptions: this.ollamaOptions,
|
||||
openAiCompatibleOptions: this.openAiCompatibleOptions,
|
||||
geminiOptions: this.geminiOptions,
|
||||
mistralOptions: this.mistralOptions,
|
||||
qdrantUrl: this.qdrantUrl,
|
||||
qdrantApiKey: this.qdrantApiKey,
|
||||
searchMinScore: this.currentSearchMinScore,
|
||||
|
|
@ -208,6 +216,11 @@ export class CodeIndexConfigManager {
|
|||
const qdrantUrl = this.qdrantUrl
|
||||
const isConfigured = !!(apiKey && qdrantUrl)
|
||||
return isConfigured
|
||||
} else if (this.embedderProvider === "mistral") {
|
||||
const apiKey = this.mistralOptions?.apiKey
|
||||
const qdrantUrl = this.qdrantUrl
|
||||
const isConfigured = !!(apiKey && qdrantUrl)
|
||||
return isConfigured
|
||||
}
|
||||
return false // Should not happen if embedderProvider is always set correctly
|
||||
}
|
||||
|
|
@ -241,6 +254,7 @@ export class CodeIndexConfigManager {
|
|||
const prevOpenAiCompatibleApiKey = prev?.openAiCompatibleApiKey ?? ""
|
||||
const prevModelDimension = prev?.modelDimension
|
||||
const prevGeminiApiKey = prev?.geminiApiKey ?? ""
|
||||
const prevMistralApiKey = prev?.mistralApiKey ?? ""
|
||||
const prevQdrantUrl = prev?.qdrantUrl ?? ""
|
||||
const prevQdrantApiKey = prev?.qdrantApiKey ?? ""
|
||||
|
||||
|
|
@ -277,6 +291,7 @@ export class CodeIndexConfigManager {
|
|||
const currentOpenAiCompatibleApiKey = this.openAiCompatibleOptions?.apiKey ?? ""
|
||||
const currentModelDimension = this.modelDimension
|
||||
const currentGeminiApiKey = this.geminiOptions?.apiKey ?? ""
|
||||
const currentMistralApiKey = this.mistralOptions?.apiKey ?? ""
|
||||
const currentQdrantUrl = this.qdrantUrl ?? ""
|
||||
const currentQdrantApiKey = this.qdrantApiKey ?? ""
|
||||
|
||||
|
|
@ -295,6 +310,14 @@ export class CodeIndexConfigManager {
|
|||
return true
|
||||
}
|
||||
|
||||
if (prevGeminiApiKey !== currentGeminiApiKey) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (prevMistralApiKey !== currentMistralApiKey) {
|
||||
return true
|
||||
}
|
||||
|
||||
// Check for model dimension changes (generic for all providers)
|
||||
if (prevModelDimension !== currentModelDimension) {
|
||||
return true
|
||||
|
|
@ -351,6 +374,7 @@ export class CodeIndexConfigManager {
|
|||
ollamaOptions: this.ollamaOptions,
|
||||
openAiCompatibleOptions: this.openAiCompatibleOptions,
|
||||
geminiOptions: this.geminiOptions,
|
||||
mistralOptions: this.mistralOptions,
|
||||
qdrantUrl: this.qdrantUrl,
|
||||
qdrantApiKey: this.qdrantApiKey,
|
||||
searchMinScore: this.currentSearchMinScore,
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ export const BATCH_SEGMENT_THRESHOLD = 60 // Number of code segments to batch fo
|
|||
export const MAX_BATCH_RETRIES = 3
|
||||
export const INITIAL_RETRY_DELAY_MS = 500
|
||||
export const PARSING_CONCURRENCY = 10
|
||||
export const MAX_PENDING_BATCHES = 20 // Maximum number of batches to accumulate before waiting
|
||||
|
||||
/**OpenAI Embedder */
|
||||
export const MAX_BATCH_TOKENS = 100000
|
||||
|
|
|
|||
193
src/services/code-index/embedders/__tests__/mistral.spec.ts
Normal file
193
src/services/code-index/embedders/__tests__/mistral.spec.ts
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
import { vitest, describe, it, expect, beforeEach } from "vitest"
|
||||
import type { MockedClass } from "vitest"
|
||||
import { MistralEmbedder } from "../mistral"
|
||||
import { OpenAICompatibleEmbedder } from "../openai-compatible"
|
||||
|
||||
// Mock the OpenAICompatibleEmbedder
|
||||
vitest.mock("../openai-compatible")
|
||||
|
||||
// Mock TelemetryService
|
||||
vitest.mock("@roo-code/telemetry", () => ({
|
||||
TelemetryService: {
|
||||
instance: {
|
||||
captureEvent: vitest.fn(),
|
||||
},
|
||||
},
|
||||
}))
|
||||
|
||||
const MockedOpenAICompatibleEmbedder = OpenAICompatibleEmbedder as MockedClass<typeof OpenAICompatibleEmbedder>
|
||||
|
||||
describe("MistralEmbedder", () => {
|
||||
let embedder: MistralEmbedder
|
||||
|
||||
beforeEach(() => {
|
||||
vitest.clearAllMocks()
|
||||
})
|
||||
|
||||
describe("constructor", () => {
|
||||
it("should create an instance with default model when no model specified", () => {
|
||||
// Arrange
|
||||
const apiKey = "test-mistral-api-key"
|
||||
|
||||
// Act
|
||||
embedder = new MistralEmbedder(apiKey)
|
||||
|
||||
// Assert
|
||||
expect(MockedOpenAICompatibleEmbedder).toHaveBeenCalledWith(
|
||||
"https://api.mistral.ai/v1",
|
||||
apiKey,
|
||||
"codestral-embed-2505",
|
||||
8191,
|
||||
)
|
||||
})
|
||||
|
||||
it("should create an instance with specified model", () => {
|
||||
// Arrange
|
||||
const apiKey = "test-mistral-api-key"
|
||||
const modelId = "custom-embed-model"
|
||||
|
||||
// Act
|
||||
embedder = new MistralEmbedder(apiKey, modelId)
|
||||
|
||||
// Assert
|
||||
expect(MockedOpenAICompatibleEmbedder).toHaveBeenCalledWith(
|
||||
"https://api.mistral.ai/v1",
|
||||
apiKey,
|
||||
"custom-embed-model",
|
||||
8191,
|
||||
)
|
||||
})
|
||||
|
||||
it("should throw error when API key is not provided", () => {
|
||||
// Act & Assert
|
||||
expect(() => new MistralEmbedder("")).toThrow("validation.apiKeyRequired")
|
||||
expect(() => new MistralEmbedder(null as any)).toThrow("validation.apiKeyRequired")
|
||||
expect(() => new MistralEmbedder(undefined as any)).toThrow("validation.apiKeyRequired")
|
||||
})
|
||||
})
|
||||
|
||||
describe("embedderInfo", () => {
|
||||
it("should return correct embedder info", () => {
|
||||
// Arrange
|
||||
embedder = new MistralEmbedder("test-api-key")
|
||||
|
||||
// Act
|
||||
const info = embedder.embedderInfo
|
||||
|
||||
// Assert
|
||||
expect(info).toEqual({
|
||||
name: "mistral",
|
||||
})
|
||||
})
|
||||
|
||||
describe("createEmbeddings", () => {
|
||||
let mockCreateEmbeddings: any
|
||||
|
||||
beforeEach(() => {
|
||||
mockCreateEmbeddings = vitest.fn()
|
||||
MockedOpenAICompatibleEmbedder.prototype.createEmbeddings = mockCreateEmbeddings
|
||||
})
|
||||
|
||||
it("should use instance model when no model parameter provided", async () => {
|
||||
// Arrange
|
||||
embedder = new MistralEmbedder("test-api-key")
|
||||
const texts = ["test text 1", "test text 2"]
|
||||
const mockResponse = {
|
||||
embeddings: [
|
||||
[0.1, 0.2],
|
||||
[0.3, 0.4],
|
||||
],
|
||||
}
|
||||
mockCreateEmbeddings.mockResolvedValue(mockResponse)
|
||||
|
||||
// Act
|
||||
const result = await embedder.createEmbeddings(texts)
|
||||
|
||||
// Assert
|
||||
expect(mockCreateEmbeddings).toHaveBeenCalledWith(texts, "codestral-embed-2505")
|
||||
expect(result).toEqual(mockResponse)
|
||||
})
|
||||
|
||||
it("should use provided model parameter when specified", async () => {
|
||||
// Arrange
|
||||
embedder = new MistralEmbedder("test-api-key", "custom-embed-model")
|
||||
const texts = ["test text 1", "test text 2"]
|
||||
const mockResponse = {
|
||||
embeddings: [
|
||||
[0.1, 0.2],
|
||||
[0.3, 0.4],
|
||||
],
|
||||
}
|
||||
mockCreateEmbeddings.mockResolvedValue(mockResponse)
|
||||
|
||||
// Act
|
||||
const result = await embedder.createEmbeddings(texts, "codestral-embed-2505")
|
||||
|
||||
// Assert
|
||||
expect(mockCreateEmbeddings).toHaveBeenCalledWith(texts, "codestral-embed-2505")
|
||||
expect(result).toEqual(mockResponse)
|
||||
})
|
||||
|
||||
it("should handle errors from OpenAICompatibleEmbedder", async () => {
|
||||
// Arrange
|
||||
embedder = new MistralEmbedder("test-api-key")
|
||||
const texts = ["test text"]
|
||||
const error = new Error("Embedding failed")
|
||||
mockCreateEmbeddings.mockRejectedValue(error)
|
||||
|
||||
// Act & Assert
|
||||
await expect(embedder.createEmbeddings(texts)).rejects.toThrow("Embedding failed")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("validateConfiguration", () => {
|
||||
let mockValidateConfiguration: any
|
||||
|
||||
beforeEach(() => {
|
||||
mockValidateConfiguration = vitest.fn()
|
||||
MockedOpenAICompatibleEmbedder.prototype.validateConfiguration = mockValidateConfiguration
|
||||
})
|
||||
|
||||
it("should delegate validation to OpenAICompatibleEmbedder", async () => {
|
||||
// Arrange
|
||||
embedder = new MistralEmbedder("test-api-key")
|
||||
mockValidateConfiguration.mockResolvedValue({ valid: true })
|
||||
|
||||
// Act
|
||||
const result = await embedder.validateConfiguration()
|
||||
|
||||
// Assert
|
||||
expect(mockValidateConfiguration).toHaveBeenCalled()
|
||||
expect(result).toEqual({ valid: true })
|
||||
})
|
||||
|
||||
it("should pass through validation errors from OpenAICompatibleEmbedder", async () => {
|
||||
// Arrange
|
||||
embedder = new MistralEmbedder("test-api-key")
|
||||
mockValidateConfiguration.mockResolvedValue({
|
||||
valid: false,
|
||||
error: "embeddings:validation.authenticationFailed",
|
||||
})
|
||||
|
||||
// Act
|
||||
const result = await embedder.validateConfiguration()
|
||||
|
||||
// Assert
|
||||
expect(mockValidateConfiguration).toHaveBeenCalled()
|
||||
expect(result).toEqual({
|
||||
valid: false,
|
||||
error: "embeddings:validation.authenticationFailed",
|
||||
})
|
||||
})
|
||||
|
||||
it("should handle validation exceptions", async () => {
|
||||
// Arrange
|
||||
embedder = new MistralEmbedder("test-api-key")
|
||||
mockValidateConfiguration.mockRejectedValue(new Error("Validation failed"))
|
||||
|
||||
// Act & Assert
|
||||
await expect(embedder.validateConfiguration()).rejects.toThrow("Validation failed")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
@ -0,0 +1,213 @@
|
|||
import { describe, it, expect, vi, beforeEach, afterEach, MockedClass, MockedFunction } from "vitest"
|
||||
import { OpenAI } from "openai"
|
||||
import { OpenAICompatibleEmbedder } from "../openai-compatible"
|
||||
|
||||
// Mock the OpenAI SDK
|
||||
vi.mock("openai")
|
||||
|
||||
// Mock TelemetryService
|
||||
vi.mock("@roo-code/telemetry", () => ({
|
||||
TelemetryService: {
|
||||
instance: {
|
||||
captureEvent: vi.fn(),
|
||||
},
|
||||
},
|
||||
}))
|
||||
|
||||
// Mock i18n
|
||||
vi.mock("../../../../i18n", () => ({
|
||||
t: (key: string, params?: Record<string, any>) => {
|
||||
const translations: Record<string, string> = {
|
||||
"embeddings:rateLimitRetry": `Rate limit hit, retrying in ${params?.delayMs}ms (attempt ${params?.attempt}/${params?.maxRetries})`,
|
||||
"embeddings:failedMaxAttempts": `Failed to create embeddings after ${params?.attempts} attempts`,
|
||||
"embeddings:failedWithStatus": `Failed to create embeddings after ${params?.attempts} attempts: HTTP ${params?.statusCode} - ${params?.errorMessage}`,
|
||||
"embeddings:failedWithError": `Failed to create embeddings after ${params?.attempts} attempts: ${params?.errorMessage}`,
|
||||
}
|
||||
return translations[key] || key
|
||||
},
|
||||
}))
|
||||
|
||||
const MockedOpenAI = OpenAI as MockedClass<typeof OpenAI>
|
||||
|
||||
describe("OpenAICompatibleEmbedder - Global Rate Limiting", () => {
|
||||
let mockOpenAIInstance: any
|
||||
let mockEmbeddingsCreate: MockedFunction<any>
|
||||
|
||||
const testBaseUrl = "https://api.openai.com/v1"
|
||||
const testApiKey = "test-api-key"
|
||||
const testModelId = "text-embedding-3-small"
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
vi.useFakeTimers()
|
||||
vi.spyOn(console, "warn").mockImplementation(() => {})
|
||||
vi.spyOn(console, "error").mockImplementation(() => {})
|
||||
|
||||
// Setup mock OpenAI instance
|
||||
mockEmbeddingsCreate = vi.fn()
|
||||
mockOpenAIInstance = {
|
||||
embeddings: {
|
||||
create: mockEmbeddingsCreate,
|
||||
},
|
||||
}
|
||||
|
||||
MockedOpenAI.mockImplementation(() => mockOpenAIInstance)
|
||||
|
||||
// Reset global rate limit state
|
||||
const embedder = new OpenAICompatibleEmbedder(testBaseUrl, testApiKey, testModelId)
|
||||
;(embedder as any).constructor.globalRateLimitState = {
|
||||
isRateLimited: false,
|
||||
rateLimitResetTime: 0,
|
||||
consecutiveRateLimitErrors: 0,
|
||||
lastRateLimitError: 0,
|
||||
mutex: (embedder as any).constructor.globalRateLimitState.mutex,
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers()
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
it("should apply global rate limiting across multiple batch requests", async () => {
|
||||
const embedder1 = new OpenAICompatibleEmbedder(testBaseUrl, testApiKey, testModelId)
|
||||
const embedder2 = new OpenAICompatibleEmbedder(testBaseUrl, testApiKey, testModelId)
|
||||
|
||||
// First batch hits rate limit
|
||||
const rateLimitError = new Error("Rate limit exceeded") as any
|
||||
rateLimitError.status = 429
|
||||
|
||||
mockEmbeddingsCreate
|
||||
.mockRejectedValueOnce(rateLimitError) // First attempt fails
|
||||
.mockResolvedValue({
|
||||
data: [{ embedding: "base64encodeddata" }],
|
||||
usage: { prompt_tokens: 10, total_tokens: 15 },
|
||||
})
|
||||
|
||||
// Start first batch request
|
||||
const batch1Promise = embedder1.createEmbeddings(["test1"])
|
||||
|
||||
// Advance time slightly to let the first request fail and set global rate limit
|
||||
await vi.advanceTimersByTimeAsync(100)
|
||||
|
||||
// Start second batch request while global rate limit is active
|
||||
const batch2Promise = embedder2.createEmbeddings(["test2"])
|
||||
|
||||
// Check that global rate limit was set
|
||||
const state = (embedder1 as any).constructor.globalRateLimitState
|
||||
expect(state.isRateLimited).toBe(true)
|
||||
expect(state.consecutiveRateLimitErrors).toBe(1)
|
||||
|
||||
// Advance time to complete rate limit delay (5 seconds base delay)
|
||||
await vi.advanceTimersByTimeAsync(5000)
|
||||
|
||||
// Both requests should complete
|
||||
const [result1, result2] = await Promise.all([batch1Promise, batch2Promise])
|
||||
|
||||
expect(result1.embeddings).toHaveLength(1)
|
||||
expect(result2.embeddings).toHaveLength(1)
|
||||
|
||||
// The second embedder should have waited for the global rate limit
|
||||
// No logging expected - we've removed it to prevent log flooding
|
||||
})
|
||||
|
||||
it("should track consecutive rate limit errors", async () => {
|
||||
const embedder = new OpenAICompatibleEmbedder(testBaseUrl, testApiKey, testModelId)
|
||||
const state = (embedder as any).constructor.globalRateLimitState
|
||||
|
||||
const rateLimitError = new Error("Rate limit exceeded") as any
|
||||
rateLimitError.status = 429
|
||||
|
||||
// Test that consecutive errors increment when they happen quickly
|
||||
// Mock multiple rate limit errors in a single request
|
||||
mockEmbeddingsCreate
|
||||
.mockRejectedValueOnce(rateLimitError) // First attempt
|
||||
.mockRejectedValueOnce(rateLimitError) // Retry 1
|
||||
.mockResolvedValueOnce({
|
||||
data: [{ embedding: "base64encodeddata" }],
|
||||
usage: { prompt_tokens: 10, total_tokens: 15 },
|
||||
})
|
||||
|
||||
const promise1 = embedder.createEmbeddings(["test1"])
|
||||
|
||||
// Wait for first attempt to fail
|
||||
await vi.advanceTimersByTimeAsync(100)
|
||||
expect(state.consecutiveRateLimitErrors).toBe(1)
|
||||
|
||||
// Wait for first retry (500ms) to also fail
|
||||
await vi.advanceTimersByTimeAsync(500)
|
||||
|
||||
// The state should show 2 consecutive errors now
|
||||
// Note: The count might be 1 if the global rate limit kicked in before the second attempt
|
||||
expect(state.consecutiveRateLimitErrors).toBeGreaterThanOrEqual(1)
|
||||
|
||||
// Wait for the global rate limit and successful retry
|
||||
await vi.advanceTimersByTimeAsync(20000)
|
||||
await promise1
|
||||
|
||||
// Verify the delay increases with consecutive errors
|
||||
// Make another request immediately that also hits rate limit
|
||||
mockEmbeddingsCreate.mockRejectedValueOnce(rateLimitError).mockResolvedValueOnce({
|
||||
data: [{ embedding: "base64encodeddata" }],
|
||||
usage: { prompt_tokens: 10, total_tokens: 15 },
|
||||
})
|
||||
|
||||
// Store the current consecutive count before the next request
|
||||
const previousCount = state.consecutiveRateLimitErrors
|
||||
|
||||
const promise2 = embedder.createEmbeddings(["test2"])
|
||||
await vi.advanceTimersByTimeAsync(100)
|
||||
|
||||
// Should have incremented from the previous count
|
||||
expect(state.consecutiveRateLimitErrors).toBeGreaterThan(previousCount)
|
||||
|
||||
// Complete the second request
|
||||
await vi.advanceTimersByTimeAsync(20000)
|
||||
await promise2
|
||||
})
|
||||
|
||||
it("should reset consecutive error count after time passes", async () => {
|
||||
const embedder = new OpenAICompatibleEmbedder(testBaseUrl, testApiKey, testModelId)
|
||||
const state = (embedder as any).constructor.globalRateLimitState
|
||||
|
||||
// Manually set state to simulate previous errors
|
||||
state.consecutiveRateLimitErrors = 3
|
||||
state.lastRateLimitError = Date.now() - 70000 // 70 seconds ago
|
||||
|
||||
const rateLimitError = new Error("Rate limit exceeded") as any
|
||||
rateLimitError.status = 429
|
||||
|
||||
mockEmbeddingsCreate.mockRejectedValueOnce(rateLimitError).mockResolvedValueOnce({
|
||||
data: [{ embedding: "base64encodeddata" }],
|
||||
usage: { prompt_tokens: 10, total_tokens: 15 },
|
||||
})
|
||||
|
||||
// Trigger the updateGlobalRateLimitState method
|
||||
await (embedder as any).updateGlobalRateLimitState(rateLimitError)
|
||||
|
||||
// Should reset to 1 since more than 60 seconds passed
|
||||
expect(state.consecutiveRateLimitErrors).toBe(1)
|
||||
})
|
||||
|
||||
it("should not exceed maximum delay of 5 minutes", async () => {
|
||||
const embedder = new OpenAICompatibleEmbedder(testBaseUrl, testApiKey, testModelId)
|
||||
const state = (embedder as any).constructor.globalRateLimitState
|
||||
|
||||
// Set state to simulate many consecutive errors
|
||||
state.consecutiveRateLimitErrors = 10 // This would normally result in a very long delay
|
||||
|
||||
const rateLimitError = new Error("Rate limit exceeded") as any
|
||||
rateLimitError.status = 429
|
||||
|
||||
// Trigger the updateGlobalRateLimitState method
|
||||
await (embedder as any).updateGlobalRateLimitState(rateLimitError)
|
||||
|
||||
// Calculate the expected delay
|
||||
const now = Date.now()
|
||||
const delay = state.rateLimitResetTime - now
|
||||
|
||||
// Should be capped at 5 minutes (300000ms)
|
||||
expect(delay).toBeLessThanOrEqual(300000)
|
||||
expect(delay).toBeGreaterThan(0)
|
||||
})
|
||||
})
|
||||
|
|
@ -60,6 +60,16 @@ describe("OpenAICompatibleEmbedder", () => {
|
|||
}
|
||||
|
||||
MockedOpenAI.mockImplementation(() => mockOpenAIInstance)
|
||||
|
||||
// Reset global rate limit state to prevent interference between tests
|
||||
const tempEmbedder = new OpenAICompatibleEmbedder(testBaseUrl, testApiKey, testModelId)
|
||||
;(tempEmbedder as any).constructor.globalRateLimitState = {
|
||||
isRateLimited: false,
|
||||
rateLimitResetTime: 0,
|
||||
consecutiveRateLimitErrors: 0,
|
||||
lastRateLimitError: 0,
|
||||
mutex: (tempEmbedder as any).constructor.globalRateLimitState.mutex,
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
|
|
@ -385,9 +395,17 @@ describe("OpenAICompatibleEmbedder", () => {
|
|||
|
||||
const resultPromise = embedder.createEmbeddings(testTexts)
|
||||
|
||||
// Fast-forward through the delays
|
||||
await vitest.advanceTimersByTimeAsync(INITIAL_RETRY_DELAY_MS) // First retry delay
|
||||
await vitest.advanceTimersByTimeAsync(INITIAL_RETRY_DELAY_MS * 2) // Second retry delay
|
||||
// First attempt fails immediately, triggering global rate limit (5s)
|
||||
await vitest.advanceTimersByTimeAsync(100)
|
||||
|
||||
// Wait for global rate limit delay
|
||||
await vitest.advanceTimersByTimeAsync(5000)
|
||||
|
||||
// Second attempt also fails, increasing delay
|
||||
await vitest.advanceTimersByTimeAsync(100)
|
||||
|
||||
// Wait for increased global rate limit delay (10s)
|
||||
await vitest.advanceTimersByTimeAsync(10000)
|
||||
|
||||
const result = await resultPromise
|
||||
|
||||
|
|
@ -445,7 +463,7 @@ describe("OpenAICompatibleEmbedder", () => {
|
|||
|
||||
expect(console.error).toHaveBeenCalledWith(
|
||||
expect.stringContaining("OpenAI Compatible embedder error"),
|
||||
expect.any(Error),
|
||||
apiError,
|
||||
)
|
||||
})
|
||||
|
||||
|
|
@ -461,7 +479,7 @@ describe("OpenAICompatibleEmbedder", () => {
|
|||
|
||||
expect(console.error).toHaveBeenCalledWith(
|
||||
expect.stringContaining("OpenAI Compatible embedder error"),
|
||||
batchError,
|
||||
expect.any(Error),
|
||||
)
|
||||
})
|
||||
|
||||
|
|
@ -791,10 +809,23 @@ describe("OpenAICompatibleEmbedder", () => {
|
|||
)
|
||||
|
||||
const resultPromise = embedder.createEmbeddings(["test"])
|
||||
await vitest.advanceTimersByTimeAsync(INITIAL_RETRY_DELAY_MS * 3)
|
||||
|
||||
// First attempt fails, triggering global rate limit
|
||||
await vitest.advanceTimersByTimeAsync(100)
|
||||
|
||||
// Wait for global rate limit (5s)
|
||||
await vitest.advanceTimersByTimeAsync(5000)
|
||||
|
||||
// Second attempt also fails
|
||||
await vitest.advanceTimersByTimeAsync(100)
|
||||
|
||||
// Wait for increased global rate limit (10s)
|
||||
await vitest.advanceTimersByTimeAsync(10000)
|
||||
|
||||
const result = await resultPromise
|
||||
|
||||
expect(global.fetch).toHaveBeenCalledTimes(3)
|
||||
// Check that rate limit warnings were logged
|
||||
expect(console.warn).toHaveBeenCalledWith(expect.stringContaining("Rate limit hit"))
|
||||
expectEmbeddingValues(result.embeddings[0], [0.1, 0.2, 0.3])
|
||||
vitest.useRealTimers()
|
||||
|
|
|
|||
91
src/services/code-index/embedders/mistral.ts
Normal file
91
src/services/code-index/embedders/mistral.ts
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
import { OpenAICompatibleEmbedder } from "./openai-compatible"
|
||||
import { IEmbedder, EmbeddingResponse, EmbedderInfo } from "../interfaces/embedder"
|
||||
import { MAX_ITEM_TOKENS } from "../constants"
|
||||
import { t } from "../../../i18n"
|
||||
import { TelemetryEventName } from "@roo-code/types"
|
||||
import { TelemetryService } from "@roo-code/telemetry"
|
||||
|
||||
/**
|
||||
* Mistral embedder implementation that wraps the OpenAI Compatible embedder
|
||||
* with configuration for Mistral's embedding API.
|
||||
*
|
||||
* Supported models:
|
||||
* - codestral-embed-2505 (dimension: 1536)
|
||||
*/
|
||||
export class MistralEmbedder implements IEmbedder {
|
||||
private readonly openAICompatibleEmbedder: OpenAICompatibleEmbedder
|
||||
private static readonly MISTRAL_BASE_URL = "https://api.mistral.ai/v1"
|
||||
private static readonly DEFAULT_MODEL = "codestral-embed-2505"
|
||||
private readonly modelId: string
|
||||
|
||||
/**
|
||||
* Creates a new Mistral embedder
|
||||
* @param apiKey The Mistral API key for authentication
|
||||
* @param modelId The model ID to use (defaults to codestral-embed-2505)
|
||||
*/
|
||||
constructor(apiKey: string, modelId?: string) {
|
||||
if (!apiKey) {
|
||||
throw new Error(t("embeddings:validation.apiKeyRequired"))
|
||||
}
|
||||
|
||||
// Use provided model or default
|
||||
this.modelId = modelId || MistralEmbedder.DEFAULT_MODEL
|
||||
|
||||
// Create an OpenAI Compatible embedder with Mistral's configuration
|
||||
this.openAICompatibleEmbedder = new OpenAICompatibleEmbedder(
|
||||
MistralEmbedder.MISTRAL_BASE_URL,
|
||||
apiKey,
|
||||
this.modelId,
|
||||
MAX_ITEM_TOKENS, // This is the max token limit (8191), not the embedding dimension
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates embeddings for the given texts using Mistral's embedding API
|
||||
* @param texts Array of text strings to embed
|
||||
* @param model Optional model identifier (uses constructor model if not provided)
|
||||
* @returns Promise resolving to embedding response
|
||||
*/
|
||||
async createEmbeddings(texts: string[], model?: string): Promise<EmbeddingResponse> {
|
||||
try {
|
||||
// Use the provided model or fall back to the instance's model
|
||||
const modelToUse = model || this.modelId
|
||||
return await this.openAICompatibleEmbedder.createEmbeddings(texts, modelToUse)
|
||||
} catch (error) {
|
||||
TelemetryService.instance.captureEvent(TelemetryEventName.CODE_INDEX_ERROR, {
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
stack: error instanceof Error ? error.stack : undefined,
|
||||
location: "MistralEmbedder:createEmbeddings",
|
||||
})
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the Mistral embedder configuration by delegating to the underlying OpenAI-compatible embedder
|
||||
* @returns Promise resolving to validation result with success status and optional error message
|
||||
*/
|
||||
async validateConfiguration(): Promise<{ valid: boolean; error?: string }> {
|
||||
try {
|
||||
// Delegate validation to the OpenAI-compatible embedder
|
||||
// The error messages will be specific to Mistral since we're using Mistral's base URL
|
||||
return await this.openAICompatibleEmbedder.validateConfiguration()
|
||||
} catch (error) {
|
||||
TelemetryService.instance.captureEvent(TelemetryEventName.CODE_INDEX_ERROR, {
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
stack: error instanceof Error ? error.stack : undefined,
|
||||
location: "MistralEmbedder:validateConfiguration",
|
||||
})
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information about this embedder
|
||||
*/
|
||||
get embedderInfo(): EmbedderInfo {
|
||||
return {
|
||||
name: "mistral",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ import { t } from "../../../i18n"
|
|||
import { withValidationErrorHandling, HttpError, formatEmbeddingError } from "../shared/validation-helpers"
|
||||
import { TelemetryEventName } from "@roo-code/types"
|
||||
import { TelemetryService } from "@roo-code/telemetry"
|
||||
import { Mutex } from "async-mutex"
|
||||
|
||||
interface EmbeddingItem {
|
||||
embedding: string | number[]
|
||||
|
|
@ -38,6 +39,16 @@ export class OpenAICompatibleEmbedder implements IEmbedder {
|
|||
private readonly isFullUrl: boolean
|
||||
private readonly maxItemTokens: number
|
||||
|
||||
// Global rate limiting state shared across all instances
|
||||
private static globalRateLimitState = {
|
||||
isRateLimited: false,
|
||||
rateLimitResetTime: 0,
|
||||
consecutiveRateLimitErrors: 0,
|
||||
lastRateLimitError: 0,
|
||||
// Mutex to ensure thread-safe access to rate limit state
|
||||
mutex: new Mutex(),
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new OpenAI Compatible embedder
|
||||
* @param baseUrl The base URL for the OpenAI-compatible API endpoint
|
||||
|
|
@ -239,6 +250,9 @@ export class OpenAICompatibleEmbedder implements IEmbedder {
|
|||
const isFullUrl = this.isFullUrl
|
||||
|
||||
for (let attempts = 0; attempts < MAX_RETRIES; attempts++) {
|
||||
// Check global rate limit before attempting request
|
||||
await this.waitForGlobalRateLimit()
|
||||
|
||||
try {
|
||||
let response: OpenAIEmbeddingResponse
|
||||
|
||||
|
|
@ -298,17 +312,26 @@ export class OpenAICompatibleEmbedder implements IEmbedder {
|
|||
|
||||
// Check if it's a rate limit error
|
||||
const httpError = error as HttpError
|
||||
if (httpError?.status === 429 && hasMoreAttempts) {
|
||||
const delayMs = INITIAL_DELAY_MS * Math.pow(2, attempts)
|
||||
console.warn(
|
||||
t("embeddings:rateLimitRetry", {
|
||||
delayMs,
|
||||
attempt: attempts + 1,
|
||||
maxRetries: MAX_RETRIES,
|
||||
}),
|
||||
)
|
||||
await new Promise((resolve) => setTimeout(resolve, delayMs))
|
||||
continue
|
||||
if (httpError?.status === 429) {
|
||||
// Update global rate limit state
|
||||
await this.updateGlobalRateLimitState(httpError)
|
||||
|
||||
if (hasMoreAttempts) {
|
||||
// Calculate delay based on global rate limit state
|
||||
const baseDelay = INITIAL_DELAY_MS * Math.pow(2, attempts)
|
||||
const globalDelay = await this.getGlobalRateLimitDelay()
|
||||
const delayMs = Math.max(baseDelay, globalDelay)
|
||||
|
||||
console.warn(
|
||||
t("embeddings:rateLimitRetry", {
|
||||
delayMs,
|
||||
attempt: attempts + 1,
|
||||
maxRetries: MAX_RETRIES,
|
||||
}),
|
||||
)
|
||||
await new Promise((resolve) => setTimeout(resolve, delayMs))
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// Log the error for debugging
|
||||
|
|
@ -376,4 +399,87 @@ export class OpenAICompatibleEmbedder implements IEmbedder {
|
|||
name: "openai-compatible",
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits if there's an active global rate limit
|
||||
*/
|
||||
private async waitForGlobalRateLimit(): Promise<void> {
|
||||
const release = await OpenAICompatibleEmbedder.globalRateLimitState.mutex.acquire()
|
||||
try {
|
||||
const state = OpenAICompatibleEmbedder.globalRateLimitState
|
||||
|
||||
if (state.isRateLimited && state.rateLimitResetTime > Date.now()) {
|
||||
const waitTime = state.rateLimitResetTime - Date.now()
|
||||
// Silent wait - no logging to prevent flooding
|
||||
release() // Release mutex before waiting
|
||||
await new Promise((resolve) => setTimeout(resolve, waitTime))
|
||||
return
|
||||
}
|
||||
|
||||
// Reset rate limit if time has passed
|
||||
if (state.isRateLimited && state.rateLimitResetTime <= Date.now()) {
|
||||
state.isRateLimited = false
|
||||
state.consecutiveRateLimitErrors = 0
|
||||
}
|
||||
} finally {
|
||||
// Only release if we haven't already
|
||||
try {
|
||||
release()
|
||||
} catch {
|
||||
// Already released
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates global rate limit state when a 429 error occurs
|
||||
*/
|
||||
private async updateGlobalRateLimitState(error: HttpError): Promise<void> {
|
||||
const release = await OpenAICompatibleEmbedder.globalRateLimitState.mutex.acquire()
|
||||
try {
|
||||
const state = OpenAICompatibleEmbedder.globalRateLimitState
|
||||
const now = Date.now()
|
||||
|
||||
// Increment consecutive rate limit errors
|
||||
if (now - state.lastRateLimitError < 60000) {
|
||||
// Within 1 minute
|
||||
state.consecutiveRateLimitErrors++
|
||||
} else {
|
||||
state.consecutiveRateLimitErrors = 1
|
||||
}
|
||||
|
||||
state.lastRateLimitError = now
|
||||
|
||||
// Calculate exponential backoff based on consecutive errors
|
||||
const baseDelay = 5000 // 5 seconds base
|
||||
const maxDelay = 300000 // 5 minutes max
|
||||
const exponentialDelay = Math.min(baseDelay * Math.pow(2, state.consecutiveRateLimitErrors - 1), maxDelay)
|
||||
|
||||
// Set global rate limit
|
||||
state.isRateLimited = true
|
||||
state.rateLimitResetTime = now + exponentialDelay
|
||||
|
||||
// Silent rate limit activation - no logging to prevent flooding
|
||||
} finally {
|
||||
release()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current global rate limit delay
|
||||
*/
|
||||
private async getGlobalRateLimitDelay(): Promise<number> {
|
||||
const release = await OpenAICompatibleEmbedder.globalRateLimitState.mutex.acquire()
|
||||
try {
|
||||
const state = OpenAICompatibleEmbedder.globalRateLimitState
|
||||
|
||||
if (state.isRateLimited && state.rateLimitResetTime > Date.now()) {
|
||||
return state.rateLimitResetTime - Date.now()
|
||||
}
|
||||
|
||||
return 0
|
||||
} finally {
|
||||
release()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue