cckit 0.2.0 → 0.3.1
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.
- package/README.md +322 -25
- package/dist/commands.d.ts +7 -2
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +1 -363
- package/dist/commands.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -267
- package/dist/config.js.map +1 -1
- package/dist/i18n.d.ts +1 -0
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +1 -239
- package/dist/i18n.js.map +1 -1
- package/dist/index.js +1 -151
- package/dist/index.js.map +1 -1
- package/dist/providers.d.ts.map +1 -1
- package/dist/providers.js +1 -174
- package/dist/providers.js.map +1 -1
- package/dist/proxy-manager.d.ts +38 -0
- package/dist/proxy-manager.d.ts.map +1 -0
- package/dist/proxy-manager.js +1 -0
- package/dist/proxy-manager.js.map +1 -0
- package/dist/types.d.ts +4 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -2
- package/dist/types.js.map +1 -1
- package/dist/utils/constants.d.ts +1 -1
- package/dist/utils/constants.js +1 -69
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/errors.js +1 -92
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/utils/helpers.js +1 -115
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/index.js +1 -8
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/logger.js +1 -68
- package/dist/utils/logger.js.map +1 -1
- package/package.json +6 -6
package/dist/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
//# sourceMappingURL=types.js.map
|
|
1
|
+
export{};
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","
|
|
1
|
+
{"version":3,"file":"/Users/qiutian00lw/Code/cckit_cli/cckit-node/dist/types.js","names":[],"sources":[],"mappings":"","ignoreList":[]}
|
package/dist/utils/constants.js
CHANGED
|
@@ -1,69 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Application constants
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Current version of the application
|
|
6
|
-
* Injected by scripts/inject-version.js during build
|
|
7
|
-
*/
|
|
8
|
-
export const APP_VERSION = '0.2.0';
|
|
9
|
-
/**
|
|
10
|
-
* Default base URLs for providers
|
|
11
|
-
*/
|
|
12
|
-
export const DEFAULT_BASE_URLS = Object.freeze({
|
|
13
|
-
zhipu: 'https://open.bigmodel.cn/api/anthropic',
|
|
14
|
-
minimax: 'https://api.minimaxi.com/anthropic',
|
|
15
|
-
kimi: 'https://api.kimi.com/coding/',
|
|
16
|
-
zenmux: 'https://zenmux.ai/api/anthropic',
|
|
17
|
-
streamlake: 'https://wanqing.streamlakeapi.com/api/gateway/v1/endpoints/kat-coder-pro-v1/claude-code-proxy',
|
|
18
|
-
custom: '',
|
|
19
|
-
});
|
|
20
|
-
/**
|
|
21
|
-
* Default models for providers
|
|
22
|
-
*/
|
|
23
|
-
export const DEFAULT_MODELS = Object.freeze({
|
|
24
|
-
zhipu: 'GLM-4.7',
|
|
25
|
-
minimax: 'MiniMax-M2',
|
|
26
|
-
kimi: 'kimi-for-coding',
|
|
27
|
-
zenmux: 'claude-3-5-sonnet-20241022',
|
|
28
|
-
claude: 'claude-3-5-sonnet-20241022',
|
|
29
|
-
streamlake: 'kat-coder-pro-v1',
|
|
30
|
-
custom: '',
|
|
31
|
-
});
|
|
32
|
-
/**
|
|
33
|
-
* Provider type enum
|
|
34
|
-
*/
|
|
35
|
-
export var ProviderType;
|
|
36
|
-
(function (ProviderType) {
|
|
37
|
-
ProviderType["ZHIPU"] = "zhipu";
|
|
38
|
-
ProviderType["MINIMAX"] = "minimax";
|
|
39
|
-
ProviderType["KIMI"] = "kimi";
|
|
40
|
-
ProviderType["CLAUDE"] = "claude";
|
|
41
|
-
ProviderType["ZENMUX"] = "zenmux";
|
|
42
|
-
ProviderType["STREAMLAKE"] = "streamlake";
|
|
43
|
-
ProviderType["CUSTOM"] = "custom";
|
|
44
|
-
})(ProviderType || (ProviderType = {}));
|
|
45
|
-
/**
|
|
46
|
-
* File paths
|
|
47
|
-
*/
|
|
48
|
-
export const PATHS = Object.freeze({
|
|
49
|
-
CONFIG_DIR: '.cckit',
|
|
50
|
-
CONFIG_FILE: 'config.json',
|
|
51
|
-
CLAUDE_DIR: '.claude',
|
|
52
|
-
CLAUDE_SETTINGS: 'settings.json',
|
|
53
|
-
});
|
|
54
|
-
/**
|
|
55
|
-
* Timeouts in milliseconds
|
|
56
|
-
*/
|
|
57
|
-
export const TIMEOUTS = Object.freeze({
|
|
58
|
-
CLI_CHECK: 5000,
|
|
59
|
-
API_REQUEST: 10000,
|
|
60
|
-
USER_INPUT: 60000,
|
|
61
|
-
});
|
|
62
|
-
/**
|
|
63
|
-
* API registry mirrors
|
|
64
|
-
*/
|
|
65
|
-
export const NPM_REGISTRIES = Object.freeze({
|
|
66
|
-
DEFAULT: 'https://registry.npmjs.org',
|
|
67
|
-
NPMMIRROR: 'https://registry.npmmirror.com',
|
|
68
|
-
});
|
|
69
|
-
//# sourceMappingURL=constants.js.map
|
|
1
|
+
export const APP_VERSION="0.3.1";export const DEFAULT_BASE_URLS=Object.freeze({zhipu:"https://open.bigmodel.cn/api/anthropic",minimax:"https://api.minimaxi.com/anthropic",kimi:"https://api.kimi.com/coding/",zenmux:"https://zenmux.ai/api/anthropic",streamlake:"https://wanqing.streamlakeapi.com/api/gateway/v1/endpoints/kat-coder-pro-v1/claude-code-proxy",custom:""});export const DEFAULT_MODELS=Object.freeze({zhipu:"GLM-4.7",minimax:"MiniMax-M2",kimi:"kimi-for-coding",zenmux:"claude-3-5-sonnet-20241022",claude:"claude-3-5-sonnet-20241022",streamlake:"kat-coder-pro-v1",custom:""});export var ProviderType;!function(e){e.ZHIPU="zhipu",e.MINIMAX="minimax",e.KIMI="kimi",e.CLAUDE="claude",e.ZENMUX="zenmux",e.STREAMLAKE="streamlake",e.CUSTOM="custom"}(ProviderType||(ProviderType={}));export const PATHS=Object.freeze({CONFIG_DIR:".cckit",CONFIG_FILE:"config.json",CLAUDE_DIR:".claude",CLAUDE_SETTINGS:"settings.json"});export const TIMEOUTS=Object.freeze({CLI_CHECK:5e3,API_REQUEST:1e4,USER_INPUT:6e4});export const NPM_REGISTRIES=Object.freeze({DEFAULT:"https://registry.npmjs.org",NPMMIRROR:"https://registry.npmmirror.com"});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","
|
|
1
|
+
{"version":3,"file":"/Users/qiutian00lw/Code/cckit_cli/cckit-node/dist/utils/constants.js","names":["APP_VERSION","DEFAULT_BASE_URLS","Object","freeze","zhipu","minimax","kimi","zenmux","streamlake","custom","DEFAULT_MODELS","claude","ProviderType","PATHS","CONFIG_DIR","CONFIG_FILE","CLAUDE_DIR","CLAUDE_SETTINGS","TIMEOUTS","CLI_CHECK","API_REQUEST","USER_INPUT","NPM_REGISTRIES","DEFAULT","NPMMIRROR"],"sources":["../../src/utils/constants.ts"],"mappings":"OAQO,MAAMA,YAAc,eAKpB,MAAMC,kBAAoBC,OAAOC,OAAO,CAC7CC,MAAO,yCACPC,QAAS,qCACTC,KAAM,+BACNC,OAAQ,kCACRC,WAAY,gGACZC,OAAQ,YAMH,MAAMC,eAAiBR,OAAOC,OAAO,CAC1CC,MAAO,UACPC,QAAS,aACTC,KAAM,kBACNC,OAAQ,6BACRI,OAAQ,6BACRH,WAAY,mBACZC,OAAQ,YAMV,IAAYG,cAAZ,SAAYA,GACVA,EAAA,cACAA,EAAA,kBACAA,EAAA,YACAA,EAAA,gBACAA,EAAA,gBACAA,EAAA,wBACAA,EAAA,eACD,CARD,CAAYA,4BAAY,YAajB,MAAMC,MAAQX,OAAOC,OAAO,CACjCW,WAAY,SACZC,YAAa,cACbC,WAAY,UACZC,gBAAiB,yBAMZ,MAAMC,SAAWhB,OAAOC,OAAO,CACpCgB,UAAW,IACXC,YAAa,IACbC,WAAY,aAMP,MAAMC,eAAiBpB,OAAOC,OAAO,CAC1CoB,QAAS,6BACTC,UAAW","ignoreList":[]}
|
package/dist/utils/errors.js
CHANGED
|
@@ -1,92 +1 @@
|
|
|
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
|
|
1
|
+
export class CCKitError extends Error{constructor(r,o,t){super(r),this.code=o,this.details=t,this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor)}}export class ProviderNotFoundError extends CCKitError{constructor(r){super(`Provider '${r}' not found`,"PROVIDER_NOT_FOUND",{providerId:r})}}export class ProviderNotConfiguredError extends CCKitError{constructor(r){super(`Provider '${r}' is not configured with an API key`,"PROVIDER_NOT_CONFIGURED",{providerId:r})}}export class ModelNotFoundError extends CCKitError{constructor(r,o){super(`Model '${r}' not found in provider '${o}'`,"MODEL_NOT_FOUND",{modelName:r,providerId:o})}}export class InvalidConfigError extends CCKitError{constructor(r,o){super(`Invalid configuration: ${r}`,"INVALID_CONFIG",{filePath:o}),this.filePath=o}}export class ClaudeCodeNotInstalledError extends CCKitError{constructor(){super("Claude Code is not installed","CLAUDE_CODE_NOT_INSTALLED")}}export class TimeoutError extends CCKitError{constructor(r,o){super(`${r} timed out after ${o}ms`,"TIMEOUT",{operation:r,timeout:o})}}export class FileSystemError extends CCKitError{constructor(r,o,t){super(`Failed to ${r} file: ${o}`,"FILESYSTEM_ERROR",{filePath:o,originalError:t?.message}),this.originalError=t}}export function isCCKitError(r){return r instanceof CCKitError}export function getErrorMessage(r){return isCCKitError(r)||r instanceof Error?r.message:String(r)}
|
package/dist/utils/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","
|
|
1
|
+
{"version":3,"file":"/Users/qiutian00lw/Code/cckit_cli/cckit-node/dist/utils/errors.js","names":["CCKitError","Error","constructor","message","code","details","super","this","name","captureStackTrace","ProviderNotFoundError","providerId","ProviderNotConfiguredError","ModelNotFoundError","modelName","InvalidConfigError","filePath","ClaudeCodeNotInstalledError","TimeoutError","operation","timeout","FileSystemError","originalError","isCCKitError","error","getErrorMessage","String"],"sources":["../../src/utils/errors.ts"],"mappings":"OAOM,MAAOA,mBAAmBC,MAC9B,WAAAC,CACEC,EACgBC,EACAC,GAEhBC,MAAMH,GAHUI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AIG;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"}
|
package/dist/utils/helpers.js
CHANGED
|
@@ -1,115 +1 @@
|
|
|
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
|
|
1
|
+
export function maskApiKey(e,n=8){return!e||e.length<=n?e?e.substring(0,4)+"***":"***":e.substring(0,n)+"***"}export function findProvider(e,n){return e.find(e=>e.id===n||e.name===n||e.provider_type===n)}export const PROVIDER_TYPE_MAP={zhipu:["zhipu","智谱 Coding Plan"],"智谱":["zhipu","智谱 Coding Plan"],minimax:["minimax","MiniMax Coding Plan"],kimi:["kimi","Kimi Coding Plan"],claude:["claude","Claude (Official)"],zenmux:["zenmux","ZenMux.ai"],streamlake:["streamlake","快手 StreamLake Coding Plan"],kuaishou:["streamlake","快手 StreamLake Coding Plan"],"快手":["streamlake","快手 StreamLake Coding Plan"],volcengine:["volcengine","火山引擎 Coding Plan"],"火山":["volcengine","火山引擎 Coding Plan"]};export function getProviderTypeInfo(e){return PROVIDER_TYPE_MAP[e]||null}export function formatBytes(e){if(0===e)return"0 B";const n=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,n)).toFixed(2))} ${["B","KB","MB","GB"][n]}`}export function safeExecute(e,n){try{return e()}catch(e){const t=e instanceof Error?e:new Error(String(e));return void(n&&n(t))}}export function delay(e){return new Promise(n=>setTimeout(n,e))}export function isDefined(e){return null!=e}export function getActiveModel(e){return e.current_model||e.models[0]}export function withTimeout(e,n,t="Operation timed out"){return Promise.race([e,new Promise((e,r)=>setTimeout(()=>r(new Error(t)),n))])}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","
|
|
1
|
+
{"version":3,"file":"/Users/qiutian00lw/Code/cckit_cli/cckit-node/dist/utils/helpers.js","names":["maskApiKey","apiKey","visibleChars","length","substring","findProvider","providers","identifier","find","p","id","name","provider_type","PROVIDER_TYPE_MAP","zhipu","minimax","kimi","claude","zenmux","streamlake","kuaishou","volcengine","getProviderTypeInfo","formatBytes","bytes","i","Math","floor","log","parseFloat","pow","toFixed","safeExecute","fn","errorHandler","error","err","Error","String","delay","ms","Promise","resolve","setTimeout","isDefined","value","getActiveModel","provider","current_model","models","withTimeout","promise","timeoutMs","errorMessage","race","_","reject"],"sources":["../../src/utils/helpers.ts"],"mappings":"OAYM,SAAUA,WAAWC,EAAgBC,EAAuB,GAChE,OAAKD,GAAUA,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AAOZ,QAAQa,KAAK,CAClBH,EACA,IAAIV,QAAW,CAACc,EAAGC,IACjBb,WAAW,IAAMa,EAAO,IAAInB,MAAMgB,IAAgBD,KAGxD","ignoreList":[]}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,8 +1 @@
|
|
|
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
|
|
1
|
+
export*from"./helpers.js";export*from"./constants.js";export*from"./errors.js";export*from"./logger.js";
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","
|
|
1
|
+
{"version":3,"file":"/Users/qiutian00lw/Code/cckit_cli/cckit-node/dist/utils/index.js","names":["from"],"sources":["../../src/utils/index.ts"],"mappings":"MAIAA,KAAc,qBACdA,KAAc,uBACdA,KAAc,oBACdA,KAAc","ignoreList":[]}
|
package/dist/utils/logger.js
CHANGED
|
@@ -1,68 +1 @@
|
|
|
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
|
|
1
|
+
import e from"chalk";export var LogLevel;!function(e){e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e[e.SUCCESS=4]="SUCCESS"}(LogLevel||(LogLevel={}));export class Logger{constructor(){this.level=LogLevel.INFO}setLevel(e){this.level=e}debug(o,...l){this.level<=LogLevel.DEBUG&&console.log(e.gray("[DEBUG]"),o,...l)}info(o,...l){this.level<=LogLevel.INFO&&console.log(e.blue("[INFO]"),o,...l)}warn(o,...l){this.level<=LogLevel.WARN&&console.log(e.yellow("[WARN]"),o,...l)}error(o,...l){this.level<=LogLevel.ERROR&&console.error(e.red("[ERROR]"),o,...l)}success(o,...l){this.level<=LogLevel.SUCCESS&&console.log(e.green("[SUCCESS]"),o,...l)}}export const logger=new Logger;export function setLogLevel(e){logger.setLevel(e)}export function enableDebugMode(){logger.setLevel(LogLevel.DEBUG)}
|
package/dist/utils/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","
|
|
1
|
+
{"version":3,"file":"/Users/qiutian00lw/Code/cckit_cli/cckit-node/dist/utils/logger.js","names":["chalk","LogLevel","Logger","constructor","this","level","INFO","setLevel","debug","message","args","DEBUG","console","log","gray","info","blue","warn","WARN","yellow","error","ERROR","red","success","SUCCESS","green","logger","setLogLevel","enableDebugMode"],"sources":["../../src/utils/logger.ts"],"mappings":"OAIOA,MAAW,eAKlB,IAAYC,UAAZ,SAAYA,GACVA,IAAA,iBACAA,IAAA,eACAA,IAAA,eACAA,IAAA,iBACAA,IAAA,oBACD,CAND,CAAYA,oBAAQ,YAWd,MAAOC,OAAb,WAAAC,GACUC,KAAAC,MAAkBJ,SAASK,IAmCrC,CAjCE,QAAAC,CAASF,GACPD,KAAKC,MAAQA,CACf,CAEA,KAAAG,CAAMC,KAAoBC,GACpBN,KAAKC,OAASJ,SAASU,OACzBC,QAAQC,IAAIb,EAAMc,KAAK,WAAYL,KAAYC,EAEnD,CAEA,IAAAK,CAAKN,KAAoBC,GACnBN,KAAKC,OAASJ,SAASK,MACzBM,QAAQC,IAAIb,EAAMgB,KAAK,UAAWP,KAAYC,EAElD,CAEA,IAAAO,CAAKR,KAAoBC,GACnBN,KAAKC,OAASJ,SAASiB,MACzBN,QAAQC,IAAIb,EAAMmB,OAAO,UAAWV,KAAYC,EAEpD,CAEA,KAAAU,CAAMX,KAAoBC,GACpBN,KAAKC,OAASJ,SAASoB,OACzBT,QAAQQ,MAAMpB,EAAMsB,IAAI,WAAYb,KAAYC,EAEpD,CAEA,OAAAa,CAAQd,KAAoBC,GACtBN,KAAKC,OAASJ,SAASuB,SACzBZ,QAAQC,IAAIb,EAAMyB,MAAM,aAAchB,KAAYC,EAEtD,SAMK,MAAMgB,OAAS,IAAIxB,cAKpB,SAAUyB,YAAYtB,GAC1BqB,OAAOnB,SAASF,EAClB,QAKM,SAAUuB,kBACdF,OAAOnB,SAASN,SAASU,MAC3B","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cckit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
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",
|
|
@@ -15,8 +15,7 @@
|
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
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",
|
|
18
|
+
"build": "node scripts/inject-version.js && tsc && node scripts/minify.js",
|
|
20
19
|
"build:prod": "node scripts/inject-version.js && tsc && node scripts/minify.js",
|
|
21
20
|
"build:info": "node scripts/build-info.js",
|
|
22
21
|
"dev": "ts-node src/index.ts",
|
|
@@ -56,18 +55,19 @@
|
|
|
56
55
|
"license": "MIT",
|
|
57
56
|
"packageManager": "pnpm@10.26.2",
|
|
58
57
|
"engines": {
|
|
59
|
-
"node": ">=
|
|
58
|
+
"node": ">=20.0.0",
|
|
60
59
|
"pnpm": ">=10.0.0"
|
|
61
60
|
},
|
|
62
61
|
"devDependencies": {
|
|
63
62
|
"@types/node": "^24.10.1",
|
|
64
63
|
"@types/yargs": "^17.0.35",
|
|
64
|
+
"standard-version": "^9.5.0",
|
|
65
65
|
"terser": "^5.36.0",
|
|
66
66
|
"ts-node": "^10.9.2",
|
|
67
|
-
"typescript": "^5.9.3"
|
|
68
|
-
"standard-version": "^9.5.0"
|
|
67
|
+
"typescript": "^5.9.3"
|
|
69
68
|
},
|
|
70
69
|
"dependencies": {
|
|
70
|
+
"@inquirer/prompts": "^8.3.0",
|
|
71
71
|
"axios": "^1.13.2",
|
|
72
72
|
"chalk": "^5.6.2",
|
|
73
73
|
"dotenv": "^17.2.3",
|