Structured JSON Output (#8119)

This commit is contained in:
Jerop Kipruto
2025-09-11 05:19:47 +09:00
committed by GitHub
parent db99fc70b6
commit 514767c88b
20 changed files with 1526 additions and 23 deletions
+16
View File
@@ -62,6 +62,7 @@ import {
RipgrepFallbackEvent,
} from '../telemetry/types.js';
import type { FallbackModelHandler } from '../fallback/types.js';
import { OutputFormat } from '../output/types.js';
// Re-export OAuth config type
export type { MCPOAuthConfig, AnyToolInvocation };
@@ -105,6 +106,10 @@ export interface TelemetrySettings {
outfile?: string;
}
export interface OutputSettings {
format?: OutputFormat;
}
export interface GeminiCLIExtension {
name: string;
version: string;
@@ -228,6 +233,7 @@ export interface ConfigParameters {
enableToolOutputTruncation?: boolean;
eventEmitter?: EventEmitter;
useSmartEdit?: boolean;
output?: OutputSettings;
}
export class Config {
@@ -310,6 +316,7 @@ export class Config {
private readonly fileExclusions: FileExclusions;
private readonly eventEmitter?: EventEmitter;
private readonly useSmartEdit: boolean;
private readonly outputSettings: OutputSettings;
constructor(params: ConfigParameters) {
this.sessionId = params.sessionId;
@@ -393,6 +400,9 @@ export class Config {
this.enablePromptCompletion = params.enablePromptCompletion ?? false;
this.fileExclusions = new FileExclusions(this);
this.eventEmitter = params.eventEmitter;
this.outputSettings = {
format: params.output?.format ?? OutputFormat.TEXT,
};
if (params.contextFileName) {
setGeminiMdFilename(params.contextFileName);
@@ -880,6 +890,12 @@ export class Config {
return this.useSmartEdit;
}
getOutputFormat(): OutputFormat {
return this.outputSettings?.format
? this.outputSettings.format
: OutputFormat.TEXT;
}
async getGitService(): Promise<GitService> {
if (!this.gitService) {
this.gitService = new GitService(this.targetDir, this.storage);