dialekt 0.1.0 → 0.1.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.
Files changed (71) hide show
  1. package/README.md +8 -10
  2. package/TESTING.md +29 -29
  3. package/dist/cli/main.d.mts +1 -1
  4. package/dist/cli/main.mjs +549 -362
  5. package/dist/formatters-De4Q-X1d.mjs +516 -435
  6. package/dist/index.d.mts +162 -25
  7. package/dist/index.mjs +119 -34
  8. package/package.json +3 -3
  9. package/pnpm-workspace.yaml +3 -3
  10. package/src/adapter/types.test.ts +57 -57
  11. package/src/adapter/types.ts +7 -4
  12. package/src/benchmark/metrics.test.ts +141 -69
  13. package/src/benchmark/metrics.ts +6 -6
  14. package/src/benchmark/report.test.ts +38 -38
  15. package/src/benchmark/report.ts +6 -6
  16. package/src/benchmark/runner.test.ts +70 -72
  17. package/src/benchmark/runner.ts +4 -4
  18. package/src/cli/commands/add.test.ts +90 -109
  19. package/src/cli/commands/add.ts +40 -28
  20. package/src/cli/commands/benchmark.test.ts +77 -64
  21. package/src/cli/commands/benchmark.ts +64 -41
  22. package/src/cli/commands/languages.test.ts +45 -42
  23. package/src/cli/commands/languages.ts +16 -12
  24. package/src/cli/commands/missing.test.ts +143 -92
  25. package/src/cli/commands/missing.ts +24 -17
  26. package/src/cli/commands/translate.test.ts +79 -79
  27. package/src/cli/commands/translate.ts +41 -31
  28. package/src/cli/commands/unused.test.ts +62 -51
  29. package/src/cli/commands/unused.ts +18 -14
  30. package/src/cli/commands/validate.test.ts +130 -72
  31. package/src/cli/commands/validate.ts +25 -20
  32. package/src/cli/config-resolution.test.ts +169 -49
  33. package/src/cli/config-resolution.ts +5 -7
  34. package/src/cli/format.test.ts +50 -50
  35. package/src/cli/format.ts +57 -60
  36. package/src/cli/formatters.test.ts +128 -106
  37. package/src/cli/formatters.ts +72 -95
  38. package/src/cli/main.ts +13 -13
  39. package/src/config/define-config.test.ts +44 -29
  40. package/src/config/define-config.ts +1 -1
  41. package/src/config/load-config.test.ts +21 -18
  42. package/src/config/load-config.ts +5 -5
  43. package/src/config/types.test.ts +50 -44
  44. package/src/config/types.ts +2 -2
  45. package/src/index.ts +22 -26
  46. package/src/keys/flatten.test.ts +52 -52
  47. package/src/keys/flatten.ts +7 -9
  48. package/src/sdk/file-io.test.ts +47 -59
  49. package/src/sdk/file-io.ts +2 -2
  50. package/src/sdk/node-layer.test.ts +18 -18
  51. package/src/sdk/node-layer.ts +2 -2
  52. package/src/sdk/php-array-reader.test.ts +49 -40
  53. package/src/sdk/php-array-reader.ts +5 -5
  54. package/src/translation/chunking.test.ts +52 -44
  55. package/src/translation/chunking.ts +1 -1
  56. package/src/translation/missing-keys.test.ts +86 -93
  57. package/src/translation/missing-keys.ts +4 -6
  58. package/src/translation/model-registry.test.ts +41 -32
  59. package/src/translation/model-registry.ts +9 -9
  60. package/src/translation/one-shot-strategy.test.ts +105 -86
  61. package/src/translation/one-shot-strategy.ts +10 -12
  62. package/src/translation/orchestrator.test.ts +90 -101
  63. package/src/translation/orchestrator.ts +26 -26
  64. package/src/translation/prompt.test.ts +76 -76
  65. package/src/translation/prompt.ts +2 -2
  66. package/src/translation/tool-loop-strategy.test.ts +134 -107
  67. package/src/translation/tool-loop-strategy.ts +14 -18
  68. package/src/translation/types.test.ts +22 -22
  69. package/src/translation/types.ts +3 -3
  70. package/tsdown.config.ts +3 -3
  71. package/vitest.config.ts +3 -3
