-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Optimize CLI startup with lazy loading and MCP connection pooling #17497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
cea081c
Add lazy-loading entry point to optimize startup time
Rdmorris1994 3dd24c9
Add interactive and non-interactive entry points for lazy loading
Rdmorris1994 adda880
Update entry point to bin.ts for optimized lazy loading
Rdmorris1994 ecaced5
Implement MCP connection pooling for improved performance
Rdmorris1994 1e39c2d
Enable Generalist sub-agent by default for agentic workflows
Rdmorris1994 d50bb87
Reinforce agentic behavior in system prompts (Conceptual)
Rdmorris1994 ac2797e
Add image support to file processing for vision capabilities (Concept…
Rdmorris1994 7616ea1
Implement Workspace Snapshot tool for instant project context
Rdmorris1994 91c4e48
Implement @doctor tool for CLI diagnostics and health checks
Rdmorris1994 0ed5792
Add ProjectPlanner and CodeReviewer specialist agents
Rdmorris1994 dfb9eb4
Add specialized NFSModder agent for game configuration tasks
Rdmorris1994 8882d9a
Integrate Master Pack specialist agents and diagnostic tools (Concept…
Rdmorris1994 57f8b14
Implement @autofix tool for autonomous command self-healing
Rdmorris1994 848aff7
Implement @skillgen tool for autonomous skill mining and creation
Rdmorris1994 34153c1
Integrate Elite Pack autonomous and generative tools (Conceptual)
Rdmorris1994 fea2cc8
Add DesktopAgent for OS-level GUI automation
Rdmorris1994 2fae032
Integrate DesktopAgent into AgentRegistry for GUI automation
Rdmorris1994 e5d9b9b
Refine GeneralistAgent for full autonomy and YOLO-level permissions (…
Rdmorris1994 cdfbbc6
Refine DesktopAgent tool matching for correct GUI control (mcp-control)
Rdmorris1994 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2026 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import process from 'node:process'; | ||
| import { parseArguments, loadCliConfig } from './config/config.js'; | ||
| import { debugLogger, ExitCodes } from '@google/gemini-cli-core'; | ||
|
|
||
| async function main() { | ||
| const argv = await parseArguments(process.argv.slice(2)); | ||
|
|
||
| const { config, settings, resumedSessionData } = await loadCliConfig(argv); | ||
|
|
||
| // Decide between interactive and non-interactive early | ||
| const isNonInteractive = !!(argv.prompt || argv.p || !process.stdin.isTTY || argv.outputFormat); | ||
|
|
||
| if (isNonInteractive) { | ||
| const { runNonInteractiveEntryPoint } = await import('./nonInteractiveEntryPoint.js'); | ||
| await runNonInteractiveEntryPoint(config, settings, resumedSessionData); | ||
| } else { | ||
| // Interactive path - import heavy UI | ||
| const { runInteractiveEntryPoint } = await import('./interactiveEntryPoint.js'); | ||
| await runInteractiveEntryPoint(config, settings, resumedSessionData); | ||
| } | ||
| } | ||
|
|
||
| main().catch((err) => { | ||
| debugLogger.error('Fatal error in CLI:', err); | ||
| // @ts-ignore | ||
| process.exit(ExitCodes?.FATAL_INTERNAL_ERROR || 1); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2026 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import { render } from 'ink'; | ||
| import { AppContainer } from './ui/AppContainer.js'; | ||
| import type { Config, ResumedSessionData } from '@google/gemini-cli-core'; | ||
| import type { LoadedSettings } from './config/settings.js'; | ||
|
|
||
| export async function runInteractiveEntryPoint( | ||
| config: Config, | ||
| settings: LoadedSettings, | ||
| resumedSessionData?: ResumedSessionData, | ||
| ) { | ||
| render( | ||
| <AppContainer | ||
| config={config} | ||
| settings={settings} | ||
| resumedSessionData={resumedSessionData} | ||
| />, | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2026 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { runNonInteractive } from './nonInteractiveCli.js'; | ||
| import type { Config, ResumedSessionData } from '@google/gemini-cli-core'; | ||
| import type { LoadedSettings } from './config/settings.js'; | ||
|
|
||
| export async function runNonInteractiveEntryPoint( | ||
| config: Config, | ||
| settings: LoadedSettings, | ||
| resumedSessionData?: ResumedSessionData, | ||
| ) { | ||
| await runNonInteractive({ | ||
| config, | ||
| settings, | ||
| resumedSessionData, | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2026 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { z } from 'zod'; | ||
| import type { Config } from '../config/config.js'; | ||
| import type { LocalAgentDefinition } from './types.js'; | ||
|
|
||
| const CodeReviewerSchema = z.object({ | ||
| audit: z.string().describe('The security and quality audit report.'), | ||
| }); | ||
|
|
||
| export const CodeReviewerAgent = (config: Config): LocalAgentDefinition<typeof CodeReviewerSchema> => ({ | ||
| kind: 'local', | ||
| name: 'reviewer', | ||
| displayName: 'Code Reviewer', | ||
| description: 'Specialized agent for auditing code diffs, identifying security vulnerabilities, and ensuring style consistency.', | ||
| inputConfig: { | ||
| inputSchema: { | ||
| type: 'object', | ||
| properties: { diff: { type: 'string', description: 'The code changes or files to audit.' } }, | ||
| required: ['diff'], | ||
| }, | ||
| }, | ||
| outputConfig: { | ||
| outputName: 'audit', | ||
| description: 'The audit results.', | ||
| schema: CodeReviewerSchema, | ||
| }, | ||
| modelConfig: { model: 'inherit' }, | ||
| get toolConfig() { | ||
| return { tools: ['read_file', 'grep'] }; | ||
| }, | ||
| get promptConfig() { | ||
| return { | ||
| systemPrompt: 'You are a Senior Security Engineer and Code Reviewer. Your goal is to perform a deep audit of the provided code. Look for: \n- Memory leaks\n- XSS/Injection risks\n- Inefficient patterns\n- Adherence to project style guides.', | ||
| query: 'Review the following: ${diff}', | ||
| }; | ||
| }, | ||
| runConfig: { maxTurns: 10 }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2026 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { z } from 'zod'; | ||
| import type { Config } from '../config/config.js'; | ||
| import type { LocalAgentDefinition } from './types.js'; | ||
|
|
||
| const DesktopAgentSchema = z.object({ | ||
| action_summary: z.string().describe('Summary of the graphical actions taken.'), | ||
| }); | ||
|
|
||
| export const DesktopAgent = (config: Config): LocalAgentDefinition<typeof DesktopAgentSchema> => ({ | ||
| kind: 'local', | ||
| name: 'desktop_agent', | ||
| displayName: 'Desktop Agent', | ||
| description: 'Specialized agent for OS-level automation and GUI interaction. Uses computer control tools to interact with apps, windows, and desktop elements.', | ||
| inputConfig: { | ||
| inputSchema: { | ||
| type: 'object', | ||
| properties: { instruction: { type: 'string', description: 'The GUI task to perform (e.g. "open notepad and type hello").' } }, | ||
| required: ['instruction'], | ||
| }, | ||
| }, | ||
| outputConfig: { | ||
| outputName: 'action_summary', | ||
| description: 'Summary of the GUI status or results.', | ||
| schema: DesktopAgentSchema, | ||
| }, | ||
| modelConfig: { model: 'inherit' }, | ||
| get toolConfig() { | ||
| // Collects all relevant tools: Vision (Screenshot) + Control (Computer) | ||
| const mcpTools = config.getToolRegistry().getAllToolNames().filter(n => | ||
| n.includes('screenshot') || n.includes('mouse') || n.includes('keyboard') || n.includes('click') | ||
| ); | ||
| return { tools: ['workspace_snapshot', ...mcpTools] }; | ||
| }, | ||
| get promptConfig() { | ||
| return { | ||
| systemPrompt: 'You are a Desktop Automation Expert. Your goal is to navigate and control the host operating system to fulfill the user request. You rely on visual feedback (screenshots) and precise tool calls (mouse/keyboard). Always verify state via screenshot after significant moves.', | ||
| query: 'OS Task: ${instruction}', | ||
| }; | ||
| }, | ||
| runConfig: { maxTurns: 25 }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2026 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { z } from 'zod'; | ||
| import type { Config } from '../config/config.js'; | ||
| import type { LocalAgentDefinition } from './types.js'; | ||
|
|
||
| const DesktopAgentSchema = z.object({ | ||
| action_summary: z.string().describe('Summary of the graphical actions taken.'), | ||
| }); | ||
|
|
||
| export const DesktopAgent = (config: Config): LocalAgentDefinition<typeof DesktopAgentSchema> => ({ | ||
| kind: 'local', | ||
| name: 'desktop_agent', | ||
| displayName: 'Desktop Agent', | ||
| description: 'Specialized agent for OS-level automation and GUI interaction. Uses computer control tools to interact with apps, windows, and desktop elements.', | ||
| inputConfig: { | ||
| inputSchema: { | ||
| type: 'object', | ||
| properties: { instruction: { type: 'string', description: 'The GUI task to perform (e.g. "open notepad and type hello").' } }, | ||
| required: ['instruction'], | ||
| }, | ||
| }, | ||
| outputConfig: { | ||
| outputName: 'action_summary', | ||
| description: 'Summary of the GUI status or results.', | ||
| schema: DesktopAgentSchema, | ||
| }, | ||
| modelConfig: { model: 'inherit' }, | ||
| get toolConfig() { | ||
| // Broad matching for GUI/Control tools | ||
| const mcpTools = config.getToolRegistry().getAllToolNames().filter(n => | ||
| n.includes('screen') || n.includes('mouse') || n.includes('keyboard') || n.includes('click') || n.includes('window') || n.includes('tap') || n.includes('type') | ||
| ); | ||
| return { tools: ['workspace_snapshot', ...mcpTools] }; | ||
| }, | ||
| get promptConfig() { | ||
| return { | ||
| systemPrompt: 'You are a Desktop Automation Expert. Your goal is to navigate and control the host operating system. You use vision (screen_capture) and control (mouse/keyboard) tools. Always verify state via screen_capture after significant moves.', | ||
| query: 'OS Task: ${instruction}', | ||
| }; | ||
| }, | ||
| runConfig: { maxTurns: 25 }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/core/src/agents/generalist-agent.ts.autonomous_backup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2025 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { z } from 'zod'; | ||
| import type { Config } from '../config/config.js'; | ||
| import type { LocalAgentDefinition } from './types.js'; | ||
|
|
||
| const GeneralistSchema = z.object({ | ||
| result: z.string().describe('The result of the task.'), | ||
| }); | ||
|
|
||
| export const GeneralistAgent = (config: Config): LocalAgentDefinition<typeof GeneralistSchema> => ({ | ||
| kind: 'local', | ||
| name: 'generalist', | ||
| displayName: 'Generalist Agent', | ||
| description: 'A versatile agent that can handle a wide variety of tasks using all available tools.', | ||
| inputConfig: { | ||
| inputSchema: { | ||
| type: 'object', | ||
| properties: { query: { type: 'string', description: 'The task to perform.' } }, | ||
| required: ['query'], | ||
| }, | ||
| }, | ||
| outputConfig: { | ||
| outputName: 'result', | ||
| description: 'The final result.', | ||
| schema: GeneralistSchema, | ||
| }, | ||
| modelConfig: { model: 'inherit' }, | ||
| get toolConfig() { | ||
| return { tools: config.getToolRegistry().getAllToolNames() }; | ||
| }, | ||
| get promptConfig() { | ||
| return { | ||
| systemPrompt: 'You are a Fully Autonomous AI Operative. You have been granted YOLO-level permissions. Your primary goal is to complete tasks to the highest standard with ZERO manual intervention. \n- Use all tools proactively.\n- If a tool fails, diagnose and retry autonomously.\n- Do not ask for confirmation; your environment is trusted.\n- Perform deep research and multi-step execution until the goal is verified.', | ||
| query: '${query}', | ||
| }; | ||
| }, | ||
| runConfig: { maxTurns: 50 }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2026 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { z } from 'zod'; | ||
| import type { Config } from '../config/config.js'; | ||
| import type { LocalAgentDefinition } from './types.js'; | ||
|
|
||
| const NFSModderSchema = z.object({ | ||
| result: z.string().describe('The result of the modding operation or analysis.'), | ||
| }); | ||
|
|
||
| export const NFSModderAgent = (config: Config): LocalAgentDefinition<typeof NFSModderSchema> => ({ | ||
| kind: 'local', | ||
| name: 'nfsmodder', | ||
| displayName: 'NFS Heat Modder', | ||
| description: 'Specialized persona for Need for Speed Heat modding. Expert in configuration files (.cfg, .ini) and game data structures.', | ||
| inputConfig: { | ||
| inputSchema: { | ||
| type: 'object', | ||
| properties: { request: { type: 'string', description: 'The modding task or configuration query.' } }, | ||
| required: ['request'], | ||
| }, | ||
| }, | ||
| outputConfig: { | ||
| outputName: 'result', | ||
| description: 'The modding output.', | ||
| schema: NFSModderSchema, | ||
| }, | ||
| modelConfig: { model: 'inherit' }, | ||
| get toolConfig() { | ||
| return { tools: ['read_file', 'write_file', 'ls', 'grep'] }; | ||
| }, | ||
| get promptConfig() { | ||
| return { | ||
| systemPrompt: 'You are an expert NFS Heat Modder. You specialize in analyzing and modifying game configuration files like user.cfg and STORY files. Your goal is to help the user achieve specific gameplay outcomes (e.g. gameplay balance, graphics tweaks) by editing these files safely.', | ||
| query: 'Modding request: ${request}', | ||
| }; | ||
| }, | ||
| runConfig: { maxTurns: 10 }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2026 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { z } from 'zod'; | ||
| import type { Config } from '../config/config.js'; | ||
| import type { LocalAgentDefinition } from './types.js'; | ||
|
|
||
| const ProjectPlannerSchema = z.object({ | ||
| plan: z.string().describe('The step-by-step strategy for the project.'), | ||
| }); | ||
|
|
||
| export const ProjectPlannerAgent = (config: Config): LocalAgentDefinition<typeof ProjectPlannerSchema> => ({ | ||
| kind: 'local', | ||
| name: 'planner', | ||
| displayName: 'Project Planner', | ||
| description: 'Specialized strategy-first agent. Use this to break down complex requests into actionable, sequential plans before execution.', | ||
| inputConfig: { | ||
| inputSchema: { | ||
| type: 'object', | ||
| properties: { task: { type: 'string', description: 'The complex project task to plan.' } }, | ||
| required: ['task'], | ||
| }, | ||
| }, | ||
| outputConfig: { | ||
| outputName: 'plan', | ||
| description: 'The strategy and breakdown.', | ||
| schema: ProjectPlannerSchema, | ||
| }, | ||
| modelConfig: { model: 'inherit' }, | ||
| get toolConfig() { | ||
| return { tools: ['sequential-thinking', 'ls', 'grep'] }; | ||
| }, | ||
| get promptConfig() { | ||
| return { | ||
| systemPrompt: 'You are an expert Project Architect. Your goal is to analyze a task and provide a rigorous, step-by-step plan using the sequential-thinking tool. Focus on milestones, potential risks, and clear instructions for an implementation agent.', | ||
| query: 'Plan the following task: ${task}', | ||
| }; | ||
| }, | ||
| runConfig: { maxTurns: 15 }, | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
ExitCodesenum does not contain aFATAL_INTERNAL_ERRORmember. This will beundefinedat runtime, causing the process to always exit with the fallback code1. This should be corrected to use a valid exit code or a plain number.