cckit 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Custom error classes
3
+ */
4
+ /**
5
+ * Base error class for application errors
6
+ */
7
+ export class CCKitError extends Error {
8
+ constructor(message, code, details) {
9
+ super(message);
10
+ this.code = code;
11
+ this.details = details;
12
+ this.name = this.constructor.name;
13
+ Error.captureStackTrace(this, this.constructor);
14
+ }
15
+ }
16
+ /**
17
+ * Error thrown when a provider is not found
18
+ */
19
+ export class ProviderNotFoundError extends CCKitError {
20
+ constructor(providerId) {
21
+ super(`Provider '${providerId}' not found`, 'PROVIDER_NOT_FOUND', { providerId });
22
+ }
23
+ }
24
+ /**
25
+ * Error thrown when a provider is not configured
26
+ */
27
+ export class ProviderNotConfiguredError extends CCKitError {
28
+ constructor(providerId) {
29
+ super(`Provider '${providerId}' is not configured with an API key`, 'PROVIDER_NOT_CONFIGURED', { providerId });
30
+ }
31
+ }
32
+ /**
33
+ * Error thrown when a model is not found in provider
34
+ */
35
+ export class ModelNotFoundError extends CCKitError {
36
+ constructor(modelName, providerId) {
37
+ super(`Model '${modelName}' not found in provider '${providerId}'`, 'MODEL_NOT_FOUND', { modelName, providerId });
38
+ }
39
+ }
40
+ /**
41
+ * Error thrown when configuration file is invalid
42
+ */
43
+ export class InvalidConfigError extends CCKitError {
44
+ constructor(message, filePath) {
45
+ super(`Invalid configuration: ${message}`, 'INVALID_CONFIG', { filePath });
46
+ this.filePath = filePath;
47
+ }
48
+ }
49
+ /**
50
+ * Error thrown when Claude Code installation check fails
51
+ */
52
+ export class ClaudeCodeNotInstalledError extends CCKitError {
53
+ constructor() {
54
+ super('Claude Code is not installed', 'CLAUDE_CODE_NOT_INSTALLED');
55
+ }
56
+ }
57
+ /**
58
+ * Error thrown when an operation times out
59
+ */
60
+ export class TimeoutError extends CCKitError {
61
+ constructor(operation, timeout) {
62
+ super(`${operation} timed out after ${timeout}ms`, 'TIMEOUT', { operation, timeout });
63
+ }
64
+ }
65
+ /**
66
+ * Error thrown when file system operation fails
67
+ */
68
+ export class FileSystemError extends CCKitError {
69
+ constructor(operation, filePath, originalError) {
70
+ super(`Failed to ${operation} file: ${filePath}`, 'FILESYSTEM_ERROR', { filePath, originalError: originalError?.message });
71
+ this.originalError = originalError;
72
+ }
73
+ }
74
+ /**
75
+ * Type guard to check if error is a CCKitError
76
+ */
77
+ export function isCCKitError(error) {
78
+ return error instanceof CCKitError;
79
+ }
80
+ /**
81
+ * Gets a user-friendly error message
82
+ */
83
+ export function getErrorMessage(error) {
84
+ if (isCCKitError(error)) {
85
+ return error.message;
86
+ }
87
+ if (error instanceof Error) {
88
+ return error.message;
89
+ }
90
+ return String(error);
91
+ }
92
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnC,YACE,OAAe,EACC,IAAY,EACZ,OAAiB;QAEjC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAU;QAGjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,UAAU;IACnD,YAAY,UAAkB;QAC5B,KAAK,CACH,aAAa,UAAU,aAAa,EACpC,oBAAoB,EACpB,EAAE,UAAU,EAAE,CACf,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,UAAU;IACxD,YAAY,UAAkB;QAC5B,KAAK,CACH,aAA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AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IAED,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IAED,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Helper utility functions
3
+ */
4
+ import type { ModelProvider } from '../types.js';
5
+ /**
6
+ * Masks an API key for secure display
7
+ * @param apiKey - The API key to mask
8
+ * @param visibleChars - Number of characters to show at the beginning (default: 8)
9
+ * @returns Masked API key string
10
+ */
11
+ export declare function maskApiKey(apiKey: string, visibleChars?: number): string;
12
+ /**
13
+ * Finds a provider by ID, name, or type
14
+ * @param providers - Array of providers to search
15
+ * @param identifier - Provider ID, name, or type
16
+ * @returns Found provider or undefined
17
+ */
18
+ export declare function findProvider(providers: ModelProvider[], identifier: string): ModelProvider | undefined;
19
+ /**
20
+ * Provider type mapping configuration
21
+ */
22
+ export declare const PROVIDER_TYPE_MAP: Record<string, [string, string]>;
23
+ /**
24
+ * Gets provider type and display name from identifier
25
+ * @param identifier - Provider identifier
26
+ * @returns Tuple of [providerType, displayName] or null
27
+ */
28
+ export declare function getProviderTypeInfo(identifier: string): [string, string] | null;
29
+ /**
30
+ * Formats file size for display
31
+ * @param bytes - Size in bytes
32
+ * @returns Formatted size string
33
+ */
34
+ export declare function formatBytes(bytes: number): string;
35
+ /**
36
+ * Safely executes a function and handles errors
37
+ * @param fn - Function to execute
38
+ * @param errorHandler - Error handler function
39
+ * @returns Result or undefined if error occurred
40
+ */
41
+ export declare function safeExecute<T>(fn: () => T, errorHandler?: (error: Error) => void): T | undefined;
42
+ /**
43
+ * Creates a promise that resolves after a delay
44
+ * @param ms - Milliseconds to delay
45
+ * @returns Promise that resolves after delay
46
+ */
47
+ export declare function delay(ms: number): Promise<void>;
48
+ /**
49
+ * Checks if a value is defined and not null
50
+ * @param value - Value to check
51
+ * @returns True if value is defined and not null
52
+ */
53
+ export declare function isDefined<T>(value: T | null | undefined): value is T;
54
+ /**
55
+ * Gets the active model for a provider
56
+ * @param provider - Provider configuration
57
+ * @returns Active model name or undefined
58
+ */
59
+ export declare function getActiveModel(provider: ModelProvider): string | undefined;
60
+ /**
61
+ * Wraps an async function with timeout
62
+ * @param promise - Promise to wrap
63
+ * @param timeoutMs - Timeout in milliseconds
64
+ * @param errorMessage - Error message on timeout
65
+ * @returns Promise that rejects on timeout
66
+ */
67
+ export declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number, errorMessage?: string): Promise<T>;
68
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,GAAE,MAAU,GAAG,MAAM,CAK3E;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,aAAa,EAAE,EAC1B,UAAU,EAAE,MAAM,GACjB,aAAa,GAAG,SAAS,CAI3B;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAU9D,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,GACjB,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAEzB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMjD;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,EAAE,EAAE,MAAM,CAAC,EACX,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GACpC,CAAC,GAAG,SAAS,CAUf;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,IAAI,CAAC,CAEpE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAE1E;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,SAAS,EAAE,MAAM,EACjB,YAAY,GAAE,MAA8B,GAC3C,OAAO,CAAC,CAAC,CAAC,CAOZ"}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Helper utility functions
3
+ */
4
+ /**
5
+ * Masks an API key for secure display
6
+ * @param apiKey - The API key to mask
7
+ * @param visibleChars - Number of characters to show at the beginning (default: 8)
8
+ * @returns Masked API key string
9
+ */
10
+ export function maskApiKey(apiKey, visibleChars = 8) {
11
+ if (!apiKey || apiKey.length <= visibleChars) {
12
+ return apiKey ? apiKey.substring(0, 4) + '***' : '***';
13
+ }
14
+ return apiKey.substring(0, visibleChars) + '***';
15
+ }
16
+ /**
17
+ * Finds a provider by ID, name, or type
18
+ * @param providers - Array of providers to search
19
+ * @param identifier - Provider ID, name, or type
20
+ * @returns Found provider or undefined
21
+ */
22
+ export function findProvider(providers, identifier) {
23
+ return providers.find((p) => p.id === identifier || p.name === identifier || p.provider_type === identifier);
24
+ }
25
+ /**
26
+ * Provider type mapping configuration
27
+ */
28
+ export const PROVIDER_TYPE_MAP = {
29
+ zhipu: ['zhipu', '智谱LLM (Zhipu)'],
30
+ '智谱': ['zhipu', '智谱LLM (Zhipu)'],
31
+ minimax: ['minimax', 'MiniMax'],
32
+ kimi: ['kimi', 'Kimi (Moonshot)'],
33
+ claude: ['claude', 'Claude (Official)'],
34
+ zenmux: ['zenmux', 'ZenMux.ai'],
35
+ streamlake: ['streamlake', 'Kuaishou StreamLake'],
36
+ kuaishou: ['streamlake', 'Kuaishou StreamLake'],
37
+ '快手': ['streamlake', 'Kuaishou StreamLake'],
38
+ };
39
+ /**
40
+ * Gets provider type and display name from identifier
41
+ * @param identifier - Provider identifier
42
+ * @returns Tuple of [providerType, displayName] or null
43
+ */
44
+ export function getProviderTypeInfo(identifier) {
45
+ return PROVIDER_TYPE_MAP[identifier] || null;
46
+ }
47
+ /**
48
+ * Formats file size for display
49
+ * @param bytes - Size in bytes
50
+ * @returns Formatted size string
51
+ */
52
+ export function formatBytes(bytes) {
53
+ if (bytes === 0)
54
+ return '0 B';
55
+ const k = 1024;
56
+ const sizes = ['B', 'KB', 'MB', 'GB'];
57
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
58
+ return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
59
+ }
60
+ /**
61
+ * Safely executes a function and handles errors
62
+ * @param fn - Function to execute
63
+ * @param errorHandler - Error handler function
64
+ * @returns Result or undefined if error occurred
65
+ */
66
+ export function safeExecute(fn, errorHandler) {
67
+ try {
68
+ return fn();
69
+ }
70
+ catch (error) {
71
+ const err = error instanceof Error ? error : new Error(String(error));
72
+ if (errorHandler) {
73
+ errorHandler(err);
74
+ }
75
+ return undefined;
76
+ }
77
+ }
78
+ /**
79
+ * Creates a promise that resolves after a delay
80
+ * @param ms - Milliseconds to delay
81
+ * @returns Promise that resolves after delay
82
+ */
83
+ export function delay(ms) {
84
+ return new Promise((resolve) => setTimeout(resolve, ms));
85
+ }
86
+ /**
87
+ * Checks if a value is defined and not null
88
+ * @param value - Value to check
89
+ * @returns True if value is defined and not null
90
+ */
91
+ export function isDefined(value) {
92
+ return value !== null && value !== undefined;
93
+ }
94
+ /**
95
+ * Gets the active model for a provider
96
+ * @param provider - Provider configuration
97
+ * @returns Active model name or undefined
98
+ */
99
+ export function getActiveModel(provider) {
100
+ return provider.current_model || provider.models[0];
101
+ }
102
+ /**
103
+ * Wraps an async function with timeout
104
+ * @param promise - Promise to wrap
105
+ * @param timeoutMs - Timeout in milliseconds
106
+ * @param errorMessage - Error message on timeout
107
+ * @returns Promise that rejects on timeout
108
+ */
109
+ export function withTimeout(promise, timeoutMs, errorMessage = 'Operation timed out') {
110
+ return Promise.race([
111
+ promise,
112
+ new Promise((_, reject) => setTimeout(() => reject(new Error(errorMessage)), timeoutMs)),
113
+ ]);
114
+ }
115
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc,EAAE,eAAuB,CAAC;IACjE,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,IAAI,YAAY,EAAE,CAAC;QAC7C,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IACzD,CAAC;IACD,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC;AACnD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAC1B,SAA0B,EAC1B,UAAkB;IAElB,OAAO,SAAS,CAAC,IAAI,CACnB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,UAAU,IAAI,CAAC,CAAC,IAAI,KAAK,UAAU,IAAI,CAAC,CAAC,aAAa,KAAK,UAAU,CACtF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,iBAA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AAC;QACH,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,GAAG,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACtE,IAAI,YAAY,EAAE,CAAC;YACjB,YAAY,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,EAAU;IAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAI,KAA2B;IACtD,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AAC/C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,QAAuB;IACpD,OAAO,QAAQ,CAAC,aAAa,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CACzB,OAAmB,EACnB,SAAiB,EACjB,eAAuB,qBAAqB;IAE5C,OAAO,OAAO,CAAC,IAAI,CAAC;QAClB,OAAO;QACP,IAAI,OAAO,CAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAC3B,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,EAAE,SAAS,CAAC,CAC7D;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Utilities index
3
+ */
4
+ export * from './helpers.js';
5
+ export * from './constants.js';
6
+ export * from './errors.js';
7
+ export * from './logger.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Utilities index
3
+ */
4
+ export * from './helpers.js';
5
+ export * from './constants.js';
6
+ export * from './errors.js';
7
+ export * from './logger.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Logging utilities
3
+ */
4
+ /**
5
+ * Log levels
6
+ */
7
+ export declare enum LogLevel {
8
+ DEBUG = 0,
9
+ INFO = 1,
10
+ WARN = 2,
11
+ ERROR = 3,
12
+ SUCCESS = 4
13
+ }
14
+ /**
15
+ * Simple logger class
16
+ */
17
+ export declare class Logger {
18
+ private level;
19
+ setLevel(level: LogLevel): void;
20
+ debug(message: string, ...args: unknown[]): void;
21
+ info(message: string, ...args: unknown[]): void;
22
+ warn(message: string, ...args: unknown[]): void;
23
+ error(message: string, ...args: unknown[]): void;
24
+ success(message: string, ...args: unknown[]): void;
25
+ }
26
+ /**
27
+ * Global logger instance
28
+ */
29
+ export declare const logger: Logger;
30
+ /**
31
+ * Sets the log level
32
+ */
33
+ export declare function setLogLevel(level: LogLevel): void;
34
+ /**
35
+ * Enables debug mode
36
+ */
37
+ export declare function enableDebugMode(): void;
38
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,oBAAY,QAAQ;IAClB,KAAK,IAAI;IACT,IAAI,IAAI;IACR,IAAI,IAAI;IACR,KAAK,IAAI;IACT,OAAO,IAAI;CACZ;AAED;;GAEG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,KAAK,CAA2B;IAExC,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAI/B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAMhD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAM/C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAM/C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAMhD,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;CAKnD;AAED;;GAEG;AACH,eAAO,MAAM,MAAM,QAAe,CAAC;AAEnC;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAEjD;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAEtC"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Logging utilities
3
+ */
4
+ import chalk from 'chalk';
5
+ /**
6
+ * Log levels
7
+ */
8
+ export var LogLevel;
9
+ (function (LogLevel) {
10
+ LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
11
+ LogLevel[LogLevel["INFO"] = 1] = "INFO";
12
+ LogLevel[LogLevel["WARN"] = 2] = "WARN";
13
+ LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
14
+ LogLevel[LogLevel["SUCCESS"] = 4] = "SUCCESS";
15
+ })(LogLevel || (LogLevel = {}));
16
+ /**
17
+ * Simple logger class
18
+ */
19
+ export class Logger {
20
+ constructor() {
21
+ this.level = LogLevel.INFO;
22
+ }
23
+ setLevel(level) {
24
+ this.level = level;
25
+ }
26
+ debug(message, ...args) {
27
+ if (this.level <= LogLevel.DEBUG) {
28
+ console.log(chalk.gray('[DEBUG]'), message, ...args);
29
+ }
30
+ }
31
+ info(message, ...args) {
32
+ if (this.level <= LogLevel.INFO) {
33
+ console.log(chalk.blue('[INFO]'), message, ...args);
34
+ }
35
+ }
36
+ warn(message, ...args) {
37
+ if (this.level <= LogLevel.WARN) {
38
+ console.log(chalk.yellow('[WARN]'), message, ...args);
39
+ }
40
+ }
41
+ error(message, ...args) {
42
+ if (this.level <= LogLevel.ERROR) {
43
+ console.error(chalk.red('[ERROR]'), message, ...args);
44
+ }
45
+ }
46
+ success(message, ...args) {
47
+ if (this.level <= LogLevel.SUCCESS) {
48
+ console.log(chalk.green('[SUCCESS]'), message, ...args);
49
+ }
50
+ }
51
+ }
52
+ /**
53
+ * Global logger instance
54
+ */
55
+ export const logger = new Logger();
56
+ /**
57
+ * Sets the log level
58
+ */
59
+ export function setLogLevel(level) {
60
+ logger.setLevel(level);
61
+ }
62
+ /**
63
+ * Enables debug mode
64
+ */
65
+ export function enableDebugMode() {
66
+ logger.setLevel(LogLevel.DEBUG);
67
+ }
68
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,MAAM,CAAN,IAAY,QAMX;AAND,WAAY,QAAQ;IAClB,yCAAS,CAAA;IACT,uCAAQ,CAAA;IACR,uCAAQ,CAAA;IACR,yCAAS,CAAA;IACT,6CAAW,CAAA;AACb,CAAC,EANW,QAAQ,KAAR,QAAQ,QAMnB;AAED;;GAEG;AACH,M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nC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;AAEnC;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,KAAe;IACzC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cckit",
3
- "version": "0.1.3",
4
- "description": "Code Kit for Claude Model Switching - Support 智谱LLM, MiniMax, Kimi, ZenMux.ai",
3
+ "version": "0.1.5",
4
+ "description": "Code Kit for Claude Model Switching - Support 智谱LLM, MiniMax, Kimi, Kuaishou StreamLake, ZenMux.ai",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -14,10 +14,19 @@
14
14
  "LICENSE"
