diff --git a/examples/kothaset.yaml b/examples/kothaset.yaml index 66facd3..aa03cb4 100644 --- a/examples/kothaset.yaml +++ b/examples/kothaset.yaml @@ -21,7 +21,3 @@ instructions: - Be creative and diverse in topics and approaches - Vary the style and complexity of responses - Use clear and concise language - -logging: - level: info - format: text diff --git a/internal/cli/generate.go b/internal/cli/generate.go index 9bf7215..727ce27 100644 --- a/internal/cli/generate.go +++ b/internal/cli/generate.go @@ -14,7 +14,6 @@ import ( "github.com/schollz/progressbar/v3" "github.com/spf13/cobra" - "github.com/shantoislamdev/kothaset/internal/fsutil" "github.com/shantoislamdev/kothaset/internal/generator" log "github.com/shantoislamdev/kothaset/internal/log" "github.com/shantoislamdev/kothaset/internal/output" @@ -134,29 +133,6 @@ func runGenerate(cmd *cobra.Command, _ []string) error { if genModel == "" { genModel = cp.Config.Model } - - // Guardrails against accidentally resuming into a different run target. - if cmd.Flags().Changed("schema") && cp.Config.Schema != "" && genSchema != cp.Config.Schema { - return fmt.Errorf("resume schema mismatch: checkpoint=%s current=%s", cp.Config.Schema, genSchema) - } - if cmd.Flags().Changed("provider") && cp.Config.Provider != "" && genProvider != cp.Config.Provider { - return fmt.Errorf("resume provider mismatch: checkpoint=%s current=%s", cp.Config.Provider, genProvider) - } - if cmd.Flags().Changed("model") && cp.Config.Model != "" && genModel != cp.Config.Model { - return fmt.Errorf("resume model mismatch: checkpoint=%s current=%s", cp.Config.Model, genModel) - } - if cmd.Flags().Changed("input") && cp.Config.InputFile != "" && genInputFile != cp.Config.InputFile { - return fmt.Errorf("resume input mismatch: checkpoint=%s current=%s", cp.Config.InputFile, genInputFile) - } - if cmd.Flags().Changed("output") && cp.Config.OutputPath != "" { - sameOutput, err := fsutil.PathsEqual(genOutput, cp.Config.OutputPath) - if err != nil { - return fmt.Errorf("failed to compare output path with checkpoint output path: %w", err) - } - if !sameOutput { - return fmt.Errorf("resume output mismatch: checkpoint=%s current=%s", cp.Config.OutputPath, genOutput) - } - } } if genInputFile == "" { diff --git a/internal/cli/root.go b/internal/cli/root.go index 6e408d9..9bddaac 100644 --- a/internal/cli/root.go +++ b/internal/cli/root.go @@ -79,6 +79,8 @@ func init() { rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "enable debug logging") rootCmd.PersistentFlags().BoolVarP(&quiet, "quiet", "q", false, "suppress non-error output") + rootCmd.MarkFlagsMutuallyExclusive("verbose", "quiet") + // Register subcommands rootCmd.AddCommand(versionCmd) rootCmd.AddCommand(initCmd) diff --git a/internal/config/config.go b/internal/config/config.go index 96493b1..f5c81a2 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -130,11 +130,6 @@ func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error { } } -// MarshalYAML implements yaml.Marshaler -func (d Duration) MarshalYAML() (interface{}, error) { - return d.String(), nil -} - // DefaultConfig returns a configuration with sensible defaults func DefaultConfig() *Config { return &Config{ diff --git a/internal/config/loader.go b/internal/config/loader.go index 2241714..a3ff0f3 100644 --- a/internal/config/loader.go +++ b/internal/config/loader.go @@ -135,9 +135,6 @@ func LoadSecretsConfig(secretsPath string) (*SecretsConfig, error) { if p.Type == "" { return nil, fmt.Errorf("provider %s type is required", p.Name) } - if p.Type != "openai" { - return nil, fmt.Errorf("unsupported provider type: %s", p.Type) - } } return secrets, nil diff --git a/internal/provider/errors.go b/internal/provider/errors.go index 88315d7..1feda04 100644 --- a/internal/provider/errors.go +++ b/internal/provider/errors.go @@ -9,14 +9,14 @@ import ( type ErrorKind string const ( - ErrKindValidation ErrorKind = "validation" // Invalid request parameters - ErrKindAuth ErrorKind = "auth" // Authentication failure - ErrKindRateLimit ErrorKind = "rate_limit" // Rate limit exceeded - ErrKindQuota ErrorKind = "quota" // Quota exceeded - ErrKindNetwork ErrorKind = "network" // Network connectivity issue - ErrKindTimeout ErrorKind = "timeout" // Request timeout - ErrKindServer ErrorKind = "server" // Provider server error - ErrKindContentFilter ErrorKind = "content_filter" // Content filtered + ErrKindValidation ErrorKind = "validation" // Invalid request parameters + ErrKindAuth ErrorKind = "auth" // Authentication failure + ErrKindRateLimit ErrorKind = "rate_limit" // Rate limit exceeded + + ErrKindNetwork ErrorKind = "network" // Network connectivity issue + ErrKindTimeout ErrorKind = "timeout" // Request timeout + ErrKindServer ErrorKind = "server" // Provider server error + ErrKindContextLength ErrorKind = "context_length" // Context too long ErrKindUnknown ErrorKind = "unknown" // Unknown error ) diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 1e2b079..964bf2b 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -96,21 +96,3 @@ type TokenUsage struct { CompletionTokens int `json:"completion_tokens"` TotalTokens int `json:"total_tokens"` } - -// StreamChunk represents a piece of a streaming response -type StreamChunk struct { - // Content is the text delta - Content string `json:"content"` - - // Done indicates the stream is complete - Done bool `json:"done"` - - // FinishReason when Done is true - FinishReason string `json:"finish_reason,omitempty"` - - // Usage when Done is true - Usage *TokenUsage `json:"usage,omitempty"` - - // Error if something went wrong - Error error `json:"error,omitempty"` -} diff --git a/internal/provider/registry.go b/internal/provider/registry.go index 5cd84eb..1b8af1a 100644 --- a/internal/provider/registry.go +++ b/internal/provider/registry.go @@ -141,16 +141,6 @@ func (r *Registry) Close() error { // Global registry functions -// RegisterFactory registers a factory in the global registry -func RegisterFactory(providerType string, factory Factory) { - globalRegistry.RegisterFactory(providerType, factory) -} - -// Register adds a provider to the global registry -func Register(name string, provider Provider) error { - return globalRegistry.Register(name, provider) -} - // Get retrieves a provider from the global registry func Get(name string) (Provider, error) { return globalRegistry.Get(name) diff --git a/internal/schema/classification.go b/internal/schema/classification.go index 68daddb..16f6954 100644 --- a/internal/schema/classification.go +++ b/internal/schema/classification.go @@ -69,7 +69,7 @@ func (s *ClassificationSchema) GeneratePrompt(ctx context.Context, opts PromptOp } if opts.Topic != "" { - sb.WriteString(fmt.Sprintf("Category/Domain: %s\n", opts.Topic)) + fmt.Fprintf(&sb, "Category/Domain: %s\n", opts.Topic) } // Get labels from variables if provided @@ -83,7 +83,7 @@ func (s *ClassificationSchema) GeneratePrompt(ctx context.Context, opts PromptOp sb.WriteString("\n") if len(labels) > 0 { - sb.WriteString(fmt.Sprintf("Available labels: %s\n\n", strings.Join(labels, ", "))) + fmt.Fprintf(&sb, "Available labels: %s\n\n", strings.Join(labels, ", ")) sb.WriteString(`Generate a text sample and assign the most appropriate label: { diff --git a/internal/schema/preference.go b/internal/schema/preference.go index 4e363aa..b707f7e 100644 --- a/internal/schema/preference.go +++ b/internal/schema/preference.go @@ -63,10 +63,10 @@ func (s *PreferenceSchema) GeneratePrompt(ctx context.Context, opts PromptOption } if opts.Topic != "" { - sb.WriteString(fmt.Sprintf("Topic: %s\n", opts.Topic)) + fmt.Fprintf(&sb, "Topic: %s\n", opts.Topic) } if opts.Category != "" { - sb.WriteString(fmt.Sprintf("Category: %s\n", opts.Category)) + fmt.Fprintf(&sb, "Category: %s\n", opts.Category) } sb.WriteString("\n") diff --git a/internal/schema/registry.go b/internal/schema/registry.go index 75e6097..7278a25 100644 --- a/internal/schema/registry.go +++ b/internal/schema/registry.go @@ -78,11 +78,6 @@ func (r *Registry) List() []string { // Global registry functions -// Register adds a schema to the global registry -func Register(schema Schema) error { - return globalRegistry.Register(schema) -} - // Get retrieves a schema from the global registry func Get(name string) (Schema, error) { return globalRegistry.Get(name) diff --git a/internal/schema/registry_test.go b/internal/schema/registry_test.go index 7844afb..761f76e 100644 --- a/internal/schema/registry_test.go +++ b/internal/schema/registry_test.go @@ -138,16 +138,10 @@ func TestGlobalRegistry(t *testing.T) { mGlobal := &mockSchema{name: "global_mock"} - // Test Register - err := Register(mGlobal) + // Register via the registry directly + err := globalRegistry.Register(mGlobal) if err != nil { - t.Errorf("Global Register failed: %v", err) - } - - // Duplicate registration should fail - err = Register(mGlobal) - if err == nil { - t.Error("Global Register should fail on duplicate") + t.Errorf("Register failed: %v", err) } // Test Get diff --git a/npm/scripts/postinstall.js b/npm/scripts/postinstall.js index d5fba3d..0b1c319 100644 --- a/npm/scripts/postinstall.js +++ b/npm/scripts/postinstall.js @@ -198,14 +198,14 @@ async function main() { const checksums = await downloadChecksums(VERSION); const releaseName = path.basename(new URL(url).pathname); const expectedHash = checksums[releaseName]; - if (expectedHash) { - await verifyChecksum(archivePath, expectedHash); - console.log('Checksum verified.'); - } else { - console.warn(`Warning: no checksum found for ${releaseName}`); + if (!expectedHash) { + throw new Error(`no checksum entry for ${releaseName} in checksums.txt`); } + await verifyChecksum(archivePath, expectedHash); + console.log('Checksum verified.'); } catch (checksumErr) { - console.warn(`Warning: checksum verification skipped: ${checksumErr.message}`); + console.error(`Checksum verification failed: ${checksumErr.message}`); + throw checksumErr; } // Extract diff --git a/website/index.html b/website/index.html index 710e5b1..320eb99 100644 --- a/website/index.html +++ b/website/index.html @@ -17,7 +17,9 @@ - +