package/dist/index.d.mts CHANGED
@@ -10,7 +10,11 @@ interface ResourceRef {
10
10
  readonly key: string;
11
11
  readonly label: string;
12
12
  }
13
- declare const AdapterReadError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
13
+ declare const AdapterReadError_base: new <A extends Record<string, any> = {}>(
14
+ args: import("effect/Types").VoidIfEmpty<{
15
+ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P];
16
+ }>,
17
+ ) => import("effect/Cause").YieldableError & {
14
18
  readonly _tag: "AdapterReadError";
15
19
  } & Readonly<A>;
16
20
  declare class AdapterReadError extends AdapterReadError_base<{
@@ -19,7 +23,11 @@ declare class AdapterReadError extends AdapterReadError_base<{
19
23
  readonly resource: string;
20
24
  readonly cause: unknown;
21
25
  }> {}
22
- declare const AdapterWriteError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
26
+ declare const AdapterWriteError_base: new <A extends Record<string, any> = {}>(
27
+ args: import("effect/Types").VoidIfEmpty<{
28
+ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P];
29
+ }>,
30
+ ) => import("effect/Cause").YieldableError & {
23
31
  readonly _tag: "AdapterWriteError";
24
32
  } & Readonly<A>;
25
33
  declare class AdapterWriteError extends AdapterWriteError_base<{
@@ -38,9 +46,16 @@ interface TranslationAdapter {
38
46
  /** List the resources available for a given locale (e.g. domain files present for "en"). */
39
47
  listResources(locale: string): Effect.Effect<readonly ResourceRef[], AdapterReadError>;
40
48
  /** Read one resource, flattened to dot-notation key → string value. Returns {} if the resource does not exist. */
41
- readResource(locale: string, resource: ResourceRef): Effect.Effect<Record<string, string>, AdapterReadError>;
49
+ readResource(
50
+ locale: string,
51
+ resource: ResourceRef,
52
+ ): Effect.Effect<Record<string, string>, AdapterReadError>;
42
53
  /** Write a full flattened key→value map back to a resource, unflattening as needed. Creates the resource if absent and `create` capability allows it. */
43
- writeResource(locale: string, resource: ResourceRef, entries: Record<string, string>): Effect.Effect<void, AdapterWriteError>;
54
+ writeResource(
55
+ locale: string,
56
+ resource: ResourceRef,
57
+ entries: Record<string, string>,
58
+ ): Effect.Effect<void, AdapterWriteError>;
44
59
  /**
45
60
  * Returns translation keys present in the resource but never referenced
46
61
  * anywhere in the project's source code. Only called by the CLI's `unused`
@@ -59,7 +74,10 @@ interface TranslationAdapter {
59
74
  * adapter's own heuristic needs — core never sees or validates those
60
75
  * options.
61
76
  */
62
- findUnusedKeys?(locale: string, resource: ResourceRef): Effect.Effect<readonly string[], AdapterReadError>;
77
+ findUnusedKeys?(
78
+ locale: string,
79
+ resource: ResourceRef,
80
+ ): Effect.Effect<readonly string[], AdapterReadError>;
63
81
  }
64
82
  interface AdapterCapabilities {
65
83
  readonly canCreateResource: boolean;
@@ -83,7 +101,7 @@ interface RetryConfig {
83
101
  interface DialektConfig {
84
102
  readonly sourceLocale: string;
85
103
  readonly targetLocales: readonly string[] | null;
86
- readonly strategy: 'one-shot' | 'tool-loop-agent';
104
+ readonly strategy: "one-shot" | "tool-loop-agent";
87
105
  readonly model: ModelConfig;
88
106
  readonly fastModel: ModelConfig;
89
107
  readonly chunking: ChunkingConfig;
@@ -95,16 +113,27 @@ interface DialektConfig {
95
113
  declare function defineConfig(config: DialektConfig): DialektConfig;
96
114
  //#endregion
97
115
  //#region src/keys/flatten.d.ts
98
- declare function flattenObject(input: Readonly<Record<string, unknown>>, prefix?: string): Record<string, string>;
116
+ declare function flattenObject(
117
+ input: Readonly<Record<string, unknown>>,
118
+ prefix?: string,
119
+ ): Record<string, string>;
99
120
  declare function unflattenObject(input: Readonly<Record<string, string>>): Record<string, unknown>;
100
- declare function diffKeys(source: Readonly<Record<string, string>>, target: Readonly<Record<string, string>>): string[];
121
+ declare function diffKeys(
122
+ source: Readonly<Record<string, string>>,
123
+ target: Readonly<Record<string, string>>,
124
+ ): string[];
101
125
  //#endregion
102
126
  //#region src/translation/chunking.d.ts
103
127
  interface ChunkingConfig$1 {
104
128
  readonly maxTokens: number;
105
129
  readonly charsPerToken: number;
106
130
  }
107
- declare function chunkKeys(keys: readonly string[], sourceMap: Readonly<Record<string, string>>, targetMap: Readonly<Record<string, string>>, config: ChunkingConfig$1): string[][];
131
+ declare function chunkKeys(
132
+ keys: readonly string[],
133
+ sourceMap: Readonly<Record<string, string>>,
134
+ targetMap: Readonly<Record<string, string>>,
135
+ config: ChunkingConfig$1,
136
+ ): string[][];
108
137
  //#endregion
109
138
  //#region src/sdk/node-layer.d.ts
110
139
  /**
@@ -116,21 +145,44 @@ declare function chunkKeys(keys: readonly string[], sourceMap: Readonly<Record<s
116
145
  declare const NodePlatformLayer: Layer.Layer<NodeContext.NodeContext, never, never>;
117
146
  //#endregion
118
147
  //#region src/sdk/file-io.d.ts
119
- declare function readFileIfExists(path: string): Effect.Effect<string | null, import("@effect/platform/Error").PlatformError, FileSystem.FileSystem>;
120
- declare function writeFileEnsuringDir(path: string, content: string): Effect.Effect<void, import("@effect/platform/Error").PlatformError, FileSystem.FileSystem | Path.Path>;
148
+ declare function readFileIfExists(
149
+ path: string,
150
+ ): Effect.Effect<
151
+ string | null,
152
+ import("@effect/platform/Error").PlatformError,
153
+ FileSystem.FileSystem
154
+ >;
155
+ declare function writeFileEnsuringDir(
156
+ path: string,
157
+ content: string,
158
+ ): Effect.Effect<
159
+ void,
160
+ import("@effect/platform/Error").PlatformError,
161
+ FileSystem.FileSystem | Path.Path
162
+ >;
121
163
  //#endregion
122
164
  //#region src/sdk/php-array-reader.d.ts
123
- declare const PhpExecutionError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
165
+ declare const PhpExecutionError_base: new <A extends Record<string, any> = {}>(
166
+ args: import("effect/Types").VoidIfEmpty<{
167
+ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P];
168
+ }>,
169
+ ) => import("effect/Cause").YieldableError & {
124
170
  readonly _tag: "PhpExecutionError";
125
171
  } & Readonly<A>;
126
172
  declare class PhpExecutionError extends PhpExecutionError_base<{
127
173
  readonly path: string;
128
174
  readonly cause: unknown;
129
175
  }> {}
130
- declare function readPhpArrayAsJson(absolutePath: string): Effect.Effect<Record<string, unknown>, PhpExecutionError, CommandExecutor>;
176
+ declare function readPhpArrayAsJson(
177
+ absolutePath: string,
178
+ ): Effect.Effect<Record<string, unknown>, PhpExecutionError, CommandExecutor>;
131
179
  //#endregion
132
180
  //#region src/translation/model-registry.d.ts
133
- declare const UnknownProviderError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
181
+ declare const UnknownProviderError_base: new <A extends Record<string, any> = {}>(
182
+ args: import("effect/Types").VoidIfEmpty<{
183
+ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P];
184
+ }>,
185
+ ) => import("effect/Cause").YieldableError & {
134
186
  readonly _tag: "UnknownProviderError";
135
187
  } & Readonly<A>;
136
188
  declare class UnknownProviderError extends UnknownProviderError_base<{
@@ -143,7 +195,9 @@ interface ModelConfig$1 {
143
195
  /**
144
196
  * The one file in the entire codebase allowed to import AI SDK provider packages.
145
197
  */
146
- declare function resolveModel(config: ModelConfig$1): Effect.Effect<LanguageModel, UnknownProviderError>;
198
+ declare function resolveModel(
199
+ config: ModelConfig$1,
200
+ ): Effect.Effect<LanguageModel, UnknownProviderError>;
147
201
  //#endregion
148
202
  //#region src/translation/types.d.ts
149
203
  interface TranslationContext {
@@ -153,7 +207,11 @@ interface TranslationContext {
153
207
  readonly targetMap: Record<string, string>;
154
208
  readonly keys: readonly string[];
155
209
  }
156
- declare const TranslationFailedError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
210
+ declare const TranslationFailedError_base: new <A extends Record<string, any> = {}>(
211
+ args: import("effect/Types").VoidIfEmpty<{
212
+ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P];
213
+ }>,
214
+ ) => import("effect/Cause").YieldableError & {
157
215
  readonly _tag: "TranslationFailedError";
158
216
  } & Readonly<A>;
159
217
  declare class TranslationFailedError extends TranslationFailedError_base<{
@@ -161,8 +219,10 @@ declare class TranslationFailedError extends TranslationFailedError_base<{
161
219
  readonly cause: unknown;
162
220
  }> {}
163
221
  interface TranslationStrategy {
164
- readonly name: 'one-shot' | 'tool-loop-agent';
165
- translateChunk(ctx: TranslationContext): Effect.Effect<Record<string, string>, TranslationFailedError>;
222
+ readonly name: "one-shot" | "tool-loop-agent";
223
+ translateChunk(
224
+ ctx: TranslationContext,
225
+ ): Effect.Effect<Record<string, string>, TranslationFailedError>;
166
226
  }
167
227
  //#endregion
168
228
  //#region src/translation/one-shot-strategy.d.ts
@@ -191,7 +251,9 @@ interface TranslationRunConfig {
191
251
  readonly targetLocales: readonly string[];
192
252
  readonly chunking: ChunkingConfig;
193
253
  }
194
- declare function runTranslation(config: TranslationRunConfig): Effect.Effect<undefined, AdapterReadError | AdapterWriteError | TranslationFailedError, never>;
254
+ declare function runTranslation(
255
+ config: TranslationRunConfig,
256
+ ): Effect.Effect<undefined, AdapterReadError | AdapterWriteError | TranslationFailedError, never>;
195
257
  //#endregion
196
258
  //#region src/translation/prompt.d.ts
197
259
  declare function buildSystemPrompt(from: string, to: string): string;
@@ -204,10 +266,18 @@ interface MissingKeyEntry$1 {
204
266
  readonly resource: ResourceRef;
205
267
  readonly missing: readonly string[];
206
268
  }
207
- declare function computeMissingKeys(adapter: TranslationAdapter, sourceLocale: string, targetLocales: readonly string[]): Effect.Effect<readonly MissingKeyEntry$1[], AdapterReadError>;
269
+ declare function computeMissingKeys(
270
+ adapter: TranslationAdapter,
271
+ sourceLocale: string,
272
+ targetLocales: readonly string[],
273
+ ): Effect.Effect<readonly MissingKeyEntry$1[], AdapterReadError>;
208
274
  //#endregion
209
275
  //#region src/config/load-config.d.ts
210
- declare const ConfigLoadError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
276
+ declare const ConfigLoadError_base: new <A extends Record<string, any> = {}>(
277
+ args: import("effect/Types").VoidIfEmpty<{
278
+ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P];
279
+ }>,
280
+ ) => import("effect/Cause").YieldableError & {
211
281
  readonly _tag: "ConfigLoadError";
212
282
  } & Readonly<A>;
213
283
  declare class ConfigLoadError extends ConfigLoadError_base<{
@@ -228,7 +298,7 @@ declare function loadConfig(configPath: string): Effect.Effect<DialektConfig, Co
228
298
  * All decoration is gated behind `isTTY` so the output is never mojibake-prone
229
299
  * when piped or consumed by another process.
230
300
  */
231
- type OutputFormat = 'pretty' | 'json';
301
+ type OutputFormat = "pretty" | "json";
232
302
  /**
233
303
  * Resolves the output format from explicit flag and environment.
234
304
  * Precedence: explicit `--format` > auto-detection.
@@ -258,7 +328,10 @@ interface Glyphs {
258
328
  warn: string;
259
329
  }
260
330
  declare function glyphs(): Glyphs;
261
- declare function drawTable(headers: readonly string[], rows: readonly (readonly string[])[]): string;
331
+ declare function drawTable(
332
+ headers: readonly string[],
333
+ rows: readonly (readonly string[])[],
334
+ ): string;
262
335
  declare function banner(title: string): string;
263
336
  declare function sectionHeader(label: string): string;
264
337
  declare function success(text: string): string;
@@ -274,7 +347,10 @@ interface MissingKeyEntry {
274
347
  readonly resource: string;
275
348
  readonly key: string;
276
349
  }
277
- declare function formatMissingKeys(entries: readonly MissingKeyEntry[], format: OutputFormat): string;
350
+ declare function formatMissingKeys(
351
+ entries: readonly MissingKeyEntry[],
352
+ format: OutputFormat,
353
+ ): string;
278
354
  interface UnusedKeyEntry {
279
355
  readonly adapter: string;
280
356
  readonly locale: string;
@@ -326,4 +402,65 @@ interface BenchmarkEntry {
326
402
  declare function formatBenchmark(entries: readonly BenchmarkEntry[], format: OutputFormat): string;
327
403
  declare function formatError(message: string, format: OutputFormat): string;
328
404
  //#endregion
329
- export { type AdapterCapabilities, AdapterReadError, AdapterWriteError, type AddResult, type BenchmarkEntry, type ChunkingConfig, ConfigLoadError, type DialektConfig, type LanguageEntry, type MissingKeyEntry, type ModelConfig, NodePlatformLayer, type OutputFormat, PhpExecutionError, type ResourceRef, type RetryConfig, type TranslateResult, type TranslationAdapter, type TranslationContext, TranslationFailedError, type TranslationStrategy, UnknownProviderError, type UnusedKeyEntry, type ValidateEntry, type ValidateResult, banner, buildSystemPrompt, buildUserPrompt, chunkKeys, color, computeMissingKeys, createOneShotStrategy, createToolLoopStrategy, defineConfig, detectFormat, diffKeys, drawTable, failure, flattenObject, formatAdd, formatBenchmark, formatError, formatLanguages, formatMissingKeys, formatTranslate, formatUnusedKeys, formatValidate, glyphs, info, keyValue, loadConfig, readFileIfExists, readPhpArrayAsJson, resolveModel, runTranslation, sectionHeader, success, unflattenObject, warning, writeFileEnsuringDir };
405
+ export {
406
+ type AdapterCapabilities,
407
+ AdapterReadError,
408
+ AdapterWriteError,
409
+ type AddResult,
410
+ type BenchmarkEntry,
411
+ type ChunkingConfig,
412
+ ConfigLoadError,
413
+ type DialektConfig,
414
+ type LanguageEntry,
415
+ type MissingKeyEntry,
416
+ type ModelConfig,
417
+ NodePlatformLayer,
418
+ type OutputFormat,
419
+ PhpExecutionError,
420
+ type ResourceRef,
421
+ type RetryConfig,
422
+ type TranslateResult,
423
+ type TranslationAdapter,
424
+ type TranslationContext,
425
+ TranslationFailedError,
426
+ type TranslationStrategy,
427
+ UnknownProviderError,
428
+ type UnusedKeyEntry,
429
+ type ValidateEntry,
430
+ type ValidateResult,
431
+ banner,
432
+ buildSystemPrompt,
433
+ buildUserPrompt,
434
+ chunkKeys,
435
+ color,
436
+ computeMissingKeys,
437
+ createOneShotStrategy,
438
+ createToolLoopStrategy,
439
+ defineConfig,
440
+ detectFormat,
441
+ diffKeys,
442
+ drawTable,
443
+ failure,
444
+ flattenObject,
445
+ formatAdd,
446
+ formatBenchmark,
447
+ formatError,
448
+ formatLanguages,
449
+ formatMissingKeys,
450
+ formatTranslate,
451
+ formatUnusedKeys,
452
+ formatValidate,
453
+ glyphs,
454
+ info,
455
+ keyValue,
456
+ loadConfig,
457
+ readFileIfExists,
458
+ readPhpArrayAsJson,
459
+ resolveModel,
460
+ runTranslation,
461
+ sectionHeader,
462
+ success,
463
+ unflattenObject,
464
+ warning,
465
+ writeFileEnsuringDir,
466
+ };
package/dist/index.mjs CHANGED
@@ -1,10 +1,45 @@
1
- import { A as resolveModel, C as runTranslation, D as buildUserPrompt, E as buildSystemPrompt, M as diffKeys, N as flattenObject, O as TranslationFailedError, P as unflattenObject, S as computeMissingKeys, T as createOneShotStrategy, _ as sectionHeader, a as formatMissingKeys, b as ConfigLoadError, c as formatValidate, d as detectFormat, f as drawTable, g as keyValue, h as info, i as formatLanguages, j as chunkKeys, k as UnknownProviderError, l as banner, m as glyphs, n as formatBenchmark, o as formatTranslate, p as failure, r as formatError, s as formatUnusedKeys, t as formatAdd, u as color, v as success, w as createToolLoopStrategy, x as loadConfig, y as warning } from "./formatters-De4Q-X1d.mjs";
1
+ import {
2
+ A as resolveModel,
3
+ C as runTranslation,
4
+ D as buildUserPrompt,
5
+ E as buildSystemPrompt,
6
+ M as diffKeys,
7
+ N as flattenObject,
8
+ O as TranslationFailedError,
9
+ P as unflattenObject,
10
+ S as computeMissingKeys,
11
+ T as createOneShotStrategy,
12
+ _ as sectionHeader,
13
+ a as formatMissingKeys,
14
+ b as ConfigLoadError,
15
+ c as formatValidate,
16
+ d as detectFormat,
17
+ f as drawTable,
18
+ g as keyValue,
19
+ h as info,
20
+ i as formatLanguages,
21
+ j as chunkKeys,
22
+ k as UnknownProviderError,
23
+ l as banner,
24
+ m as glyphs,
25
+ n as formatBenchmark,
26
+ o as formatTranslate,
27
+ p as failure,
28
+ r as formatError,
29
+ s as formatUnusedKeys,
30
+ t as formatAdd,
31
+ u as color,
32
+ v as success,
33
+ w as createToolLoopStrategy,
34
+ x as loadConfig,
35
+ y as warning,
36
+ } from "./formatters-De4Q-X1d.mjs";
2
37
  import { Data, Effect } from "effect";
3
38
  import { NodeContext } from "@effect/platform-node";
4
39
  import { Command, FileSystem, Path } from "@effect/platform";
5
40
  //#region src/config/define-config.ts
6
41
  function defineConfig(config) {
7
- return config;
42
+ return config;
8
43
  }
9
44
  //#endregion
10
45
  //#region src/adapter/types.ts
@@ -13,48 +48,98 @@ var AdapterWriteError = class extends Data.TaggedError("AdapterWriteError") {};
13
48
  //#endregion
14
49
  //#region src/sdk/node-layer.ts
15
50
  /**
16
- * The only file in this package (besides cli/main.ts) permitted to know
17
- * this is running on Node.js. Provides FileSystem, Path, and
18
- * CommandExecutor. Swapping to Bun/Deno later means swapping this one
19
- * import for @effect/platform-bun's equivalent — nothing else changes.
20
- */
51
+ * The only file in this package (besides cli/main.ts) permitted to know
52
+ * this is running on Node.js. Provides FileSystem, Path, and
53
+ * CommandExecutor. Swapping to Bun/Deno later means swapping this one
54
+ * import for @effect/platform-bun's equivalent — nothing else changes.
55
+ */
21
56
  const NodePlatformLayer = NodeContext.layer;
22
57
  //#endregion
23
58
  //#region src/sdk/file-io.ts
24
59
  function readFileIfExists(path) {
25
- return Effect.gen(function* () {
26
- const fs = yield* FileSystem.FileSystem;
27
- if (!(yield* fs.exists(path))) return null;
28
- return yield* fs.readFileString(path);
29
- });
60
+ return Effect.gen(function* () {
61
+ const fs = yield* FileSystem.FileSystem;
62
+ if (!(yield* fs.exists(path))) return null;
63
+ return yield* fs.readFileString(path);
64
+ });
30
65
  }
31
66
  function writeFileEnsuringDir(path, content) {
32
- return Effect.gen(function* () {
33
- const fs = yield* FileSystem.FileSystem;
34
- const dir = (yield* Path.Path).dirname(path);
35
- yield* fs.makeDirectory(dir, { recursive: true });
36
- yield* fs.writeFileString(path, content);
37
- });
67
+ return Effect.gen(function* () {
68
+ const fs = yield* FileSystem.FileSystem;
69
+ const dir = (yield* Path.Path).dirname(path);
70
+ yield* fs.makeDirectory(dir, { recursive: true });
71
+ yield* fs.writeFileString(path, content);
72
+ });
38
73
  }
39
74
  //#endregion
40
75
  //#region src/sdk/php-array-reader.ts
41
76
  var PhpExecutionError = class extends Data.TaggedError("PhpExecutionError") {};
42
- const DUMP_SCRIPT = "echo json_encode(is_array($v = require $argv[1]) ? $v : [], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);";
77
+ const DUMP_SCRIPT =
78
+ "echo json_encode(is_array($v = require $argv[1]) ? $v : [], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);";
43
79
  function readPhpArrayAsJson(absolutePath) {
44
- return Effect.gen(function* () {
45
- const cmd = Command.make("php", "-r", DUMP_SCRIPT, "--", absolutePath);
46
- const output = yield* Command.string(cmd).pipe(Effect.mapError((cause) => new PhpExecutionError({
47
- path: absolutePath,
48
- cause
49
- })));
50
- return yield* Effect.try({
51
- try: () => JSON.parse(output),
52
- catch: (cause) => new PhpExecutionError({
53
- path: absolutePath,
54
- cause
55
- })
56
- });
57
- });
80
+ return Effect.gen(function* () {
81
+ const cmd = Command.make("php", "-r", DUMP_SCRIPT, "--", absolutePath);
82
+ const output = yield* Command.string(cmd).pipe(
83
+ Effect.mapError(
84
+ (cause) =>
85
+ new PhpExecutionError({
86
+ path: absolutePath,
87
+ cause,
88
+ }),
89
+ ),
90
+ );
91
+ return yield* Effect.try({
92
+ try: () => JSON.parse(output),
93
+ catch: (cause) =>
94
+ new PhpExecutionError({
95
+ path: absolutePath,
96
+ cause,
97
+ }),
98
+ });
99
+ });
58
100
  }
59
101
  //#endregion
60
- export { AdapterReadError, AdapterWriteError, ConfigLoadError, NodePlatformLayer, PhpExecutionError, TranslationFailedError, UnknownProviderError, banner, buildSystemPrompt, buildUserPrompt, chunkKeys, color, computeMissingKeys, createOneShotStrategy, createToolLoopStrategy, defineConfig, detectFormat, diffKeys, drawTable, failure, flattenObject, formatAdd, formatBenchmark, formatError, formatLanguages, formatMissingKeys, formatTranslate, formatUnusedKeys, formatValidate, glyphs, info, keyValue, loadConfig, readFileIfExists, readPhpArrayAsJson, resolveModel, runTranslation, sectionHeader, success, unflattenObject, warning, writeFileEnsuringDir };
102
+ export {
103
+ AdapterReadError,
104
+ AdapterWriteError,
105
+ ConfigLoadError,
106
+ NodePlatformLayer,
107
+ PhpExecutionError,
108
+ TranslationFailedError,
109
+ UnknownProviderError,
110
+ banner,
111
+ buildSystemPrompt,
112
+ buildUserPrompt,
113
+ chunkKeys,
114
+ color,
115
+ computeMissingKeys,
116
+ createOneShotStrategy,
117
+ createToolLoopStrategy,
118
+ defineConfig,
119
+ detectFormat,
120
+ diffKeys,
121
+ drawTable,
122
+ failure,
123
+ flattenObject,
124
+ formatAdd,
125
+ formatBenchmark,
126
+ formatError,
127
+ formatLanguages,
128
+ formatMissingKeys,
129
+ formatTranslate,
130
+ formatUnusedKeys,
131
+ formatValidate,
132
+ glyphs,
133
+ info,
134
+ keyValue,
135
+ loadConfig,
136
+ readFileIfExists,
137
+ readPhpArrayAsJson,
138
+ resolveModel,
139
+ runTranslation,
140
+ sectionHeader,
141
+ success,
142
+ unflattenObject,
143
+ warning,
144
+ writeFileEnsuringDir,
145
+ };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "dialekt",
3
- "version": "0.1.0",
4
- "type": "module",
3
+ "version": "0.1.1",
5
4
  "bin": {
6
5
  "dialekt": "./dist/cli/main.mjs"
7
6
  },
7
+ "type": "module",
8
8
  "exports": {
9
9
  ".": {
10
10
  "types": "./dist/index.d.mts",
@@ -15,11 +15,11 @@
15
15
  "@ai-sdk/anthropic": "^4.0.4",
16
16
  "@ai-sdk/google": "^4.0.3",
17
17
  "@ai-sdk/openai": "^4.0.4",
18
- "dialekt": "link:",
19
18
  "@effect/cli": "^0.75.0",
20
19
  "@effect/platform": "^0.96.0",
21
20
  "@effect/platform-node": "^0.107.0",
22
21
  "ai": "^7.0.0",
22
+ "dialekt": "link:",
23
23
  "effect": "^3.21.0",
24
24
  "jiti": "^2.7.0",
25
25
  "zod": "^3.24.0"
@@ -1,7 +1,7 @@
1
1
  allowBuilds:
2
- '@parcel/watcher': true
2
+ "@parcel/watcher": true
3
3
  msgpackr-extract: true
4
4
  minimumReleaseAgeExclude:
5
- - '@ai-sdk/anthropic@4.0.4'
5
+ - "@ai-sdk/anthropic@4.0.4"
6
6
  overrides:
7
- 'dialekt': 'link:'
7
+ "dialekt": "link:"