15
15
  ],
16
16
  "scripts": {
17
- "build": "tsc",
17
+ "prebuild": "node scripts/inject-version.js",
18
+ "build": "node scripts/inject-version.js && tsc",
19
+ "build:minify": "node scripts/inject-version.js && tsc && node scripts/minify.js",
20
+ "build:prod": "node scripts/inject-version.js && tsc && node scripts/minify.js",
21
+ "build:info": "node scripts/build-info.js",
18
22
  "dev": "ts-node src/index.ts",
23
+ "release": "standard-version",
24
+ "release:patch": "standard-version --release-as patch",
25
+ "release:minor": "standard-version --release-as minor",
26
+ "release:major": "standard-version --release-as major",
27
+ "postrelease": "npm run build:prod && git push --follow-tags && npm publish",
19
28
  "test": "echo \"Error: no test specified\" && exit 1",
20
- "prepublishOnly": "npm run build",
29
+ "prepublishOnly": "npm run build:prod",
21
30
  "prepare": "npm run build"
22
31
  },
23
32
  "keywords": [
@@ -28,6 +37,8 @@
28
37
  "zhipu",
29
38
  "minimax",
30
39
  "kimi",
40
+ "kuaishou",
41
+ "streamlake",
31
42
  "zenmux",
32
43
  "anthropic",
33
44
  "cli",
@@ -49,8 +60,10 @@
49
60
  "devDependencies": {
50
61
  "@types/node": "^24.10.1",
51
62
  "@types/yargs": "^17.0.35",
63
+ "terser": "^5.36.0",
52
64
  "ts-node": "^10.9.2",
53
- "typescript": "^5.9.3"
65
+ "typescript": "^5.9.3",
66
+ "standard-version": "^9.5.0"
54
67
  },
55
68
  "dependencies": {
56
69
  "axios": "^1.13.2",