@viso/code-shared
v0.0.7
Published
Shared types and utilities for Code CLI
Downloads
17
Maintainers
Readme
@viso/code-shared
English | 中文
Shared types and utilities for the Code CLI ecosystem.
🚀 Features
- Type Definitions: Common TypeScript interfaces and types
- Error Classes: Standardized error handling across packages
- Utility Functions: Shared helper functions and constants
- Provider Types: Common interfaces for AI providers
- API Types: Request/response type definitions
📦 Installation
npm install @viso/code-shared🔧 Usage
Import Types
import { APIResponse, ProviderConfig, CommonError } from '@viso/code-shared';Error Handling
import { ApplicationError, ProviderError } from '@viso/code-shared/errors';
try {
// Your code here
} catch (error) {
if (error instanceof ApplicationError) {
console.error('Application error:', error.message);
}
}Provider Types
import { ProviderType, ProviderConfig } from '@viso/code-shared/types';
const config: ProviderConfig = {
name: 'example-provider',
type: ProviderType.CHAT,
apiKey: 'your-api-key',
};📖 API Reference
Types
APIResponse<T>
Generic response type for API calls.
interface APIResponse<T> {
success: boolean;
data?: T;
error?: string;
timestamp: number;
}ProviderConfig
Configuration interface for AI providers.
interface ProviderConfig {
name: string;
type: ProviderType;
apiKey: string;
baseUrl?: string;
timeout?: number;
}Error Classes
ApplicationError
Base error class for application-level errors.
ProviderError
Specialized error class for provider-related issues.
🔗 Related Packages
- @viso/code-core - Core functionality
- @viso/code-cli - Command line interface
🤝 Contributing
Contributions are welcome! Please read our contributing guidelines before submitting PRs.
📄 License
MIT License - see LICENSE for details.
