mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-17 07:13:07 -07:00
tweaks
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { SidecarLoader } from './SidecarLoader.js';
|
||||
import { SidecarLoader } from './configLoader.js';
|
||||
import { defaultSidecarProfile } from './profiles.js';
|
||||
import { SidecarRegistry } from './registry.js';
|
||||
import { InMemoryFileSystem } from '../system/InMemoryFileSystem.js';
|
||||
+3
-11
@@ -12,6 +12,7 @@ import { getSidecarConfigSchema } from './schema.js';
|
||||
import type { SidecarRegistry } from './registry.js';
|
||||
import type { IFileSystem } from '../system/IFileSystem.js';
|
||||
import { NodeFileSystem } from '../system/NodeFileSystem.js';
|
||||
import { getErrorMessage } from '../../utils/errors.js';
|
||||
|
||||
export class SidecarLoader {
|
||||
/**
|
||||
@@ -24,18 +25,13 @@ export class SidecarLoader {
|
||||
fileSystem: IFileSystem = new NodeFileSystem(),
|
||||
): ContextProfile {
|
||||
const fileContent = fileSystem.readFileSync(sidecarPath, 'utf8');
|
||||
|
||||
if (!fileContent.trim()) {
|
||||
throw new Error(`Sidecar configuration file at ${sidecarPath} is empty.`);
|
||||
}
|
||||
|
||||
let parsed: unknown;
|
||||
try {
|
||||
parsed = JSON.parse(fileContent);
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
`Failed to parse Sidecar configuration file at ${sidecarPath}: ${
|
||||
error instanceof Error ? error.message : String(error)
|
||||
getErrorMessage(error)
|
||||
}`,
|
||||
);
|
||||
}
|
||||
@@ -58,11 +54,7 @@ export class SidecarLoader {
|
||||
// That function dynamically maps the \`processorOptions\` to strict JSON schema definitions,
|
||||
// so we know with absolute certainty at runtime that \`parsed\` conforms to this shape.
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
const validConfig = parsed as {
|
||||
budget?: SidecarConfig['budget'];
|
||||
processorOptions?: SidecarConfig['processorOptions'];
|
||||
};
|
||||
|
||||
const validConfig = parsed as SidecarConfig;
|
||||
return {
|
||||
...defaultSidecarProfile,
|
||||
config: {
|
||||
@@ -14,7 +14,7 @@ export interface ContextProcessorDef {
|
||||
* (Dynamic instantiation has been replaced by static ContextProfiles)
|
||||
*/
|
||||
export class SidecarRegistry {
|
||||
private processors = new Map<string, ContextProcessorDef>();
|
||||
private readonly processors = new Map<string, ContextProcessorDef>();
|
||||
|
||||
registerProcessor(def: ContextProcessorDef) {
|
||||
this.processors.set(def.id, def);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import { describe, it, expect, vi, beforeAll, afterAll } from 'vitest';
|
||||
import { SimulationHarness } from './SimulationHarness.js';
|
||||
import { SimulationHarness } from './simulationHarness.js';
|
||||
import { createMockLlmClient } from '../testing/contextTestUtils.js';
|
||||
import type { ContextProfile } from '../config/profiles.js';
|
||||
import { createToolMaskingProcessor } from '../processors/toolMaskingProcessor.js';
|
||||
|
||||
@@ -12,7 +12,7 @@ import { DeterministicIdGenerator } from '../system/DeterministicIdGenerator.js'
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import { ContextTracer } from '../tracer.js';
|
||||
import { ContextEnvironmentImpl } from '../pipeline/environmentImpl.js';
|
||||
import { SidecarLoader } from '../config/SidecarLoader.js';
|
||||
import { SidecarLoader } from '../config/configLoader.js';
|
||||
import { SidecarRegistry } from '../config/registry.js';
|
||||
import { ContextEventBus } from '../eventBus.js';
|
||||
import { PipelineOrchestrator } from '../pipeline/orchestrator.js';
|
||||
@@ -24,6 +24,7 @@ import type { Content, GenerateContentResponse } from '@google/genai';
|
||||
import { InboxSnapshotImpl } from '../pipeline/inbox.js';
|
||||
import type { InboxMessage, ProcessArgs } from '../pipeline.js';
|
||||
import type { ContextProfile } from '../config/profiles.js';
|
||||
import type { Mock } from 'vitest';
|
||||
|
||||
/**
|
||||
* Creates a valid mock GenerateContentResponse with the provided text.
|
||||
@@ -94,8 +95,6 @@ export function createDummyToolNode(
|
||||
} as unknown as ToolExecution;
|
||||
}
|
||||
|
||||
import type { Mock } from 'vitest';
|
||||
|
||||
export interface MockLlmClient extends BaseLlmClient {
|
||||
generateContent: Mock;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user