locai 2.1.2 → 2.2.0
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/dist/cli.d.ts +2 -0
- package/dist/commands/review.d.ts +109 -0
- package/dist/commands/translator.d.ts +23 -0
- package/dist/config/index.d.ts +145 -0
- package/dist/core/adapters/base-adapter.d.ts +20 -0
- package/dist/core/adapters/factory.d.ts +16 -0
- package/dist/core/adapters/json-adapter.d.ts +9 -0
- package/dist/core/adapters/po-adapter.d.ts +9 -0
- package/dist/core/adapters/properties-adapter.d.ts +9 -0
- package/dist/core/adapters/yaml-adapter.d.ts +9 -0
- package/dist/core/context-processor.d.ts +81 -0
- package/dist/core/detection/framework-detector.d.ts +9 -0
- package/dist/core/detection/structure-detector.d.ts +9 -0
- package/dist/core/fallback-provider.d.ts +54 -0
- package/dist/core/orchestrator.d.ts +101 -0
- package/dist/core/pipeline/Pipeline.d.ts +23 -0
- package/dist/core/pipeline/PipelineStep.d.ts +18 -0
- package/dist/core/pipeline/context.d.ts +29 -0
- package/dist/core/pipeline/steps/CacheReadStep.d.ts +25 -0
- package/dist/core/pipeline/steps/CacheWriteStep.d.ts +11 -0
- package/dist/core/pipeline/steps/ConfidenceCheckStep.d.ts +10 -0
- package/dist/core/pipeline/steps/GlossaryPostStep.d.ts +9 -0
- package/dist/core/pipeline/steps/GlossaryPreStep.d.ts +9 -0
- package/dist/core/pipeline/steps/InputValidationStep.d.ts +8 -0
- package/dist/core/pipeline/steps/QualityCheckStep.d.ts +10 -0
- package/dist/core/pipeline/steps/ToneCheckStep.d.ts +13 -0
- package/dist/core/pipeline/steps/TranslationStep.d.ts +22 -0
- package/dist/core/pipeline/steps/VectorCacheReadStep.d.ts +17 -0
- package/dist/core/pipeline/steps/VectorCacheWriteStep.d.ts +11 -0
- package/dist/core/pipeline/steps/__tests__/ToneCheckStep.test.d.ts +1 -0
- package/dist/core/provider-factory.d.ts +41 -0
- package/dist/core/provider-factory.js +4 -0
- package/dist/providers/anthropic.d.ts +25 -0
- package/dist/providers/anthropic.js +178 -0
- package/dist/providers/base-provider.d.ts +66 -0
- package/dist/providers/dashscope.d.ts +24 -0
- package/dist/providers/deepseek.d.ts +22 -0
- package/dist/providers/gemini.d.ts +22 -0
- package/dist/providers/gemini.js +3 -3
- package/dist/providers/openai.d.ts +28 -0
- package/dist/providers/openai.js +3 -3
- package/dist/providers/xai.d.ts +22 -0
- package/dist/services/embedding-provider.d.ts +26 -0
- package/dist/services/translation-service.d.ts +138 -0
- package/dist/services/vector-store.d.ts +26 -0
- package/dist/utils/ai-context-analyzer.d.ts +73 -0
- package/dist/utils/confidence-scorer.d.ts +77 -0
- package/dist/utils/error-helper.d.ts +87 -0
- package/dist/utils/error-helper.js +3 -1
- package/dist/utils/file-manager.d.ts +129 -0
- package/dist/utils/glossary-manager.d.ts +69 -0
- package/dist/utils/graceful-shutdown.d.ts +22 -0
- package/dist/utils/input-validator.d.ts +227 -0
- package/dist/utils/input-validator.js +8 -1
- package/dist/utils/logger.d.ts +134 -0
- package/dist/utils/object-transformer.d.ts +38 -0
- package/dist/utils/progress-tracker.d.ts +63 -0
- package/dist/utils/prompt-templates.d.ts +37 -0
- package/dist/utils/prompt-templates.js +18 -0
- package/dist/utils/quality/__tests__/tone-verifier.test.d.ts +1 -0
- package/dist/utils/quality/base-checker.d.ts +79 -0
- package/dist/utils/quality/code-block-checker.d.ts +64 -0
- package/dist/utils/quality/html-tag-checker.d.ts +33 -0
- package/dist/utils/quality/index.d.ts +39 -0
- package/dist/utils/quality/length-checker.d.ts +70 -0
- package/dist/utils/quality/markdown-checker.d.ts +63 -0
- package/dist/utils/quality/placeholder-checker.d.ts +42 -0
- package/dist/utils/quality/punctuation-checker.d.ts +31 -0
- package/dist/utils/quality/quote-balance-checker.d.ts +37 -0
- package/dist/utils/quality/special-characters-checker.d.ts +66 -0
- package/dist/utils/quality/style-guide-checker.d.ts +71 -0
- package/dist/utils/quality/text-sanitizer.d.ts +51 -0
- package/dist/utils/quality/tone-verifier.d.ts +14 -0
- package/dist/utils/rate-limiter.d.ts +73 -0
- package/dist/utils/rate-limiter.js +6 -0
- package/dist/utils/retry-helper.d.ts +49 -0
- package/dist/utils/state-manager.d.ts +62 -0
- package/dist/utils/statistics-manager.d.ts +47 -0
- package/dist/utils/ui-manager.d.ts +21 -0
- package/package.json +13 -5
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export interface RateLimiterConfig {
|
|
2
|
+
queueStrategy?: "fifo" | "priority";
|
|
3
|
+
queueTimeout?: number;
|
|
4
|
+
adaptiveThrottling?: boolean;
|
|
5
|
+
providerLimits?: Record<string, {
|
|
6
|
+
rpm?: number;
|
|
7
|
+
concurrency?: number;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Handles API rate limiting and request throttling.
|
|
12
|
+
* Supports provider-specific limits and adaptive throttling.
|
|
13
|
+
*/
|
|
14
|
+
declare class RateLimiter {
|
|
15
|
+
private queues;
|
|
16
|
+
private processing;
|
|
17
|
+
private config;
|
|
18
|
+
private metrics;
|
|
19
|
+
private providers;
|
|
20
|
+
private _processingLocks;
|
|
21
|
+
/**
|
|
22
|
+
* Create a new RateLimiter.
|
|
23
|
+
* @param config - Rate limiter configuration.
|
|
24
|
+
*/
|
|
25
|
+
constructor(config?: RateLimiterConfig);
|
|
26
|
+
/**
|
|
27
|
+
* Update rate limiter configuration.
|
|
28
|
+
* @param config - Configuration updates.
|
|
29
|
+
*/
|
|
30
|
+
updateConfig(config: RateLimiterConfig): void;
|
|
31
|
+
/**
|
|
32
|
+
* Enqueue a task for execution with rate limiting.
|
|
33
|
+
* @param provider - Provider name.
|
|
34
|
+
* @param task - Async task to execute.
|
|
35
|
+
* @param priority - Task priority (higher is better).
|
|
36
|
+
* @returns Task result.
|
|
37
|
+
*/
|
|
38
|
+
enqueue<T>(provider: string, task: () => Promise<T>, priority?: number): Promise<T>;
|
|
39
|
+
/**
|
|
40
|
+
* Process the queue for a specific provider.
|
|
41
|
+
* @param provider - Provider name.
|
|
42
|
+
*/
|
|
43
|
+
private _processQueue;
|
|
44
|
+
private _trackResponseTime;
|
|
45
|
+
private _trackErrorRate;
|
|
46
|
+
private _adjustThrottling;
|
|
47
|
+
private _shouldThrottle;
|
|
48
|
+
private _calculateWaitTime;
|
|
49
|
+
private _resetCounters;
|
|
50
|
+
/**
|
|
51
|
+
* Get current queue size for a provider.
|
|
52
|
+
* @param provider - Provider name.
|
|
53
|
+
* @returns Queue size.
|
|
54
|
+
*/
|
|
55
|
+
getQueueSize(provider: string): number;
|
|
56
|
+
/**
|
|
57
|
+
* Get complete rate limiter status.
|
|
58
|
+
* @returns Status object including active metrics.
|
|
59
|
+
*/
|
|
60
|
+
getStatus(): Record<string, any>;
|
|
61
|
+
/**
|
|
62
|
+
* Get current configuration.
|
|
63
|
+
* @returns Configuration object.
|
|
64
|
+
*/
|
|
65
|
+
getConfig(): RateLimiterConfig;
|
|
66
|
+
/**
|
|
67
|
+
* Clear all pending queues.
|
|
68
|
+
*/
|
|
69
|
+
clearAllQueues(): void;
|
|
70
|
+
private _cleanupMetrics;
|
|
71
|
+
}
|
|
72
|
+
declare const _default: RateLimiter;
|
|
73
|
+
export default _default;
|
|
@@ -59,6 +59,12 @@ class RateLimiter {
|
|
|
59
59
|
lastReset: performance.now(),
|
|
60
60
|
maxConcurrent: 8,
|
|
61
61
|
},
|
|
62
|
+
anthropic: {
|
|
63
|
+
requestsPerMinute: 50,
|
|
64
|
+
currentRequests: 0,
|
|
65
|
+
lastReset: performance.now(),
|
|
66
|
+
maxConcurrent: 5,
|
|
67
|
+
},
|
|
62
68
|
};
|
|
63
69
|
this._processingLocks = {};
|
|
64
70
|
Object.keys(this.providers).forEach((provider) => {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retry helper for API operations with exponential backoff
|
|
3
|
+
*/
|
|
4
|
+
export interface RetryOptions {
|
|
5
|
+
provider?: string;
|
|
6
|
+
perProviderRetry?: Record<string, Partial<RetryConfig>>;
|
|
7
|
+
retryableErrors?: string[];
|
|
8
|
+
maxRetries?: number;
|
|
9
|
+
initialDelay?: number;
|
|
10
|
+
maxDelay?: number;
|
|
11
|
+
context?: string;
|
|
12
|
+
logContext?: Record<string, any>;
|
|
13
|
+
retryCondition?: (error: any, attempts: number, maxRetries: number) => boolean | Promise<boolean>;
|
|
14
|
+
}
|
|
15
|
+
export interface RetryConfig {
|
|
16
|
+
maxRetries: number;
|
|
17
|
+
initialDelay: number;
|
|
18
|
+
maxDelay: number;
|
|
19
|
+
}
|
|
20
|
+
export interface RetryStats {
|
|
21
|
+
attempts: number;
|
|
22
|
+
totalTime: number;
|
|
23
|
+
provider?: string;
|
|
24
|
+
success?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Retry helper for API operations with exponential backoff.
|
|
28
|
+
*/
|
|
29
|
+
declare class RetryHelper {
|
|
30
|
+
/**
|
|
31
|
+
* Retry an operation with configurable backoff strategy.
|
|
32
|
+
* Supports per-provider retry configuration.
|
|
33
|
+
*/
|
|
34
|
+
static withRetry<T>(operation: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
35
|
+
/**
|
|
36
|
+
* Calculate exponential backoff with jitter.
|
|
37
|
+
*/
|
|
38
|
+
static calculateBackoff(attempt: number, initialDelay: number, maxDelay: number): number;
|
|
39
|
+
/**
|
|
40
|
+
* Default retry condition based on error type.
|
|
41
|
+
* Checks against retryableErrors list.
|
|
42
|
+
*/
|
|
43
|
+
static defaultRetryCondition(error: any, retryableErrors?: string[]): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Promise-based delay.
|
|
46
|
+
*/
|
|
47
|
+
static delay(ms: number): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
export default RetryHelper;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export interface StateOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
stateFileName?: string;
|
|
4
|
+
stateDir?: string;
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}
|
|
7
|
+
export interface StateComparison {
|
|
8
|
+
deletedKeys: string[];
|
|
9
|
+
modifiedKeys: string[];
|
|
10
|
+
newKeys: string[];
|
|
11
|
+
hasChanges: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface StateComparisonStats {
|
|
14
|
+
totalChanges: number;
|
|
15
|
+
deletedCount: number;
|
|
16
|
+
modifiedCount: number;
|
|
17
|
+
newCount: number;
|
|
18
|
+
hasChanges: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* StateManager - Tracks changes in source locale files using hash-based state management
|
|
22
|
+
* This enables detection of deleted/modified keys to synchronize target locale files
|
|
23
|
+
*/
|
|
24
|
+
declare class StateManager {
|
|
25
|
+
private options;
|
|
26
|
+
constructor(options?: StateOptions | {
|
|
27
|
+
stateTracking: StateOptions;
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Generate a SHA-256 hash for given text content
|
|
31
|
+
*/
|
|
32
|
+
_generateHash(text: string | object): string;
|
|
33
|
+
/**
|
|
34
|
+
* Get the full path to the state file
|
|
35
|
+
*/
|
|
36
|
+
_getStateFilePath(projectRoot: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Load previous state from state file
|
|
39
|
+
*/
|
|
40
|
+
loadState(projectRoot: string): Promise<Record<string, string>>;
|
|
41
|
+
/**
|
|
42
|
+
* Save current state to state file
|
|
43
|
+
*/
|
|
44
|
+
saveState(projectRoot: string, state: Record<string, string>): Promise<boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* Generate state object from source content by creating hashes for each key
|
|
47
|
+
*/
|
|
48
|
+
generateStateFromSource(sourceContent: Record<string, string>): Record<string, string>;
|
|
49
|
+
/**
|
|
50
|
+
* Compare two states and identify changes
|
|
51
|
+
*/
|
|
52
|
+
compareStates(previousState: Record<string, string>, currentState: Record<string, string>): StateComparison;
|
|
53
|
+
/**
|
|
54
|
+
* Get statistics about the state comparison
|
|
55
|
+
*/
|
|
56
|
+
getComparisonStats(comparison: StateComparison): StateComparisonStats;
|
|
57
|
+
/**
|
|
58
|
+
* Clean up old state files (maintenance utility)
|
|
59
|
+
*/
|
|
60
|
+
cleanupState(projectRoot: string): Promise<boolean>;
|
|
61
|
+
}
|
|
62
|
+
export default StateManager;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Statistics manager to track translation progress and metrics
|
|
3
|
+
*/
|
|
4
|
+
export interface GlobalStats {
|
|
5
|
+
total: number;
|
|
6
|
+
byCategory: Record<string, number>;
|
|
7
|
+
details: Record<string, {
|
|
8
|
+
samples: number;
|
|
9
|
+
totalConfidence: number;
|
|
10
|
+
}>;
|
|
11
|
+
totalTime: number;
|
|
12
|
+
success: number;
|
|
13
|
+
failed: number;
|
|
14
|
+
skipped: number;
|
|
15
|
+
languages: Record<string, LanguageStats>;
|
|
16
|
+
startTime: string;
|
|
17
|
+
orchestrators: any[];
|
|
18
|
+
}
|
|
19
|
+
export interface LanguageStats {
|
|
20
|
+
processed: number;
|
|
21
|
+
added: number;
|
|
22
|
+
skipped: number;
|
|
23
|
+
failed: number;
|
|
24
|
+
timeMs: number;
|
|
25
|
+
}
|
|
26
|
+
export declare class StatisticsManager {
|
|
27
|
+
private stats;
|
|
28
|
+
constructor();
|
|
29
|
+
/**
|
|
30
|
+
* Initialize global statistics structure
|
|
31
|
+
*/
|
|
32
|
+
initializeGlobalStats(): GlobalStats;
|
|
33
|
+
/**
|
|
34
|
+
* Reset statistics
|
|
35
|
+
*/
|
|
36
|
+
reset(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Get current stats
|
|
39
|
+
*/
|
|
40
|
+
getStats(): GlobalStats;
|
|
41
|
+
/**
|
|
42
|
+
* Initialize language stats
|
|
43
|
+
*/
|
|
44
|
+
initLanguageStats(langCode: string): void;
|
|
45
|
+
}
|
|
46
|
+
declare const _default: StatisticsManager;
|
|
47
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { GlobalStats } from "./statistics-manager.js";
|
|
2
|
+
/**
|
|
3
|
+
* UI Manager for handling CLI output and user interaction
|
|
4
|
+
*/
|
|
5
|
+
export declare class UIManager {
|
|
6
|
+
private consoleLock;
|
|
7
|
+
constructor();
|
|
8
|
+
/**
|
|
9
|
+
* Log a message safely preventing overlap
|
|
10
|
+
*/
|
|
11
|
+
log(message: string): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Display global summary of translation
|
|
14
|
+
*/
|
|
15
|
+
displayGlobalSummary(stats: GlobalStats & {
|
|
16
|
+
totalDuration?: number;
|
|
17
|
+
}, totalLanguages: number): Promise<void>;
|
|
18
|
+
logBatchResults(batchResults: any[]): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
declare const _default: UIManager;
|
|
21
|
+
export default _default;
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "locai",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/core/orchestrator.js",
|
|
6
|
+
"types": "dist/core/orchestrator.d.ts",
|
|
6
7
|
"directories": {
|
|
7
8
|
"src": "src",
|
|
8
9
|
"dist": "dist"
|
|
@@ -30,7 +31,14 @@
|
|
|
30
31
|
"localization",
|
|
31
32
|
"i18n",
|
|
32
33
|
"nextjs",
|
|
33
|
-
"ai-translation"
|
|
34
|
+
"ai-translation",
|
|
35
|
+
"cli",
|
|
36
|
+
"automation",
|
|
37
|
+
"llm",
|
|
38
|
+
"openai",
|
|
39
|
+
"gemini",
|
|
40
|
+
"deepseek",
|
|
41
|
+
"developer-tools"
|
|
34
42
|
],
|
|
35
43
|
"author": {
|
|
36
44
|
"name": "Ahmet Enes Dur",
|
|
@@ -41,12 +49,12 @@
|
|
|
41
49
|
"description": "Global, AI-Powered Translation CLI for every project.",
|
|
42
50
|
"repository": {
|
|
43
51
|
"type": "git",
|
|
44
|
-
"url": "git+https://github.com/ahmetenesdur/
|
|
52
|
+
"url": "git+https://github.com/ahmetenesdur/locai.git"
|
|
45
53
|
},
|
|
46
54
|
"bugs": {
|
|
47
|
-
"url": "https://github.com/ahmetenesdur/
|
|
55
|
+
"url": "https://github.com/ahmetenesdur/locai/issues"
|
|
48
56
|
},
|
|
49
|
-
"homepage": "https://github.com/ahmetenesdur/
|
|
57
|
+
"homepage": "https://github.com/ahmetenesdur/locai#readme",
|
|
50
58
|
"engines": {
|
|
51
59
|
"node": ">=14.13.0"
|
|
52
60
|
},
|