mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-03 07:57:22 +00:00
Revert "Default to OpenCode Zen with big-pickle model for zero-config first experience"
This reverts commit 0a2cbf4bca.
This commit is contained in:
5 files changed
+27
-38
No files matched your search
@@ -4,17 +4,22 @@ import { AISettingsContext, type AISettings, type AIProvider, type MCPServer, ty
|
||||
import { useFS } from '@/hooks/useFS';
|
||||
import { useFSPaths } from '@/hooks/useFSPaths';
|
||||
import { readAISettings, writeAISettings } from '@/lib/configUtils';
|
||||
import { OPENCODE_DEFAULT_SETTINGS } from '@/lib/opencode-defaults';
|
||||
|
||||
interface AISettingsProviderProps {
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
const DEFAULT_SETTINGS: AISettings = {
|
||||
providers: [],
|
||||
recentlyUsedModels: [],
|
||||
mcpServers: {},
|
||||
};
|
||||
|
||||
export function AISettingsProvider({ children }: AISettingsProviderProps) {
|
||||
const queryClient = useQueryClient();
|
||||
const { fs } = useFS();
|
||||
const { configPath } = useFSPaths();
|
||||
const [settings, setSettings] = useState<AISettings>(OPENCODE_DEFAULT_SETTINGS);
|
||||
const [settings, setSettings] = useState<AISettings>(DEFAULT_SETTINGS);
|
||||
const [isInitialized, setIsInitialized] = useState(false);
|
||||
|
||||
// Initialize settings from VFS on mount
|
||||
@@ -25,7 +30,7 @@ export function AISettingsProvider({ children }: AISettingsProviderProps) {
|
||||
setSettings(settings);
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize AI settings:', error);
|
||||
setSettings(OPENCODE_DEFAULT_SETTINGS);
|
||||
setSettings(DEFAULT_SETTINGS);
|
||||
} finally {
|
||||
setIsInitialized(true);
|
||||
}
|
||||
|
||||
@@ -36,16 +36,6 @@ export function createAIClient(provider: AIProvider, user?: NUser, corsProxy?: s
|
||||
request = new Request(request, { headers });
|
||||
}
|
||||
|
||||
// Add OpenCode headers for higher rate limit
|
||||
if (provider.id === 'opencode' || provider.baseURL === 'https://opencode.ai/zen/v1') {
|
||||
const headers = new Headers(request.headers);
|
||||
headers.set('x-opencode-project', 'shakespeare');
|
||||
headers.set('x-opencode-session', 'shakespeare');
|
||||
headers.set('x-opencode-request', crypto.randomUUID());
|
||||
headers.set('x-opencode-client', 'shakespeare');
|
||||
request = new Request(request, { headers });
|
||||
}
|
||||
|
||||
// If Nostr authentication is required and we have a user, use NIP-98
|
||||
if (provider.nostr && user?.signer) {
|
||||
// Create the NIP98 token
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
readDeploySettings,
|
||||
writeDeploySettings
|
||||
} from './configUtils';
|
||||
import { OPENCODE_DEFAULT_SETTINGS } from './opencode-defaults';
|
||||
import type { JSRuntimeFS } from './JSRuntime';
|
||||
import type { AISettings } from '@/contexts/AISettingsContext';
|
||||
import type { GitSettings } from '@/contexts/GitSettingsContext';
|
||||
@@ -90,22 +89,30 @@ describe('configUtils', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should return default settings with OpenCode Zen if file does not exist and no localStorage data', async () => {
|
||||
it('should return default settings if file does not exist and no localStorage data', async () => {
|
||||
vi.mocked(mockFS.readFile).mockRejectedValue(new Error('File not found'));
|
||||
mockLocalStorage.getItem.mockReturnValue(null);
|
||||
|
||||
const result = await readAISettings(mockFS);
|
||||
|
||||
expect(result).toEqual(OPENCODE_DEFAULT_SETTINGS);
|
||||
expect(result).toEqual({
|
||||
providers: [],
|
||||
recentlyUsedModels: [],
|
||||
mcpServers: {},
|
||||
});
|
||||
});
|
||||
|
||||
it('should return default settings with OpenCode Zen if JSON is invalid and no localStorage data', async () => {
|
||||
it('should return default settings if JSON is invalid and no localStorage data', async () => {
|
||||
vi.mocked(mockFS.readFile).mockResolvedValue('invalid json');
|
||||
mockLocalStorage.getItem.mockReturnValue(null);
|
||||
|
||||
const result = await readAISettings(mockFS);
|
||||
|
||||
expect(result).toEqual(OPENCODE_DEFAULT_SETTINGS);
|
||||
expect(result).toEqual({
|
||||
providers: [],
|
||||
recentlyUsedModels: [],
|
||||
mcpServers: {},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import z from 'zod';
|
||||
import { filteredArray } from '@/lib/schema';
|
||||
import { AI_PROVIDER_PRESETS } from '@/lib/aiProviderPresets';
|
||||
import { OPENCODE_DEFAULT_SETTINGS } from '@/lib/opencode-defaults';
|
||||
import type { JSRuntimeFS } from '@/lib/JSRuntime';
|
||||
import type { AISettings, MCPServer } from '@/contexts/AISettingsContext';
|
||||
import type { GitSettings, GitCredential } from '@/contexts/GitSettingsContext';
|
||||
@@ -170,6 +169,12 @@ async function ensureConfigDir(fs: JSRuntimeFS, configPath = '/config'): Promise
|
||||
* @param configPath - Custom config path (default: /config)
|
||||
*/
|
||||
export async function readAISettings(fs: JSRuntimeFS, configPath = '/config'): Promise<AISettings> {
|
||||
const defaultSettings: AISettings = {
|
||||
providers: [],
|
||||
recentlyUsedModels: [],
|
||||
mcpServers: {},
|
||||
};
|
||||
|
||||
try {
|
||||
const aiConfigPath = getAIConfigPath(configPath);
|
||||
const content = await fs.readFile(aiConfigPath, 'utf8');
|
||||
@@ -205,7 +210,7 @@ export async function readAISettings(fs: JSRuntimeFS, configPath = '/config'): P
|
||||
if (error instanceof z.ZodError) {
|
||||
console.error('AI settings parsing error:', error.issues);
|
||||
}
|
||||
return OPENCODE_DEFAULT_SETTINGS;
|
||||
return defaultSettings;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import type { AISettings } from '@/contexts/AISettingsContext';
|
||||
import { AI_PROVIDER_PRESETS } from '@/lib/aiProviderPresets';
|
||||
|
||||
const opencodePreset = AI_PROVIDER_PRESETS.find((p) => p.id === 'opencode')!;
|
||||
|
||||
/** Default AI settings with OpenCode Zen pre-configured and big-pickle selected. */
|
||||
export const OPENCODE_DEFAULT_SETTINGS: AISettings = {
|
||||
providers: [
|
||||
{
|
||||
id: opencodePreset.id,
|
||||
name: opencodePreset.name,
|
||||
baseURL: opencodePreset.baseURL,
|
||||
proxy: opencodePreset.proxy,
|
||||
},
|
||||
],
|
||||
recentlyUsedModels: ['opencode/big-pickle'],
|
||||
mcpServers: {},
|
||||
};
|
||||
Reference in new issue
Block a user