locai 2.1.2 → 2.1.3
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/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/openai.d.ts +28 -0
- 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/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/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/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/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,31 @@
|
|
|
1
|
+
export interface PunctuationIssue {
|
|
2
|
+
type: "punctuation";
|
|
3
|
+
message: string;
|
|
4
|
+
}
|
|
5
|
+
export interface PunctuationFixResult {
|
|
6
|
+
text: string;
|
|
7
|
+
foundIssues: PunctuationIssue[];
|
|
8
|
+
appliedFixes: {
|
|
9
|
+
type: "punctuation";
|
|
10
|
+
message: string;
|
|
11
|
+
}[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Punctuation Consistency Checker.
|
|
15
|
+
* Ensures end punctuation marks are preserved in translation.
|
|
16
|
+
*/
|
|
17
|
+
declare class PunctuationChecker {
|
|
18
|
+
/**
|
|
19
|
+
* Check for punctuation mismatches.
|
|
20
|
+
*/
|
|
21
|
+
checkPunctuation(source: string, translated: string): PunctuationIssue[];
|
|
22
|
+
/**
|
|
23
|
+
* Fix missing punctuation marks.
|
|
24
|
+
*/
|
|
25
|
+
fixPunctuation(source: string, translated: string): PunctuationFixResult;
|
|
26
|
+
/**
|
|
27
|
+
* Add punctuation to the end of text.
|
|
28
|
+
*/
|
|
29
|
+
addPunctuation(text: string, punctuation: string): string;
|
|
30
|
+
}
|
|
31
|
+
export default PunctuationChecker;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface QuoteIssue {
|
|
2
|
+
type: "unbalanced-quotes" | "quote-consistency" | "quote-balance";
|
|
3
|
+
severity: "error" | "warning";
|
|
4
|
+
message: string;
|
|
5
|
+
char?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface QuoteFixResult {
|
|
8
|
+
text: string;
|
|
9
|
+
foundIssues: QuoteIssue[];
|
|
10
|
+
appliedFixes: {
|
|
11
|
+
type: "quote-balance";
|
|
12
|
+
message: string;
|
|
13
|
+
}[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Quote Balance Checker.
|
|
17
|
+
* Ensures quotes (single, double, guillemets, etc.) are balanced in translation.
|
|
18
|
+
*/
|
|
19
|
+
declare class QuoteBalanceChecker {
|
|
20
|
+
/**
|
|
21
|
+
* Check for unbalanced quotes.
|
|
22
|
+
*/
|
|
23
|
+
checkQuoteBalance(text: string): QuoteIssue[];
|
|
24
|
+
/**
|
|
25
|
+
* Count occurrences of a quote character.
|
|
26
|
+
*/
|
|
27
|
+
private _countQuotes;
|
|
28
|
+
/**
|
|
29
|
+
* Fix unbalanced quotes.
|
|
30
|
+
*/
|
|
31
|
+
fixQuoteBalance(text: string): QuoteFixResult;
|
|
32
|
+
/**
|
|
33
|
+
* Validate that quotes in source and translation match in pattern.
|
|
34
|
+
*/
|
|
35
|
+
validateQuoteConsistency(source: string, translated: string): QuoteIssue[];
|
|
36
|
+
}
|
|
37
|
+
export default QuoteBalanceChecker;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export interface SpecialCharIssue {
|
|
2
|
+
type: "special-characters" | "special-character-substitution" | "emoji-preservation" | "missing-special-chars" | "character-substitution";
|
|
3
|
+
category?: string;
|
|
4
|
+
severity: "error" | "warning";
|
|
5
|
+
message: string;
|
|
6
|
+
details?: any;
|
|
7
|
+
}
|
|
8
|
+
export interface SpecialCharFixResult {
|
|
9
|
+
text: string;
|
|
10
|
+
foundIssues: SpecialCharIssue[];
|
|
11
|
+
appliedFixes: {
|
|
12
|
+
type: "critical-char-restore" | "character-substitution";
|
|
13
|
+
message: string;
|
|
14
|
+
}[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Special Characters Preservation Checker.
|
|
18
|
+
* Ensures special characters, symbols, and formatting are preserved.
|
|
19
|
+
*/
|
|
20
|
+
declare class SpecialCharactersChecker {
|
|
21
|
+
private specialCharacterSets;
|
|
22
|
+
private criticalCharacters;
|
|
23
|
+
constructor();
|
|
24
|
+
/**
|
|
25
|
+
* Check if special characters are preserved.
|
|
26
|
+
*/
|
|
27
|
+
checkSpecialCharacters(sourceText: string, translatedText: string): SpecialCharIssue[];
|
|
28
|
+
/**
|
|
29
|
+
* Check emoji preservation.
|
|
30
|
+
*/
|
|
31
|
+
checkEmojiPreservation(sourceText: string, translatedText: string): SpecialCharIssue[];
|
|
32
|
+
/**
|
|
33
|
+
* Fix special character issues.
|
|
34
|
+
*/
|
|
35
|
+
fixSpecialCharacters(sourceText: string, translatedText: string): SpecialCharFixResult;
|
|
36
|
+
/**
|
|
37
|
+
* Extract special characters by category.
|
|
38
|
+
*/
|
|
39
|
+
extractSpecialCharacters(text: string): Record<string, string[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Restore critical characters that were lost.
|
|
42
|
+
*/
|
|
43
|
+
restoreCriticalCharacters(sourceText: string, translatedText: string, missingChars: string[]): {
|
|
44
|
+
text: string;
|
|
45
|
+
appliedFixes: {
|
|
46
|
+
type: "critical-char-restore";
|
|
47
|
+
message: string;
|
|
48
|
+
}[];
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Fix common character substitutions.
|
|
52
|
+
*/
|
|
53
|
+
fixCommonSubstitutions(sourceText: string, translatedText: string): {
|
|
54
|
+
text: string;
|
|
55
|
+
foundIssues: SpecialCharIssue[];
|
|
56
|
+
appliedFixes: {
|
|
57
|
+
type: "character-substitution";
|
|
58
|
+
message: string;
|
|
59
|
+
}[];
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Check if text has special characters.
|
|
63
|
+
*/
|
|
64
|
+
hasSpecialCharacters(text: string): boolean;
|
|
65
|
+
}
|
|
66
|
+
export default SpecialCharactersChecker;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ProviderConfig } from "../../providers/base-provider.js";
|
|
2
|
+
export interface StyleGuideConfig {
|
|
3
|
+
formality?: string;
|
|
4
|
+
toneOfVoice?: string;
|
|
5
|
+
toneProvider?: string;
|
|
6
|
+
analysisOptions?: ProviderConfig;
|
|
7
|
+
enforceTone?: boolean;
|
|
8
|
+
conventions?: {
|
|
9
|
+
useOxfordComma?: boolean;
|
|
10
|
+
useSentenceCase?: boolean;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface StyleIssue {
|
|
15
|
+
type: "oxford-comma" | "sentence-case";
|
|
16
|
+
severity: "warning" | "info";
|
|
17
|
+
message: string;
|
|
18
|
+
suggestion?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface StyleFixResult {
|
|
21
|
+
text: string;
|
|
22
|
+
foundIssues: StyleIssue[];
|
|
23
|
+
appliedFixes: {
|
|
24
|
+
type: "oxford-comma" | "sentence-case";
|
|
25
|
+
message: string;
|
|
26
|
+
}[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Style Guide Checker.
|
|
30
|
+
* Enforces style guide conventions like Oxford comma and sentence case.
|
|
31
|
+
*/
|
|
32
|
+
declare class StyleGuideChecker {
|
|
33
|
+
private styleGuide;
|
|
34
|
+
constructor(styleGuide?: StyleGuideConfig);
|
|
35
|
+
/**
|
|
36
|
+
* Check if text follows style guide conventions.
|
|
37
|
+
*/
|
|
38
|
+
checkStyleGuide(_sourceText: string, translatedText: string): StyleIssue[];
|
|
39
|
+
/**
|
|
40
|
+
* Check for Oxford comma usage in lists.
|
|
41
|
+
*/
|
|
42
|
+
checkOxfordComma(text: string): StyleIssue[];
|
|
43
|
+
/**
|
|
44
|
+
* Check sentence case for headings/titles.
|
|
45
|
+
*/
|
|
46
|
+
checkSentenceCase(text: string): StyleIssue[];
|
|
47
|
+
/**
|
|
48
|
+
* Fix style guide issues.
|
|
49
|
+
*/
|
|
50
|
+
fixStyleGuide(sourceText: string, translatedText: string): StyleFixResult;
|
|
51
|
+
/**
|
|
52
|
+
* Fix missing Oxford commas.
|
|
53
|
+
*/
|
|
54
|
+
fixOxfordComma(text: string): StyleFixResult;
|
|
55
|
+
/**
|
|
56
|
+
* Fix sentence case issues.
|
|
57
|
+
*/
|
|
58
|
+
fixSentenceCase(text: string): {
|
|
59
|
+
text: string;
|
|
60
|
+
foundIssues: StyleIssue[];
|
|
61
|
+
appliedFixes: {
|
|
62
|
+
type: "sentence-case";
|
|
63
|
+
message: string;
|
|
64
|
+
}[];
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Convert text to sentence case.
|
|
68
|
+
*/
|
|
69
|
+
convertToSentenceCase(text: string): string;
|
|
70
|
+
}
|
|
71
|
+
export default StyleGuideChecker;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text Sanitizer.
|
|
3
|
+
* Cleans up translated text by removing AI artifacts, think tags, and unwanted formatting.
|
|
4
|
+
*/
|
|
5
|
+
declare class TextSanitizer {
|
|
6
|
+
/**
|
|
7
|
+
* Sanitize text by applying a sequence of cleaning rules.
|
|
8
|
+
*/
|
|
9
|
+
sanitize(text: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Apply a list of rules to text.
|
|
12
|
+
*/
|
|
13
|
+
applyRules(text: string, rules: ((text: string) => string)[]): string;
|
|
14
|
+
/**
|
|
15
|
+
* Remove <think> tags and their content.
|
|
16
|
+
*/
|
|
17
|
+
removeThinkTags: (text: string) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Remove bold/italic markdown formatting.
|
|
20
|
+
*/
|
|
21
|
+
removeMarkdownFormatting: (text: string) => string;
|
|
22
|
+
/**
|
|
23
|
+
* Remove leading/trailing quotes.
|
|
24
|
+
*/
|
|
25
|
+
removeQuotes: (text: string) => string;
|
|
26
|
+
/**
|
|
27
|
+
* Remove bullet points at the start.
|
|
28
|
+
*/
|
|
29
|
+
removeBulletPoints: (text: string) => string;
|
|
30
|
+
/**
|
|
31
|
+
* Remove explanatory text and metadata.
|
|
32
|
+
*/
|
|
33
|
+
removeExplanations: (text: string) => string;
|
|
34
|
+
/**
|
|
35
|
+
* Remove common AI conversational artifacts.
|
|
36
|
+
*/
|
|
37
|
+
removeAIArtifacts: (text: string) => string;
|
|
38
|
+
/**
|
|
39
|
+
* Trim special characters from ends.
|
|
40
|
+
*/
|
|
41
|
+
trimSpecialChars: (text: string) => string;
|
|
42
|
+
/**
|
|
43
|
+
* Normalize whitespace and remove duplicate lines.
|
|
44
|
+
*/
|
|
45
|
+
normalizeWhitespace: (text: string) => string;
|
|
46
|
+
/**
|
|
47
|
+
* Aggressive cleanup of all artifacts.
|
|
48
|
+
*/
|
|
49
|
+
removeAllArtifacts: (text: string) => string;
|
|
50
|
+
}
|
|
51
|
+
export default TextSanitizer;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ProviderConfig } from "../../providers/base-provider.js";
|
|
2
|
+
export interface ToneVerificationResult {
|
|
3
|
+
passed: boolean;
|
|
4
|
+
score: number;
|
|
5
|
+
reasoning: string;
|
|
6
|
+
suggestions?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class ToneVerifier {
|
|
9
|
+
private provider;
|
|
10
|
+
private initialized;
|
|
11
|
+
constructor();
|
|
12
|
+
private initProvider;
|
|
13
|
+
verify(sourceText: string, translatedText: string, sourceLang: string, targetLang: string, targetTone: string, providerName?: string, options?: ProviderConfig): Promise<ToneVerificationResult>;
|
|
14
|
+
}
|
|
@@ -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;
|
|
@@ -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.1.
|
|
3
|
+
"version": "2.1.3",
|
|
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
|
},
|