mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 08:47:44 +00:00
Various spelling improvements (#3497)
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com> Co-authored-by: Sandy Tao <sandytao520@icloud.com>
This commit is contained in:
@@ -229,14 +229,14 @@ describe('runNonInteractive', () => {
|
||||
it('should not exit if a tool is not found, and should send error back to model', async () => {
|
||||
const functionCall: FunctionCall = {
|
||||
id: 'fcNotFound',
|
||||
name: 'nonExistentTool',
|
||||
name: 'nonexistentTool',
|
||||
args: {},
|
||||
};
|
||||
const errorResponsePart: Part = {
|
||||
functionResponse: {
|
||||
name: 'nonExistentTool',
|
||||
name: 'nonexistentTool',
|
||||
id: 'fcNotFound',
|
||||
response: { error: 'Tool "nonExistentTool" not found in registry.' },
|
||||
response: { error: 'Tool "nonexistentTool" not found in registry.' },
|
||||
},
|
||||
};
|
||||
|
||||
@@ -246,8 +246,8 @@ describe('runNonInteractive', () => {
|
||||
vi.mocked(mockCoreExecuteToolCall).mockResolvedValue({
|
||||
callId: 'fcNotFound',
|
||||
responseParts: [errorResponsePart],
|
||||
resultDisplay: 'Tool "nonExistentTool" not found in registry.',
|
||||
error: new Error('Tool "nonExistentTool" not found in registry.'),
|
||||
resultDisplay: 'Tool "nonexistentTool" not found in registry.',
|
||||
error: new Error('Tool "nonexistentTool" not found in registry.'),
|
||||
});
|
||||
|
||||
const stream1 = (async function* () {
|
||||
@@ -278,7 +278,7 @@ describe('runNonInteractive', () => {
|
||||
);
|
||||
|
||||
expect(consoleErrorSpy).toHaveBeenCalledWith(
|
||||
'Error executing tool nonExistentTool: Tool "nonExistentTool" not found in registry.',
|
||||
'Error executing tool nonexistentTool: Tool "nonexistentTool" not found in registry.',
|
||||
);
|
||||
|
||||
expect(mockProcessExit).not.toHaveBeenCalled();
|
||||
|
||||
@@ -298,7 +298,7 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
|
||||
config.getContentGeneratorConfig().authType ===
|
||||
AuthType.LOGIN_WITH_GOOGLE
|
||||
) {
|
||||
// Use actual user tier if available, otherwise default to FREE tier behavior (safe default)
|
||||
// Use actual user tier if available; otherwise, default to FREE tier behavior (safe default)
|
||||
const isPaidTier =
|
||||
userTier === UserTierId.LEGACY || userTier === UserTierId.STANDARD;
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ export const Footer: React.FC<FooterProps> = ({
|
||||
</Text>
|
||||
) : process.env.SANDBOX === 'sandbox-exec' ? (
|
||||
<Text color={Colors.AccentYellow}>
|
||||
MacOS Seatbelt{' '}
|
||||
macOS Seatbelt{' '}
|
||||
<Text color={Colors.Gray}>({process.env.SEATBELT_PROFILE})</Text>
|
||||
</Text>
|
||||
) : (
|
||||
|
||||
@@ -448,7 +448,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
|
||||
return;
|
||||
}
|
||||
|
||||
// Fallback to the text buffer's default input handling for all other keys
|
||||
// Fall back to the text buffer's default input handling for all other keys
|
||||
buffer.handleInput(key);
|
||||
},
|
||||
[
|
||||
|
||||
@@ -73,7 +73,7 @@ export function ThemeDialog({
|
||||
const initialThemeIndex = themeItems.findIndex(
|
||||
(item) => item.value === selectedThemeName,
|
||||
);
|
||||
// If not found, fallback to the first theme
|
||||
// If not found, fall back to the first theme
|
||||
const safeInitialThemeIndex = initialThemeIndex >= 0 ? initialThemeIndex : 0;
|
||||
|
||||
const scopeItems = [
|
||||
@@ -185,7 +185,7 @@ export function ThemeDialog({
|
||||
}
|
||||
|
||||
// Don't focus the scope selection if it is hidden due to height constraints.
|
||||
const currenFocusedSection = !showScopeSelection ? 'theme' : focusedSection;
|
||||
const currentFocusedSection = !showScopeSelection ? 'theme' : focusedSection;
|
||||
|
||||
// Vertical space taken by elements other than the two code blocks in the preview pane.
|
||||
// Includes "Preview" title, borders, and margin between blocks.
|
||||
@@ -224,8 +224,8 @@ export function ThemeDialog({
|
||||
<Box flexDirection="row">
|
||||
{/* Left Column: Selection */}
|
||||
<Box flexDirection="column" width="45%" paddingRight={2}>
|
||||
<Text bold={currenFocusedSection === 'theme'} wrap="truncate">
|
||||
{currenFocusedSection === 'theme' ? '> ' : ' '}Select Theme{' '}
|
||||
<Text bold={currentFocusedSection === 'theme'} wrap="truncate">
|
||||
{currentFocusedSection === 'theme' ? '> ' : ' '}Select Theme{' '}
|
||||
<Text color={Colors.Gray}>{otherScopeModifiedMessage}</Text>
|
||||
</Text>
|
||||
<RadioButtonSelect
|
||||
@@ -234,25 +234,25 @@ export function ThemeDialog({
|
||||
initialIndex={safeInitialThemeIndex}
|
||||
onSelect={handleThemeSelect}
|
||||
onHighlight={handleThemeHighlight}
|
||||
isFocused={currenFocusedSection === 'theme'}
|
||||
isFocused={currentFocusedSection === 'theme'}
|
||||
maxItemsToShow={8}
|
||||
showScrollArrows={true}
|
||||
showNumbers={currenFocusedSection === 'theme'}
|
||||
showNumbers={currentFocusedSection === 'theme'}
|
||||
/>
|
||||
|
||||
{/* Scope Selection */}
|
||||
{showScopeSelection && (
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text bold={currenFocusedSection === 'scope'} wrap="truncate">
|
||||
{currenFocusedSection === 'scope' ? '> ' : ' '}Apply To
|
||||
<Text bold={currentFocusedSection === 'scope'} wrap="truncate">
|
||||
{currentFocusedSection === 'scope' ? '> ' : ' '}Apply To
|
||||
</Text>
|
||||
<RadioButtonSelect
|
||||
items={scopeItems}
|
||||
initialIndex={0} // Default to User Settings
|
||||
onSelect={handleScopeSelect}
|
||||
onHighlight={handleScopeHighlight}
|
||||
isFocused={currenFocusedSection === 'scope'}
|
||||
showNumbers={currenFocusedSection === 'scope'}
|
||||
isFocused={currentFocusedSection === 'scope'}
|
||||
showNumbers={currentFocusedSection === 'scope'}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
@@ -261,7 +261,7 @@ export function ThemeDialog({
|
||||
{/* Right Column: Preview */}
|
||||
<Box flexDirection="column" width="55%" paddingLeft={2}>
|
||||
<Text bold>Preview</Text>
|
||||
{/* Get the Theme object for the highlighted theme, fallback to default if not found */}
|
||||
{/* Get the Theme object for the highlighted theme, fall back to default if not found */}
|
||||
{(() => {
|
||||
const previewTheme =
|
||||
themeManager.getTheme(
|
||||
|
||||
@@ -146,7 +146,7 @@ function executeShellCommand(
|
||||
process.kill(-child.pid, 'SIGKILL');
|
||||
}
|
||||
} catch (_e) {
|
||||
// Fallback to killing just the main process if group kill fails.
|
||||
// Fall back to killing just the main process if group kill fails.
|
||||
if (!exited) child.kill('SIGKILL');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ describe('useHistoryManager', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should not change history if updateHistoryItem is called with a non-existent ID', () => {
|
||||
it('should not change history if updateHistoryItem is called with a nonexistent ID', () => {
|
||||
const { result } = renderHook(() => useHistory());
|
||||
const timestamp = Date.now();
|
||||
const itemData: Omit<HistoryItem, 'id'> = {
|
||||
@@ -107,7 +107,7 @@ describe('useHistoryManager', () => {
|
||||
const originalHistory = [...result.current.history]; // Clone before update attempt
|
||||
|
||||
act(() => {
|
||||
result.current.updateItem(99999, { text: 'Should not apply' }); // Non-existent ID
|
||||
result.current.updateItem(99999, { text: 'Should not apply' }); // Nonexistent ID
|
||||
});
|
||||
|
||||
expect(result.current.history).toEqual(originalHistory);
|
||||
|
||||
@@ -67,7 +67,7 @@ describe('useShellHistory', () => {
|
||||
expect(command).toBe('cmd2');
|
||||
});
|
||||
|
||||
it('should handle a non-existent history file gracefully', async () => {
|
||||
it('should handle a nonexistent history file gracefully', async () => {
|
||||
const error = new Error('File not found') as NodeJS.ErrnoException;
|
||||
error.code = 'ENOENT';
|
||||
mockedFs.readFile.mockRejectedValue(error);
|
||||
|
||||
@@ -341,7 +341,7 @@ describe('useReactToolScheduler', () => {
|
||||
const schedule = result.current[1];
|
||||
const request: ToolCallRequestInfo = {
|
||||
callId: 'call1',
|
||||
name: 'nonExistentTool',
|
||||
name: 'nonexistentTool',
|
||||
args: {},
|
||||
};
|
||||
|
||||
@@ -361,7 +361,7 @@ describe('useReactToolScheduler', () => {
|
||||
request,
|
||||
response: expect.objectContaining({
|
||||
error: expect.objectContaining({
|
||||
message: 'Tool "nonExistentTool" not found in registry.',
|
||||
message: 'Tool "nonexistentTool" not found in registry.',
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Shades of Purple Theme — for Highlightjs.
|
||||
* Shades of Purple Theme — for Highlight.js.
|
||||
* @author Ahmad Awais <https://twitter.com/mrahmadawais/>
|
||||
*/
|
||||
import { type ColorsTheme, Theme } from './theme.js';
|
||||
|
||||
@@ -85,7 +85,7 @@ describe('ThemeManager', () => {
|
||||
expect(themeManager.getTheme('MyCustomTheme')).toBeDefined();
|
||||
});
|
||||
|
||||
it('should fallback to default theme if active theme is invalid', () => {
|
||||
it('should fall back to default theme if active theme is invalid', () => {
|
||||
(themeManager as unknown as { activeTheme: unknown }).activeTheme = {
|
||||
name: 'NonExistent',
|
||||
type: 'custom',
|
||||
|
||||
@@ -117,7 +117,7 @@ class ThemeManager {
|
||||
if (process.env.NO_COLOR) {
|
||||
return NoColorTheme;
|
||||
}
|
||||
// Ensure the active theme is always valid (fallback to default if not)
|
||||
// Ensure the active theme is always valid (fall back to default if not)
|
||||
if (!this.activeTheme || !this.findThemeByName(this.activeTheme.name)) {
|
||||
this.activeTheme = DEFAULT_THEME;
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ export class Theme {
|
||||
inkTheme[key] = resolvedColor;
|
||||
}
|
||||
// If color is not resolvable, it's omitted from the map,
|
||||
// allowing fallback to the default foreground color.
|
||||
// this enables falling back to the default foreground color.
|
||||
}
|
||||
// We currently only care about the 'color' property for Ink rendering.
|
||||
// Other properties like background, fontStyle, etc., are ignored.
|
||||
|
||||
@@ -50,7 +50,7 @@ function renderHastNode(
|
||||
}
|
||||
|
||||
// Determine the color to pass down: Use this element's specific color
|
||||
// if found, otherwise, continue passing down the already inherited color.
|
||||
// if found; otherwise, continue passing down the already inherited color.
|
||||
const colorToPassDown = elementColor || inheritedColor;
|
||||
|
||||
// Recursively render children, passing the determined color down
|
||||
@@ -70,7 +70,7 @@ function renderHastNode(
|
||||
|
||||
// Handle Root Node: Start recursion with initially inherited color
|
||||
if (node.type === 'root') {
|
||||
// Check if children array is empty - this happens when lowlight can't detect language – fallback to plain text
|
||||
// Check if children array is empty - this happens when lowlight can't detect language – fall back to plain text
|
||||
if (!node.children || node.children.length === 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -161,7 +161,7 @@ export function colorizeCode(
|
||||
`[colorizeCode] Error highlighting code for language "${language}":`,
|
||||
error,
|
||||
);
|
||||
// Fallback to plain text with default color on error
|
||||
// Fall back to plain text with default color on error
|
||||
// Also display line numbers in fallback
|
||||
const lines = codeToHighlight.split('\n');
|
||||
const padWidth = String(lines.length).length; // Calculate padding width based on number of lines
|
||||
|
||||
@@ -200,7 +200,7 @@ describe('commandUtils', () => {
|
||||
expect(mockChild.stdin.end).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should fallback to xsel when xclip fails', async () => {
|
||||
it('should fall back to xsel when xclip fails', async () => {
|
||||
const testText = 'Hello, world!';
|
||||
let callCount = 0;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ This function aims to find an *intelligent* or "safe" index within the provided
|
||||
* **Single Line Breaks:** If no double newline is found in a suitable range, it will look for a single newline (`\n`).
|
||||
* Any newline chosen as a split point must also not be inside a code block.
|
||||
|
||||
4. **Fallback to `idealMaxLength`:**
|
||||
4. **Fall back to `idealMaxLength`:**
|
||||
* If no "safer" split point (respecting code blocks or finding suitable newlines) is identified before or at `idealMaxLength`, and `idealMaxLength` itself is not determined to be an unsafe split point (e.g., inside a code block), the function may return a length larger than `idealMaxLength`, again it CANNOT break markdown formatting. This could happen with very long lines of text without Markdown block structures or newlines.
|
||||
|
||||
**In essence, `findSafeSplitPoint` tries to be a good Markdown citizen when forced to divide content, preferring structural boundaries over arbitrary character limits, with a strong emphasis on not corrupting code blocks.**
|
||||
|
||||
@@ -99,7 +99,7 @@ async function shouldUseCurrentUserInSandbox(): Promise<boolean> {
|
||||
}
|
||||
|
||||
// docker does not allow container names to contain ':' or '/', so we
|
||||
// parse those out and make the name a little shorter
|
||||
// parse those out to shorten the name
|
||||
function parseImageName(image: string): string {
|
||||
const [fullName, tag] = image.split(':');
|
||||
const name = fullName.split('/').at(-1) ?? 'unknown-image';
|
||||
@@ -187,7 +187,7 @@ export async function start_sandbox(
|
||||
if (config.command === 'sandbox-exec') {
|
||||
// disallow BUILD_SANDBOX
|
||||
if (process.env.BUILD_SANDBOX) {
|
||||
console.error('ERROR: cannot BUILD_SANDBOX when using MacOS Seatbelt');
|
||||
console.error('ERROR: cannot BUILD_SANDBOX when using macOS Seatbelt');
|
||||
process.exit(1);
|
||||
}
|
||||
const profile = (process.env.SEATBELT_PROFILE ??= 'permissive-open');
|
||||
@@ -847,7 +847,7 @@ async function ensureSandboxImageIsPresent(
|
||||
|
||||
console.info(`Sandbox image ${image} not found locally.`);
|
||||
if (image === LOCAL_DEV_SANDBOX_IMAGE_NAME) {
|
||||
// user needs to build the image themself
|
||||
// user needs to build the image themselves
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
CodeAssistGlobalUserSettingResponse,
|
||||
LoadCodeAssistRequest,
|
||||
LoadCodeAssistResponse,
|
||||
LongrunningOperationResponse,
|
||||
LongRunningOperationResponse,
|
||||
OnboardUserRequest,
|
||||
SetCodeAssistGlobalUserSettingRequest,
|
||||
} from './types.js';
|
||||
@@ -79,8 +79,8 @@ export class CodeAssistServer implements ContentGenerator {
|
||||
|
||||
async onboardUser(
|
||||
req: OnboardUserRequest,
|
||||
): Promise<LongrunningOperationResponse> {
|
||||
return await this.requestPost<LongrunningOperationResponse>(
|
||||
): Promise<LongRunningOperationResponse> {
|
||||
return await this.requestPost<LongRunningOperationResponse>(
|
||||
'onboardUser',
|
||||
req,
|
||||
);
|
||||
|
||||
@@ -127,10 +127,10 @@ export interface OnboardUserRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents LongrunningOperation proto
|
||||
* Represents LongRunningOperation proto
|
||||
* http://google3/google/longrunning/operations.proto;rcl=698857719;l=107
|
||||
*/
|
||||
export interface LongrunningOperationResponse {
|
||||
export interface LongRunningOperationResponse {
|
||||
name: string;
|
||||
done?: boolean;
|
||||
response?: OnboardUserResponse;
|
||||
|
||||
@@ -72,7 +72,7 @@ describe('Flash Model Fallback Configuration', () => {
|
||||
expect(config.getModel()).toBe(DEFAULT_GEMINI_FLASH_MODEL);
|
||||
});
|
||||
|
||||
it('should fallback to initial model if contentGeneratorConfig is not available', () => {
|
||||
it('should fall back to initial model if contentGeneratorConfig is not available', () => {
|
||||
// Test with fresh config where contentGeneratorConfig might not be set
|
||||
const newConfig = new Config({
|
||||
sessionId: 'test-session-2',
|
||||
|
||||
@@ -798,8 +798,8 @@ When requested to perform tasks like fixing bugs, adding features, refactoring,
|
||||
- **Feedback:** To report a bug or provide feedback, please use the /bug command.
|
||||
|
||||
|
||||
# MacOS Seatbelt
|
||||
You are running under macos seatbelt with limited access to files outside the project directory or system temp directory, and with limited access to host system resources such as ports. If you encounter failures that could be due to MacOS Seatbelt (e.g. if a command fails with 'Operation not permitted' or similar error), as you report the error to the user, also explain why you think it could be due to MacOS Seatbelt, and how the user may need to adjust their Seatbelt profile.
|
||||
# macOS Seatbelt
|
||||
You are running under macos seatbelt with limited access to files outside the project directory or system temp directory, and with limited access to host system resources such as ports. If you encounter failures that could be due to macOS Seatbelt (e.g. if a command fails with 'Operation not permitted' or similar error), as you report the error to the user, also explain why you think it could be due to macOS Seatbelt, and how the user may need to adjust their Seatbelt profile.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -665,8 +665,8 @@ export class GeminiClient {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles fallback to Flash model when persistent 429 errors occur for OAuth users.
|
||||
* Uses a fallback handler if provided by the config, otherwise returns null.
|
||||
* Handles falling back to Flash model when persistent 429 errors occur for OAuth users.
|
||||
* Uses a fallback handler if provided by the config; otherwise, returns null.
|
||||
*/
|
||||
private async handleFlashFallback(
|
||||
authType?: string,
|
||||
|
||||
@@ -62,7 +62,7 @@ export function createContentGeneratorConfig(
|
||||
const googleCloudProject = process.env.GOOGLE_CLOUD_PROJECT || undefined;
|
||||
const googleCloudLocation = process.env.GOOGLE_CLOUD_LOCATION || undefined;
|
||||
|
||||
// Use runtime model from config if available, otherwise fallback to parameter or default
|
||||
// Use runtime model from config if available; otherwise, fall back to parameter or default
|
||||
const effectiveModel = config.getModel() || DEFAULT_GEMINI_MODEL;
|
||||
|
||||
const contentGeneratorConfig: ContentGeneratorConfig = {
|
||||
|
||||
@@ -201,8 +201,8 @@ export class GeminiChat {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles fallback to Flash model when persistent 429 errors occur for OAuth users.
|
||||
* Uses a fallback handler if provided by the config, otherwise returns null.
|
||||
* Handles falling back to Flash model when persistent 429 errors occur for OAuth users.
|
||||
* Uses a fallback handler if provided by the config; otherwise, returns null.
|
||||
*/
|
||||
private async handleFlashFallback(
|
||||
authType?: string,
|
||||
|
||||
@@ -453,7 +453,7 @@ describe('Logger', () => {
|
||||
});
|
||||
|
||||
it('should return an empty array if a tagged checkpoint file does not exist', async () => {
|
||||
const loaded = await logger.loadCheckpoint('non-existent-tag');
|
||||
const loaded = await logger.loadCheckpoint('nonexistent-tag');
|
||||
expect(loaded).toEqual([]);
|
||||
});
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ describe('executeToolCall', () => {
|
||||
it('should return an error if tool is not found', async () => {
|
||||
const request: ToolCallRequestInfo = {
|
||||
callId: 'call2',
|
||||
name: 'nonExistentTool',
|
||||
name: 'nonexistentTool',
|
||||
args: {},
|
||||
isClientInitiated: false,
|
||||
prompt_id: 'prompt-id-2',
|
||||
@@ -123,17 +123,17 @@ describe('executeToolCall', () => {
|
||||
expect(response.callId).toBe('call2');
|
||||
expect(response.error).toBeInstanceOf(Error);
|
||||
expect(response.error?.message).toBe(
|
||||
'Tool "nonExistentTool" not found in registry.',
|
||||
'Tool "nonexistentTool" not found in registry.',
|
||||
);
|
||||
expect(response.resultDisplay).toBe(
|
||||
'Tool "nonExistentTool" not found in registry.',
|
||||
'Tool "nonexistentTool" not found in registry.',
|
||||
);
|
||||
expect(response.responseParts).toEqual([
|
||||
{
|
||||
functionResponse: {
|
||||
name: 'nonExistentTool',
|
||||
name: 'nonexistentTool',
|
||||
id: 'call2',
|
||||
response: { error: 'Tool "nonExistentTool" not found in registry.' },
|
||||
response: { error: 'Tool "nonexistentTool" not found in registry.' },
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -67,7 +67,7 @@ describe('Core System Prompt (prompts.ts)', () => {
|
||||
vi.stubEnv('SANDBOX', 'true'); // Generic sandbox value
|
||||
const prompt = getCoreSystemPrompt();
|
||||
expect(prompt).toContain('# Sandbox');
|
||||
expect(prompt).not.toContain('# MacOS Seatbelt');
|
||||
expect(prompt).not.toContain('# macOS Seatbelt');
|
||||
expect(prompt).not.toContain('# Outside of Sandbox');
|
||||
expect(prompt).toMatchSnapshot();
|
||||
});
|
||||
@@ -75,7 +75,7 @@ describe('Core System Prompt (prompts.ts)', () => {
|
||||
it('should include seatbelt-specific instructions when SANDBOX env var is "sandbox-exec"', () => {
|
||||
vi.stubEnv('SANDBOX', 'sandbox-exec');
|
||||
const prompt = getCoreSystemPrompt();
|
||||
expect(prompt).toContain('# MacOS Seatbelt');
|
||||
expect(prompt).toContain('# macOS Seatbelt');
|
||||
expect(prompt).not.toContain('# Sandbox');
|
||||
expect(prompt).not.toContain('# Outside of Sandbox');
|
||||
expect(prompt).toMatchSnapshot();
|
||||
@@ -86,7 +86,7 @@ describe('Core System Prompt (prompts.ts)', () => {
|
||||
const prompt = getCoreSystemPrompt();
|
||||
expect(prompt).toContain('# Outside of Sandbox');
|
||||
expect(prompt).not.toContain('# Sandbox');
|
||||
expect(prompt).not.toContain('# MacOS Seatbelt');
|
||||
expect(prompt).not.toContain('# macOS Seatbelt');
|
||||
expect(prompt).toMatchSnapshot();
|
||||
});
|
||||
|
||||
|
||||
@@ -116,8 +116,8 @@ ${(function () {
|
||||
|
||||
if (isSandboxExec) {
|
||||
return `
|
||||
# MacOS Seatbelt
|
||||
You are running under macos seatbelt with limited access to files outside the project directory or system temp directory, and with limited access to host system resources such as ports. If you encounter failures that could be due to MacOS Seatbelt (e.g. if a command fails with 'Operation not permitted' or similar error), as you report the error to the user, also explain why you think it could be due to MacOS Seatbelt, and how the user may need to adjust their Seatbelt profile.
|
||||
# macOS Seatbelt
|
||||
You are running under macos seatbelt with limited access to files outside the project directory or system temp directory, and with limited access to host system resources such as ports. If you encounter failures that could be due to macOS Seatbelt (e.g. if a command fails with 'Operation not permitted' or similar error), as you report the error to the user, also explain why you think it could be due to macOS Seatbelt, and how the user may need to adjust their Seatbelt profile.
|
||||
`;
|
||||
} else if (isGenericSandbox) {
|
||||
return `
|
||||
|
||||
@@ -86,7 +86,7 @@ export function createIdeContextStore() {
|
||||
|
||||
/**
|
||||
* Retrieves the current active file context.
|
||||
* @returns The `OpenFiles` object if a file is active, otherwise `undefined`.
|
||||
* @returns The `OpenFiles` object if a file is active; otherwise, `undefined`.
|
||||
*/
|
||||
function getOpenFilesContext(): OpenFiles | undefined {
|
||||
return openFilesContext;
|
||||
|
||||
@@ -209,7 +209,7 @@ Expectation for required parameters:
|
||||
// Creating a new file
|
||||
isNewFile = true;
|
||||
} else if (!fileExists) {
|
||||
// Trying to edit a non-existent file (and old_string is not empty)
|
||||
// Trying to edit a nonexistent file (and old_string is not empty)
|
||||
error = {
|
||||
display: `File not found. Cannot apply edit. Use an empty old_string to create a new file.`,
|
||||
raw: `File not found: ${params.file_path}`,
|
||||
@@ -239,12 +239,12 @@ Expectation for required parameters:
|
||||
raw: `Failed to edit, 0 occurrences found for old_string in ${params.file_path}. No edits made. The exact text in old_string was not found. Ensure you're not escaping content incorrectly and check whitespace, indentation, and context. Use ${ReadFileTool.Name} tool to verify.`,
|
||||
};
|
||||
} else if (occurrences !== expectedReplacements) {
|
||||
const occurenceTerm =
|
||||
const occurrenceTerm =
|
||||
expectedReplacements === 1 ? 'occurrence' : 'occurrences';
|
||||
|
||||
error = {
|
||||
display: `Failed to edit, expected ${expectedReplacements} ${occurenceTerm} but found ${occurrences}.`,
|
||||
raw: `Failed to edit, Expected ${expectedReplacements} ${occurenceTerm} but found ${occurrences} for old_string in file: ${params.file_path}`,
|
||||
display: `Failed to edit, expected ${expectedReplacements} ${occurrenceTerm} but found ${occurrences}.`,
|
||||
raw: `Failed to edit, Expected ${expectedReplacements} ${occurrenceTerm} but found ${occurrences} for old_string in file: ${params.file_path}`,
|
||||
};
|
||||
} else if (finalOldString === finalNewString) {
|
||||
error = {
|
||||
|
||||
@@ -17,7 +17,7 @@ vi.mock('child_process', () => ({
|
||||
on: (event: string, cb: (...args: unknown[]) => void) => {
|
||||
if (event === 'error' || event === 'close') {
|
||||
// Simulate command not found or error for git grep and system grep
|
||||
// to force fallback to JS implementation.
|
||||
// to force it to fall back to JS implementation.
|
||||
setTimeout(() => cb(1), 0); // cb(1) for error/close
|
||||
}
|
||||
},
|
||||
|
||||
@@ -272,7 +272,7 @@ describe('ReadManyFilesTool', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should handle non-existent specific files gracefully', async () => {
|
||||
it('should handle nonexistent specific files gracefully', async () => {
|
||||
const params = { paths: ['nonexistent-file.txt'] };
|
||||
const result = await tool.execute(params, new AbortController().signal);
|
||||
expect(result.llmContent).toEqual([
|
||||
|
||||
@@ -81,7 +81,7 @@ describe('editCorrector', () => {
|
||||
it('should correctly count occurrences when substring is longer', () => {
|
||||
expect(countOccurrences('abc', 'abcdef')).toBe(0);
|
||||
});
|
||||
it('should be case sensitive', () => {
|
||||
it('should be case-sensitive', () => {
|
||||
expect(countOccurrences('abcABC', 'a')).toBe(1);
|
||||
expect(countOccurrences('abcABC', 'A')).toBe(1);
|
||||
});
|
||||
|
||||
@@ -202,7 +202,7 @@ describe('editor utils', () => {
|
||||
});
|
||||
}
|
||||
|
||||
it(`should fallback to last command "${commands[commands.length - 1]}" when none exist on non-windows`, () => {
|
||||
it(`should fall back to last command "${commands[commands.length - 1]}" when none exist on non-windows`, () => {
|
||||
Object.defineProperty(process, 'platform', { value: 'linux' });
|
||||
(execSync as Mock).mockImplementation(() => {
|
||||
throw new Error(); // all commands not found
|
||||
@@ -247,7 +247,7 @@ describe('editor utils', () => {
|
||||
});
|
||||
}
|
||||
|
||||
it(`should fallback to last command "${win32Commands[win32Commands.length - 1]}" when none exist on windows`, () => {
|
||||
it(`should fall back to last command "${win32Commands[win32Commands.length - 1]}" when none exist on windows`, () => {
|
||||
Object.defineProperty(process, 'platform', { value: 'win32' });
|
||||
(execSync as Mock).mockImplementation(() => {
|
||||
throw new Error(); // all commands not found
|
||||
|
||||
@@ -42,7 +42,7 @@ describe('fileUtils', () => {
|
||||
let testImageFilePath: string;
|
||||
let testPdfFilePath: string;
|
||||
let testBinaryFilePath: string;
|
||||
let nonExistentFilePath: string;
|
||||
let nonexistentFilePath: string;
|
||||
let directoryPath: string;
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -57,7 +57,7 @@ describe('fileUtils', () => {
|
||||
testImageFilePath = path.join(tempRootDir, 'image.png');
|
||||
testPdfFilePath = path.join(tempRootDir, 'document.pdf');
|
||||
testBinaryFilePath = path.join(tempRootDir, 'app.exe');
|
||||
nonExistentFilePath = path.join(tempRootDir, 'notfound.txt');
|
||||
nonexistentFilePath = path.join(tempRootDir, 'nonexistent.txt');
|
||||
directoryPath = path.join(tempRootDir, 'subdir');
|
||||
|
||||
actualNodeFs.mkdirSync(directoryPath, { recursive: true }); // Ensure subdir exists
|
||||
@@ -284,7 +284,7 @@ describe('fileUtils', () => {
|
||||
|
||||
it('should handle file not found', async () => {
|
||||
const result = await processSingleFileContent(
|
||||
nonExistentFilePath,
|
||||
nonexistentFilePath,
|
||||
tempRootDir,
|
||||
);
|
||||
expect(result.error).toContain('File not found');
|
||||
|
||||
@@ -185,7 +185,7 @@ export async function detectFileType(
|
||||
return 'binary';
|
||||
}
|
||||
|
||||
// Fallback to content-based check if mime type wasn't conclusive for image/pdf
|
||||
// Fall back to content-based check if mime type wasn't conclusive for image/pdf
|
||||
// and it's not a known binary extension.
|
||||
if (await isBinaryFile(filePath)) {
|
||||
return 'binary';
|
||||
|
||||
@@ -245,7 +245,7 @@ Showing up to 1 items (files + folders). Folders or files indicated with ... con
|
||||
expect(structure.trim()).toBe(expectedRevisedMax1);
|
||||
});
|
||||
|
||||
it('should handle non-existent directory', async () => {
|
||||
it('should handle nonexistent directory', async () => {
|
||||
// Temporarily make fsPromises.readdir throw ENOENT for this specific path
|
||||
const originalReaddir = fsPromises.readdir;
|
||||
(fsPromises.readdir as Mock).mockImplementation(
|
||||
|
||||
@@ -44,7 +44,7 @@ export function shortenPath(filePath: string, maxLen: number = 35): string {
|
||||
|
||||
// Handle cases with no segments after root (e.g., "/", "C:\") or only one segment
|
||||
if (segments.length <= 1) {
|
||||
// Fallback to simple start/end truncation for very short paths or single segments
|
||||
// Fall back to simple start/end truncation for very short paths or single segments
|
||||
const keepLen = Math.floor((maxLen - 3) / 2);
|
||||
// Ensure keepLen is not negative if maxLen is very small
|
||||
if (keepLen <= 0) {
|
||||
|
||||
@@ -196,7 +196,7 @@ export async function retryWithBackoff<T>(
|
||||
// Reset currentDelay for next potential non-429 error, or if Retry-After is not present next time
|
||||
currentDelay = initialDelayMs;
|
||||
} else {
|
||||
// Fallback to exponential backoff with jitter
|
||||
// Fall back to exponential backoff with jitter
|
||||
logRetryAttempt(attempt, error, errorStatus);
|
||||
// Add jitter: +/- 30% of currentDelay
|
||||
const jitter = currentDelay * 0.3 * (Math.random() * 2 - 1);
|
||||
|
||||
Reference in New Issue
Block a user