fix(patch): cherry-pick 828afe1 to release/v0.20.0-preview.1-pr-14159 to patch version v0.20.0-preview.1 and create version 0.20.0-preview.2 (#14733)

Co-authored-by: Allen Hutchison <adh@google.com>
This commit is contained in:
gemini-cli-robot
2025-12-08 11:54:40 -08:00
committed by GitHub
parent aae64683ce
commit f9997f92c9
12 changed files with 31 additions and 24 deletions

View File

@@ -50,7 +50,7 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
),
),
patchStdio: vi.fn(() => () => {}),
createInkStdio: vi.fn(() => ({
createWorkingStdio: vi.fn(() => ({
stdout: {
write: vi.fn((...args) =>
process.stdout.write(

View File

@@ -47,7 +47,7 @@ import {
recordSlowRender,
coreEvents,
CoreEvent,
createInkStdio,
createWorkingStdio,
patchStdio,
writeToStdout,
writeToStderr,
@@ -203,7 +203,7 @@ export async function startInteractiveUI(
consolePatcher.patch();
registerCleanup(consolePatcher.cleanup);
const { stdout: inkStdout, stderr: inkStderr } = createInkStdio();
const { stdout: inkStdout, stderr: inkStderr } = createWorkingStdio();
// Create wrapper component to use hooks inside render
const AppWrapper = () => {

View File

@@ -24,7 +24,7 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
...actual,
writeToStdout: vi.fn(),
patchStdio: vi.fn(() => () => {}),
createInkStdio: vi.fn(() => ({
createWorkingStdio: vi.fn(() => ({
stdout: {
write: vi.fn(),
columns: 80,

View File

@@ -68,6 +68,10 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
getMetrics: vi.fn(),
},
coreEvents: mockCoreEvents,
createWorkingStdio: vi.fn(() => ({
stdout: process.stdout,
stderr: process.stderr,
})),
};
});

View File

@@ -28,6 +28,7 @@ import {
debugLogger,
coreEvents,
CoreEvent,
createWorkingStdio,
} from '@google/gemini-cli-core';
import type { Content, Part } from '@google/genai';
@@ -70,7 +71,8 @@ export async function runNonInteractive({
coreEvents.emitConsoleLog(msg.type, msg.content);
},
});
const textOutput = new TextOutput();
const { stdout: workingStdout } = createWorkingStdio();
const textOutput = new TextOutput(workingStdout);
const handleUserFeedback = (payload: UserFeedbackPayload) => {
const prefix = payload.severity.toUpperCase();

View File

@@ -65,7 +65,7 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
),
),
patchStdio: vi.fn(() => () => {}),
createInkStdio: vi.fn(() => ({
createWorkingStdio: vi.fn(() => ({
stdout: process.stdout,
stderr: process.stderr,
})),

View File

@@ -13,6 +13,11 @@ import stripAnsi from 'strip-ansi';
export class TextOutput {
private atStartOfLine = true;
private outputStream: NodeJS.WriteStream;
constructor(outputStream: NodeJS.WriteStream = process.stdout) {
this.outputStream = outputStream;
}
/**
* Writes a string to stdout.
@@ -22,7 +27,7 @@ export class TextOutput {
if (str.length === 0) {
return;
}
process.stdout.write(str);
this.outputStream.write(str);
const strippedStr = stripAnsi(str);
if (strippedStr.length > 0) {
this.atStartOfLine = strippedStr.endsWith('\n');

View File

@@ -30,6 +30,7 @@ import {
debugLogger,
ReadManyFilesTool,
getEffectiveModel,
createWorkingStdio,
startupProfiler,
} from '@google/gemini-cli-core';
import * as acp from './acp.js';
@@ -51,15 +52,10 @@ export async function runZedIntegration(
settings: LoadedSettings,
argv: CliArgs,
) {
const stdout = Writable.toWeb(process.stdout) as WritableStream;
const { stdout: workingStdout } = createWorkingStdio();
const stdout = Writable.toWeb(workingStdout) as WritableStream;
const stdin = Readable.toWeb(process.stdin) as ReadableStream<Uint8Array>;
// Stdout is used to send messages to the client, so console.log/console.info
// messages to stderr so that they don't interfere with ACP.
console.log = console.error;
console.info = console.error;
console.debug = console.error;
new acp.AgentSideConnection(
(client: acp.Client) => new GeminiAgent(config, settings, argv, client),
stdout,