fix(ci): satisfy runtime catalog lint gate
This commit is contained in:
parent
e20d74d95e
commit
2e87e12774
2 changed files with 41 additions and 21 deletions
|
|
@ -1,15 +1,27 @@
|
||||||
import { normalizeCodexReasoningEffort, CODEX_REASONING_EFFORTS } from './codexReasoningEffort';
|
import { CODEX_REASONING_EFFORTS, normalizeCodexReasoningEffort } from './codexReasoningEffort';
|
||||||
|
|
||||||
import type { CodexAppServerModel } from '@main/services/infrastructure/codexAppServer';
|
|
||||||
import type { CliProviderModelCatalogItem, CliProviderReasoningEffort } from '@shared/types';
|
import type { CliProviderModelCatalogItem, CliProviderReasoningEffort } from '@shared/types';
|
||||||
|
|
||||||
|
export interface CodexAppServerModelLike {
|
||||||
|
id?: string;
|
||||||
|
model?: string;
|
||||||
|
displayName?: string;
|
||||||
|
hidden?: boolean;
|
||||||
|
supportedReasoningEfforts?: unknown[];
|
||||||
|
defaultReasoningEffort?: unknown;
|
||||||
|
inputModalities?: unknown;
|
||||||
|
supportsPersonality?: boolean;
|
||||||
|
isDefault?: boolean;
|
||||||
|
upgrade?: unknown;
|
||||||
|
}
|
||||||
|
|
||||||
export interface NormalizedCodexModelCatalogResult {
|
export interface NormalizedCodexModelCatalogResult {
|
||||||
models: CliProviderModelCatalogItem[];
|
models: CliProviderModelCatalogItem[];
|
||||||
defaultModelId: string | null;
|
defaultModelId: string | null;
|
||||||
diagnostics: string[];
|
diagnostics: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeModelId(model: CodexAppServerModel): string | null {
|
function normalizeModelId(model: CodexAppServerModelLike): string | null {
|
||||||
const id = model.id?.trim() || model.model?.trim() || null;
|
const id = model.id?.trim() || model.model?.trim() || null;
|
||||||
return id && id.length > 0 ? id : null;
|
return id && id.length > 0 ? id : null;
|
||||||
}
|
}
|
||||||
|
|
@ -26,7 +38,7 @@ function normalizeEffortOption(option: unknown): CliProviderReasoningEffort | nu
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeEfforts(model: CodexAppServerModel): CliProviderReasoningEffort[] {
|
function normalizeEfforts(model: CodexAppServerModelLike): CliProviderReasoningEffort[] {
|
||||||
const efforts = model.supportedReasoningEfforts?.flatMap((option) => {
|
const efforts = model.supportedReasoningEfforts?.flatMap((option) => {
|
||||||
const normalized = normalizeEffortOption(option);
|
const normalized = normalizeEffortOption(option);
|
||||||
return normalized ? [normalized] : [];
|
return normalized ? [normalized] : [];
|
||||||
|
|
@ -82,7 +94,7 @@ function asBadgeLabel(modelId: string): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function normalizeCodexAppServerModels(
|
export function normalizeCodexAppServerModels(
|
||||||
models: readonly CodexAppServerModel[] | undefined,
|
models: readonly CodexAppServerModelLike[] | undefined,
|
||||||
options: {
|
options: {
|
||||||
includeHidden?: boolean;
|
includeHidden?: boolean;
|
||||||
} = {}
|
} = {}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,15 @@ type LedgerApplyOutcome =
|
||||||
| { handled: true; status: 'applied' | 'skipped' }
|
| { handled: true; status: 'applied' | 'skipped' }
|
||||||
| { handled: true; status: 'conflict' | 'error'; error: string; code: ApplyErrorCode };
|
| { handled: true; status: 'conflict' | 'error'; error: string; code: ApplyErrorCode };
|
||||||
|
|
||||||
|
type CurrentTextReadResult =
|
||||||
|
| { missing: true; content: '' }
|
||||||
|
| { missing: false; content: string }
|
||||||
|
| { missing: false; content: ''; error: string };
|
||||||
|
|
||||||
|
function getCurrentTextReadError(result: CurrentTextReadResult): string | null {
|
||||||
|
return 'error' in result ? result.error : null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service for applying reject decisions from code review.
|
* Service for applying reject decisions from code review.
|
||||||
*
|
*
|
||||||
|
|
@ -518,12 +527,13 @@ export class ReviewApplierService {
|
||||||
if (current.missing) {
|
if (current.missing) {
|
||||||
return { handled: true, status: 'applied' };
|
return { handled: true, status: 'applied' };
|
||||||
}
|
}
|
||||||
if (current.error) {
|
const currentError = getCurrentTextReadError(current);
|
||||||
|
if (currentError) {
|
||||||
return {
|
return {
|
||||||
handled: true,
|
handled: true,
|
||||||
status: 'error',
|
status: 'error',
|
||||||
code: 'io-error',
|
code: 'io-error',
|
||||||
error: current.error,
|
error: currentError,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (!afterHash) {
|
if (!afterHash) {
|
||||||
|
|
@ -570,12 +580,13 @@ export class ReviewApplierService {
|
||||||
}
|
}
|
||||||
const current = await this.readCurrentText(filePath);
|
const current = await this.readCurrentText(filePath);
|
||||||
if (!current.missing) {
|
if (!current.missing) {
|
||||||
|
const currentError = getCurrentTextReadError(current);
|
||||||
return {
|
return {
|
||||||
handled: true,
|
handled: true,
|
||||||
status: 'conflict',
|
status: 'conflict',
|
||||||
code: 'conflict',
|
code: 'conflict',
|
||||||
error:
|
error:
|
||||||
current.error || 'File exists on disk; refusing to overwrite while rejecting delete.',
|
currentError || 'File exists on disk; refusing to overwrite while rejecting delete.',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
@ -672,12 +683,13 @@ export class ReviewApplierService {
|
||||||
|
|
||||||
const newCurrent = await this.readCurrentText(newFilePath);
|
const newCurrent = await this.readCurrentText(newFilePath);
|
||||||
if (!newCurrent.missing) {
|
if (!newCurrent.missing) {
|
||||||
if (newCurrent.error) {
|
const newCurrentError = getCurrentTextReadError(newCurrent);
|
||||||
|
if (newCurrentError) {
|
||||||
return {
|
return {
|
||||||
handled: true,
|
handled: true,
|
||||||
status: 'error',
|
status: 'error',
|
||||||
code: 'io-error',
|
code: 'io-error',
|
||||||
error: newCurrent.error,
|
error: newCurrentError,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (this.hashText(newCurrent.content) !== newHash) {
|
if (this.hashText(newCurrent.content) !== newHash) {
|
||||||
|
|
@ -692,12 +704,13 @@ export class ReviewApplierService {
|
||||||
|
|
||||||
const oldCurrent = await this.readCurrentText(oldFilePath);
|
const oldCurrent = await this.readCurrentText(oldFilePath);
|
||||||
if (!oldCurrent.missing) {
|
if (!oldCurrent.missing) {
|
||||||
if (oldCurrent.error) {
|
const oldCurrentError = getCurrentTextReadError(oldCurrent);
|
||||||
|
if (oldCurrentError) {
|
||||||
return {
|
return {
|
||||||
handled: true,
|
handled: true,
|
||||||
status: 'error',
|
status: 'error',
|
||||||
code: 'io-error',
|
code: 'io-error',
|
||||||
error: oldCurrent.error,
|
error: oldCurrentError,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (!oldHash || this.hashText(oldCurrent.content) !== oldHash) {
|
if (!oldHash || this.hashText(oldCurrent.content) !== oldHash) {
|
||||||
|
|
@ -781,14 +794,15 @@ export class ReviewApplierService {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (current.error) {
|
const currentError = getCurrentTextReadError(current);
|
||||||
|
if (currentError) {
|
||||||
return {
|
return {
|
||||||
ok: false,
|
ok: false,
|
||||||
outcome: {
|
outcome: {
|
||||||
handled: true,
|
handled: true,
|
||||||
status: 'error',
|
status: 'error',
|
||||||
code: 'io-error',
|
code: 'io-error',
|
||||||
error: current.error,
|
error: currentError,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -806,13 +820,7 @@ export class ReviewApplierService {
|
||||||
return { ok: true };
|
return { ok: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
private async readCurrentText(
|
private async readCurrentText(filePath: string): Promise<CurrentTextReadResult> {
|
||||||
filePath: string
|
|
||||||
): Promise<
|
|
||||||
| { missing: true; content: ''; error?: undefined }
|
|
||||||
| { missing: false; content: string; error?: undefined }
|
|
||||||
| { missing: false; content: ''; error: string }
|
|
||||||
> {
|
|
||||||
try {
|
try {
|
||||||
return { missing: false, content: await readFile(filePath, 'utf8') };
|
return { missing: false, content: await readFile(filePath, 'utf8') };
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue