* fix: restore Grep and Glob reliability on OpenAI paths Preserve Grep and Glob pattern fields during OpenAI/Codex schema sanitization, and fall back to system ripgrep when the packaged binary is missing. This keeps search tool schemas intact and improves Linux usability for npm/source installs. Co-Authored-By: Claude Opus 4.6 <noreply@openclaude.dev> * test: clean up ripgrep fallback test helpers Remove the unused ripgrepCommand import and normalize mocked builtin ripgrep paths so the test behaves consistently across platforms. Co-Authored-By: Claude Opus 4.6 <noreply@openclaude.dev> * test: remove duplicate Codex URI schema case Drop the duplicated WebFetch URI-format test in codexShim.test.ts so test names stay unique and failures remain easier to read. Co-Authored-By: Claude Opus 4.6 <noreply@openclaude.dev> * test: stabilize ripgrep fallback coverage Avoid fs/module mocking in ripgrep fallback tests by extracting the config selection logic into a pure helper. This preserves the fallback coverage while removing the test interaction that caused the narrowed Bun hang repro. Co-Authored-By: Claude Opus 4.6 <noreply@openclaude.dev> * test: tighten ripgrep and schema coverage Align the ripgrep fallback test with the actual auto-fallback branch, clean up strict typing in schema sanitizer tests, and tighten ripgrep error narrowing for type safety. Co-Authored-By: Claude Opus 4.6 <noreply@openclaude.dev> --------- Co-authored-by: Claude Opus 4.6 <noreply@openclaude.dev>
69 lines
2.0 KiB
TypeScript
69 lines
2.0 KiB
TypeScript
import { describe, expect, test } from 'bun:test'
|
|
|
|
import { sanitizeSchemaForOpenAICompat } from './schemaSanitizer'
|
|
|
|
describe('sanitizeSchemaForOpenAICompat', () => {
|
|
test('preserves Grep-like properties.pattern while keeping it required', () => {
|
|
const schema = {
|
|
type: 'object',
|
|
properties: {
|
|
pattern: {
|
|
type: 'string',
|
|
description: 'The regular expression pattern to search for in file contents',
|
|
},
|
|
path: { type: 'string' },
|
|
glob: { type: 'string' },
|
|
},
|
|
required: ['pattern'],
|
|
}
|
|
|
|
const sanitized = sanitizeSchemaForOpenAICompat(schema)
|
|
const properties = sanitized.properties as Record<string, unknown> | undefined
|
|
|
|
expect(Object.keys(properties ?? {})).toEqual(['pattern', 'path', 'glob'])
|
|
expect(properties?.pattern).toEqual({
|
|
type: 'string',
|
|
description: 'The regular expression pattern to search for in file contents',
|
|
})
|
|
expect(sanitized.required).toEqual(['pattern'])
|
|
})
|
|
|
|
test('preserves Glob-like properties.pattern while keeping it required', () => {
|
|
const schema = {
|
|
type: 'object',
|
|
properties: {
|
|
pattern: {
|
|
type: 'string',
|
|
description: 'The glob pattern to match files against',
|
|
},
|
|
path: { type: 'string' },
|
|
},
|
|
required: ['pattern'],
|
|
}
|
|
|
|
const sanitized = sanitizeSchemaForOpenAICompat(schema)
|
|
const properties = sanitized.properties as Record<string, unknown> | undefined
|
|
|
|
expect(Object.keys(properties ?? {})).toEqual(['pattern', 'path'])
|
|
expect(properties?.pattern).toEqual({
|
|
type: 'string',
|
|
description: 'The glob pattern to match files against',
|
|
})
|
|
expect(sanitized.required).toEqual(['pattern'])
|
|
})
|
|
|
|
test('strips JSON Schema validator pattern from string schemas', () => {
|
|
const schema = {
|
|
type: 'string',
|
|
pattern: '^[a-z]+$',
|
|
minLength: 1,
|
|
}
|
|
|
|
const sanitized = sanitizeSchemaForOpenAICompat(schema)
|
|
|
|
expect(sanitized).toEqual({
|
|
type: 'string',
|
|
})
|
|
})
|
|
})
|