mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-01 08:13:37 +00:00
feat: enhance SDK options with thinking level support
- Introduced a new function, buildThinkingOptions, to handle the conversion of ThinkingLevel to maxThinkingTokens for the Claude SDK. - Updated existing SDK option creation functions to incorporate thinking options, ensuring that maxThinkingTokens are included based on the specified thinking level. - Enhanced the settings service to support migration of phase models to include thinking levels, improving compatibility with new configurations. - Added comprehensive tests for thinking level integration and migration logic, ensuring robust functionality across the application. This update significantly improves the SDK's configurability and performance by allowing for more nuanced control over reasoning capabilities.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* Feature types for AutoMaker feature management
|
||||
*/
|
||||
|
||||
import type { PlanningMode } from './settings.js';
|
||||
import type { PlanningMode, ThinkingLevel } from './settings.js';
|
||||
|
||||
export interface FeatureImagePath {
|
||||
id: string;
|
||||
@@ -38,7 +38,7 @@ export interface Feature {
|
||||
// Branch info - worktree path is derived at runtime from branchName
|
||||
branchName?: string; // Name of the feature branch (undefined = use current worktree)
|
||||
skipTests?: boolean;
|
||||
thinkingLevel?: string;
|
||||
thinkingLevel?: ThinkingLevel;
|
||||
planningMode?: PlanningMode;
|
||||
requirePlanApproval?: boolean;
|
||||
planSpec?: {
|
||||
|
||||
@@ -71,6 +71,7 @@ export type {
|
||||
PlanningMode,
|
||||
ThinkingLevel,
|
||||
ModelProvider,
|
||||
PhaseModelEntry,
|
||||
PhaseModelConfig,
|
||||
PhaseModelKey,
|
||||
KeyboardShortcuts,
|
||||
@@ -95,8 +96,10 @@ export {
|
||||
SETTINGS_VERSION,
|
||||
CREDENTIALS_VERSION,
|
||||
PROJECT_SETTINGS_VERSION,
|
||||
THINKING_TOKEN_BUDGET,
|
||||
profileHasThinking,
|
||||
getProfileModelString,
|
||||
getThinkingTokenBudget,
|
||||
} from './settings.js';
|
||||
|
||||
// Model display constants
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* Shared types for AI model providers
|
||||
*/
|
||||
|
||||
import type { ThinkingLevel } from './settings.js';
|
||||
|
||||
/**
|
||||
* Configuration for a provider instance
|
||||
*/
|
||||
@@ -84,6 +86,12 @@ export interface ExecuteOptions {
|
||||
* Default: false (allows edits)
|
||||
*/
|
||||
readOnly?: boolean;
|
||||
/**
|
||||
* Extended thinking level for Claude models.
|
||||
* Controls the amount of reasoning tokens allocated.
|
||||
* Only applies to Claude models; Cursor models handle thinking internally.
|
||||
*/
|
||||
thinkingLevel?: ThinkingLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -70,9 +70,46 @@ export type PlanningMode = 'skip' | 'lite' | 'spec' | 'full';
|
||||
/** ThinkingLevel - Extended thinking levels for Claude models (reasoning intensity) */
|
||||
export type ThinkingLevel = 'none' | 'low' | 'medium' | 'high' | 'ultrathink';
|
||||
|
||||
/**
|
||||
* Thinking token budget mapping based on Claude SDK documentation.
|
||||
* @see https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking
|
||||
*
|
||||
* - Minimum budget: 1,024 tokens
|
||||
* - Complex tasks starting point: 16,000+ tokens
|
||||
* - Above 32,000: Risk of timeouts (batch processing recommended)
|
||||
*/
|
||||
export const THINKING_TOKEN_BUDGET: Record<ThinkingLevel, number | undefined> = {
|
||||
none: undefined, // Thinking disabled
|
||||
low: 1024, // Minimum per docs
|
||||
medium: 10000, // Light reasoning
|
||||
high: 16000, // Complex tasks (recommended starting point)
|
||||
ultrathink: 32000, // Maximum safe (above this risks timeouts)
|
||||
};
|
||||
|
||||
/**
|
||||
* Convert thinking level to SDK maxThinkingTokens value
|
||||
*/
|
||||
export function getThinkingTokenBudget(level: ThinkingLevel | undefined): number | undefined {
|
||||
if (!level || level === 'none') return undefined;
|
||||
return THINKING_TOKEN_BUDGET[level];
|
||||
}
|
||||
|
||||
/** ModelProvider - AI model provider for credentials and API key management */
|
||||
export type ModelProvider = 'claude' | 'cursor';
|
||||
|
||||
/**
|
||||
* PhaseModelEntry - Configuration for a single phase model
|
||||
*
|
||||
* Encapsulates both the model selection and optional thinking level
|
||||
* for Claude models. Cursor models handle thinking internally.
|
||||
*/
|
||||
export interface PhaseModelEntry {
|
||||
/** The model to use (Claude alias or Cursor model ID) */
|
||||
model: ModelAlias | CursorModelId;
|
||||
/** Extended thinking level (only applies to Claude models, defaults to 'none') */
|
||||
thinkingLevel?: ThinkingLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* PhaseModelConfig - Configuration for AI models used in different application phases
|
||||
*
|
||||
@@ -83,25 +120,25 @@ export type ModelProvider = 'claude' | 'cursor';
|
||||
export interface PhaseModelConfig {
|
||||
// Quick tasks - recommend fast/cheap models (Haiku, Cursor auto)
|
||||
/** Model for enhancing feature names and descriptions */
|
||||
enhancementModel: ModelAlias | CursorModelId;
|
||||
enhancementModel: PhaseModelEntry;
|
||||
/** Model for generating file context descriptions */
|
||||
fileDescriptionModel: ModelAlias | CursorModelId;
|
||||
fileDescriptionModel: PhaseModelEntry;
|
||||
/** Model for analyzing and describing context images */
|
||||
imageDescriptionModel: ModelAlias | CursorModelId;
|
||||
imageDescriptionModel: PhaseModelEntry;
|
||||
|
||||
// Validation tasks - recommend smart models (Sonnet, Opus)
|
||||
/** Model for validating and improving GitHub issues */
|
||||
validationModel: ModelAlias | CursorModelId;
|
||||
validationModel: PhaseModelEntry;
|
||||
|
||||
// Generation tasks - recommend powerful models (Opus, Sonnet)
|
||||
/** Model for generating full application specifications */
|
||||
specGenerationModel: ModelAlias | CursorModelId;
|
||||
specGenerationModel: PhaseModelEntry;
|
||||
/** Model for creating features from specifications */
|
||||
featureGenerationModel: ModelAlias | CursorModelId;
|
||||
featureGenerationModel: PhaseModelEntry;
|
||||
/** Model for reorganizing and prioritizing backlog */
|
||||
backlogPlanningModel: ModelAlias | CursorModelId;
|
||||
backlogPlanningModel: PhaseModelEntry;
|
||||
/** Model for analyzing project structure */
|
||||
projectAnalysisModel: ModelAlias | CursorModelId;
|
||||
projectAnalysisModel: PhaseModelEntry;
|
||||
}
|
||||
|
||||
/** Keys of PhaseModelConfig for type-safe access */
|
||||
@@ -559,22 +596,22 @@ export interface ProjectSettings {
|
||||
/** Default phase model configuration - sensible defaults for each task type */
|
||||
export const DEFAULT_PHASE_MODELS: PhaseModelConfig = {
|
||||
// Quick tasks - use fast models for speed and cost
|
||||
enhancementModel: 'sonnet',
|
||||
fileDescriptionModel: 'haiku',
|
||||
imageDescriptionModel: 'haiku',
|
||||
enhancementModel: { model: 'sonnet' },
|
||||
fileDescriptionModel: { model: 'haiku' },
|
||||
imageDescriptionModel: { model: 'haiku' },
|
||||
|
||||
// Validation - use smart models for accuracy
|
||||
validationModel: 'sonnet',
|
||||
validationModel: { model: 'sonnet' },
|
||||
|
||||
// Generation - use powerful models for quality
|
||||
specGenerationModel: 'opus',
|
||||
featureGenerationModel: 'sonnet',
|
||||
backlogPlanningModel: 'sonnet',
|
||||
projectAnalysisModel: 'sonnet',
|
||||
specGenerationModel: { model: 'opus' },
|
||||
featureGenerationModel: { model: 'sonnet' },
|
||||
backlogPlanningModel: { model: 'sonnet' },
|
||||
projectAnalysisModel: { model: 'sonnet' },
|
||||
};
|
||||
|
||||
/** Current version of the global settings schema */
|
||||
export const SETTINGS_VERSION = 2;
|
||||
export const SETTINGS_VERSION = 3;
|
||||
/** Current version of the credentials schema */
|
||||
export const CREDENTIALS_VERSION = 1;
|
||||
/** Current version of the project settings schema */
|
||||
|
||||
Reference in New Issue
Block a user