#
tokens: 49897/50000 47/626 files (page 4/16)
lines: off (toggle) GitHub
raw markdown copy
This is page 4 of 16. Use http://codebase.md/lingodotdev/lingo.dev?lines=false&page={x} to view the full context.

# Directory Structure

```
├── .changeset
│   ├── config.json
│   └── README.md
├── .claude
│   ├── agents
│   │   └── code-architect-reviewer.md
│   └── commands
│       ├── analyze-bucket-type.md
│       └── create-bucket-docs.md
├── .editorconfig
├── .github
│   ├── dependabot.yml
│   └── workflows
│       ├── docker.yml
│       ├── lingodotdev.yml
│       ├── pr-check.yml
│       ├── pr-lint.yml
│       └── release.yml
├── .gitignore
├── .husky
│   └── commit-msg
├── .npmrc
├── .prettierignore
├── .prettierrc
├── .vscode
│   ├── extensions.json
│   ├── launch.json
│   └── settings.json
├── action.yml
├── CLAUDE.md
├── CODE_OF_CONDUCT.md
├── commitlint.config.js
├── composer.json
├── content
│   ├── banner.compiler.png
│   ├── banner.dark.png
│   └── banner.launch.png
├── CONTRIBUTING.md
├── DEBUGGING.md
├── demo
│   ├── adonisjs
│   │   ├── .editorconfig
│   │   ├── .env.example
│   │   ├── .gitignore
│   │   ├── ace.js
│   │   ├── adonisrc.ts
│   │   ├── app
│   │   │   ├── exceptions
│   │   │   │   └── handler.ts
│   │   │   └── middleware
│   │   │       └── container_bindings_middleware.ts
│   │   ├── bin
│   │   │   ├── console.ts
│   │   │   ├── server.ts
│   │   │   └── test.ts
│   │   ├── CHANGELOG.md
│   │   ├── config
│   │   │   ├── app.ts
│   │   │   ├── bodyparser.ts
│   │   │   ├── cors.ts
│   │   │   ├── hash.ts
│   │   │   ├── inertia.ts
│   │   │   ├── logger.ts
│   │   │   ├── session.ts
│   │   │   ├── shield.ts
│   │   │   ├── static.ts
│   │   │   └── vite.ts
│   │   ├── eslint.config.js
│   │   ├── inertia
│   │   │   ├── app
│   │   │   │   ├── app.tsx
│   │   │   │   └── ssr.tsx
│   │   │   ├── css
│   │   │   │   └── app.css
│   │   │   ├── lingo
│   │   │   │   ├── dictionary.js
│   │   │   │   └── meta.json
│   │   │   ├── pages
│   │   │   │   ├── errors
│   │   │   │   │   ├── not_found.tsx
│   │   │   │   │   └── server_error.tsx
│   │   │   │   └── home.tsx
│   │   │   └── tsconfig.json
│   │   ├── package.json
│   │   ├── README.md
│   │   ├── resources
│   │   │   └── views
│   │   │       └── inertia_layout.edge
│   │   ├── start
│   │   │   ├── env.ts
│   │   │   ├── kernel.ts
│   │   │   └── routes.ts
│   │   ├── tests
│   │   │   └── bootstrap.ts
│   │   ├── tsconfig.json
│   │   └── vite.config.ts
│   ├── next-app
│   │   ├── .gitignore
│   │   ├── CHANGELOG.md
│   │   ├── eslint.config.mjs
│   │   ├── next.config.ts
│   │   ├── package.json
│   │   ├── postcss.config.mjs
│   │   ├── public
│   │   │   ├── file.svg
│   │   │   ├── globe.svg
│   │   │   ├── next.svg
│   │   │   ├── vercel.svg
│   │   │   └── window.svg
│   │   ├── README.md
│   │   ├── src
│   │   │   ├── app
│   │   │   │   ├── client-component.tsx
│   │   │   │   ├── favicon.ico
│   │   │   │   ├── globals.css
│   │   │   │   ├── layout.tsx
│   │   │   │   ├── lingo-dot-dev.tsx
│   │   │   │   ├── page.tsx
│   │   │   │   └── test
│   │   │   │       └── page.tsx
│   │   │   ├── components
│   │   │   │   ├── hero-actions.tsx
│   │   │   │   ├── hero-subtitle.tsx
│   │   │   │   ├── hero-title.tsx
│   │   │   │   └── index.ts
│   │   │   └── lingo
│   │   │       ├── dictionary.js
│   │   │       └── meta.json
│   │   └── tsconfig.json
│   ├── react-router-app
│   │   ├── .dockerignore
│   │   ├── .gitignore
│   │   ├── app
│   │   │   ├── app.css
│   │   │   ├── lingo
│   │   │   │   ├── dictionary.js
│   │   │   │   └── meta.json
│   │   │   ├── root.tsx
│   │   │   ├── routes
│   │   │   │   ├── home.tsx
│   │   │   │   └── test.tsx
│   │   │   ├── routes.ts
│   │   │   └── welcome
│   │   │       ├── lingo-dot-dev.tsx
│   │   │       ├── logo-dark.svg
│   │   │       ├── logo-light.svg
│   │   │       └── welcome.tsx
│   │   ├── Dockerfile
│   │   ├── package.json
│   │   ├── public
│   │   │   └── favicon.ico
│   │   ├── react-router.config.ts
│   │   ├── README.md
│   │   ├── tsconfig.json
│   │   └── vite.config.ts
│   └── vite-project
│       ├── .gitignore
│       ├── CHANGELOG.md
│       ├── eslint.config.js
│       ├── index.html
│       ├── package.json
│       ├── public
│       │   └── vite.svg
│       ├── README.md
│       ├── src
│       │   ├── App.css
│       │   ├── App.tsx
│       │   ├── assets
│       │   │   └── react.svg
│       │   ├── components
│       │   │   └── test.tsx
│       │   ├── index.css
│       │   ├── lingo
│       │   │   ├── dictionary.js
│       │   │   └── meta.json
│       │   ├── lingo-dot-dev.tsx
│       │   ├── main.tsx
│       │   └── vite-env.d.ts
│       ├── tsconfig.app.json
│       ├── tsconfig.json
│       ├── tsconfig.node.json
│       └── vite.config.ts
├── Dockerfile
├── i18n.json
├── i18n.lock
├── integrations
│   └── directus
│       ├── .gitignore
│       ├── CHANGELOG.md
│       ├── docker-compose.yml
│       ├── Dockerfile
│       ├── package.json
│       ├── README.md
│       ├── src
│       │   ├── api.ts
│       │   ├── app.ts
│       │   └── index.spec.ts
│       ├── tsconfig.json
│       ├── tsconfig.test.json
│       └── tsup.config.ts
├── ISSUE_TEMPLATE.md
├── legacy
│   ├── cli
│   │   ├── bin
│   │   │   └── cli.mjs
│   │   ├── CHANGELOG.md
│   │   ├── package.json
│   │   └── readme.md
│   └── sdk
│       ├── CHANGELOG.md
│       ├── index.d.ts
│       ├── index.js
│       ├── package.json
│       └── README.md
├── LICENSE.md
├── mcp.md
├── package.json
├── packages
│   ├── cli
│   │   ├── assets
│   │   │   ├── failure.mp3
│   │   │   └── success.mp3
│   │   ├── bin
│   │   │   └── cli.mjs
│   │   ├── CHANGELOG.md
│   │   ├── demo
│   │   │   ├── android
│   │   │   │   ├── en
│   │   │   │   │   └── example.xml
│   │   │   │   ├── es
│   │   │   │   │   └── example.xml
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── csv
│   │   │   │   ├── example.csv
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── demo.spec.ts
│   │   │   ├── ejs
│   │   │   │   ├── en
│   │   │   │   │   └── example.ejs
│   │   │   │   ├── es
│   │   │   │   │   └── example.ejs
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── flutter
│   │   │   │   ├── en
│   │   │   │   │   └── example.arb
│   │   │   │   ├── es
│   │   │   │   │   └── example.arb
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── html
│   │   │   │   ├── en
│   │   │   │   │   └── example.html
│   │   │   │   ├── es
│   │   │   │   │   └── example.html
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── json
│   │   │   │   ├── en
│   │   │   │   │   └── example.json
│   │   │   │   ├── es
│   │   │   │   │   └── example.json
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── json-dictionary
│   │   │   │   ├── example.json
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── json5
│   │   │   │   ├── en
│   │   │   │   │   └── example.json5
│   │   │   │   ├── es
│   │   │   │   │   └── example.json5
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── jsonc
│   │   │   │   ├── en
│   │   │   │   │   └── example.jsonc
│   │   │   │   ├── es
│   │   │   │   │   └── example.jsonc
│   │   │   │   ├── i18n.json
│   │   │   │   ├── i18n.lock
│   │   │   │   └── ru
│   │   │   │       └── example.jsonc
│   │   │   ├── markdoc
│   │   │   │   ├── en
│   │   │   │   │   └── example.markdoc
│   │   │   │   ├── es
│   │   │   │   │   └── example.markdoc
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── markdown
│   │   │   │   ├── en
│   │   │   │   │   └── example.md
│   │   │   │   ├── es
│   │   │   │   │   └── example.md
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── mdx
│   │   │   │   ├── en
│   │   │   │   │   └── example.mdx
│   │   │   │   ├── es
│   │   │   │   │   └── example.mdx
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── php
│   │   │   │   ├── en
│   │   │   │   │   └── example.php
│   │   │   │   ├── es
│   │   │   │   │   └── example.php
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── po
│   │   │   │   ├── en
│   │   │   │   │   └── example.po
│   │   │   │   ├── es
│   │   │   │   │   └── example.po
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── properties
│   │   │   │   ├── en
│   │   │   │   │   └── example.properties
│   │   │   │   ├── es
│   │   │   │   │   └── example.properties
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── run_i18n.sh
│   │   │   ├── srt
│   │   │   │   ├── en
│   │   │   │   │   └── example.srt
│   │   │   │   ├── es
│   │   │   │   │   └── example.srt
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── txt
│   │   │   │   ├── en
│   │   │   │   │   └── example.txt
│   │   │   │   ├── es
│   │   │   │   │   └── example.txt
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── typescript
│   │   │   │   ├── en
│   │   │   │   │   └── example.ts
│   │   │   │   ├── es
│   │   │   │   │   └── example.ts
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── vtt
│   │   │   │   ├── en
│   │   │   │   │   └── example.vtt
│   │   │   │   ├── es
│   │   │   │   │   └── example.vtt
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── vue-json
│   │   │   │   ├── example.vue
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── xcode-strings
│   │   │   │   ├── en
│   │   │   │   │   └── example.strings
│   │   │   │   ├── es
│   │   │   │   │   └── example.strings
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── xcode-stringsdict
│   │   │   │   ├── en
│   │   │   │   │   └── example.stringsdict
│   │   │   │   ├── es
│   │   │   │   │   └── example.stringsdict
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── xcode-xcstrings
│   │   │   │   ├── example.xcstrings
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── xcode-xcstrings-v2
│   │   │   │   ├── complex-example.xcstrings
│   │   │   │   ├── example.xcstrings
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── xliff
│   │   │   │   ├── en
│   │   │   │   │   ├── example-v1.2.xliff
│   │   │   │   │   └── example-v2.xliff
│   │   │   │   ├── es
│   │   │   │   │   ├── example-v1.2.xliff
│   │   │   │   │   ├── example-v2.xliff
│   │   │   │   │   └── example.xliff
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── xml
│   │   │   │   ├── en
│   │   │   │   │   └── example.xml
│   │   │   │   ├── es
│   │   │   │   │   └── example.xml
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   ├── yaml
│   │   │   │   ├── en
│   │   │   │   │   └── example.yml
│   │   │   │   ├── es
│   │   │   │   │   └── example.yml
│   │   │   │   ├── i18n.json
│   │   │   │   └── i18n.lock
│   │   │   └── yaml-root-key
│   │   │       ├── en
│   │   │       │   └── example.yml
│   │   │       ├── es
│   │   │       │   └── example.yml
│   │   │       ├── i18n.json
│   │   │       └── i18n.lock
│   │   ├── i18n.json
│   │   ├── i18n.lock
│   │   ├── package.json
│   │   ├── README.md
│   │   ├── src
│   │   │   ├── cli
│   │   │   │   ├── cmd
│   │   │   │   │   ├── auth.ts
│   │   │   │   │   ├── ci
│   │   │   │   │   │   ├── flows
│   │   │   │   │   │   │   ├── _base.ts
│   │   │   │   │   │   │   ├── in-branch.ts
│   │   │   │   │   │   │   └── pull-request.ts
│   │   │   │   │   │   ├── index.ts
│   │   │   │   │   │   └── platforms
│   │   │   │   │   │       ├── _base.ts
│   │   │   │   │   │       ├── bitbucket.ts
│   │   │   │   │   │       ├── github.ts
│   │   │   │   │   │       ├── gitlab.ts
│   │   │   │   │   │       └── index.ts
│   │   │   │   │   ├── cleanup.ts
│   │   │   │   │   ├── config
│   │   │   │   │   │   ├── get.ts
│   │   │   │   │   │   ├── index.ts
│   │   │   │   │   │   ├── set.ts
│   │   │   │   │   │   └── unset.ts
│   │   │   │   │   ├── i18n.ts
│   │   │   │   │   ├── init.ts
│   │   │   │   │   ├── lockfile.ts
│   │   │   │   │   ├── login.ts
│   │   │   │   │   ├── logout.ts
│   │   │   │   │   ├── may-the-fourth.ts
│   │   │   │   │   ├── mcp.ts
│   │   │   │   │   ├── purge.ts
│   │   │   │   │   ├── run
│   │   │   │   │   │   ├── _const.ts
│   │   │   │   │   │   ├── _types.ts
│   │   │   │   │   │   ├── _utils.ts
│   │   │   │   │   │   ├── execute.spec.ts
│   │   │   │   │   │   ├── execute.ts
│   │   │   │   │   │   ├── frozen.ts
│   │   │   │   │   │   ├── index.ts
│   │   │   │   │   │   ├── plan.ts
│   │   │   │   │   │   ├── setup.ts
│   │   │   │   │   │   └── watch.ts
│   │   │   │   │   ├── show
│   │   │   │   │   │   ├── _shared-key-command.ts
│   │   │   │   │   │   ├── config.ts
│   │   │   │   │   │   ├── files.ts
│   │   │   │   │   │   ├── ignored-keys.ts
│   │   │   │   │   │   ├── index.ts
│   │   │   │   │   │   ├── locale.ts
│   │   │   │   │   │   └── locked-keys.ts
│   │   │   │   │   └── status.ts
│   │   │   │   ├── constants.ts
│   │   │   │   ├── index.spec.ts
│   │   │   │   ├── index.ts
│   │   │   │   ├── loaders
│   │   │   │   │   ├── _types.ts
│   │   │   │   │   ├── _utils.ts
│   │   │   │   │   ├── android.spec.ts
│   │   │   │   │   ├── android.ts
│   │   │   │   │   ├── csv.spec.ts
│   │   │   │   │   ├── csv.ts
│   │   │   │   │   ├── dato
│   │   │   │   │   │   ├── _base.ts
│   │   │   │   │   │   ├── _utils.ts
│   │   │   │   │   │   ├── api.ts
│   │   │   │   │   │   ├── extract.ts
│   │   │   │   │   │   ├── filter.ts
│   │   │   │   │   │   └── index.ts
│   │   │   │   │   ├── ejs.spec.ts
│   │   │   │   │   ├── ejs.ts
│   │   │   │   │   ├── ensure-key-order.spec.ts
│   │   │   │   │   ├── ensure-key-order.ts
│   │   │   │   │   ├── flat.spec.ts
│   │   │   │   │   ├── flat.ts
│   │   │   │   │   ├── flutter.spec.ts
│   │   │   │   │   ├── flutter.ts
│   │   │   │   │   ├── formatters
│   │   │   │   │   │   ├── _base.ts
│   │   │   │   │   │   ├── biome.ts
│   │   │   │   │   │   ├── index.ts
│   │   │   │   │   │   └── prettier.ts
│   │   │   │   │   ├── html.ts
│   │   │   │   │   ├── icu-safety.spec.ts
│   │   │   │   │   ├── ignored-keys-buckets.spec.ts
│   │   │   │   │   ├── ignored-keys.spec.ts
│   │   │   │   │   ├── ignored-keys.ts
│   │   │   │   │   ├── index.spec.ts
│   │   │   │   │   ├── index.ts
│   │   │   │   │   ├── inject-locale.spec.ts
│   │   │   │   │   ├── inject-locale.ts
│   │   │   │   │   ├── json-dictionary.spec.ts
│   │   │   │   │   ├── json-dictionary.ts
│   │   │   │   │   ├── json-sorting.test.ts
│   │   │   │   │   ├── json-sorting.ts
│   │   │   │   │   ├── json.ts
│   │   │   │   │   ├── json5.spec.ts
│   │   │   │   │   ├── json5.ts
│   │   │   │   │   ├── jsonc.spec.ts
│   │   │   │   │   ├── jsonc.ts
│   │   │   │   │   ├── locked-keys.spec.ts
│   │   │   │   │   ├── locked-keys.ts
│   │   │   │   │   ├── locked-patterns.spec.ts
│   │   │   │   │   ├── locked-patterns.ts
│   │   │   │   │   ├── markdoc.spec.ts
│   │   │   │   │   ├── markdoc.ts
│   │   │   │   │   ├── markdown.ts
│   │   │   │   │   ├── mdx.spec.ts
│   │   │   │   │   ├── mdx.ts
│   │   │   │   │   ├── mdx2
│   │   │   │   │   │   ├── _types.ts
│   │   │   │   │   │   ├── _utils.ts
│   │   │   │   │   │   ├── code-placeholder.spec.ts
│   │   │   │   │   │   ├── code-placeholder.ts
│   │   │   │   │   │   ├── frontmatter-split.spec.ts
│   │   │   │   │   │   ├── frontmatter-split.ts
│   │   │   │   │   │   ├── localizable-document.spec.ts
│   │   │   │   │   │   ├── localizable-document.ts
│   │   │   │   │   │   ├── section-split.spec.ts
│   │   │   │   │   │   ├── section-split.ts
│   │   │   │   │   │   └── sections-split-2.ts
│   │   │   │   │   ├── passthrough.ts
│   │   │   │   │   ├── php.ts
│   │   │   │   │   ├── plutil-json-loader.ts
│   │   │   │   │   ├── po
│   │   │   │   │   │   ├── _types.ts
│   │   │   │   │   │   ├── index.spec.ts
│   │   │   │   │   │   └── index.ts
│   │   │   │   │   ├── properties.ts
│   │   │   │   │   ├── root-key.ts
│   │   │   │   │   ├── srt.ts
│   │   │   │   │   ├── sync.ts
│   │   │   │   │   ├── text-file.ts
│   │   │   │   │   ├── txt.ts
│   │   │   │   │   ├── typescript
│   │   │   │   │   │   ├── cjs-interop.ts
│   │   │   │   │   │   ├── index.spec.ts
│   │   │   │   │   │   └── index.ts
│   │   │   │   │   ├── unlocalizable.spec.ts
│   │   │   │   │   ├── unlocalizable.ts
│   │   │   │   │   ├── variable
│   │   │   │   │   │   ├── index.spec.ts
│   │   │   │   │   │   └── index.ts
│   │   │   │   │   ├── vtt.ts
│   │   │   │   │   ├── vue-json.ts
│   │   │   │   │   ├── xcode-strings
│   │   │   │   │   │   ├── escape.ts
│   │   │   │   │   │   ├── parser.ts
│   │   │   │   │   │   ├── tokenizer.ts
│   │   │   │   │   │   └── types.ts
│   │   │   │   │   ├── xcode-strings.spec.ts
│   │   │   │   │   ├── xcode-strings.ts
│   │   │   │   │   ├── xcode-stringsdict.ts
│   │   │   │   │   ├── xcode-xcstrings-icu.spec.ts
│   │   │   │   │   ├── xcode-xcstrings-icu.ts
│   │   │   │   │   ├── xcode-xcstrings-lock-compatibility.spec.ts
│   │   │   │   │   ├── xcode-xcstrings-v2-loader.ts
│   │   │   │   │   ├── xcode-xcstrings.spec.ts
│   │   │   │   │   ├── xcode-xcstrings.ts
│   │   │   │   │   ├── xliff.spec.ts
│   │   │   │   │   ├── xliff.ts
│   │   │   │   │   ├── xml.ts
│   │   │   │   │   └── yaml.ts
│   │   │   │   ├── localizer
│   │   │   │   │   ├── _types.ts
│   │   │   │   │   ├── explicit.ts
│   │   │   │   │   ├── index.ts
│   │   │   │   │   └── lingodotdev.ts
│   │   │   │   ├── processor
│   │   │   │   │   ├── _base.ts
│   │   │   │   │   ├── basic.ts
│   │   │   │   │   ├── index.ts
│   │   │   │   │   └── lingo.ts
│   │   │   │   └── utils
│   │   │   │       ├── auth.ts
│   │   │   │       ├── buckets.spec.ts
│   │   │   │       ├── buckets.ts
│   │   │   │       ├── cache.ts
│   │   │   │       ├── cloudflare-status.ts
│   │   │   │       ├── config.ts
│   │   │   │       ├── delta.spec.ts
│   │   │   │       ├── delta.ts
│   │   │   │       ├── ensure-patterns.ts
│   │   │   │       ├── errors.ts
│   │   │   │       ├── exec.spec.ts
│   │   │   │       ├── exec.ts
│   │   │   │       ├── exit-gracefully.spec.ts
│   │   │   │       ├── exit-gracefully.ts
│   │   │   │       ├── exp-backoff.ts
│   │   │   │       ├── find-locale-paths.spec.ts
│   │   │   │       ├── find-locale-paths.ts
│   │   │   │       ├── fs.ts
│   │   │   │       ├── init-ci-cd.ts
│   │   │   │       ├── key-matching.spec.ts
│   │   │   │       ├── key-matching.ts
│   │   │   │       ├── lockfile.ts
│   │   │   │       ├── md5.ts
│   │   │   │       ├── observability.ts
│   │   │   │       ├── plutil-formatter.spec.ts
│   │   │   │       ├── plutil-formatter.ts
│   │   │   │       ├── settings.ts
│   │   │   │       ├── ui.ts
│   │   │   │       └── update-gitignore.ts
│   │   │   ├── compiler
│   │   │   │   └── index.ts
│   │   │   ├── locale-codes
│   │   │   │   └── index.ts
│   │   │   ├── react
│   │   │   │   ├── client.ts
│   │   │   │   ├── index.ts
│   │   │   │   ├── react-router.ts
│   │   │   │   └── rsc.ts
│   │   │   ├── sdk
│   │   │   │   └── index.ts
│   │   │   └── spec
│   │   │       └── index.ts
│   │   ├── tests
│   │   │   └── mock-storage.ts
│   │   ├── troubleshooting.md
│   │   ├── tsconfig.json
│   │   ├── tsconfig.test.json
│   │   ├── tsup.config.ts
│   │   ├── types
│   │   │   ├── vtt.d.ts
│   │   │   └── xliff.d.ts
│   │   ├── vitest.config.ts
│   │   └── WATCH_MODE.md
│   ├── compiler
│   │   ├── CHANGELOG.md
│   │   ├── package.json
│   │   ├── README.md
│   │   ├── src
│   │   │   ├── _base.ts
│   │   │   ├── _const.ts
│   │   │   ├── _loader-utils.spec.ts
│   │   │   ├── _loader-utils.ts
│   │   │   ├── _utils.spec.ts
│   │   │   ├── _utils.ts
│   │   │   ├── client-dictionary-loader.ts
│   │   │   ├── i18n-directive.spec.ts
│   │   │   ├── i18n-directive.ts
│   │   │   ├── index.spec.ts
│   │   │   ├── index.ts
│   │   │   ├── jsx-attribute-flag.spec.ts
│   │   │   ├── jsx-attribute-flag.ts
│   │   │   ├── jsx-attribute-scope-inject.spec.ts
│   │   │   ├── jsx-attribute-scope-inject.ts
│   │   │   ├── jsx-attribute-scopes-export.spec.ts
│   │   │   ├── jsx-attribute-scopes-export.ts
│   │   │   ├── jsx-attribute.spec.ts
│   │   │   ├── jsx-attribute.ts
│   │   │   ├── jsx-fragment.spec.ts
│   │   │   ├── jsx-fragment.ts
│   │   │   ├── jsx-html-lang.spec.ts
│   │   │   ├── jsx-html-lang.ts
│   │   │   ├── jsx-provider.spec.ts
│   │   │   ├── jsx-provider.ts
│   │   │   ├── jsx-remove-attributes.spec.ts
│   │   │   ├── jsx-remove-attributes.ts
│   │   │   ├── jsx-root-flag.spec.ts
│   │   │   ├── jsx-root-flag.ts
│   │   │   ├── jsx-scope-flag.spec.ts
│   │   │   ├── jsx-scope-flag.ts
│   │   │   ├── jsx-scope-inject.spec.ts
│   │   │   ├── jsx-scope-inject.ts
│   │   │   ├── jsx-scopes-export.spec.ts
│   │   │   ├── jsx-scopes-export.ts
│   │   │   ├── lib
│   │   │   │   └── lcp
│   │   │   │       ├── api
│   │   │   │       │   ├── index.ts
│   │   │   │       │   ├── prompt.spec.ts
│   │   │   │       │   ├── prompt.ts
│   │   │   │       │   ├── provider-details.spec.ts
│   │   │   │       │   ├── provider-details.ts
│   │   │   │       │   ├── shots.ts
│   │   │   │       │   ├── xml2obj.spec.ts
│   │   │   │       │   └── xml2obj.ts
│   │   │   │       ├── api.spec.ts
│   │   │   │       ├── cache.spec.ts
│   │   │   │       ├── cache.ts
│   │   │   │       ├── index.spec.ts
│   │   │   │       ├── index.ts
│   │   │   │       ├── schema.ts
│   │   │   │       ├── server.spec.ts
│   │   │   │       └── server.ts
│   │   │   ├── lingo-turbopack-loader.ts
│   │   │   ├── react-router-dictionary-loader.ts
│   │   │   ├── rsc-dictionary-loader.ts
│   │   │   └── utils
│   │   │       ├── ast-key.spec.ts
│   │   │       ├── ast-key.ts
│   │   │       ├── create-locale-import-map.spec.ts
│   │   │       ├── create-locale-import-map.ts
│   │   │       ├── env.spec.ts
│   │   │       ├── env.ts
│   │   │       ├── hash.spec.ts
│   │   │       ├── hash.ts
│   │   │       ├── index.spec.ts
│   │   │       ├── index.ts
│   │   │       ├── invokations.spec.ts
│   │   │       ├── invokations.ts
│   │   │       ├── jsx-attribute-scope.ts
│   │   │       ├── jsx-attribute.spec.ts
│   │   │       ├── jsx-attribute.ts
│   │   │       ├── jsx-content-whitespace.spec.ts
│   │   │       ├── jsx-content.spec.ts
│   │   │       ├── jsx-content.ts
│   │   │       ├── jsx-element.spec.ts
│   │   │       ├── jsx-element.ts
│   │   │       ├── jsx-expressions.test.ts
│   │   │       ├── jsx-expressions.ts
│   │   │       ├── jsx-functions.spec.ts
│   │   │       ├── jsx-functions.ts
│   │   │       ├── jsx-scope.spec.ts
│   │   │       ├── jsx-scope.ts
│   │   │       ├── jsx-variables.spec.ts
│   │   │       ├── jsx-variables.ts
│   │   │       ├── llm-api-key.ts
│   │   │       ├── llm-api-keys.spec.ts
│   │   │       ├── locales.spec.ts
│   │   │       ├── locales.ts
│   │   │       ├── module-params.spec.ts
│   │   │       ├── module-params.ts
│   │   │       ├── observability.spec.ts
│   │   │       ├── observability.ts
│   │   │       ├── rc.spec.ts
│   │   │       └── rc.ts
│   │   ├── tsconfig.json
│   │   ├── tsup.config.ts
│   │   └── vitest.config.ts
│   ├── locales
│   │   ├── CHANGELOG.md
│   │   ├── package.json
│   │   ├── README.md
│   │   ├── src
│   │   │   ├── constants.ts
│   │   │   ├── index.ts
│   │   │   ├── names
│   │   │   │   ├── index.spec.ts
│   │   │   │   ├── index.ts
│   │   │   │   ├── integration.spec.ts
│   │   │   │   └── loader.ts
│   │   │   ├── parser.spec.ts
│   │   │   ├── parser.ts
│   │   │   ├── types.ts
│   │   │   ├── validation.spec.ts
│   │   │   └── validation.ts
│   │   ├── tsconfig.json
│   │   └── tsup.config.ts
│   ├── react
│   │   ├── build.config.ts
│   │   ├── CHANGELOG.md
│   │   ├── package.json
│   │   ├── README.md
│   │   ├── src
│   │   │   ├── client
│   │   │   │   ├── attribute-component.spec.tsx
│   │   │   │   ├── attribute-component.tsx
│   │   │   │   ├── component.lingo-component.spec.tsx
│   │   │   │   ├── component.spec.tsx
│   │   │   │   ├── component.tsx
│   │   │   │   ├── context.spec.tsx
│   │   │   │   ├── context.ts
│   │   │   │   ├── index.ts
│   │   │   │   ├── loader.spec.ts
│   │   │   │   ├── loader.ts
│   │   │   │   ├── locale-switcher.spec.tsx
│   │   │   │   ├── locale-switcher.tsx
│   │   │   │   ├── locale.spec.ts
│   │   │   │   ├── locale.ts
│   │   │   │   ├── provider.spec.tsx
│   │   │   │   ├── provider.tsx
│   │   │   │   ├── utils.spec.ts
│   │   │   │   └── utils.ts
│   │   │   ├── core
│   │   │   │   ├── attribute-component.spec.tsx
│   │   │   │   ├── attribute-component.tsx
│   │   │   │   ├── component.spec.tsx
│   │   │   │   ├── component.tsx
│   │   │   │   ├── const.ts
│   │   │   │   ├── get-dictionary.spec.ts
│   │   │   │   ├── get-dictionary.ts
│   │   │   │   └── index.ts
│   │   │   ├── react-router
│   │   │   │   ├── index.ts
│   │   │   │   ├── loader.spec.ts
│   │   │   │   └── loader.ts
│   │   │   ├── rsc
│   │   │   │   ├── attribute-component.tsx
│   │   │   │   ├── component.lingo-component.spec.tsx
│   │   │   │   ├── component.spec.tsx
│   │   │   │   ├── component.tsx
│   │   │   │   ├── index.ts
│   │   │   │   ├── loader.spec.ts
│   │   │   │   ├── loader.ts
│   │   │   │   ├── provider.spec.tsx
│   │   │   │   ├── provider.tsx
│   │   │   │   ├── utils.spec.ts
│   │   │   │   └── utils.ts
│   │   │   └── test
│   │   │       └── setup.ts
│   │   ├── tsconfig.json
│   │   └── vitest.config.ts
│   ├── sdk
│   │   ├── CHANGELOG.md
│   │   ├── package.json
│   │   ├── README.md
│   │   ├── src
│   │   │   ├── abort-controller.specs.ts
│   │   │   ├── index.spec.ts
│   │   │   └── index.ts
│   │   ├── tsconfig.json
│   │   ├── tsconfig.test.json
│   │   └── tsup.config.ts
│   └── spec
│       ├── CHANGELOG.md
│       ├── package.json
│       ├── README.md
│       ├── src
│       │   ├── config.spec.ts
│       │   ├── config.ts
│       │   ├── formats.ts
│       │   ├── index.spec.ts
│       │   ├── index.ts
│       │   ├── json-schema.ts
│       │   ├── locales.spec.ts
│       │   └── locales.ts
│       ├── tsconfig.json
│       ├── tsconfig.test.json
│       └── tsup.config.ts
├── pnpm-lock.yaml
├── pnpm-workspace.yaml
├── readme
│   ├── ar.md
│   ├── bn.md
│   ├── de.md
│   ├── en.md
│   ├── es.md
│   ├── fa.md
│   ├── fr.md
│   ├── he.md
│   ├── hi.md
│   ├── it.md
│   ├── ja.md
│   ├── ko.md
│   ├── pl.md
│   ├── pt-BR.md
│   ├── ru.md
│   ├── tr.md
│   ├── uk-UA.md
│   └── zh-Hans.md
├── readme.md
├── scripts
│   ├── docs
│   │   ├── package.json
│   │   ├── README.md
│   │   ├── src
│   │   │   ├── generate-cli-docs.ts
│   │   │   ├── generate-config-docs.ts
│   │   │   ├── json-schema
│   │   │   │   ├── markdown-renderer.test.ts
│   │   │   │   ├── markdown-renderer.ts
│   │   │   │   ├── parser.test.ts
│   │   │   │   ├── parser.ts
│   │   │   │   └── types.ts
│   │   │   ├── utils.test.ts
│   │   │   └── utils.ts
│   │   ├── tsconfig.json
│   │   └── vitest.config.ts
│   └── packagist-publish.php
└── turbo.json
```

# Files

--------------------------------------------------------------------------------
/packages/cli/src/cli/loaders/unlocalizable.spec.ts:
--------------------------------------------------------------------------------

```typescript
import { describe, expect, it } from "vitest";
import createUnlocalizableLoader from "./unlocalizable";

describe("unlocalizable loader", () => {
  const data = {
    foo: "bar",
    num: 1,
    numStr: "1.0",
    empty: "",
    boolTrue: true,
    boolFalse: false,
    boolStr: "false",
    isoDate: "2025-02-21",
    isoDateTime: "2025-02-21T00:00:00.000Z",
    bar: "foo",
    url: "https://example.com",
    systemId: "Ab1cdefghijklmnopqrst2",
  };

  it("should remove unlocalizable keys on pull", async () => {
    const loader = createUnlocalizableLoader();
    loader.setDefaultLocale("en");
    const result = await loader.pull("en", data);

    expect(result).toEqual({
      foo: "bar",
      numStr: "1.0",
      boolStr: "false",
      bar: "foo",
    });
  });

  it("should handle unlocalizable keys on push", async () => {
    const pushData = {
      foo: "bar-es",
      bar: "foo-es",
      numStr: "2.0",
      boolStr: "true",
    };

    const loader = createUnlocalizableLoader();
    loader.setDefaultLocale("en");
    await loader.pull("en", data);
    const result = await loader.push("es", pushData);

    expect(result).toEqual({ ...data, ...pushData });
  });

  describe("return unlocalizable keys", () => {
    describe.each([true, false])("%s", (returnUnlocalizedKeys) => {
      it("should return unlocalizable keys on pull", async () => {
        const loader = createUnlocalizableLoader(returnUnlocalizedKeys);
        loader.setDefaultLocale("en");
        const result = await loader.pull("en", data);

        const extraUnlocalizableData = returnUnlocalizedKeys
          ? {
              unlocalizable: {
                num: 1,
                empty: "",
                boolTrue: true,
                boolFalse: false,
                isoDate: "2025-02-21",
                isoDateTime: "2025-02-21T00:00:00.000Z",
                url: "https://example.com",
                systemId: "Ab1cdefghijklmnopqrst2",
              },
            }
          : {};

        expect(result).toEqual({
          foo: "bar",
          numStr: "1.0",
          boolStr: "false",
          bar: "foo",
          ...extraUnlocalizableData,
        });
      });

      it("should not affect push", async () => {
        const pushData = {
          foo: "bar-es",
          bar: "foo-es",
          numStr: "2.0",
          boolStr: "true",
        };

        const loader = createUnlocalizableLoader(returnUnlocalizedKeys);
        loader.setDefaultLocale("en");
        await loader.pull("en", data);
        const result = await loader.push("es", pushData);

        const expectedData = { ...data, ...pushData };
        expect(result).toEqual(expectedData);
      });
    });
  });
});

```

--------------------------------------------------------------------------------
/integrations/directus/CHANGELOG.md:
--------------------------------------------------------------------------------

```markdown
# @replexica/integration-directus

## 0.1.10

### Patch Changes

- [#937](https://github.com/lingodotdev/lingo.dev/pull/937) [`4e5983d`](https://github.com/lingodotdev/lingo.dev/commit/4e5983d7e59ebf9eb529c4b7c1c87689432ac873) Thanks [@devin-ai-integration](https://github.com/apps/devin-ai-integration)! - Update documentation URLs from docs.lingo.dev to lingo.dev/cli and lingo.dev/compiler

## 0.1.9

### Patch Changes

- [`fc3cb88`](https://github.com/lingodotdev/lingo.dev/commit/fc3cb8839cbbb574b69087625dd5f97cf37d5d35) Thanks [@vrcprl](https://github.com/vrcprl)! - Updated README file with target languages changes

## 0.1.8

### Patch Changes

- [`2571fcd`](https://github.com/lingodotdev/lingo.dev/commit/2571fcdce6e969d9df96526188c9f3f89dd80677) Thanks [@vrcprl](https://github.com/vrcprl)! - Added multimple target languages option

## 0.1.7

### Patch Changes

- [`bd7c0a6`](https://github.com/lingodotdev/lingo.dev/commit/bd7c0a62ddfc5144690f6f572667a27d572e521a) Thanks [@maxprilutskiy](https://github.com/maxprilutskiy)! - update `@replexica/sdk` version

## 0.1.6

### Patch Changes

- [`e808190`](https://github.com/lingodotdev/lingo.dev/commit/e80819059b89f4a3f69980bab0979432cb7823bf) Thanks [@vrcprl](https://github.com/vrcprl)! - Fixed screenshot

- Updated dependencies []:
  - @replexica/[email protected]

## 0.1.5

### Patch Changes

- [`ca7a085`](https://github.com/lingodotdev/lingo.dev/commit/ca7a085033ff31780001db1e6d58d818b60beded) Thanks [@vrcprl](https://github.com/vrcprl)! - Add README

## 0.1.4

### Patch Changes

- [`998a4a6`](https://github.com/lingodotdev/lingo.dev/commit/998a4a6267ff8542279a8f6d812d5579e3a78a42) Thanks [@vrcprl](https://github.com/vrcprl)! - Update primary key selection

## 0.1.3

### Patch Changes

- [`75253b6`](https://github.com/lingodotdev/lingo.dev/commit/75253b66833b000bf80d6880e92e3c60f5bcd068) Thanks [@vrcprl](https://github.com/vrcprl)! - Update replexica sdk version

## 0.1.2

### Patch Changes

- Updated dependencies []:
  - @replexica/[email protected]

## 0.1.1

### Patch Changes

- [`22490ab`](https://github.com/lingodotdev/lingo.dev/commit/22490ab94f22d8e5769b23dc58d811fc8483f714) Thanks [@maxprilutskiy](https://github.com/maxprilutskiy)! - add Directus integration

## 0.1.0

### Minor Changes

- [`03b4506`](https://github.com/lingodotdev/lingo.dev/commit/03b45063f435715967825f70daf3f5bbdb05b9a0) Thanks [@vrcprl](https://github.com/vrcprl)! - Lingo.dev integration for Directus

## 0.0.1

### Patch Changes

- [#341](https://github.com/lingodotdev/lingo.dev/pull/341) [`1df47d6`](https://github.com/lingodotdev/lingo.dev/commit/1df47d6095f907e1d756524f5e2cc2e043fdb093) Thanks [@maxprilutskiy](https://github.com/maxprilutskiy)! - empty directus integration package

```

--------------------------------------------------------------------------------
/scripts/packagist-publish.php:
--------------------------------------------------------------------------------

```php
<?php
/**
 * Packagist Publishing Script
 * 
 * This script handles publishing a package to Packagist using the Packagist API.
 * It requires the following environment variables:
 * - PACKAGIST_USERNAME: The Packagist username
 * - PACKAGIST_API_TOKEN: The Packagist API token
 * - PACKAGE_NAME: The name of the package to publish (e.g., vendor/package)
 * 
 * @php      7.4
 */

$username = getenv('PACKAGIST_USERNAME');
$apiToken = getenv('PACKAGIST_API_TOKEN');
$packageName = getenv('PACKAGE_NAME');

if (!$username || !$apiToken || !$packageName) {
    echo "Error: Missing required environment variables.\n";
    echo "Please ensure PACKAGIST_USERNAME, PACKAGIST_API_TOKEN, and PACKAGE_NAME are set.\n";
    exit(1);
}

echo "Starting Packagist publishing process for package: $packageName\n";

$checkUrl = "https://packagist.org/packages/$packageName.json";
$ch = curl_init($checkUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Accept: application/json'
]);

echo "Checking if package exists on Packagist...\n";
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$packageExists = ($httpCode === 200);

if ($packageExists) {
    echo "Package $packageName already exists on Packagist. Updating...\n";
    $apiUrl = "https://packagist.org/api/update-package?username=$username&apiToken=$apiToken";
} else {
    echo "Package $packageName does not exist on Packagist. Creating new package...\n";
    $apiUrl = "https://packagist.org/api/create-package?username=$username&apiToken=$apiToken";
}

$repoUrl = "https://github.com/lingodotdev/lingo.dev";

$data = [
    'repository' => [
        'url' => $repoUrl
    ]
];

$ch = curl_init($apiUrl);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'Accept: application/json'
]);

echo "Sending request to Packagist API ($apiUrl)...\n";
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if (curl_errno($ch)) {
    echo "Error: " . curl_error($ch) . "\n";
    curl_close($ch);
    exit(1);
}

curl_close($ch);

$responseData = json_decode($response, true);

echo "HTTP Response Code: $httpCode\n";
echo "Response: " . print_r($responseData, true) . "\n";

if ($httpCode >= 200 && $httpCode < 300) {
    echo "Package $packageName successfully " . ($packageExists ? "updated" : "submitted") . " to Packagist!\n";
    exit(0);
} else {
    echo "Failed to " . ($packageExists ? "update" : "submit") . " package $packageName to Packagist.\n";
    exit(1);
}

```

--------------------------------------------------------------------------------
/packages/cli/i18n.json:
--------------------------------------------------------------------------------

```json
{
  "version": "1.10",
  "locale": {
    "source": "en",
    "targets": ["es"]
  },
  "buckets": {
    "xliff": {
      "include": ["demo/xliff/[locale]/*.xliff"]
    },
    "android": {
      "include": ["demo/android/[locale]/*.xml"]
    },
    "csv": {
      "include": ["demo/csv/example.csv"]
    },
    "ejs": {
      "include": ["demo/ejs/[locale]/*.ejs"]
    },
    "flutter": {
      "include": ["demo/flutter/[locale]/*.arb"]
    },
    "html": {
      "include": ["demo/html/[locale]/*.html"]
    },
    "json": {
      "include": ["demo/json/[locale]/example.json"],
      "lockedKeys": ["locked_key_1"],
      "ignoredKeys": ["ignored_key_1"]
    },
    "jsonc": {
      "include": ["demo/jsonc/[locale]/example.jsonc"],
      "lockedKeys": ["locked_key_1"],
      "ignoredKeys": ["ignored_key_1"]
    },
    "json5": {
      "include": ["demo/json5/[locale]/example.json5"]
    },
    "json-dictionary": {
      "include": ["demo/json-dictionary/example.json"]
    },
    "markdoc": {
      "include": ["demo/markdoc/[locale]/*.markdoc"]
    },
    "markdown": {
      "include": ["demo/markdown/[locale]/*.md"],
      "exclude": ["demo/markdown/[locale]/ignored.md"]
    },
    "mdx": {
      "include": ["demo/mdx/[locale]/*.mdx"],
      "lockedKeys": ["meta/locked_key_1"],
      "ignoredKeys": ["meta/ignored_key_1"]
    },
    "po": {
      "include": ["demo/po/[locale]/*.po"]
    },
    "properties": {
      "include": ["demo/properties/[locale]/*.properties"]
    },
    "srt": {
      "include": ["demo/srt/[locale]/*.srt"]
    },
    "txt": {
      "include": ["demo/txt/[locale]/*.txt"]
    },
    "typescript": {
      "include": ["demo/typescript/[locale]/*.ts"],
      "lockedKeys": ["forms/locked_key_1"],
      "ignoredKeys": ["forms/ignored_key_1"]
    },
    "vtt": {
      "include": ["demo/vtt/[locale]/*.vtt"]
    },
    "xcode-strings": {
      "include": ["demo/xcode-strings/[locale]/*.strings"]
    },
    "xcode-stringsdict": {
      "include": ["demo/xcode-stringsdict/[locale]/*.stringsdict"]
    },
    "xcode-xcstrings": {
      "include": ["demo/xcode-xcstrings/*.xcstrings"],
      "lockedKeys": ["api_key"],
      "ignoredKeys": ["item_count"]
    },
    "xcode-xcstrings-v2": {
      "include": ["demo/xcode-xcstrings-v2/*.xcstrings"]
    },
    "xml": {
      "include": ["demo/xml/[locale]/*.xml"]
    },
    "yaml": {
      "include": ["demo/yaml/[locale]/*.yml"],
      "lockedKeys": ["locked_key_1"],
      "ignoredKeys": ["ignored_key_1"]
    },
    "yaml-root-key": {
      "include": ["demo/yaml-root-key/[locale]/*.yml"]
    },
    "php": {
      "include": ["demo/php/[locale]/*.php"]
    },
    "vue-json": {
      "include": ["demo/vue-json/*.vue"]
    }
  },
  "$schema": "https://lingo.dev/schema/i18n.json"
}

```

--------------------------------------------------------------------------------
/packages/cli/src/cli/utils/observability.ts:
--------------------------------------------------------------------------------

```typescript
import pkg from "node-machine-id";
const { machineIdSync } = pkg;
import https from "https";

const POSTHOG_API_KEY = "phc_eR0iSoQufBxNY36k0f0T15UvHJdTfHlh8rJcxsfhfXk";
const POSTHOG_HOST = "eu.i.posthog.com";
const POSTHOG_PATH = "/i/v0/e/"; // Correct PostHog capture endpoint
const REQUEST_TIMEOUT_MS = 1000;

/**
 * Sends an analytics event to PostHog using direct HTTPS API.
 * This is a fire-and-forget implementation that won't block the process.
 *
 * @param distinctId - Unique identifier for the user/device
 * @param event - Name of the event to track
 * @param properties - Additional properties to attach to the event
 */
export default function trackEvent(
  distinctId: string | null | undefined,
  event: string,
  properties?: Record<string, any>,
): void {
  // Skip tracking if explicitly disabled or in CI environment
  if (process.env.DO_NOT_TRACK === "1") {
    return;
  }

  // Defer execution to next tick to avoid blocking
  setImmediate(() => {
    try {
      const actualId = distinctId || `device-${machineIdSync()}`;

      // PostHog expects distinct_id at the root level, not nested in properties
      const eventData = {
        api_key: POSTHOG_API_KEY,
        event,
        distinct_id: actualId,
        properties: {
          ...properties,
          $lib: "lingo.dev-cli",
          $lib_version: process.env.npm_package_version || "unknown",
          // Essential debugging context only
          node_version: process.version,
          is_ci: !!process.env.CI,
          debug_enabled: process.env.DEBUG === "true",
        },
        timestamp: new Date().toISOString(),
      };

      const payload = JSON.stringify(eventData);

      const options: https.RequestOptions = {
        hostname: POSTHOG_HOST,
        path: POSTHOG_PATH,
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          "Content-Length": Buffer.byteLength(payload).toString(),
        },
        timeout: REQUEST_TIMEOUT_MS,
      };

      const req = https.request(options);

      // Handle timeout by destroying the request
      req.on("timeout", () => {
        req.destroy();
      });

      // Silently ignore errors to prevent crashes
      req.on("error", (error) => {
        if (process.env.DEBUG === "true") {
          console.error("[Tracking] Error ignored:", error.message);
        }
      });

      // Send payload and close the request
      req.write(payload);
      req.end();

      // Ensure cleanup after timeout
      setTimeout(() => {
        if (!req.destroyed) {
          req.destroy();
        }
      }, REQUEST_TIMEOUT_MS);
    } catch (error) {
      // Catch-all for any synchronous errors
      if (process.env.DEBUG === "true") {
        console.error("[Tracking] Failed to send event:", error);
      }
    }
  });
}

```

--------------------------------------------------------------------------------
/packages/react/src/rsc/utils.ts:
--------------------------------------------------------------------------------

```typescript
import { cookies, headers } from "next/headers";
import { LOCALE_HEADER_NAME, LOCALE_COOKIE_NAME } from "../core";

/**
 * Gets the current locale code from the `"x-lingo-locale"` header.
 *
 * @returns Promise that resolves to the current locale code, or `"en"` if no header is found.
 *
 * @example Get locale from headers in a server component
 * ```typescript
 * import { loadLocaleFromHeaders } from "lingo.dev/react/rsc";
 *
 * export default async function ServerComponent() {
 *   const locale = await loadLocaleFromHeaders();
 *   return <div>Current locale: {locale}</div>;
 * }
 * ```
 */
export async function loadLocaleFromHeaders() {
  const requestHeaders = await headers();
  const result = requestHeaders.get(LOCALE_HEADER_NAME);
  return result;
}

/**
 * Gets the current locale code from the `"lingo-locale"` cookie.
 *
 * @returns Promise that resolves to the current locale code, or `"en"` if no cookie is found.
 *
 * @example Get locale from cookies in a server component
 * ```typescript
 * import { loadLocaleFromCookies } from "lingo.dev/react/rsc";
 *
 * export default async function ServerComponent() {
 *   const locale = await loadLocaleFromCookies();
 *   return <div>User's saved locale: {locale}</div>;
 * }
 * ```
 */
export async function loadLocaleFromCookies() {
  const requestCookies = await cookies();
  const result = requestCookies.get(LOCALE_COOKIE_NAME)?.value || "en";
  return result;
}

/**
 * Sets the current locale in the `"lingo-locale"` cookie.
 *
 * @param locale - The locale code to store in the cookie.
 *
 * @example Set locale in a server action
 * ```typescript
 * import { setLocaleInCookies } from "lingo.dev/react/rsc";
 *
 * export async function changeLocale(locale: string) {
 *   "use server";
 *   await setLocaleInCookies(locale);
 *   redirect("/");
 * }
 * ```
 */
export async function setLocaleInCookies(locale: string) {
  const requestCookies = await cookies();
  requestCookies.set(LOCALE_COOKIE_NAME, locale);
}

/**
 * Loads the dictionary for the current locale.
 *
 * The current locale is determined by the `"lingo-locale"` cookie.
 *
 * @param loader - A callback function that loads the dictionary for the current locale.
 *
 * @returns Promise that resolves to the dictionary object containing localized content.
 *
 * @example Load dictionary from request in a server component
 * ```typescript
 * import { loadDictionaryFromRequest, loadDictionary } from "lingo.dev/react/rsc";
 *
 * export default async function ServerComponent() {
 *   const dictionary = await loadDictionaryFromRequest(loadDictionary);
 *   return <div>{dictionary.welcome}</div>;
 * }
 * ```
 */
export async function loadDictionaryFromRequest(
  loader: (locale: string) => Promise<any>,
) {
  const locale = await loadLocaleFromCookies();
  return loader(locale);
}

```

--------------------------------------------------------------------------------
/packages/react/src/react-router/loader.ts:
--------------------------------------------------------------------------------

```typescript
import { LOCALE_COOKIE_NAME, getDictionary } from "../core";

/**
 * A placeholder function for loading dictionaries that contain localized content.
 *
 * This function:
 *
 * - Should be used in React Router and Remix applications
 * - Should be passed into the `LingoProvider` component
 * - Is transformed into functional code by Lingo.dev Compiler
 *
 * @param requestOrExplicitLocale - Either a `Request` object (from loader functions) or an explicit locale string.
 *
 * @returns Promise that resolves to the dictionary object containing localized content.
 *
 * @example Use in a React Router application
 * ```tsx
 * import { LingoProvider } from "lingo.dev/react/client";
 * import { loadDictionary } from "lingo.dev/react/react-router";
 * import {
 *   Links,
 *   Meta,
 *   Outlet,
 *   Scripts,
 *   ScrollRestoration,
 *   useLoaderData,
 *   type LoaderFunctionArgs,
 * } from "react-router";
 * import "./app.css";
 *
 * export const loader = async ({ request }: LoaderFunctionArgs) => {
 *   return {
 *     lingoDictionary: await loadDictionary(request),
 *   };
 * };
 *
 * export function Layout({ children }: { children: React.ReactNode }) {
 *   const { lingoDictionary } = useLoaderData<typeof loader>();
 *
 *   return (
 *     <LingoProvider dictionary={lingoDictionary}>
 *       <html lang="en">
 *         <head>
 *           <meta charSet="utf-8" />
 *           <meta name="viewport" content="width=device-width, initial-scale=1" />
 *           <Meta />
 *           <Links />
 *         </head>
 *         <body>
 *           {children}
 *           <ScrollRestoration />
 *           <Scripts />
 *         </body>
 *       </html>
 *     </LingoProvider>
 *   );
 * }
 *
 * export default function App() {
 *   return <Outlet />;
 * }
 * ```
 */
export const loadDictionary = async (
  requestOrExplicitLocale: Request | string,
): Promise<any> => {
  return null;
};

function loadLocaleFromCookies(request: Request) {
  // it's a Request, so get the Cookie header
  const cookieHeaderValue = request.headers.get("Cookie");

  // there's no Cookie header, so return null
  if (!cookieHeaderValue) {
    return null;
  }

  // get the lingo-locale cookie
  const cookiePrefix = `${LOCALE_COOKIE_NAME}=`;
  const cookie = cookieHeaderValue
    .split(";")
    .find((cookie) => cookie.trim().startsWith(cookiePrefix));

  // there's no lingo-locale cookie, so return null
  if (!cookie) {
    return null;
  }

  // extract the locale value from the cookie
  return cookie.trim().substring(cookiePrefix.length);
}

export async function loadDictionary_internal(
  requestOrExplicitLocale: Request | string,
  dictionaryLoaders: Record<string, () => Promise<any>>,
) {
  // gets the locale (falls back to "en")
  const locale =
    typeof requestOrExplicitLocale === "string"
      ? requestOrExplicitLocale
      : loadLocaleFromCookies(requestOrExplicitLocale);

  return getDictionary(locale, dictionaryLoaders);
}

```

--------------------------------------------------------------------------------
/packages/cli/src/cli/loaders/csv.ts:
--------------------------------------------------------------------------------

```typescript
import { parse } from "csv-parse/sync";
import { stringify } from "csv-stringify/sync";
import _ from "lodash";
import { ILoader } from "./_types";
import { composeLoaders, createLoader } from "./_utils";

/**
 * Tries to detect the key column name from a csvString.
 *
 * Current logic: get first cell > 'KEY' fallback if empty
 */
export function detectKeyColumnName(csvString: string) {
  const row: string[] | undefined = parse(csvString)[0];
  const firstColumn = row?.[0]?.trim();
  return firstColumn || "KEY";
}

export default function createCsvLoader() {
  return composeLoaders(_createCsvLoader(), createPullOutputCleaner());
}

type InternalTransferState = {
  keyColumnName: string;
  inputParsed: Record<string, any>[];
  items: Record<string, string>;
};

function _createCsvLoader(): ILoader<string, InternalTransferState> {
  return createLoader({
    async pull(locale, input) {
      const keyColumnName = detectKeyColumnName(
        input.split("\n").find((l) => l.length)!,
      );
      const inputParsed = parse(input, {
        columns: true,
        skip_empty_lines: true,
        relax_column_count_less: true,
      }) as Record<string, any>[];

      const items: Record<string, string> = {};

      // Assign keys that already have translation so AI doesn't re-generate it.
      _.forEach(inputParsed, (row) => {
        const key = row[keyColumnName];
        if (key && row[locale] && row[locale].trim() !== "") {
          items[key] = row[locale];
        }
      });

      return {
        inputParsed,
        keyColumnName,
        items,
      };
    },
    async push(locale, { inputParsed, keyColumnName, items }) {
      const columns =
        inputParsed.length > 0
          ? Object.keys(inputParsed[0])
          : [keyColumnName, locale];
      if (!columns.includes(locale)) {
        columns.push(locale);
      }

      const updatedRows = inputParsed.map((row) => ({
        ...row,
        [locale]: items[row[keyColumnName]] || row[locale] || "",
      }));
      const existingKeys = new Set(
        inputParsed.map((row) => row[keyColumnName]),
      );

      Object.entries(items).forEach(([key, value]) => {
        if (!existingKeys.has(key)) {
          const newRow: Record<string, string> = {
            [keyColumnName]: key,
            ...Object.fromEntries(columns.map((column) => [column, ""])),
          };
          newRow[locale] = value;
          updatedRows.push(newRow);
        }
      });

      return stringify(updatedRows, {
        header: true,
        columns,
      });
    },
  });
}

/**
 * This is a simple extra loader that is used to clean the data written to lockfile
 */
function createPullOutputCleaner(): ILoader<
  InternalTransferState,
  Record<string, string>
> {
  return createLoader({
    async pull(_locale, input) {
      return input.items;
    },
    async push(_locale, data, _oI, _oL, pullInput) {
      return { ...pullInput!, items: data };
    },
  });
}

```

--------------------------------------------------------------------------------
/packages/cli/src/cli/loaders/locked-patterns.ts:
--------------------------------------------------------------------------------

```typescript
import { ILoader } from "./_types";
import { createLoader } from "./_utils";
import { md5 } from "../utils/md5";

/**
 * Extracts content matching regex patterns and replaces it with placeholders.
 * Returns the transformed content and a mapping of placeholders to original content.
 */
function extractLockedPatterns(
  content: string,
  patterns: string[] = [],
): {
  content: string;
  lockedPlaceholders: Record<string, string>;
} {
  let finalContent = content;
  const lockedPlaceholders: Record<string, string> = {};

  if (!patterns || patterns.length === 0) {
    return { content: finalContent, lockedPlaceholders };
  }

  for (const patternStr of patterns) {
    try {
      const pattern = new RegExp(patternStr, "gm");
      const matches = Array.from(finalContent.matchAll(pattern));

      for (const match of matches) {
        const matchedText = match[0];
        const matchHash = md5(matchedText);
        const placeholder = `---LOCKED-PATTERN-${matchHash}---`;

        lockedPlaceholders[placeholder] = matchedText;
        finalContent = finalContent.replace(matchedText, placeholder);
      }
    } catch (error) {
      console.warn(`Invalid regex pattern: ${patternStr}`);
    }
  }

  return {
    content: finalContent,
    lockedPlaceholders,
  };
}

/**
 * Creates a loader that preserves content matching regex patterns during translation.
 *
 * This loader extracts content matching the provided regex patterns and replaces it
 * with placeholders before translation. After translation, the placeholders are
 * restored with the original content.
 *
 * This is useful for preserving technical terms, code snippets, URLs, template
 * variables, and other non-translatable content within translatable files.
 *
 * Works with any string-based format (JSON, YAML, XML, Markdown, HTML, etc.).
 * Note: For structured formats (JSON, XML, YAML), ensure patterns only match
 * content within values, not structural syntax, to avoid breaking parsing.
 *
 * @param defaultPatterns - Array of regex pattern strings to match and preserve
 * @returns A loader that handles pattern locking/unlocking
 */
export default function createLockedPatternsLoader(
  defaultPatterns?: string[],
): ILoader<string, string> {
  return createLoader({
    async pull(locale, input, initCtx, originalLocale) {
      const patterns = defaultPatterns || [];

      const { content } = extractLockedPatterns(input || "", patterns);

      return content;
    },

    async push(
      locale,
      data,
      originalInput,
      originalLocale,
      pullInput,
      pullOutput,
    ) {
      const patterns = defaultPatterns || [];

      if (!pullInput) {
        return data;
      }

      const { lockedPlaceholders } = extractLockedPatterns(
        pullInput as string,
        patterns,
      );

      let result = data;
      for (const [placeholder, original] of Object.entries(
        lockedPlaceholders,
      )) {
        result = result.replaceAll(placeholder, original);
      }

      return result;
    },
  });
}

```

--------------------------------------------------------------------------------
/packages/compiler/src/lib/lcp/api/xml2obj.spec.ts:
--------------------------------------------------------------------------------

```typescript
import { describe, it, expect } from "vitest";
import { xml2obj, obj2xml } from "./xml2obj";

function normalize(xml: string) {
  return xml.replace(/\s+/g, " ").trim();
}

describe("xml2obj / obj2xml", () => {
  it("should convert simple XML to object with key attributes", () => {
    const xml = `
      <object>
        <object key="user">
          <value key="id">123</value>
          <value key="dataValue">abc</value>
          <value key="firstName">John</value>
          <value key="lastName">Doe</value>
        </object>
      </object>
    `;
    const obj = xml2obj(xml);
    expect(obj).toEqual({
      user: {
        id: 123,
        dataValue: "abc",
        firstName: "John",
        lastName: "Doe",
      },
    });
  });

  it("should preserve complex structures through round-trip conversion", () => {
    const original = {
      root: {
        id: 123,
        name: "John & Jane <> \" '",
        notes: "Line1\nLine2",
        isActive: true,
        tags: {
          tag: ["a & b", "c < d"],
        },
        nestedObj: {
          childId: 456,
          weirdSymbols: "@#$%^&*()_+",
        },
        items: {
          item: [
            { keyOne: "value1", keyTwo: "value2" },
            { keyOne: "value3", keyTwo: "value4" },
          ],
        },
      },
    } as const;

    const result = xml2obj(obj2xml(original));
    expect(result).toEqual(original);
  });

  it("should handle empty elements, arrays and self-closing tags", () => {
    const original = `
      <object>
        <value key="products" />
        <array key="prices">
          <value>1.99</value>
          <value>9.99</value>
        </array>
      </object>
    `;
    const expected = {
      products: "",
      prices: [1.99, 9.99],
    };
    expect(xml2obj(original)).toEqual(expected);
  });

  it("should correctly escape special characters when building XML", () => {
    const original = { message: "5 < 6 & 7 > 4" } as const;
    const result = xml2obj(obj2xml(original));
    expect(result).toEqual(original);
  });

  it("check 1", () => {
    const original = `<?xml version="1.0" encoding="UTF-8"?>
<object>
 <value key="version">0.1.1</value>
 <value key="locale">ja</value>
 <object key="files">
 <object key="routes/($locale).z.tsx">
 <object key="entries">
 <value key="1/declaration/body/3/argument">&lt;element:select&gt;&lt;element:option&gt;使用済み&lt;/element:option&gt;&lt;element:option&gt;合計&lt;/element:option&gt;&lt;/element:select&gt; 🚀 あなたの使用状況: {wordType} {subscription.words[wordType]}</value>
 </object>
 </object>
 </object>
</object>`;

    const result = xml2obj(original);
    expect(result).toEqual({
      version: "0.1.1",
      locale: "ja",
      files: {
        "routes/($locale).z.tsx": {
          entries: {
            "1/declaration/body/3/argument":
              "<element:select><element:option>使用済み</element:option><element:option>合計</element:option></element:select> 🚀 あなたの使用状況: {wordType} {subscription.words[wordType]}",
          },
        },
      },
    });
  });
});

```

--------------------------------------------------------------------------------
/packages/cli/src/cli/cmd/show/_shared-key-command.ts:
--------------------------------------------------------------------------------

```typescript
import { resolveOverriddenLocale, I18nConfig } from "@lingo.dev/_spec";
import createBucketLoader from "../../loaders";
import {
  matchesKeyPattern,
  formatDisplayValue,
} from "../../utils/key-matching";

export type KeyFilterType = "lockedKeys" | "ignoredKeys";

export interface KeyCommandOptions {
  bucket?: string;
}

export interface KeyCommandConfig {
  filterType: KeyFilterType;
  displayName: string; // e.g., "locked", "ignored"
}

export async function executeKeyCommand(
  i18nConfig: I18nConfig,
  buckets: any[],
  options: KeyCommandOptions,
  config: KeyCommandConfig,
): Promise<void> {
  let hasAnyKeys = false;

  for (const bucket of buckets) {
    // Filter by bucket name if specified
    if (options.bucket && bucket.type !== options.bucket) {
      continue;
    }

    // Skip buckets without the specified key patterns
    const keyPatterns = bucket[config.filterType];
    if (!keyPatterns || keyPatterns.length === 0) {
      continue;
    }

    hasAnyKeys = true;

    console.log(`\nBucket: ${bucket.type}`);
    console.log(
      `${capitalize(config.displayName)} key patterns: ${keyPatterns.join(", ")}`,
    );

    for (const bucketConfig of bucket.paths) {
      const sourceLocale = resolveOverriddenLocale(
        i18nConfig.locale.source,
        bucketConfig.delimiter,
      );
      const sourcePath = bucketConfig.pathPattern.replace(
        /\[locale\]/g,
        sourceLocale,
      );

      try {
        // Create a loader to read the source file
        const loader = createBucketLoader(
          bucket.type,
          bucketConfig.pathPattern,
          {
            defaultLocale: sourceLocale,
            injectLocale: bucket.injectLocale,
          },
          [], // Don't apply any filtering when reading
          [],
          [],
        );
        loader.setDefaultLocale(sourceLocale);

        // Read the source file content
        const data = await loader.pull(sourceLocale);

        if (!data || Object.keys(data).length === 0) {
          continue;
        }

        // Filter keys that match the patterns
        const matchedEntries = Object.entries(data).filter(([key]) =>
          matchesKeyPattern(key, keyPatterns),
        );

        if (matchedEntries.length > 0) {
          console.log(`\nMatches in ${sourcePath}:`);
          for (const [key, value] of matchedEntries) {
            const displayValue = formatDisplayValue(value);
            console.log(`  - ${key}: ${displayValue}`);
          }
          console.log(
            `Total: ${matchedEntries.length} ${config.displayName} key(s)`,
          );
        }
      } catch (error: any) {
        console.error(`  Error reading ${sourcePath}: ${error.message}`);
      }
    }
  }

  if (!hasAnyKeys) {
    if (options.bucket) {
      console.log(
        `No ${config.displayName} keys configured for bucket: ${options.bucket}`,
      );
    } else {
      console.log(`No ${config.displayName} keys configured in any bucket.`);
    }
  }
}

function capitalize(str: string): string {
  return str.charAt(0).toUpperCase() + str.slice(1);
}

```

--------------------------------------------------------------------------------
/packages/cli/src/cli/loaders/_utils.ts:
--------------------------------------------------------------------------------

```typescript
import { ILoader, ILoaderDefinition } from "./_types";

export function composeLoaders(
  ...loaders: ILoader<any, any, any>[]
): ILoader<any, any> {
  return {
    init: async () => {
      for (const loader of loaders) {
        await loader.init?.();
      }
    },
    setDefaultLocale(locale: string) {
      for (const loader of loaders) {
        loader.setDefaultLocale?.(locale);
      }
      return this;
    },
    pull: async (locale, input) => {
      let result: any = input;
      for (let i = 0; i < loaders.length; i++) {
        result = await loaders[i].pull(locale, result);
      }
      return result;
    },
    push: async (locale, data) => {
      let result: any = data;
      for (let i = loaders.length - 1; i >= 0; i--) {
        result = await loaders[i].push(locale, result);
      }
      return result;
    },
    pullHints: async (originalInput) => {
      let result: any = originalInput;
      for (let i = 0; i < loaders.length; i++) {
        const subResult = await loaders[i].pullHints?.(result);
        if (subResult) {
          result = subResult;
        }
      }
      return result;
    },
  };
}

export function createLoader<I, O, C>(
  lDefinition: ILoaderDefinition<I, O, C>,
): ILoader<I, O, C> {
  const state = {
    defaultLocale: undefined as string | undefined,
    originalInput: undefined as I | undefined | null,
    pullInput: undefined as I | undefined | null,
    pullOutput: undefined as O | undefined | null,
    initCtx: undefined as C | undefined,
  };
  return {
    async init() {
      if (state.initCtx) {
        return state.initCtx;
      }
      state.initCtx = await lDefinition.init?.();
      return state.initCtx as C;
    },
    setDefaultLocale(locale) {
      if (state.defaultLocale) {
        throw new Error("Default locale already set");
      }
      state.defaultLocale = locale;
      return this;
    },
    async pullHints() {
      return lDefinition.pullHints?.(state.originalInput!);
    },
    async pull(locale, input) {
      if (!state.defaultLocale) {
        throw new Error("Default locale not set");
      }
      if (state.originalInput === undefined && locale !== state.defaultLocale) {
        throw new Error("The first pull must be for the default locale");
      }
      if (locale === state.defaultLocale) {
        state.originalInput = input || null;
      }

      state.pullInput = input;
      const result = await lDefinition.pull(
        locale,
        input,
        state.initCtx!,
        state.defaultLocale,
        state.originalInput!,
      );
      state.pullOutput = result;

      return result;
    },
    async push(locale, data) {
      if (!state.defaultLocale) {
        throw new Error("Default locale not set");
      }
      if (state.originalInput === undefined) {
        throw new Error("Cannot push data without pulling first");
      }

      const pushResult = await lDefinition.push(
        locale,
        data,
        state.originalInput,
        state.defaultLocale,
        state.pullInput!,
        state.pullOutput!,
      );
      return pushResult;
    },
  };
}

```

--------------------------------------------------------------------------------
/.claude/commands/analyze-bucket-type.md:
--------------------------------------------------------------------------------

```markdown
---
argument-hint: <bucket-type>
description: Analyze a bucket type implementation to identify all behaviors and configurations
---

Given the bucket type ID "$ARGUMENTS" (e.g., "json", "mdx", "typescript"), analyze the implementation code to identify ALL bucket-specific behaviors, configurations, and characteristics.

## Instructions

1. **Locate where this bucket type is processed** in the codebase by searching for the bucket type string. Start with the main loader composition/pipeline code.

2. **Trace the complete execution pipeline** for this bucket:

   - List every function/loader in the processing chain, in order
   - For each function/loader, read its implementation to understand:
     - Input parameters it receives
     - Transformations it performs on the data
     - Output format it produces
     - Any side effects or file operations

3. **Identify configuration parameters** by:

   - Finding which variables are passed into the loaders (e.g., lockedKeys, ignoredKeys)
   - Tracing these variables back to their source (configuration parsing)
   - Determining if they're bucket-specific or universal

4. **Analyze file I/O behavior**:

   - How are file paths constructed?
   - Does the path pattern contain locale placeholders that would create separate files?
   - What file operations are performed (read, write, create, delete)?
   - Are files overwritten or are new files created?
   - **IMPORTANT**: Note that "overwrites existing files completely" and "[locale] placeholder support" are mutually exclusive in practice:
     - If a bucket type stores all locales in a single file (like CSV with columns per locale), it overwrites that single file and does NOT support `[locale]` placeholders
     - If a bucket type creates separate files per locale using `[locale]` placeholders, each locale file is overwritten individually
     - Clarify which pattern the bucket type follows

5. **Examine data transformation logic**:

   - How is the file content parsed?
   - What internal data structures are used?
   - How is the data serialized back to file format?
   - Are there any format-preserving mechanisms?

6. **Identify special behaviors** by examining:

   - Conditional logic specific to this bucket
   - Error handling unique to this format
   - Any validation or normalization steps
   - Interactions between multiple loaders in the pipeline

7. **Determine constraints and capabilities**:

   - What data types/structures are supported?
   - Are there any size or complexity limitations?
   - What happens with edge cases (empty files, malformed content)?

## Required Depth

- Read the ACTUAL implementation of each loader/function
- Follow all function calls to understand the complete flow
- Don't make assumptions - verify behavior in the code
- Consider the order of operations in the pipeline

## Output Format

List all findings categorized as:

- Configuration parameters (with their types and defaults)
- Processing pipeline (ordered list of transformations)
- File handling behavior
- Data transformation characteristics
- Special capabilities or limitations
- Edge case handling

```

--------------------------------------------------------------------------------
/packages/spec/src/config.spec.ts:
--------------------------------------------------------------------------------

```typescript
import { describe, it, expect } from "vitest";
import {
  parseI18nConfig,
  defaultConfig,
  LATEST_CONFIG_DEFINITION,
} from "./config";

// Helper function to create a v0 config
const createV0Config = () => ({
  version: 0,
});

// Helper function to create a v1 config
const createV1Config = () => ({
  version: 1,
  locale: {
    source: "en",
    targets: ["es"],
  },
  buckets: {
    "src/ui/[locale]/.json": "json",
    "src/blog/[locale]/*.md": "markdown",
  },
});

// Helper function to create a v1.1 config
const createV1_1Config = () => ({
  version: 1.1,
  locale: {
    source: "en",
    targets: ["es", "fr", "pt-PT", "pt_BR"],
  },
  buckets: {
    json: {
      include: ["src/ui/[locale]/.json"],
    },
    markdown: {
      include: ["src/blog/[locale]/*.md"],
      exclude: ["src/blog/[locale]/drafts.md"],
    },
  },
});

const createV1_2Config = () => ({
  ...createV1_1Config(),
  version: 1.2,
});

const createV1_3Config = () => ({
  ...createV1_2Config(),
  version: 1.3,
});

const createV1_4Config = () => ({
  ...createV1_3Config(),
  version: 1.4,
  $schema: "https://lingo.dev/schema/i18n.json",
});

const createInvalidLocaleConfig = () => ({
  version: 1,
  locale: {
    source: "bbbb",
    targets: ["es", "aaaa"],
  },
  buckets: {
    "src/ui/[locale]/.json": "json",
    "src/blog/[locale]/*.md": "markdown",
  },
});

describe("I18n Config Parser", () => {
  it("should upgrade v0 config to latest version", () => {
    const v0Config = createV0Config();
    const result = parseI18nConfig(v0Config);

    expect(result["$schema"]).toBeDefined();
    expect(result.version).toBe(LATEST_CONFIG_DEFINITION.defaultValue.version);
    expect(result.locale).toEqual(defaultConfig.locale);
    expect(result.buckets).toEqual({});
  });

  it("should upgrade v1 config to latest version", () => {
    const v1Config = createV1Config();
    const result = parseI18nConfig(v1Config);

    expect(result["$schema"]).toBeDefined();
    expect(result.version).toBe(LATEST_CONFIG_DEFINITION.defaultValue.version);
    expect(result.locale).toEqual(v1Config.locale);
    expect(result.buckets).toEqual({
      json: {
        include: ["src/ui/[locale]/.json"],
      },
      markdown: {
        include: ["src/blog/[locale]/*.md"],
      },
    });
  });

  it("should handle empty config and use defaults", () => {
    const emptyConfig = {};
    const result = parseI18nConfig(emptyConfig);

    expect(result).toEqual(defaultConfig);
  });

  it("should ignore extra fields in the config", () => {
    const configWithExtra = {
      ...createV1_4Config(),
      extraField: "should be ignored",
    };
    const result = parseI18nConfig(configWithExtra);

    expect(result).not.toHaveProperty("extraField");
    expect(result).toEqual(createV1_4Config());
  });

  it("should throw an error for unsupported locales", () => {
    const invalidLocaleConfig = createInvalidLocaleConfig();
    expect(() => parseI18nConfig(invalidLocaleConfig)).toThrow(
      `\nUnsupported locale: ${invalidLocaleConfig.locale.source}\nUnsupported locale: ${invalidLocaleConfig.locale.targets[1]}`,
    );
  });
});

```

--------------------------------------------------------------------------------
/packages/compiler/src/utils/jsx-content-whitespace.spec.ts:
--------------------------------------------------------------------------------

```typescript
import { describe, it, expect } from "vitest";
import { extractJsxContent } from "./jsx-content";
import * as t from "@babel/types";
import traverse, { NodePath } from "@babel/traverse";
import { parse } from "@babel/parser";

describe("Whitespace Issue Test", () => {
  function parseJSX(code: string): t.File {
    return parse(code, {
      plugins: ["jsx"],
      sourceType: "module",
    });
  }

  function getJSXElementPath(code: string): NodePath<t.JSXElement> {
    const ast = parseJSX(code);
    let result: NodePath<t.JSXElement>;

    traverse(ast, {
      JSXElement(path) {
        result = path;
        path.stop();
      },
    });

    return result!;
  }

  it("should preserve leading space in nested elements", () => {
    const path = getJSXElementPath(`
      <h1 className="text-5xl md:text-7xl font-bold text-white mb-6 leading-tight">
        Hello World
        <span className="bg-gradient-to-r from-purple-400 via-pink-400 to-yellow-400 bg-clip-text text-transparent"> From Lingo.dev Compiler</span>
      </h1>
    `);

    const content = extractJsxContent(path);
    console.log("Extracted content:", JSON.stringify(content));

    // Let's also check the raw JSX structure to understand what's happening
    let jsxTexts: string[] = [];
    path.traverse({
      JSXText(textPath) {
        jsxTexts.push(JSON.stringify(textPath.node.value));
      },
    });
    console.log("JSXText nodes found:", jsxTexts);

    // The span should have " From Lingo.dev Compiler" with the leading space
    expect(content).toContain(
      "<element:span> From Lingo.dev Compiler</element:span>",
    );
  });

  it("should handle explicit whitespace correctly", () => {
    const path = getJSXElementPath(`
      <div>
        Hello{" "}
        <span> World</span>
      </div>
    `);

    const content = extractJsxContent(path);
    console.log("Explicit whitespace test:", JSON.stringify(content));

    // Should preserve both the explicit space and the leading space in span
    expect(content).toContain("Hello <element:span> World</element:span>");
  });

  it("should preserve space before nested bold element like in HeroSubtitle", () => {
    const path = getJSXElementPath(`
      <p className="text-lg sm:text-xl text-gray-600 mb-10 max-w-xl mx-auto leading-relaxed">
        Localize your React app in every language in minutes. Scale to millions
        <b> from day one</b>.
      </p>
    `);

    const content = extractJsxContent(path);
    console.log("HeroSubtitle test content:", JSON.stringify(content));

    // Let's also check the raw JSX structure
    let jsxTexts: string[] = [];
    path.traverse({
      JSXText(textPath) {
        jsxTexts.push(JSON.stringify(textPath.node.value));
      },
    });
    console.log("HeroSubtitle JSXText nodes found:", jsxTexts);

    // The bold element should have " from day one" with the leading space
    expect(content).toContain("<element:b> from day one</element:b>");
    // The full content should preserve the space between "millions" and the bold element
    expect(content).toContain("millions <element:b> from day one</element:b>");
  });
});

```

--------------------------------------------------------------------------------
/packages/cli/src/cli/loaders/csv.spec.ts:
--------------------------------------------------------------------------------

```typescript
import { describe, expect, it } from "vitest";
import { parse } from "csv-parse/sync";
import createCsvLoader from "./csv";

// Helper to build CSV strings easily
function buildCsv(rows: string[][]): string {
  return rows.map((r) => r.join(",")).join("\n");
}

describe("csv loader", () => {
  const sampleCsv = buildCsv([
    ["id", "en", "es"],
    ["hello", "Hello", "Hola"],
    ["bye", "Bye", "Adiós"],
    ["unused", "", "Sin uso"],
  ]);

  it("pull should extract translation map for the requested locale and skip empty values", async () => {
    const loader = createCsvLoader();
    loader.setDefaultLocale("en");

    const enResult = await loader.pull("en", sampleCsv);
    expect(enResult).toEqual({ hello: "Hello", bye: "Bye" });

    const esResult = await loader.pull("es", sampleCsv);
    expect(esResult).toEqual({
      hello: "Hola",
      bye: "Adiós",
      unused: "Sin uso",
    });
  });

  it("push should update existing rows and append new keys for the same locale", async () => {
    const loader = createCsvLoader();
    loader.setDefaultLocale("en");
    await loader.pull("en", sampleCsv);

    const updatedCsv = await loader.push("en", {
      hello: "Hello edited",
      newKey: "New Message",
    });

    const parsed = parse(updatedCsv, { columns: true, skip_empty_lines: true });
    expect(parsed).toEqual([
      { id: "hello", en: "Hello edited", es: "Hola" },
      { id: "bye", en: "Bye", es: "Adiós" },
      { id: "unused", en: "", es: "Sin uso" },
      { id: "", en: "New Message", es: "" },
    ]);
  });

  it("push should add a new locale column when pushing for a different locale", async () => {
    const loader = createCsvLoader();
    loader.setDefaultLocale("en");
    await loader.pull("en", sampleCsv);

    const esCsv = await loader.push("es", {
      hello: "Hola",
      bye: "Adiós",
    });

    const parsed = parse(esCsv, { columns: true, skip_empty_lines: true });
    expect(parsed).toEqual([
      { id: "hello", en: "Hello", es: "Hola" },
      { id: "bye", en: "Bye", es: "Adiós" },
      { id: "unused", en: "", es: "Sin uso" },
    ]);
  });

  it("push should add a completely new locale column when it previously didn't exist", async () => {
    const loader = createCsvLoader();
    loader.setDefaultLocale("en");
    await loader.pull("en", sampleCsv); // sampleCsv only has en & es columns

    const frCsv = await loader.push("fr", {
      hello: "Bonjour",
      bye: "Au revoir",
    });

    const parsed = parse(frCsv, { columns: true, skip_empty_lines: true });
    // Expect new column 'fr' to exist alongside existing ones, with empty strings when no translation provided
    expect(parsed).toEqual([
      { id: "hello", en: "Hello", es: "Hola", fr: "Bonjour" },
      { id: "bye", en: "Bye", es: "Adiós", fr: "Au revoir" },
      { id: "unused", en: "", es: "Sin uso", fr: "" },
    ]);
  });

  it("should throw an error if the first pull is not for the default locale", async () => {
    const loader = createCsvLoader();
    loader.setDefaultLocale("en");

    await expect(loader.pull("es", sampleCsv)).rejects.toThrow(
      "The first pull must be for the default locale",
    );
  });
});

```

--------------------------------------------------------------------------------
/packages/compiler/src/utils/invokations.spec.ts:
--------------------------------------------------------------------------------

```typescript
import { it, describe, expect } from "vitest";
import { parse } from "@babel/parser";
import * as t from "@babel/types";
import { findInvokations } from "./invokations";

describe("findInvokations", () => {
  it("should find named import invocation", () => {
    const ast = parseCode(`
      import { targetFunc } from 'target-module';
      
      function test() {
        targetFunc(1, 2);
        otherFunc();
      }
    `);

    const result = findInvokations(ast, {
      moduleName: "target-module",
      functionName: "targetFunc",
    });

    expect(result.length).toBe(1);
    expect(result[0].type).toBe("CallExpression");

    const callee = result[0].callee as t.Identifier;
    expect(callee.name).toBe("targetFunc");
  });

  it("should find default import invocation", () => {
    const ast = parseCode(`
      import defaultFunc from 'target-module';
      
      function test() {
        defaultFunc('test');
      }
    `);

    const result = findInvokations(ast, {
      moduleName: "target-module",
      functionName: "default",
    });

    expect(result.length).toBe(1);

    const callee = result[0].callee as t.Identifier;
    expect(callee.name).toBe("defaultFunc");
  });

  it("should find namespace import invocation", () => {
    const ast = parseCode(`
      import * as targetModule from 'target-module';
      
      function test() {
        targetModule.targetFunc();
        targetModule.otherFunc();
      }
    `);

    const result = findInvokations(ast, {
      moduleName: "target-module",
      functionName: "targetFunc",
    });

    expect(result.length).toBe(1);

    const callee = result[0].callee as t.MemberExpression;
    expect((callee.object as t.Identifier).name).toBe("targetModule");
    expect((callee.property as t.Identifier).name).toBe("targetFunc");
  });

  it("should find renamed import invocation", () => {
    const ast = parseCode(`
      import { targetFunc as renamedFunc } from 'target-module';
      
      function test() {
        renamedFunc();
      }
    `);

    const result = findInvokations(ast, {
      moduleName: "target-module",
      functionName: "targetFunc",
    });

    expect(result.length).toBe(1);

    const callee = result[0].callee as t.Identifier;
    expect(callee.name).toBe("renamedFunc");
  });

  it("should return empty array when no matching imports exist", () => {
    const ast = parseCode(`
      import { otherFunc } from 'other-module';
      
      function test() {
        otherFunc();
      }
    `);

    const result = findInvokations(ast, {
      moduleName: "target-module",
      functionName: "targetFunc",
    });

    expect(result.length).toBe(0);
  });

  it("should return empty array when import exists but not invoked", () => {
    const ast = parseCode(`
      import { targetFunc } from 'target-module';
      
      function test() {
        // No invocation here
      }
    `);

    const result = findInvokations(ast, {
      moduleName: "target-module",
      functionName: "targetFunc",
    });

    expect(result.length).toBe(0);
  });
});

function parseCode(code: string): t.File {
  return parse(code, {
    sourceType: "module",
    plugins: ["typescript"],
  });
}

```

--------------------------------------------------------------------------------
/packages/compiler/src/utils/jsx-functions.spec.ts:
--------------------------------------------------------------------------------

```typescript
import { parse } from "@babel/parser";
import traverse from "@babel/traverse";
import generate from "@babel/generator";
import { getJsxFunctions } from "./jsx-functions";
import { describe, expect, it } from "vitest";

function parseJSX(code: string) {
  return parse(code, {
    plugins: ["jsx"],
    sourceType: "module",
  });
}

describe("getJsxFunctions", () => {
  it("extracts simple function calls", () => {
    const ast = parseJSX("<div>{getName()}</div>");
    let result;

    traverse(ast, {
      JSXElement(path) {
        result = getJsxFunctions(path);
        path.stop();
      },
    });

    expect(generate(result).code).toBe('{\n  "getName": [getName()]\n}');
  });

  it("extracts function calls with arguments", () => {
    const ast = parseJSX("<div>{getName(user, 123)}</div>");
    let result;

    traverse(ast, {
      JSXElement(path) {
        result = getJsxFunctions(path);
        path.stop();
      },
    });

    expect(generate(result).code).toBe(
      '{\n  "getName": [getName(user, 123)]\n}',
    );
  });

  it("extracts multiple function calls", () => {
    const ast = parseJSX("<div>{getName(user)} {getCount()}</div>");
    let result;

    traverse(ast, {
      JSXElement(path) {
        result = getJsxFunctions(path);
        path.stop();
      },
    });

    expect(generate(result).code).toBe(
      '{\n  "getName": [getName(user)],\n  "getCount": [getCount()]\n}',
    );
  });

  it("ignores non-function expressions", () => {
    const ast = parseJSX("<div>{user.name} {getCount()}</div>");
    let result;

    traverse(ast, {
      JSXElement(path) {
        result = getJsxFunctions(path);
        path.stop();
      },
    });

    expect(generate(result).code).toBe('{\n  "getCount": [getCount()]\n}');
  });

  it("extracts function with chained names", () => {
    const ast = parseJSX(
      "<div>{getCount()} {user.details.products.items.map((item) => item.value).filter(value => value > 0)}</div>",
    );
    let result;

    traverse(ast, {
      JSXElement(path) {
        result = getJsxFunctions(path);
        path.stop();
      },
    });

    expect(generate(result!).code).toBe(
      '{\n  "getCount": [getCount()],\n  "user.details.products.items.map": [user.details.products.items.map(item => item.value).filter(value => value > 0)]\n}',
    );
  });

  it("extracts multiple usages of the same function", () => {
    const ast = parseJSX(
      "<div>{getCount(foo)} is more than {getCount(bar)} but less than {getCount(baz)}</div>",
    );
    let result;

    traverse(ast, {
      JSXElement(path) {
        result = getJsxFunctions(path);
        path.stop();
      },
    });

    expect(generate(result!).code).toBe(
      '{\n  "getCount": [getCount(foo), getCount(bar), getCount(baz)]\n}',
    );
  });

  it("should extract function calls on classes with 'new' keyword", () => {
    const ast = parseJSX("<div>&copy; {new Date().getFullYear()} vitest</div>");
    let result;
    traverse(ast, {
      JSXElement(path) {
        result = getJsxFunctions(path);
        path.stop();
      },
    });

    expect(generate(result!).code).toBe(
      '{\n  "Date.getFullYear": [new Date().getFullYear()]\n}',
    );
  });
});

```

--------------------------------------------------------------------------------
/scripts/docs/src/utils.ts:
--------------------------------------------------------------------------------

```typescript
import { existsSync } from "fs";
import path from "path";
import { fileURLToPath } from "url";
import { readFileSync } from "fs";
import { Octokit } from "@octokit/rest";
import * as prettier from "prettier";

export function getRepoRoot(): string {
  const __filename = fileURLToPath(import.meta.url);
  const __dirname = path.dirname(__filename);
  let currentDir = __dirname;

  while (currentDir !== path.parse(currentDir).root) {
    if (existsSync(path.join(currentDir, ".git"))) {
      return currentDir;
    }
    currentDir = path.dirname(currentDir);
  }

  throw new Error("Could not find project root");
}

export function getGitHubToken() {
  const token = process.env.GITHUB_TOKEN;

  if (!token) {
    throw new Error("GITHUB_TOKEN environment variable is required.");
  }

  return token;
}

export function getGitHubRepo() {
  const repository = process.env.GITHUB_REPOSITORY;

  if (!repository) {
    throw new Error("GITHUB_REPOSITORY environment variable is missing.");
  }

  const [_, repo] = repository.split("/");

  return repo;
}

export function getGitHubOwner() {
  const repository = process.env.GITHUB_REPOSITORY;

  if (!repository) {
    throw new Error("GITHUB_REPOSITORY environment variable is missing.");
  }

  const [owner] = repository.split("/");

  return owner;
}

export function getGitHubPRNumber() {
  const prNumber = process.env.PR_NUMBER;

  if (prNumber) {
    return Number(prNumber);
  }

  const eventPath = process.env.GITHUB_EVENT_PATH;

  if (eventPath && existsSync(eventPath)) {
    try {
      const eventData = JSON.parse(readFileSync(eventPath, "utf8"));
      return Number(eventData.pull_request?.number);
    } catch (err) {
      console.warn("Failed to parse GITHUB_EVENT_PATH JSON:", err);
    }
  }

  throw new Error("Could not determine pull request number.");
}

export type GitHubCommentOptions = {
  commentMarker: string;
  body: string;
};

export async function createOrUpdateGitHubComment(
  options: GitHubCommentOptions,
): Promise<void> {
  const token = getGitHubToken();
  const owner = getGitHubOwner();
  const repo = getGitHubRepo();
  const prNumber = getGitHubPRNumber();

  const octokit = new Octokit({ auth: token });

  const commentsResponse = await octokit.rest.issues.listComments({
    owner,
    repo,
    issue_number: prNumber,
    per_page: 100,
  });

  const comments = commentsResponse.data;

  const existing = comments.find((c) => {
    if (!c.body) {
      return false;
    }
    return c.body.startsWith(options.commentMarker);
  });

  if (existing) {
    console.log(`Updating existing comment (id: ${existing.id}).`);
    await octokit.rest.issues.updateComment({
      owner,
      repo,
      comment_id: existing.id,
      body: options.body,
    });
    return;
  }

  console.log("Creating new comment.");
  await octokit.rest.issues.createComment({
    owner,
    repo,
    issue_number: prNumber,
    body: options.body,
  });
}

export async function formatMarkdown(markdown: string): Promise<string> {
  const repoRoot = getRepoRoot();
  const prettierConfig = await prettier.resolveConfig(repoRoot);
  return await prettier.format(markdown, {
    ...prettierConfig,
    parser: "markdown",
  });
}

```

--------------------------------------------------------------------------------
/packages/cli/src/cli/loaders/ensure-key-order.spec.ts:
--------------------------------------------------------------------------------

```typescript
import { describe, it, expect } from "vitest";
import createEnsureKeyOrderLoader from "./ensure-key-order";

describe("ensure-key-order loader", () => {
  const loader = createEnsureKeyOrderLoader();
  loader.setDefaultLocale("en");

  it("should return input unchanged on pull", async () => {
    const input = { b: 1, a: 2 };
    const result = await loader.pull("en", input);
    expect(result).toEqual(input);
  });

  it("should reorder keys to match original input order on push", async () => {
    const originalInput = { a: 1, b: 2, c: 3 };
    await loader.pull("en", originalInput);
    const data = { b: 22, a: 11, c: 33 };
    const result = await loader.push("en", data);
    expect(result).toEqual({ a: 11, b: 22, c: 33 });
  });

  it("should reorder keys in objects of nested arrays to match original input order on push", async () => {
    const originalInput = [
      { a: 1, b: 2, c: 3 },
      { a: 4, b: 5, c: 6 },
      {
        values: [
          { a: 7, b: 8, c: 9 },
          { a: 10, b: 11, c: 12 },
        ],
      },
    ];
    await loader.pull("en", originalInput);
    const data = [
      { b: 22, a: 11, c: 33 },
      { b: 55, c: 66, a: 44 },
      {
        values: [
          { b: 88, c: 99, a: 77 },
          { c: 122, b: 111, a: 100 },
        ],
      },
    ];
    const result = await loader.push("en", data);
    expect(result).toEqual([
      { a: 11, b: 22, c: 33 },
      { a: 44, b: 55, c: 66 },
      {
        values: [
          { a: 77, b: 88, c: 99 },
          { a: 100, b: 111, c: 122 },
        ],
      },
    ]);
  });

  it("should reorder falsy keys to match original input order on push", async () => {
    const originalInput = {
      a: 1,
      b: 0,
      c: null,
      d: "a",
      e: false,
      g: "",
      h: undefined,
    };
    await loader.pull("en", originalInput);
    const data = {
      b: 0,
      a: 11,
      c: null,
      d: "b",
      e: false,
      g: "",
      h: undefined,
    };
    const result = await loader.push("en", data);
    expect(result).toEqual({
      a: 11,
      b: 0,
      c: null,
      d: "b",
      e: false,
      g: "",
      h: undefined,
    });
  });

  it("should handle nested objects and preserve key order", async () => {
    const originalInput = { x: { b: 2, a: 1 }, y: 3, z: { d: 9, f: 7, e: 8 } };
    await loader.pull("en", originalInput);
    const data = { x: { a: 11, b: 22 }, z: { d: 99, e: 88, f: 77 }, y: 33 };
    const result = await loader.push("en", data);
    expect(result).toEqual({
      x: { b: 22, a: 11 },
      y: 33,
      z: { d: 99, e: 88, f: 77 },
    });
  });

  it("should skip keys not in original input of source locale", async () => {
    const originalInput = { a: 1, b: 2 };
    await loader.pull("en", originalInput);
    const data = { a: 11, b: 22, c: 33 };
    const result = await loader.push("en", data);
    expect(result).toEqual({ a: 11, b: 22 });
  });

  it("should skip keys not in the target locale data", async () => {
    const originalInput = { a: 1, b: 2, c: 2 };
    await loader.pull("en", originalInput);
    const data = { a: 11, c: 33 };
    const result = await loader.push("en", data);
    expect(result).toEqual({ a: 11, c: 33 });
  });
});

```

--------------------------------------------------------------------------------
/packages/cli/src/cli/utils/exec.spec.ts:
--------------------------------------------------------------------------------

```typescript
import { describe, it, expect, vi } from "vitest";
import { execAsync, ExecAsyncOptions } from "./exec";

// describe('execAsync', () => {
//   // Helper function to create a delayed async function
//   const createDelayedFunction = (value: any, delay: number) => {
//     return async () => {
//       console.log(`[${Date.now()}] start`, value);
//       await new Promise(resolve => setTimeout(resolve, delay));
//       console.log(`[${Date.now()}] end`, value);
//       return value;
//     };
//   };

//   it('run', async () => {
//     await execAsync([
//       createDelayedFunction(1, 750),
//       createDelayedFunction(2, 750),
//       createDelayedFunction(3, 750),
//       createDelayedFunction(4, 750),
//     ], {
//       concurrency: 2,
//       delay: 250,
//     });
//   });
// });

describe("execAsync", () => {
  it("executes all functions and returns their results", async () => {
    const fns = [async () => 1, async () => 2, async () => 3];
    const options: ExecAsyncOptions = { concurrency: 1, delay: 0 };
    const results = await execAsync(fns, options);
    expect(results).toEqual([1, 2, 3]);
  });

  it("calls onProgress with correct values", async () => {
    const fns = [async () => 1, async () => 2, async () => 3];
    const onProgress = vi.fn();
    const options: ExecAsyncOptions = { concurrency: 1, delay: 0, onProgress };
    await execAsync(fns, options);
    expect(onProgress).toHaveBeenCalledTimes(4);
    expect(onProgress).toHaveBeenNthCalledWith(1, 0, 3);
    expect(onProgress).toHaveBeenNthCalledWith(2, 1, 3);
    expect(onProgress).toHaveBeenNthCalledWith(3, 2, 3);
    expect(onProgress).toHaveBeenNthCalledWith(4, 3, 3);
  });

  it("starts next function if previous finishes before delay", async () => {
    const delay = 100;
    const fns = [
      vi.fn().mockResolvedValue(1),
      vi
        .fn()
        .mockImplementation(
          () => new Promise((resolve) => setTimeout(() => resolve(2), 50)),
        ),
      vi.fn().mockResolvedValue(3),
    ];
    const options: ExecAsyncOptions = { concurrency: 1, delay };
    const start = Date.now();
    await execAsync(fns, options);
    const end = Date.now();
    expect(end - start).toBeLessThan(delay * 3);
  });

  it("respects concurrency limit", async () => {
    const concurrency = 2;
    const delay = 100;
    let maxConcurrent = 0;
    let currentConcurrent = 0;

    const fns = Array(5)
      .fill(null)
      .map(() => async () => {
        currentConcurrent++;
        maxConcurrent = Math.max(maxConcurrent, currentConcurrent);
        await new Promise((resolve) => setTimeout(resolve, delay));
        currentConcurrent--;
      });

    const options: ExecAsyncOptions = { concurrency, delay: 0 };
    await execAsync(fns, options);
    expect(maxConcurrent).toBe(concurrency);
  });

  it("handles empty array of functions", async () => {
    const options: ExecAsyncOptions = { concurrency: 1, delay: 0 };
    const results = await execAsync([], options);
    expect(results).toEqual([]);
  });

  it("handles single function", async () => {
    const fn = async () => 42;
    const options: ExecAsyncOptions = { concurrency: 1, delay: 0 };
    const results = await execAsync([fn], options);
    expect(results).toEqual([42]);
  });
});

```

--------------------------------------------------------------------------------
/packages/locales/src/names/index.ts:
--------------------------------------------------------------------------------

```typescript
import {
  loadTerritoryNames,
  loadLanguageNames,
  loadScriptNames,
} from "./loader";

/**
 * Gets a country name in the specified display language
 *
 * @param countryCode - The ISO country code (e.g., "US", "CN", "DE")
 * @param displayLanguage - The language to display the name in (default: "en")
 * @returns Promise<string> - The localized country name
 *
 * @example
 * ```typescript
 * // Default English
 * await getCountryName("US");           // "United States"
 * await getCountryName("CN");           // "China"
 *
 * // Spanish
 * await getCountryName("US", "es");     // "Estados Unidos"
 * await getCountryName("CN", "es");     // "China"
 *
 * // French
 * await getCountryName("US", "fr");     // "États-Unis"
 * ```
 */
export async function getCountryName(
  countryCode: string,
  displayLanguage: string = "en",
): Promise<string> {
  if (!countryCode) {
    throw new Error("Country code is required");
  }

  const territories = await loadTerritoryNames(displayLanguage);
  const name = territories[countryCode.toUpperCase()];

  if (!name) {
    throw new Error(`Country code "${countryCode}" not found`);
  }

  return name;
}

/**
 * Gets a language name in the specified display language
 *
 * @param languageCode - The ISO language code (e.g., "en", "zh", "es")
 * @param displayLanguage - The language to display the name in (default: "en")
 * @returns Promise<string> - The localized language name
 *
 * @example
 * ```typescript
 * // Default English
 * await getLanguageName("en");          // "English"
 * await getLanguageName("zh");          // "Chinese"
 *
 * // Spanish
 * await getLanguageName("en", "es");    // "inglés"
 * await getLanguageName("zh", "es");    // "chino"
 *
 * // Chinese
 * await getLanguageName("en", "zh");    // "英语"
 * ```
 */
export async function getLanguageName(
  languageCode: string,
  displayLanguage: string = "en",
): Promise<string> {
  if (!languageCode) {
    throw new Error("Language code is required");
  }

  const languages = await loadLanguageNames(displayLanguage);
  const name = languages[languageCode.toLowerCase()];

  if (!name) {
    throw new Error(`Language code "${languageCode}" not found`);
  }

  return name;
}

/**
 * Gets a script name in the specified display language
 *
 * @param scriptCode - The ISO script code (e.g., "Hans", "Hant", "Latn")
 * @param displayLanguage - The language to display the name in (default: "en")
 * @returns Promise<string> - The localized script name
 *
 * @example
 * ```typescript
 * // Default English
 * await getScriptName("Hans");          // "Simplified"
 * await getScriptName("Hant");          // "Traditional"
 * await getScriptName("Latn");          // "Latin"
 *
 * // Spanish
 * await getScriptName("Hans", "es");    // "simplificado"
 * await getScriptName("Cyrl", "es");    // "cirílico"
 *
 * // Chinese
 * await getScriptName("Latn", "zh");    // "拉丁文"
 * ```
 */
export async function getScriptName(
  scriptCode: string,
  displayLanguage: string = "en",
): Promise<string> {
  if (!scriptCode) {
    throw new Error("Script code is required");
  }

  const scripts = await loadScriptNames(displayLanguage);
  const name = scripts[scriptCode];

  if (!name) {
    throw new Error(`Script code "${scriptCode}" not found`);
  }

  return name;
}

```

--------------------------------------------------------------------------------
/packages/compiler/src/utils/jsx-attribute-scope.ts:
--------------------------------------------------------------------------------

```typescript
import * as t from "@babel/types";
import traverse from "@babel/traverse";
import { NodePath } from "@babel/traverse";

export function collectJsxAttributeScopes(
  node: t.Node,
): Array<[NodePath<t.JSXElement>, string[]]> {
  const result: Array<[NodePath<t.JSXElement>, string[]]> = [];

  traverse(node, {
    JSXElement(path: NodePath<t.JSXElement>) {
      if (!hasJsxAttributeScopeAttribute(path)) return;

      const localizableAttributes = getJsxAttributeScopeAttribute(path);
      if (!localizableAttributes) return;

      result.push([path, localizableAttributes]);
    },
  });

  return result;
}

export function getJsxAttributeScopes(
  node: t.Node,
): Array<[NodePath<t.JSXElement>, string[]]> {
  const result: Array<[NodePath<t.JSXElement>, string[]]> = [];

  // List of attributes that should be considered localizable
  const LOCALIZABLE_ATTRIBUTES = [
    "title",
    "aria-label",
    "aria-description",
    "alt",
    "label",
    "description",
    "placeholder",
    "content",
    "subtitle",
  ];

  traverse(node, {
    JSXElement(path: NodePath<t.JSXElement>) {
      const openingElement = path.node.openingElement;

      // Only process lowercase HTML elements (not components)
      const elementName = openingElement.name;
      if (!t.isJSXIdentifier(elementName) || !elementName.name) {
        return;
      }

      const hasAttributeScope = openingElement.attributes.find(
        (attr) =>
          t.isJSXAttribute(attr) &&
          attr.name.name === "data-jsx-attribute-scope",
      );
      if (hasAttributeScope) {
        return;
      }

      // Find all localizable attributes
      const localizableAttrs = openingElement.attributes
        .filter(
          (
            attr: t.JSXAttribute | t.JSXSpreadAttribute,
          ): attr is t.JSXAttribute => {
            if (!t.isJSXAttribute(attr) || !t.isStringLiteral(attr.value)) {
              return false;
            }

            const name = attr.name.name;
            return (
              typeof name === "string" && LOCALIZABLE_ATTRIBUTES.includes(name)
            );
          },
        )
        .map((attr: t.JSXAttribute) => attr.name.name as string);

      // Only add the element if we found localizable attributes
      if (localizableAttrs.length > 0) {
        result.push([path, localizableAttrs]);
      }
    },
  });

  return result;
}

export function hasJsxAttributeScopeAttribute(path: NodePath<t.JSXElement>) {
  return !!getJsxAttributeScopeAttribute(path);
}

export function getJsxAttributeScopeAttribute(path: NodePath<t.JSXElement>) {
  const attribute = path.node.openingElement.attributes.find(
    (attr) =>
      attr.type === "JSXAttribute" &&
      attr.name.name === "data-jsx-attribute-scope",
  );

  if (!attribute || !t.isJSXAttribute(attribute)) {
    return undefined;
  }

  // Handle array of string literals
  if (
    t.isJSXExpressionContainer(attribute.value) &&
    t.isArrayExpression(attribute.value.expression)
  ) {
    const arrayExpr = attribute.value.expression;
    return arrayExpr.elements
      .filter((el): el is t.StringLiteral => t.isStringLiteral(el))
      .map((el) => el.value);
  }

  // Fallback for single string literal
  if (t.isStringLiteral(attribute.value)) {
    return [attribute.value.value];
  }

  return undefined;
}

```

--------------------------------------------------------------------------------
/packages/compiler/src/jsx-provider.ts:
--------------------------------------------------------------------------------

```typescript
import traverse, { NodePath } from "@babel/traverse";
import * as t from "@babel/types";
import { CompilerPayload, createCodeMutation } from "./_base";
import { getJsxElementName } from "./utils/jsx-element";
import { getModuleExecutionMode, getOrCreateImport } from "./utils";
import { ModuleId } from "./_const";

/**
 * This mutation is used to wrap the html component with the LingoProvider component.
 * It only works with server components.
 */
const jsxProviderMutation = createCodeMutation((payload) => {
  traverse(payload.ast, {
    JSXElement: (path) => {
      if (getJsxElementName(path)?.toLowerCase() === "html") {
        const mode = getModuleExecutionMode(payload.ast, payload.params.rsc);
        if (mode === "client") {
          return;
        }

        // TODO: later
        // replaceHtmlComponent(payload, path);

        const lingoProviderImport = getOrCreateImport(payload.ast, {
          moduleName: ModuleId.ReactRSC,
          exportedName: "LingoProvider",
        });
        const loadDictionaryImport = getOrCreateImport(payload.ast, {
          moduleName: ModuleId.ReactRSC,
          exportedName: "loadDictionary",
        });

        const loadDictionaryArrow = t.arrowFunctionExpression(
          [t.identifier("locale")],
          t.callExpression(t.identifier(loadDictionaryImport.importedName), [
            t.identifier("locale"),
          ]),
        );

        const providerProps = [
          t.jsxAttribute(
            t.jsxIdentifier("loadDictionary"),
            t.jsxExpressionContainer(loadDictionaryArrow),
          ),
        ];

        const provider = t.jsxElement(
          t.jsxOpeningElement(
            t.jsxIdentifier(lingoProviderImport.importedName),
            providerProps,
            false,
          ),
          t.jsxClosingElement(
            t.jsxIdentifier(lingoProviderImport.importedName),
          ),
          [path.node],
          false,
        );

        path.replaceWith(provider);
        path.skip();
      }
    },
  });

  return payload;
});

export default jsxProviderMutation;

function replaceHtmlComponent(
  payload: CompilerPayload,
  path: NodePath<t.JSXElement>,
) {
  // Find the parent function and make it async since locale is retrieved from cookies asynchronously
  const parentFunction = path.findParent(
    (p): p is NodePath<t.FunctionDeclaration | t.ArrowFunctionExpression> =>
      t.isFunctionDeclaration(p.node) || t.isArrowFunctionExpression(p.node),
  );
  if (
    parentFunction?.node.type === "FunctionDeclaration" ||
    parentFunction?.node.type === "ArrowFunctionExpression"
  ) {
    parentFunction.node.async = true;
  }

  // html lang attribute
  const loadLocaleFromCookiesImport = getOrCreateImport(payload.ast, {
    moduleName: ModuleId.ReactRSC,
    exportedName: "loadLocaleFromCookies",
  });
  let langAttribute = path.node.openingElement.attributes.find(
    (attr) => attr.type === "JSXAttribute" && attr.name.name === "lang",
  );
  if (!t.isJSXAttribute(langAttribute)) {
    (langAttribute = t.jsxAttribute(
      t.jsxIdentifier("lang"),
      t.stringLiteral(""),
    )),
      path.node.openingElement.attributes.push(langAttribute);
  }
  langAttribute.value = t.jsxExpressionContainer(
    t.awaitExpression(
      t.callExpression(
        t.identifier(loadLocaleFromCookiesImport.importedName),
        [],
      ),
    ),
  );
}

```

--------------------------------------------------------------------------------
/demo/adonisjs/adonisrc.ts:
--------------------------------------------------------------------------------

```typescript
import { defineConfig } from '@adonisjs/core/app'

export default defineConfig({
  /*
  |--------------------------------------------------------------------------
  | Experimental flags
  |--------------------------------------------------------------------------
  |
  | The following features will be enabled by default in the next major release
  | of AdonisJS. You can opt into them today to avoid any breaking changes
  | during upgrade.
  |
  */
  experimental: {
    mergeMultipartFieldsAndFiles: true,
    shutdownInReverseOrder: true,
  },

  /*
  |--------------------------------------------------------------------------
  | Commands
  |--------------------------------------------------------------------------
  |
  | List of ace commands to register from packages. The application commands
  | will be scanned automatically from the "./commands" directory.
  |
  */
  commands: [() => import('@adonisjs/core/commands')],

  /*
  |--------------------------------------------------------------------------
  | Service providers
  |--------------------------------------------------------------------------
  |
  | List of service providers to import and register when booting the
  | application
  |
  */
  providers: [
    () => import('@adonisjs/core/providers/app_provider'),
    () => import('@adonisjs/core/providers/hash_provider'),
    {
      file: () => import('@adonisjs/core/providers/repl_provider'),
      environment: ['repl', 'test'],
    },
    () => import('@adonisjs/core/providers/vinejs_provider'),
    () => import('@adonisjs/core/providers/edge_provider'),
    () => import('@adonisjs/session/session_provider'),
    () => import('@adonisjs/vite/vite_provider'),
    () => import('@adonisjs/shield/shield_provider'),
    () => import('@adonisjs/static/static_provider'),
    () => import('@adonisjs/cors/cors_provider'),
    () => import('@adonisjs/inertia/inertia_provider'),
  ],

  /*
  |--------------------------------------------------------------------------
  | Preloads
  |--------------------------------------------------------------------------
  |
  | List of modules to import before starting the application.
  |
  */
  preloads: [() => import('#start/routes'), () => import('#start/kernel')],

  /*
  |--------------------------------------------------------------------------
  | Tests
  |--------------------------------------------------------------------------
  |
  | List of test suites to organize tests by their type. Feel free to remove
  | and add additional suites.
  |
  */
  tests: {
    suites: [
      {
        files: ['tests/unit/**/*.spec(.ts|.js)'],
        name: 'unit',
        timeout: 2000,
      },
      {
        files: ['tests/functional/**/*.spec(.ts|.js)'],
        name: 'functional',
        timeout: 30000,
      },
    ],
    forceExit: false,
  },

  /*
  |--------------------------------------------------------------------------
  | Metafiles
  |--------------------------------------------------------------------------
  |
  | A collection of files you want to copy to the build folder when creating
  | the production build.
  |
  */
  metaFiles: [
    {
      pattern: 'resources/views/**/*.edge',
      reloadServer: false,
    },
    {
      pattern: 'public/**',
      reloadServer: false,
    },
  ],

  assetsBundler: false,
  hooks: {
    onBuildStarting: [() => import('@adonisjs/vite/build_hook')],
  },
})

```

--------------------------------------------------------------------------------
/packages/cli/src/cli/cmd/ci/platforms/gitlab.ts:
--------------------------------------------------------------------------------

```typescript
import { Gitlab } from "@gitbeaker/rest";
import Z from "zod";
import { PlatformKit } from "./_base";

const gl = new Gitlab({ token: "" });

export class GitlabPlatformKit extends PlatformKit {
  private _gitlab?: InstanceType<typeof Gitlab>;

  constructor() {
    super();

    // change directory to current repository before executing replexica
    process.chdir(this.platformConfig.projectDir);
  }

  private get gitlab(): InstanceType<typeof Gitlab> {
    if (!this._gitlab) {
      this._gitlab = new Gitlab({
        token: this.platformConfig.glToken || "",
      });
    }
    return this._gitlab;
  }

  get platformConfig() {
    const env = Z.object({
      GL_TOKEN: Z.string().optional(),
      CI_COMMIT_BRANCH: Z.string(),
      CI_MERGE_REQUEST_SOURCE_BRANCH_NAME: Z.string().optional(),
      CI_PROJECT_NAMESPACE: Z.string(),
      CI_PROJECT_NAME: Z.string(),
      CI_PROJECT_ID: Z.string(),
      CI_PROJECT_DIR: Z.string(),
      CI_REPOSITORY_URL: Z.string(),
    }).parse(process.env);

    const config = {
      glToken: env.GL_TOKEN,
      baseBranchName:
        env.CI_MERGE_REQUEST_SOURCE_BRANCH_NAME ?? env.CI_COMMIT_BRANCH,
      repositoryOwner: env.CI_PROJECT_NAMESPACE,
      repositoryName: env.CI_PROJECT_NAME,
      gitlabProjectId: env.CI_PROJECT_ID,
      projectDir: env.CI_PROJECT_DIR,
      reporitoryUrl: env.CI_REPOSITORY_URL,
    };

    return config;
  }

  async branchExists({ branch }: { branch: string }): Promise<boolean> {
    try {
      await this.gitlab.Branches.show(
        this.platformConfig.gitlabProjectId,
        branch,
      );
      return true;
    } catch {
      return false;
    }
  }

  async getOpenPullRequestNumber({
    branch,
  }: {
    branch: string;
  }): Promise<number | undefined> {
    const mergeRequests = await this.gitlab.MergeRequests.all({
      projectId: this.platformConfig.gitlabProjectId,
      sourceBranch: branch,
      state: "opened",
    });
    return mergeRequests[0]?.iid;
  }

  async closePullRequest({
    pullRequestNumber,
  }: {
    pullRequestNumber: number;
  }): Promise<void> {
    await this.gitlab.MergeRequests.edit(
      this.platformConfig.gitlabProjectId,
      pullRequestNumber,
      {
        stateEvent: "close",
      },
    );
  }

  async createPullRequest({
    head,
    title,
    body,
  }: {
    head: string;
    title: string;
    body?: string;
  }): Promise<number> {
    const mr = await this.gitlab.MergeRequests.create(
      this.platformConfig.gitlabProjectId,
      head,
      this.platformConfig.baseBranchName,
      title,
      {
        description: body,
      },
    );
    return mr.iid;
  }

  async commentOnPullRequest({
    pullRequestNumber,
    body,
  }: {
    pullRequestNumber: number;
    body: string;
  }): Promise<void> {
    await this.gitlab.MergeRequestNotes.create(
      this.platformConfig.gitlabProjectId,
      pullRequestNumber,
      body,
    );
  }

  gitConfig(): Promise<void> | void {
    const glToken = this.platformConfig.glToken;
    const url = `https://oauth2:${glToken}@gitlab.com/${this.platformConfig.repositoryOwner}/${this.platformConfig.repositoryName}.git`;

    super.gitConfig(glToken, url);
  }

  buildPullRequestUrl(pullRequestNumber: number): string {
    return `https://gitlab.com/${this.platformConfig.repositoryOwner}/${this.platformConfig.repositoryName}/-/merge_requests/${pullRequestNumber}`;
  }
}

```

--------------------------------------------------------------------------------
/demo/adonisjs/inertia/lingo/meta.json:
--------------------------------------------------------------------------------

```json
{
  "files": {
    "pages/errors/not_found.tsx": {
      "scopes": {
        "1/declaration/body/0/argument/1/1": {
          "type": "element",
          "hash": "97612e6230bc7a1ebd99380bf561b732",
          "context": "",
          "skip": false,
          "overrides": {},
          "content": "Page not found"
        },
        "1/declaration/body/0/argument/1/3": {
          "type": "element",
          "hash": "7b6bcd0a4f23e42eeb0c972c2004efad",
          "context": "",
          "skip": false,
          "overrides": {},
          "content": "This page does not exist."
        }
      }
    },
    "pages/errors/server_error.tsx": {
      "scopes": {
        "1/declaration/body/0/argument/1/1": {
          "type": "element",
          "hash": "d574aa7e2d84d112dc79ac0e59d794cf",
          "context": "",
          "skip": false,
          "overrides": {},
          "content": "Server Error"
        }
      }
    },
    "pages/home.tsx": {
      "scopes": {
        "2/declaration/body/0/argument/1-title": {
          "type": "attribute",
          "hash": "7c2d68be7446e6de191c11d53f1e07b4",
          "context": "",
          "skip": false,
          "overrides": {},
          "content": "Homepage"
        },
        "2/declaration/body/0/argument/3/1/1": {
          "type": "element",
          "hash": "0468579ef2fbc83c9d520c2f2f1c5059",
          "context": "",
          "skip": false,
          "overrides": {},
          "content": "Hello, world!"
        },
        "2/declaration/body/0/argument/3/1/3": {
          "type": "element",
          "hash": "82b29979a52b215b94b2e811e8c03005",
          "context": "",
          "skip": false,
          "overrides": {},
          "content": "This is an example app that demonstrates how <element:strong>Lingo.dev Compiler</element:strong> can be used to localize apps built with <element:a>AdonisJS</element:a> ."
        },
        "2/declaration/body/0/argument/3/1/5": {
          "type": "element",
          "hash": "9ffb5f98cf11c88f3903e060f4028b46",
          "context": "",
          "skip": false,
          "overrides": {},
          "content": "To switch between locales, use the following dropdown:"
        },
        "3/declaration/body/0/argument/1-title": {
          "type": "attribute",
          "hash": "7c2d68be7446e6de191c11d53f1e07b4",
          "context": "",
          "skip": false,
          "overrides": {},
          "content": "Homepage"
        },
        "3/declaration/body/0/argument/3/1/1": {
          "type": "element",
          "hash": "0468579ef2fbc83c9d520c2f2f1c5059",
          "context": "",
          "skip": false,
          "overrides": {},
          "content": "Hello, world!"
        },
        "3/declaration/body/0/argument/3/1/3": {
          "type": "element",
          "hash": "82b29979a52b215b94b2e811e8c03005",
          "context": "",
          "skip": false,
          "overrides": {},
          "content": "This is an example app that demonstrates how <element:strong>Lingo.dev Compiler</element:strong> can be used to localize apps built with <element:a>AdonisJS</element:a> ."
        },
        "3/declaration/body/0/argument/3/1/5": {
          "type": "element",
          "hash": "9ffb5f98cf11c88f3903e060f4028b46",
          "context": "",
          "skip": false,
          "overrides": {},
          "content": "To switch between locales, use the following dropdown:"
        }
      }
    }
  }
}

```

--------------------------------------------------------------------------------
/packages/cli/src/cli/utils/key-matching.spec.ts:
--------------------------------------------------------------------------------

```typescript
import { describe, it, expect } from "vitest";
import {
  matchesKeyPattern,
  filterEntriesByPattern,
  formatDisplayValue,
} from "./key-matching";

describe("matchesKeyPattern", () => {
  it("should match keys with prefix matching", () => {
    const patterns = ["api", "settings"];

    expect(matchesKeyPattern("api/users", patterns)).toBe(true);
    expect(matchesKeyPattern("api/posts", patterns)).toBe(true);
    expect(matchesKeyPattern("settings/theme", patterns)).toBe(true);
    expect(matchesKeyPattern("other/key", patterns)).toBe(false);
  });

  it("should match keys with glob patterns", () => {
    const patterns = ["api/*/users", "settings/*"];

    expect(matchesKeyPattern("api/v1/users", patterns)).toBe(true);
    expect(matchesKeyPattern("api/v2/users", patterns)).toBe(true);
    expect(matchesKeyPattern("settings/theme", patterns)).toBe(true);
    expect(matchesKeyPattern("settings/notifications", patterns)).toBe(true);
    expect(matchesKeyPattern("api/users", patterns)).toBe(false);
  });

  it("should return false for empty patterns", () => {
    expect(matchesKeyPattern("any/key", [])).toBe(false);
  });

  it("should handle complex glob patterns", () => {
    const patterns = ["steps/*/type", "learningGoals/*/goal"];

    expect(matchesKeyPattern("steps/0/type", patterns)).toBe(true);
    expect(matchesKeyPattern("steps/1/type", patterns)).toBe(true);
    expect(matchesKeyPattern("learningGoals/0/goal", patterns)).toBe(true);
    expect(matchesKeyPattern("steps/0/name", patterns)).toBe(false);
  });
});

describe("filterEntriesByPattern", () => {
  it("should filter entries that match patterns", () => {
    const entries: [string, any][] = [
      ["api/users", "Users API"],
      ["api/posts", "Posts API"],
      ["settings/theme", "Dark"],
      ["other/key", "Value"],
    ];
    const patterns = ["api", "settings"];

    const result = filterEntriesByPattern(entries, patterns);

    expect(result).toHaveLength(3);
    expect(result).toEqual([
      ["api/users", "Users API"],
      ["api/posts", "Posts API"],
      ["settings/theme", "Dark"],
    ]);
  });

  it("should return empty array when no matches", () => {
    const entries: [string, any][] = [
      ["key1", "value1"],
      ["key2", "value2"],
    ];
    const patterns = ["nonexistent"];

    const result = filterEntriesByPattern(entries, patterns);

    expect(result).toHaveLength(0);
  });
});

describe("formatDisplayValue", () => {
  it("should return short strings as-is", () => {
    expect(formatDisplayValue("Hello")).toBe("Hello");
    expect(formatDisplayValue("Short text")).toBe("Short text");
  });

  it("should truncate long strings", () => {
    const longString = "a".repeat(100);
    const result = formatDisplayValue(longString);

    expect(result).toHaveLength(53); // 50 chars + "..."
    expect(result.endsWith("...")).toBe(true);
  });

  it("should use custom max length", () => {
    const text = "Hello, World!";
    const result = formatDisplayValue(text, 5);

    expect(result).toBe("Hello...");
  });

  it("should stringify non-string values", () => {
    expect(formatDisplayValue(42)).toBe("42");
    expect(formatDisplayValue(true)).toBe("true");
    expect(formatDisplayValue({ key: "value" })).toBe('{"key":"value"}');
    expect(formatDisplayValue(null)).toBe("null");
  });

  it("should handle arrays", () => {
    expect(formatDisplayValue([1, 2, 3])).toBe("[1,2,3]");
  });
});

```

--------------------------------------------------------------------------------
/packages/compiler/src/jsx-attribute-scope-inject.ts:
--------------------------------------------------------------------------------

```typescript
import { createCodeMutation } from "./_base";
import { getModuleExecutionMode, getOrCreateImport } from "./utils";
import * as t from "@babel/types";
import _ from "lodash";
import { ModuleId } from "./_const";
import { getJsxElementName, getNestedJsxElements } from "./utils/jsx-element";
import { collectJsxAttributeScopes } from "./utils/jsx-attribute-scope";
import { setJsxAttributeValue } from "./utils/jsx-attribute";

export const lingoJsxAttributeScopeInjectMutation = createCodeMutation(
  (payload) => {
    const mode = getModuleExecutionMode(payload.ast, payload.params.rsc);
    const jsxAttributeScopes = collectJsxAttributeScopes(payload.ast);

    for (const [jsxScope, attributes] of jsxAttributeScopes) {
      // Import LingoComponent based on the module execution mode
      const packagePath =
        mode === "client" ? ModuleId.ReactClient : ModuleId.ReactRSC;
      const lingoComponentImport = getOrCreateImport(payload.ast, {
        moduleName: packagePath,
        exportedName: "LingoAttributeComponent",
      });

      // Get the original JSX element name
      const originalJsxElementName = getJsxElementName(jsxScope);
      if (!originalJsxElementName) {
        continue;
      }

      // Replace the name with the lingo component
      jsxScope.node.openingElement.name = t.jsxIdentifier(
        lingoComponentImport.importedName,
      );
      if (jsxScope.node.closingElement) {
        jsxScope.node.closingElement.name = t.jsxIdentifier(
          lingoComponentImport.importedName,
        );
      }

      // Add $attrAs ($as) prop
      const as = /^[A-Z]/.test(originalJsxElementName)
        ? t.jsxExpressionContainer(t.identifier(originalJsxElementName))
        : t.stringLiteral(originalJsxElementName);

      jsxScope.node.openingElement.attributes.push(
        t.jsxAttribute(t.jsxIdentifier("$attrAs"), as),
      );

      // Add $fileKey prop
      setJsxAttributeValue(jsxScope, "$fileKey", payload.relativeFilePath);

      // Add $attributes prop
      setJsxAttributeValue(
        jsxScope,
        "$attributes",
        t.objectExpression(
          attributes.map((attributeDefinition) => {
            const [attribute, key = ""] = attributeDefinition.split(":");
            return t.objectProperty(
              t.stringLiteral(attribute),
              t.stringLiteral(key),
            );
          }),
        ),
      );

      // // Extract $variables from original JSX scope
      // const $variables = getJsxVariables(originalJsxScope);
      // if ($variables.properties.length > 0) {
      //   setJsxAttributeValue(jsxScope, "$variables", $variables);
      // }

      // // Extract nested JSX elements
      // const $elements = getNestedJsxElements(originalJsxScope);
      // if ($elements.elements.length > 0) {
      //   setJsxAttributeValue(jsxScope, "$elements", $elements);
      // }

      if (mode === "server") {
        // Add $loadDictionary prop
        const loadDictionaryImport = getOrCreateImport(payload.ast, {
          exportedName: "loadDictionary",
          moduleName: ModuleId.ReactRSC,
        });
        setJsxAttributeValue(
          jsxScope,
          "$loadDictionary",
          t.arrowFunctionExpression(
            [t.identifier("locale")],
            t.callExpression(t.identifier(loadDictionaryImport.importedName), [
              t.identifier("locale"),
            ]),
          ),
        );
      }
    }

    return payload;
  },
);

```

--------------------------------------------------------------------------------
/packages/cli/src/cli/loaders/formatters/biome.ts:
--------------------------------------------------------------------------------

```typescript
import path from "path";
import fs from "fs/promises";
import { Biome, Distribution } from "@biomejs/js-api";
import { parse as parseJsonc } from "jsonc-parser";
import { ILoader } from "../_types";
import { createBaseFormatterLoader } from "./_base";

export type BiomeLoaderOptions = {
  bucketPathPattern: string;
  stage?: "pull" | "push" | "both";
  alwaysFormat?: boolean;
};

export default function createBiomeLoader(
  options: BiomeLoaderOptions,
): ILoader<string, string> {
  return createBaseFormatterLoader(options, async (data, filePath) => {
    return await formatDataWithBiome(data, filePath, options);
  });
}

async function findBiomeConfig(startPath: string): Promise<string | null> {
  let currentDir = path.dirname(startPath);
  const root = path.parse(currentDir).root;

  while (currentDir !== root) {
    for (const configName of ["biome.json", "biome.jsonc"]) {
      const configPath = path.join(currentDir, configName);
      try {
        await fs.access(configPath);
        return configPath;
      } catch {
        // Config file doesn't exist, continue searching
      }
    }

    const parentDir = path.dirname(currentDir);
    if (parentDir === currentDir) break;
    currentDir = parentDir;
  }

  return null;
}

async function formatDataWithBiome(
  data: string,
  filePath: string,
  options: BiomeLoaderOptions,
): Promise<string> {
  let configPath: string | null = null;

  try {
    const biome = await Biome.create({
      distribution: Distribution.NODE,
    });

    // Open a project (required in v3.0.0+)
    const openResult = biome.openProject(".");
    const projectKey = openResult.projectKey;

    // Load config from biome.json/biome.jsonc if exists
    configPath = await findBiomeConfig(filePath);
    if (!configPath && !options.alwaysFormat) {
      console.log();
      console.log(
        `⚠️  Biome config not found for ${path.basename(filePath)} - skipping formatting`,
      );
      return data;
    }

    if (configPath) {
      const configContent = await fs.readFile(configPath, "utf-8");
      try {
        // Parse JSONC (JSON with comments) properly using jsonc-parser
        const config = parseJsonc(configContent);

        // WORKAROUND: Biome JS API v3 has a bug where applying the full config
        // causes formatter settings to be ignored. Apply only relevant sections.
        // Specifically, exclude $schema, vcs, and files from the config.
        const { $schema, vcs, files, ...relevantConfig } = config;

        biome.applyConfiguration(projectKey, relevantConfig);
      } catch (parseError) {
        throw new Error(
          `Invalid Biome configuration in ${configPath}: ${parseError instanceof Error ? parseError.message : "JSON parse error"}`,
        );
      }
    }

    const formatted = biome.formatContent(projectKey, data, {
      filePath,
    });

    return formatted.content;
  } catch (error) {
    // Extract error message from Biome
    const errorMessage =
      error instanceof Error
        ? error.message || (error as any).stackTrace?.toString().split("\n")[0]
        : "";

    if (errorMessage?.includes("does not exist in the workspace")) {
      // Biome says "file does not exist in workspace" for unsupported formats - skip
    } else {
      console.log(`⚠️  Biome skipped ${path.basename(filePath)}`);
      if (errorMessage) {
        console.log(`   ${errorMessage}`);
      }
    }

    return data; // Fallback to unformatted
  }
}

```

--------------------------------------------------------------------------------
/packages/spec/src/locales.spec.ts:
--------------------------------------------------------------------------------

```typescript
import { describe, it, expect } from "vitest";
import {
  getLocaleCodeDelimiter,
  normalizeLocale,
  resolveLocaleCode,
  resolveOverriddenLocale,
} from "./locales";

describe("normalizeLocale", () => {
  it("should return normalized locale for short locale codes", () => {
    expect(normalizeLocale("en")).toEqual("en");
    expect(normalizeLocale("fr")).toEqual("fr");
  });

  it("should return normalized locale for full locale codes", () => {
    expect(normalizeLocale("en-US")).toEqual("en-US");
    expect(normalizeLocale("fr-FR")).toEqual("fr-FR");
  });

  it("should return normalized locale for full underscore locale codes", () => {
    expect(normalizeLocale("en_US")).toEqual("en-US");
    expect(normalizeLocale("fr_FR")).toEqual("fr-FR");
    expect(normalizeLocale("zh_Hans_CN")).toEqual("zh-Hans-CN");
  });

  it("should return normalized locale for full explicit region locale codes", () => {
    expect(normalizeLocale("en-rUS")).toEqual("en-US");
    expect(normalizeLocale("fr-rFR")).toEqual("fr-FR");
    expect(normalizeLocale("zh-rCN")).toEqual("zh-CN");
  });
});

describe("resolveLocaleCode", () => {
  it("should resolve a short locale code to the first full locale code in the map", () => {
    expect(resolveLocaleCode("en")).toEqual("en-US");
    expect(resolveLocaleCode("fr")).toEqual("fr-FR");
    expect(resolveLocaleCode("az")).toEqual("az-AZ");
  });

  it("should return the full locale code if it is already provided", () => {
    expect(resolveLocaleCode("en-US")).toEqual("en-US");
    expect(resolveLocaleCode("fr-CA")).toEqual("fr-CA");
    expect(resolveLocaleCode("es-MX")).toEqual("es-MX");
  });

  it("should throw an error for an invalid or unsupported locale code", () => {
    expect(() => resolveLocaleCode("az-US")).toThrow("Invalid locale code");
    expect(() => resolveLocaleCode("au")).toThrow("Invalid locale code");
  });

  it("should return first code for locales with multiple variants", () => {
    expect(resolveLocaleCode("sr")).toEqual("sr-RS");
    expect(resolveLocaleCode("zh")).toEqual("zh-CN");
  });
});

describe("getLocaleCodeDelimiter", () => {
  it("should return '-' for locale codes with hyphen delimiter", () => {
    expect(getLocaleCodeDelimiter("en-US")).toEqual("-");
    expect(getLocaleCodeDelimiter("fr-FR")).toEqual("-");
  });

  it("should return '_' for locale codes with underscore delimiter", () => {
    expect(getLocaleCodeDelimiter("en_US")).toEqual("_");
    expect(getLocaleCodeDelimiter("fr_FR")).toEqual("_");
  });

  it("should return undefined for locale codes without a recognized delimiter", () => {
    expect(getLocaleCodeDelimiter("enUS")).toBeNull();
    expect(getLocaleCodeDelimiter("frFR")).toBeNull();
    expect(getLocaleCodeDelimiter("kaGE")).toBeNull();
  });
});

describe("resolveOverridenLocale", () => {
  it("should return the same locale if no delimiter is provided", () => {
    expect(resolveOverriddenLocale("en-US")).toEqual("en-US");
    expect(resolveOverriddenLocale("fr_FR")).toEqual("fr_FR");
  });

  it("should replace the delimiter with the specified one", () => {
    expect(resolveOverriddenLocale("en-US", "_")).toEqual("en_US");
    expect(resolveOverriddenLocale("fr_FR", "-")).toEqual("fr-FR");
  });

  it("should return the same locale if no recognized delimiter is found", () => {
    expect(resolveOverriddenLocale("enUS", "_")).toEqual("enUS");
    expect(resolveOverriddenLocale("frFR", "-")).toEqual("frFR");
  });
});

```

--------------------------------------------------------------------------------
/packages/cli/src/cli/loaders/flutter.spec.ts:
--------------------------------------------------------------------------------

```typescript
import { describe, it, expect } from "vitest";
import createFlutterLoader from "./flutter";

const locale = "en";
const originalLocale = "en";

describe("createFlutterLoader", () => {
  describe("pull", () => {
    it("should remove metadata keys starting with @", async () => {
      const loader = createFlutterLoader();
      loader.setDefaultLocale(locale);
      const input = {
        "@metadata": "some-data",
        hello: "world",
        another_key: "another_value",
        "@@locale": "en",
      };
      const expected = {
        hello: "world",
        another_key: "another_value",
      };
      const result = await loader.pull("en", input);
      expect(result).toEqual(expected);
    });

    it("should return an empty object if all keys are metadata", async () => {
      const loader = createFlutterLoader();
      loader.setDefaultLocale(locale);
      const input = {
        "@metadata": "some-data",
        "@@locale": "en",
      };
      const expected = {};
      const result = await loader.pull("en", input);
      expect(result).toEqual(expected);
    });

    it("should return the same object if no keys are metadata", async () => {
      const loader = createFlutterLoader();
      loader.setDefaultLocale(locale);
      const input = {
        hello: "world",
        another_key: "another_value",
      };
      const expected = {
        hello: "world",
        another_key: "another_value",
      };
      const result = await loader.pull("en", input);
      expect(result).toEqual(expected);
    });

    it("should handle empty input", async () => {
      const loader = createFlutterLoader();
      loader.setDefaultLocale(locale);
      const input = {};
      const expected = {};
      const result = await loader.pull("en", input);
      expect(result).toEqual(expected);
    });
  });

  describe("push", () => {
    it("should merge data and add locale", async () => {
      const loader = createFlutterLoader();
      loader.setDefaultLocale(locale);
      const originalInput = {
        hello: "world",
        "@metadata": "some-data",
      };
      await loader.pull(originalLocale, originalInput);
      const data = {
        foo: "bar",
        hello: "monde",
      };
      const expected = {
        hello: "monde",
        foo: "bar",
        "@metadata": "some-data",
        "@@locale": "fr",
      };
      const result = await loader.push("fr", data);
      expect(result).toEqual(expected);
    });

    it("should handle empty original input", async () => {
      const loader = createFlutterLoader();
      loader.setDefaultLocale(locale);
      const originalInput = {};
      await loader.pull(originalLocale, originalInput);
      const data = {
        foo: "bar",
      };
      const expected = {
        foo: "bar",
        "@@locale": "en",
      };
      const result = await loader.push("en", data);
      expect(result).toEqual(expected);
    });

    it("should handle empty data, not add extra keys from originalInput", async () => {
      const loader = createFlutterLoader();
      loader.setDefaultLocale(locale);
      const originalInput = {
        hello: "world",
      };
      await loader.pull(originalLocale, originalInput);
      const data = {
        goodbye: "moon",
      };
      const expected = {
        goodbye: "moon",
        "@@locale": "en",
      };
      const result = await loader.push("en", data);
      expect(result).toEqual(expected);
    });
  });
});

```

--------------------------------------------------------------------------------
/packages/cli/src/cli/cmd/ci/platforms/github.ts:
--------------------------------------------------------------------------------

```typescript
import { Octokit } from "octokit";
import { PlatformKit } from "./_base";
import Z from "zod";

export class GitHubPlatformKit extends PlatformKit {
  private _octokit?: Octokit;

  private get octokit(): Octokit {
    if (!this._octokit) {
      this._octokit = new Octokit({ auth: this.platformConfig.ghToken });
    }
    return this._octokit;
  }

  async branchExists({ branch }: { branch: string }) {
    return await this.octokit.rest.repos
      .getBranch({
        branch,
        owner: this.platformConfig.repositoryOwner,
        repo: this.platformConfig.repositoryName,
      })
      .then((r) => r.data)
      .then((v) => !!v)
      .catch((r) => (r.status === 404 ? false : Promise.reject(r)));
  }

  async getOpenPullRequestNumber({ branch }: { branch: string }) {
    return await this.octokit.rest.pulls
      .list({
        head: `${this.platformConfig.repositoryOwner}:${branch}`,
        owner: this.platformConfig.repositoryOwner,
        repo: this.platformConfig.repositoryName,
        base: this.platformConfig.baseBranchName,
        state: "open",
      })
      .then(({ data }) => data[0])
      .then((pr) => pr?.number);
  }

  async closePullRequest({ pullRequestNumber }: { pullRequestNumber: number }) {
    await this.octokit.rest.pulls.update({
      pull_number: pullRequestNumber,
      owner: this.platformConfig.repositoryOwner,
      repo: this.platformConfig.repositoryName,
      state: "closed",
    });
  }

  async createPullRequest({
    head,
    title,
    body,
  }: {
    head: string;
    title: string;
    body?: string;
  }) {
    return await this.octokit.rest.pulls
      .create({
        head,
        title,
        body,
        owner: this.platformConfig.repositoryOwner,
        repo: this.platformConfig.repositoryName,
        base: this.platformConfig.baseBranchName,
      })
      .then(({ data }) => data.number);
  }

  async commentOnPullRequest({
    pullRequestNumber,
    body,
  }: {
    pullRequestNumber: number;
    body: string;
  }) {
    await this.octokit.rest.issues.createComment({
      issue_number: pullRequestNumber,
      body,
      owner: this.platformConfig.repositoryOwner,
      repo: this.platformConfig.repositoryName,
    });
  }

  async gitConfig() {
    const { ghToken, repositoryOwner, repositoryName } = this.platformConfig;
    const { processOwnCommits } = this.config;

    if (ghToken && processOwnCommits) {
      console.log(
        "Using provided GH_TOKEN. This will trigger your CI/CD pipeline to run again.",
      );

      const url = `https://${ghToken}@github.com/${repositoryOwner}/${repositoryName}.git`;

      super.gitConfig(ghToken, url);
    }
  }

  get platformConfig() {
    const env = Z.object({
      GITHUB_REPOSITORY: Z.string(),
      GITHUB_REPOSITORY_OWNER: Z.string(),
      GITHUB_REF_NAME: Z.string(),
      GITHUB_HEAD_REF: Z.string(),
      GH_TOKEN: Z.string().optional(),
    }).parse(process.env);

    const baseBranchName = !env.GITHUB_REF_NAME.endsWith("/merge")
      ? env.GITHUB_REF_NAME
      : env.GITHUB_HEAD_REF;

    return {
      ghToken: env.GH_TOKEN,
      baseBranchName,
      repositoryOwner: env.GITHUB_REPOSITORY_OWNER,
      repositoryName: env.GITHUB_REPOSITORY.split("/")[1],
    };
  }

  buildPullRequestUrl(pullRequestNumber: number) {
    const { repositoryOwner, repositoryName } = this.platformConfig;
    return `https://github.com/${repositoryOwner}/${repositoryName}/pull/${pullRequestNumber}`;
  }
}

```

--------------------------------------------------------------------------------
/packages/locales/src/parser.spec.ts:
--------------------------------------------------------------------------------

```typescript
import { describe, it, expect } from "vitest";
import {
  parseLocale,
  getLanguageCode,
  getScriptCode,
  getRegionCode,
} from "./parser";

describe("parseLocale", () => {
  it("should parse basic language-region locales with hyphen", () => {
    expect(parseLocale("en-US")).toEqual({
      language: "en",
      region: "US",
    });
  });

  it("should parse basic language-region locales with underscore", () => {
    expect(parseLocale("en_US")).toEqual({
      language: "en",
      region: "US",
    });
  });

  it("should parse language-script-region locales with hyphen", () => {
    expect(parseLocale("zh-Hans-CN")).toEqual({
      language: "zh",
      script: "Hans",
      region: "CN",
    });
  });

  it("should parse language-script-region locales with underscore", () => {
    expect(parseLocale("zh_Hans_CN")).toEqual({
      language: "zh",
      script: "Hans",
      region: "CN",
    });
  });

  it("should parse language-only locales", () => {
    expect(parseLocale("es")).toEqual({
      language: "es",
    });
  });

  it("should parse complex script locales", () => {
    expect(parseLocale("sr-Cyrl-RS")).toEqual({
      language: "sr",
      script: "Cyrl",
      region: "RS",
    });
  });

  it("should handle numeric region codes", () => {
    expect(parseLocale("es-419")).toEqual({
      language: "es",
      region: "419",
    });
  });

  it("should normalize language to lowercase", () => {
    expect(parseLocale("EN-US")).toEqual({
      language: "en",
      region: "US",
    });
  });

  it("should normalize region to uppercase", () => {
    expect(parseLocale("en-us")).toEqual({
      language: "en",
      region: "US",
    });
  });

  it("should preserve script case", () => {
    expect(parseLocale("zh-hans-cn")).toEqual({
      language: "zh",
      script: "hans",
      region: "CN",
    });
  });

  it("should throw error for invalid locale format", () => {
    expect(() => parseLocale("invalid")).toThrow(
      "Invalid locale format: invalid",
    );
  });

  it("should throw error for empty string", () => {
    expect(() => parseLocale("")).toThrow("Locale cannot be empty");
  });

  it("should throw error for non-string input", () => {
    expect(() => parseLocale(null as any)).toThrow("Locale must be a string");
  });
});

describe("getLanguageCode", () => {
  it("should extract language code from various formats", () => {
    expect(getLanguageCode("en-US")).toBe("en");
    expect(getLanguageCode("zh-Hans-CN")).toBe("zh");
    expect(getLanguageCode("es-MX")).toBe("es");
    expect(getLanguageCode("fr_CA")).toBe("fr");
    expect(getLanguageCode("es")).toBe("es");
  });
});

describe("getScriptCode", () => {
  it("should extract script code when present", () => {
    expect(getScriptCode("zh-Hans-CN")).toBe("Hans");
    expect(getScriptCode("zh-Hant-TW")).toBe("Hant");
    expect(getScriptCode("sr-Cyrl-RS")).toBe("Cyrl");
  });

  it("should return null when script is not present", () => {
    expect(getScriptCode("en-US")).toBeNull();
    expect(getScriptCode("es")).toBeNull();
  });
});

describe("getRegionCode", () => {
  it("should extract region code when present", () => {
    expect(getRegionCode("en-US")).toBe("US");
    expect(getRegionCode("zh-Hans-CN")).toBe("CN");
    expect(getRegionCode("fr_CA")).toBe("CA");
  });

  it("should return null when region is not present", () => {
    expect(getRegionCode("es")).toBeNull();
    expect(getRegionCode("zh-Hans")).toBeNull();
  });
});

```

--------------------------------------------------------------------------------
/packages/compiler/src/utils/jsx-scope.spec.ts:
--------------------------------------------------------------------------------

```typescript
import { describe, it, expect } from "vitest";
import { parse } from "@babel/parser";
import traverse, { NodePath } from "@babel/traverse";
import * as t from "@babel/types";
import {
  collectJsxScopes,
  getJsxScopes,
  hasJsxScopeAttribute,
  getJsxScopeAttribute,
} from "./jsx-scope";

function parseJSX(code: string): t.File {
  return parse(code, {
    sourceType: "module",
    plugins: ["jsx", "typescript"],
  });
}

function getJSXElementPaths(ast: t.File): NodePath<t.JSXElement>[] {
  const paths: NodePath<t.JSXElement>[] = [];
  traverse(ast, {
    JSXElement(path) {
      paths.push(path);
    },
  });
  return paths;
}

describe("jsx-scope utils", () => {
  describe("collectJsxScopes", () => {
    it("collects elements with data-jsx-scope attribute", () => {
      const ast = parseJSX(`
        <div>
          <span data-jsx-scope="foo">A</span>
          <b>B</b>
          <section data-jsx-scope="bar">C</section>
        </div>
      `);
      const scopes = collectJsxScopes(ast);
      expect(scopes).toHaveLength(2);
      expect(getJsxScopeAttribute(scopes[0])).toBe("foo");
      expect(getJsxScopeAttribute(scopes[1])).toBe("bar");
    });
    it("returns empty if no elements have data-jsx-scope", () => {
      const ast = parseJSX(`<div><span>A</span></div>`);
      const scopes = collectJsxScopes(ast);
      expect(scopes).toHaveLength(0);
    });
  });

  describe("getJsxScopes", () => {
    it("finds elements with non-empty JSXText children and no non-empty siblings", () => {
      const ast = parseJSX(`
        <div>
          <span>Text</span>
          <b></b>
          <section>  </section>
          <div>
            <span>Text</span> and <b>Bold</b>
          </div>
          <p>
            <span>Text</span> here
          </p>
        </div>
      `);
      const scopes = getJsxScopes(ast);
      const scopeNames = scopes.map(
        (scope) => (scope.node.openingElement.name as t.JSXIdentifier).name,
      );
      expect(scopes).toHaveLength(3);
      expect(scopeNames).toEqual(["span", "div", "p"]);
    });
    it("skips LingoProvider component", () => {
      const ast = parseJSX(`
        <div>
          <LingoProvider>ShouldSkip</LingoProvider>
          <span>Text</span>
        </div>
      `);
      const scopes = getJsxScopes(ast);
      expect(scopes).toHaveLength(1);
      expect((scopes[0].node.openingElement.name as t.JSXIdentifier).name).toBe(
        "span",
      );
    });
  });

  describe("hasJsxScopeAttribute", () => {
    it("returns true if data-jsx-scope attribute exists", () => {
      const ast = parseJSX(`<div data-jsx-scope="foo">A</div>`);
      const [path] = getJSXElementPaths(ast);
      expect(hasJsxScopeAttribute(path)).toBe(true);
    });
    it("returns false if data-jsx-scope attribute does not exist", () => {
      const ast = parseJSX(`<div>A</div>`);
      const [path] = getJSXElementPaths(ast);
      expect(hasJsxScopeAttribute(path)).toBe(false);
    });
  });

  describe("getJsxScopeAttribute", () => {
    it("returns the value of data-jsx-scope attribute", () => {
      const ast = parseJSX(`<div data-jsx-scope="bar">B</div>`);
      const [path] = getJSXElementPaths(ast);
      expect(getJsxScopeAttribute(path)).toBe("bar");
    });
    it("returns undefined if data-jsx-scope attribute does not exist", () => {
      const ast = parseJSX(`<div>B</div>`);
      const [path] = getJSXElementPaths(ast);
      expect(getJsxScopeAttribute(path)).toBeUndefined();
    });
  });
});

```

--------------------------------------------------------------------------------
/packages/compiler/src/jsx-scope-flag.spec.ts:
--------------------------------------------------------------------------------

```typescript
import { describe, it, expect } from "vitest";
import jsxScopeFlagMutation from "./jsx-scope-flag";
import { createPayload, createOutput, defaultParams } from "./_base";

// Helper function to run mutation and get result
function runMutation(code: string) {
  const input = createPayload({ code, params: defaultParams, fileKey: "test" });
  const mutated = jsxScopeFlagMutation(input);
  if (!mutated) throw new Error("Mutation returned null");
  return createOutput(mutated).code;
}

describe("jsxScopeFlagMutation", () => {
  it("should add data-jsx-scope flag to element containing text without text siblings", () => {
    const input = `
function Component() {
  return <div>
      <span>Hello World</span>
    </div>;
}
`.trim();

    const expected = `
function Component() {
  return <div>
      <span data-jsx-scope="0/body/0/argument/1">Hello World</span>
    </div>;
}
`.trim();
    const result = runMutation(input);
    expect(result).toBe(expected);
  });

  it("should not add flag when element has text siblings", () => {
    const input = `
function Component() {
  return <div>
      Some text
      <span>Hello World</span>
      More text
    </div>;
}
`.trim();

    const expected = `
function Component() {
  return <div data-jsx-scope="0/body/0/argument">
      Some text
      <span>Hello World</span>
      More text
    </div>;
}
`.trim();
    const result = runMutation(input);
    expect(result).toBe(expected);
  });

  it("should handle multiple nested scopes correctly", () => {
    const input = `
function Component() {
  return <div>
      <section>
        <p>First text</p>
      </section>
      <section>
        Text here
        <div>More text</div>
      </section>
    </div>;
}
`.trim();

    const expected = `
function Component() {
  return <div>
      <section>
        <p data-jsx-scope="0/body/0/argument/1/1">First text</p>
      </section>
      <section data-jsx-scope="0/body/0/argument/3">
        Text here
        <div>More text</div>
      </section>
    </div>;
}
`.trim();
    const result = runMutation(input);
    expect(result).toBe(expected);
  });

  it("should not add flag to elements without text content", () => {
    const input = `
function Component() {
  return <div>
      <span></span>
      <p>{variable}</p>
    </div>;
}
`.trim();

    const expected = `
function Component() {
  return <div>
      <span></span>
      <p>{variable}</p>
    </div>;
}
`.trim();
    const result = runMutation(input);
    expect(result).toBe(expected);
  });

  it("should handle whitespace-only text nodes correctly", () => {
    const input = `
function Component() {
  return <div>
      <span>
        
        Hello
        
      </span>
    </div>;
}
`.trim();

    const expected = `
function Component() {
  return <div>
      <span data-jsx-scope="0/body/0/argument/1">
        
        Hello
        
      </span>
    </div>;
}
`.trim();
    const result = runMutation(input);
    expect(result).toBe(expected);
  });

  it("should handle JSX in props", () => {
    const input = `
function Component() {
  return <MyComponent label={<label>Hello</label>}>
      <p>Foobar</p>
    </MyComponent>;
}
`.trim();

    const expected = `
function Component() {
  return <MyComponent label={<label data-jsx-scope="0/body/0/argument/openingElement/0/value/expression">Hello</label>}>
      <p data-jsx-scope="0/body/0/argument/1">Foobar</p>
    </MyComponent>;
}
`.trim();
    const result = runMutation(input);
    expect(result).toBe(expected);
  });
});

```

--------------------------------------------------------------------------------
/packages/compiler/src/_loader-utils.ts:
--------------------------------------------------------------------------------

```typescript
import _ from "lodash";
import path from "path";
import { composeMutations, createOutput, createPayload } from "./_base";
import { LCP_DICTIONARY_FILE_NAME } from "./_const";
import { clientDictionaryLoaderMutation } from "./client-dictionary-loader";
import i18nDirectiveMutation from "./i18n-directive";
import jsxAttributeFlagMutation from "./jsx-attribute-flag";
import { lingoJsxAttributeScopeInjectMutation } from "./jsx-attribute-scope-inject";
import { jsxAttributeScopesExportMutation } from "./jsx-attribute-scopes-export";
import { jsxFragmentMutation } from "./jsx-fragment";
import { jsxHtmlLangMutation } from "./jsx-html-lang";
import jsxProviderMutation from "./jsx-provider";
import { jsxRemoveAttributesMutation } from "./jsx-remove-attributes";
import jsxRootFlagMutation from "./jsx-root-flag";
import jsxScopeFlagMutation from "./jsx-scope-flag";
import { lingoJsxScopeInjectMutation } from "./jsx-scope-inject";
import { jsxScopesExportMutation } from "./jsx-scopes-export";
import { LCP } from "./lib/lcp";
import { LCPServer } from "./lib/lcp/server";
import { reactRouterDictionaryLoaderMutation } from "./react-router-dictionary-loader";
import { rscDictionaryLoaderMutation } from "./rsc-dictionary-loader";
import { parseParametrizedModuleId } from "./utils/module-params";

/**
 * Loads a dictionary for a specific locale
 */
export async function loadDictionary(options: {
  resourcePath: string;
  resourceQuery?: string;
  params: any;
  sourceRoot: string;
  lingoDir: string;
  isDev: boolean;
}) {
  const {
    resourcePath,
    resourceQuery = "",
    params,
    sourceRoot,
    lingoDir,
    isDev,
  } = options;
  const fullResourcePath = `${resourcePath}${resourceQuery}`;

  if (!resourcePath.match(LCP_DICTIONARY_FILE_NAME)) {
    return null; // Not a dictionary file
  }

  const moduleInfo = parseParametrizedModuleId(fullResourcePath);
  const locale = moduleInfo.params.locale;

  if (!locale) {
    return null; // No locale specified
  }

  const lcpParams = {
    sourceRoot,
    lingoDir,
    isDev,
  };

  await LCP.ready(lcpParams);
  const lcp = LCP.getInstance(lcpParams);

  const dictionaries = await LCPServer.loadDictionaries({
    ...params,
    lcp: lcp.data,
  });

  const dictionary = dictionaries[locale];
  if (!dictionary) {
    throw new Error(
      `Lingo.dev: Dictionary for locale "${locale}" could not be generated.`,
    );
  }

  return dictionary;
}

/**
 * Transforms component code
 */
export function transformComponent(options: {
  code: string;
  params: any;
  resourcePath: string;
  sourceRoot: string;
}) {
  const { code, params, resourcePath, sourceRoot } = options;

  return _.chain({
    code,
    params,
    relativeFilePath: path
      .relative(path.resolve(process.cwd(), sourceRoot), resourcePath)
      .split(path.sep)
      .join("/"), // Always normalize for consistent dictionaries
  })
    .thru(createPayload)
    .thru(
      composeMutations(
        i18nDirectiveMutation,
        jsxFragmentMutation,
        jsxAttributeFlagMutation,
        jsxProviderMutation,
        jsxHtmlLangMutation,
        jsxRootFlagMutation,
        jsxScopeFlagMutation,
        jsxAttributeScopesExportMutation,
        jsxScopesExportMutation,
        lingoJsxAttributeScopeInjectMutation,
        lingoJsxScopeInjectMutation,
        rscDictionaryLoaderMutation,
        reactRouterDictionaryLoaderMutation,
        jsxRemoveAttributesMutation,
        clientDictionaryLoaderMutation,
      ),
    )
    .thru(createOutput)
    .value();
}

```

--------------------------------------------------------------------------------
/packages/cli/src/cli/utils/delta.ts:
--------------------------------------------------------------------------------

```typescript
import _ from "lodash";
import z from "zod";
import { md5 } from "./md5";
import { tryReadFile, writeFile, checkIfFileExists } from "../utils/fs";
import * as path from "path";
import YAML from "yaml";

const LockSchema = z.object({
  version: z.literal(1).default(1),
  checksums: z
    .record(
      z.string(), // localizable files' keys
      // checksums hashmap
      z
        .record(
          // key
          z.string(),
          // checksum of the key's value in the source locale
          z.string(),
        )
        .default({}),
    )
    .default({}),
});
export type LockData = z.infer<typeof LockSchema>;

export type Delta = {
  added: string[];
  removed: string[];
  updated: string[];
  renamed: [string, string][];
  hasChanges: boolean;
};

export function createDeltaProcessor(fileKey: string) {
  const lockfilePath = path.join(process.cwd(), "i18n.lock");
  return {
    async checkIfLockExists() {
      return checkIfFileExists(lockfilePath);
    },
    async calculateDelta(params: {
      sourceData: Record<string, any>;
      targetData: Record<string, any>;
      checksums: Record<string, string>;
    }): Promise<Delta> {
      let added = _.difference(
        Object.keys(params.sourceData),
        Object.keys(params.targetData),
      );
      let removed = _.difference(
        Object.keys(params.targetData),
        Object.keys(params.sourceData),
      );
      const updated = Object.keys(params.sourceData).filter(
        (key) =>
          md5(params.sourceData[key]) !== params.checksums[key] &&
          params.checksums[key],
      );

      const renamed: [string, string][] = [];
      for (const addedKey of added) {
        const addedHash = md5(params.sourceData[addedKey]);
        for (const removedKey of removed) {
          if (params.checksums[removedKey] === addedHash) {
            renamed.push([removedKey, addedKey]);
            break;
          }
        }
      }
      added = added.filter(
        (key) => !renamed.some(([oldKey, newKey]) => newKey === key),
      );
      removed = removed.filter(
        (key) => !renamed.some(([oldKey, newKey]) => oldKey === key),
      );

      const hasChanges = [
        added.length > 0,
        removed.length > 0,
        updated.length > 0,
        renamed.length > 0,
      ].some((v) => v);

      return {
        added,
        removed,
        updated,
        renamed,
        hasChanges,
      };
    },
    async loadLock() {
      const lockfileContent = tryReadFile(lockfilePath, null);
      const lockfileYaml = lockfileContent ? YAML.parse(lockfileContent) : null;
      const lockfileData: z.infer<typeof LockSchema> = lockfileYaml
        ? LockSchema.parse(lockfileYaml)
        : {
            version: 1,
            checksums: {},
          };
      return lockfileData;
    },
    async saveLock(lockData: LockData) {
      const lockfileYaml = YAML.stringify(lockData);
      writeFile(lockfilePath, lockfileYaml);
    },
    async loadChecksums() {
      const id = md5(fileKey);
      const lockfileData = await this.loadLock();
      return lockfileData.checksums[id] || {};
    },
    async saveChecksums(checksums: Record<string, string>) {
      const id = md5(fileKey);
      const lockfileData = await this.loadLock();
      lockfileData.checksums[id] = checksums;
      await this.saveLock(lockfileData);
    },
    async createChecksums(sourceData: Record<string, any>) {
      const checksums = _.mapValues(sourceData, (value) => md5(value));
      return checksums;
    },
  };
}

```

--------------------------------------------------------------------------------
/packages/cli/src/cli/utils/init-ci-cd.ts:
--------------------------------------------------------------------------------

```typescript
import { checkbox, confirm } from "@inquirer/prompts";
import fs from "fs";
import { Ora } from "ora";
import path from "path";

type Platform = "github" | "bitbucket" | "gitlab";

const platforms: Platform[] = ["github", "bitbucket", "gitlab"];

export default async function initCICD(spinner: Ora) {
  const initializers = getPlatformInitializers(spinner);

  const init = await confirm({
    message: "Would you like to use Lingo.dev in your CI/CD?",
  });

  if (!init) {
    spinner.warn(
      "CI/CD not initialized. To set it up later, see docs: https://lingo.dev/ci",
    );
    return;
  }

  const selectedPlatforms: Platform[] = await checkbox({
    message: "Please select CI/CD platform(s) you want to use:",
    choices: platforms.map((platform) => ({
      name: initializers[platform].name,
      value: platform,
      checked: initializers[platform].isEnabled(),
    })),
  });

  for (const platform of selectedPlatforms) {
    await initializers[platform].init();
  }
}

function getPlatformInitializers(spinner: Ora) {
  return {
    github: makeGithubInitializer(spinner),
    bitbucket: makeBitbucketInitializer(spinner),
    gitlab: makeGitlabInitializer(spinner),
  };
}

type PlatformConfig = {
  name: string;
  checkPath: string;
  ciConfigPath: string;
  ciConfigContent: string;
};

function makePlatformInitializer(config: PlatformConfig, spinner: Ora) {
  return {
    name: config.name,
    isEnabled: () => {
      const filePath = path.join(process.cwd(), config.checkPath);
      return fs.existsSync(filePath);
    },
    init: async () => {
      const filePath = path.join(process.cwd(), config.ciConfigPath);
      const dirPath = path.dirname(filePath);
      if (!fs.existsSync(dirPath)) {
        fs.mkdirSync(dirPath, { recursive: true });
      }
      let canWrite = true;
      if (fs.existsSync(filePath)) {
        canWrite = await confirm({
          message: `File ${filePath} already exists. Do you want to overwrite it?`,
          default: false,
        });
      }
      if (canWrite) {
        fs.writeFileSync(filePath, config.ciConfigContent);
        spinner.succeed(`CI/CD initialized for ${config.name}`);
      } else {
        spinner.warn(`CI/CD not initialized for ${config.name}`);
      }
    },
  };
}

function makeGithubInitializer(spinner: Ora) {
  return makePlatformInitializer(
    {
      name: "GitHub Action",
      checkPath: ".github",
      ciConfigPath: ".github/workflows/i18n.yml",
      ciConfigContent: `name: Lingo.dev i18n

on:
  push:
    branches:
      - main

permissions:
  contents: write
  pull-requests: write

jobs:
  i18n:
    name: Run i18n
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: lingodotdev/lingo.dev@main
        with:
          api-key: \${{ secrets.LINGODOTDEV_API_KEY }}
`,
    },
    spinner,
  );
}

function makeBitbucketInitializer(spinner: Ora) {
  return makePlatformInitializer(
    {
      name: "Bitbucket Pipeline",
      checkPath: "bitbucket-pipelines.yml",
      ciConfigPath: "bitbucket-pipelines.yml",
      ciConfigContent: `pipelines:
  branches:
    main:
      - step:
          name: Run i18n
          script:
            - pipe: lingodotdev/lingo.dev:main`,
    },
    spinner,
  );
}

function makeGitlabInitializer(spinner: Ora) {
  return makePlatformInitializer(
    {
      name: "Gitlab CI",
      checkPath: ".gitlab-ci.yml",
      ciConfigPath: ".gitlab-ci.yml",
      ciConfigContent: `lingodotdev:
  image: lingodotdev/ci-action:latest
  script:
    - echo "Done"
`,
    },
    spinner,
  );
}

```

--------------------------------------------------------------------------------
/packages/cli/src/cli/loaders/xliff.spec.ts:
--------------------------------------------------------------------------------

```typescript
import { describe, it, expect } from "vitest";
import dedent from "dedent";
import createXliffLoader from "./xliff";

function normalize(xml: string) {
  return xml.trim().replace(/\r?\n/g, "\n");
}

describe("XLIFF loader", () => {
  it("round-trips a simple file without changes", async () => {
    const input = dedent`<?xml version="1.0" encoding="utf-8"?>
    <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
      <file original="demo" source-language="en" target-language="en" datatype="plaintext">
        <body>
          <trans-unit id="hello" resname="hello">
            <source>Hello</source>
            <target state="translated">Hello</target>
          </trans-unit>
        </body>
      </file>
    </xliff>`;

    const loader = createXliffLoader();
    loader.setDefaultLocale("en");

    const data = await loader.pull("en", input);
    expect(data).toEqual({ hello: "Hello" });

    // push back identical payload
    const output = await loader.push("en", data);
    expect(normalize(output)).toBe(normalize(input));
  });

  it("handles duplicate resnames deterministically", async () => {
    const input = dedent`<?xml version="1.0" encoding="utf-8"?>
    <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
      <file original="dup" source-language="en" target-language="en" datatype="plaintext">
        <body>
          <trans-unit id="a" resname="dup_key"><source>A</source><target>A</target></trans-unit>
          <trans-unit id="b" resname="dup_key"><source>B</source><target>B</target></trans-unit>
        </body>
      </file>
    </xliff>`;

    const loader = createXliffLoader();
    loader.setDefaultLocale("en");
    const pulled = await loader.pull("en", input);
    expect(pulled).toEqual({
      dup_key: "A",
      "dup_key#b": "B",
    });

    // translate and push
    const esPayload = {
      dup_key: "AA",
      "dup_key#b": "BB",
    } as const;

    const esXml = await loader.push("es", esPayload);

    // Pull from Spanish to verify the values were set correctly
    const loaderEs = createXliffLoader();
    loaderEs.setDefaultLocale("en");
    await loaderEs.pull("en", input); // pull original first
    const pullEs = await loaderEs.pull("es", esXml);

    // Should get the translated values, not the original
    expect(pullEs).toEqual({
      dup_key: "AA",
      "dup_key#b": "BB",
    });
  });

  it("wraps XML-sensitive target in CDATA", async () => {
    const input = dedent`<?xml version="1.0" encoding="utf-8"?>
    <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
      <file original="cdata" source-language="en" target-language="en" datatype="plaintext">
        <body>
          <trans-unit id="expr" resname="expr"><source>5 &lt; 7</source><target>5 &lt; 7</target></trans-unit>
        </body>
      </file>
    </xliff>`;

    const loader = createXliffLoader();
    loader.setDefaultLocale("en");
    await loader.pull("en", input);

    const out = await loader.push("es", { expr: "5 < 7 & 8 > 3" });

    expect(out.includes("<![CDATA[5 < 7 & 8 > 3]]>")).toBe(true);
  });

  it("creates skeleton for missing locale", async () => {
    const loader = createXliffLoader();
    loader.setDefaultLocale("en");

    // pulling default locale from scratch (empty)
    await loader.pull("en", "");

    const payload = { key1: "Valor" };
    const esXml = await loader.push("es", payload);

    // Ensure skeleton contains our translated value
    expect(esXml.includes("Valor")).toBe(true);
    expect(esXml.includes('target-language="es"'));
  });
});

```

--------------------------------------------------------------------------------
/packages/cli/src/cli/loaders/json-dictionary.spec.ts:
--------------------------------------------------------------------------------

```typescript
import { forEach } from "lodash";
import createJsonKeysLoader from "./json-dictionary";
import { describe, it, expect } from "vitest";

describe("json-dictionary loader", () => {
  const input = {
    title: {
      en: "I am a title",
    },
    logoPosition: "right",
    pages: [
      {
        name: "Welcome to my world",
        elements: [
          {
            title: {
              en: "I am an element title",
            },
            description: {
              en: "I am an element description",
            },
          },
        ],
      },
    ],
  };

  it("should return nested object of only translatable keys on pull", async () => {
    const loader = createJsonKeysLoader();
    loader.setDefaultLocale("en");
    const pulled = await loader.pull("en", input);
    expect(pulled).toEqual({
      title: "I am a title",
      pages: [
        {
          elements: [
            {
              title: "I am an element title",
              description: "I am an element description",
            },
          ],
        },
      ],
    });
  });

  it("should add target locale keys only where source locale keys exist on push", async () => {
    const loader = createJsonKeysLoader();
    loader.setDefaultLocale("en");
    const pulled = await loader.pull("en", input);
    const output = await loader.push("es", {
      title: "Yo soy un titulo",
      logoPosition: "right",
      pages: [
        {
          name: "Welcome to my world",
          elements: [
            {
              title: "Yo soy un elemento de titulo",
              description: "Yo soy una descripcion de elemento",
            },
          ],
        },
      ],
    });
    expect(output).toEqual({
      title: { en: "I am a title", es: "Yo soy un titulo" },
      logoPosition: "right",
      pages: [
        {
          name: "Welcome to my world",
          elements: [
            {
              title: {
                en: "I am an element title",
                es: "Yo soy un elemento de titulo",
              },
              description: {
                en: "I am an element description",
                es: "Yo soy una descripcion de elemento",
              },
            },
          ],
        },
      ],
    });
  });

  it("should correctly order locale keys on push", async () => {
    const loader = createJsonKeysLoader();
    loader.setDefaultLocale("en");
    const pulled = await loader.pull("en", {
      data: {
        en: "foo1",
        es: "foo2",
        de: "foo3",
      },
    });
    const output = await loader.push("fr", { data: "foo4" });
    expect(Object.keys(output.data)).toEqual(["en", "de", "es", "fr"]);
  });

  it("should not add target locale keys to non-object values", async () => {
    const loader = createJsonKeysLoader();
    loader.setDefaultLocale("en");
    const data = { foo: 123, bar: true, baz: null };
    const pulled = await loader.pull("en", data);
    expect(pulled).toEqual({});
    const output = await loader.push("es", pulled);
    expect(output).toEqual({
      foo: 123,
      bar: true,
      baz: null,
    });
  });

  it("should handle locale keys on top level", async () => {
    const loader = createJsonKeysLoader();
    loader.setDefaultLocale("en");
    const pulled = await loader.pull("en", {
      en: "foo1",
      es: "foo2",
      other: "bar",
    });
    expect(pulled).toEqual({ "--content--": "foo1" });
    const output = await loader.push("fr", { "--content--": "foo3" });
    expect(output).toEqual({
      en: "foo1",
      es: "foo2",
      fr: "foo3",
      other: "bar",
    });
  });
});

```

--------------------------------------------------------------------------------
/.claude/agents/code-architect-reviewer.md:
--------------------------------------------------------------------------------

```markdown
---
name: code-architect-reviewer
description: Use this agent when you need expert code review focusing on architectural quality, clean code principles, and best practices. Examples: <example>Context: User has just written a new service class and wants architectural feedback. user: 'I just implemented a user authentication service. Can you review it?' assistant: 'I'll use the code-architect-reviewer agent to provide comprehensive architectural review of your authentication service.' <commentary>Since the user is requesting code review with architectural focus, use the code-architect-reviewer agent to analyze the code structure, design patterns, and clean code adherence.</commentary></example> <example>Context: User has refactored a complex module and wants validation. user: 'I refactored the payment processing module to improve maintainability' assistant: 'Let me use the code-architect-reviewer agent to evaluate your refactoring and ensure it follows clean architecture principles.' <commentary>The user has made architectural changes and needs expert validation, so use the code-architect-reviewer agent to assess the improvements.</commentary></example>
tools: Task, Bash, Glob, Grep, LS, ExitPlanMode, Read, Edit, MultiEdit, Write, NotebookRead, NotebookEdit, WebFetch, TodoWrite, WebSearch
---

You are an Expert Software Architect and Code Reviewer with deep expertise in clean code principles, software design patterns, and architectural best practices. Your mission is to provide thorough, actionable code reviews that elevate code quality and maintainability.

When reviewing code, you will:

**Architectural Analysis:**

- Evaluate overall code structure and organization
- Assess adherence to SOLID principles and design patterns
- Identify architectural smells and suggest improvements
- Review separation of concerns and modularity
- Analyze dependency management and coupling

**Clean Code Assessment:**

- Review naming conventions for clarity and expressiveness
- Evaluate function and class sizes (single responsibility)
- Check for code duplication and suggest DRY improvements
- Assess readability and self-documenting code practices
- Review error handling and edge case coverage

**Best Practices Validation:**

- Verify adherence to language-specific conventions
- Check for proper use of abstractions and interfaces
- Evaluate testing strategy and testability
- Review performance considerations and potential bottlenecks
- Assess security implications and vulnerabilities

**Review Process:**

1. First, understand the code's purpose and context
2. Analyze the overall architecture and design decisions
3. Examine implementation details for clean code violations
4. Identify specific improvement opportunities
5. Prioritize feedback by impact (critical, important, nice-to-have)
6. Provide concrete, actionable recommendations with examples

**Feedback Format:**

- Start with positive observations about good practices
- Organize feedback by category (Architecture, Clean Code, Performance, etc.)
- For each issue, explain the problem, why it matters, and how to fix it
- Provide code examples for suggested improvements when helpful
- End with a summary of key action items

**Quality Standards:**

- Be thorough but focus on the most impactful improvements
- Explain the reasoning behind each recommendation
- Consider maintainability, scalability, and team collaboration
- Balance perfectionism with pragmatism
- Encourage best practices while respecting project constraints

You are not just identifying problems—you are mentoring developers toward architectural excellence and clean code mastery.

```

--------------------------------------------------------------------------------
/packages/cli/src/cli/utils/find-locale-paths.ts:
--------------------------------------------------------------------------------

```typescript
import fs from "fs";
import path from "path";
import { glob } from "glob";
import _ from "lodash";
import { LocaleCode, resolveLocaleCode } from "@lingo.dev/_spec";

export default function findLocaleFiles(bucket: string) {
  switch (bucket) {
    case "json":
      return findLocaleFilesWithExtension(".json");
    case "yaml":
      return findLocaleFilesWithExtension(".yml");
    case "flutter":
      return findLocaleFilesWithExtension(".arb");
    case "android":
      return findLocaleFilesWithExtension(".xml");
    case "markdown":
      return findLocaleFilesWithExtension(".md");
    case "php":
      return findLocaleFilesWithExtension(".php");
    case "po":
      return findLocaleFilesWithExtension(".po");
    case "xcode-xcstrings":
      return findLocaleFilesForFilename("Localizable.xcstrings");
    case "xcode-strings":
      return findLocaleFilesForFilename("Localizable.strings");
    case "xcode-stringsdict":
      return findLocaleFilesForFilename("Localizable.stringsdict");
    default:
      return null;
  }
}

function findLocaleFilesWithExtension(ext: string) {
  const files = glob.sync(`**/*${ext}`, {
    ignore: ["node_modules/**", "package*.json", "i18n.json", "lingo.json"],
  });

  const localeFilePattern = new RegExp(`\/([a-z]{2}(-[A-Z]{2})?)${ext}$`);
  const localeDirectoryPattern = new RegExp(
    `\/([a-z]{2}(-[A-Z]{2})?)\/[^\/]+${ext}$`,
  );
  const potentialLocaleFiles = files.filter(
    (file: string) =>
      localeFilePattern.test(file) || localeDirectoryPattern.test(file),
  );

  const potantialLocaleFilesAndPatterns = potentialLocaleFiles
    .map((file: string) => {
      const matchPotentialLocales = Array.from(
        file.matchAll(
          new RegExp(`\/([a-z]{2}(-[A-Z]{2})?|[^\/]+)(?=\/|${ext})`, "g"),
        ),
      );
      const potantialLocales = matchPotentialLocales.map((match) => match[1]);
      return { file, potantialLocales };
    })
    .map(({ file, potantialLocales }) => {
      for (const locale of potantialLocales) {
        try {
          resolveLocaleCode(locale as LocaleCode);
          return { locale, file };
        } catch (e) {}
      }
      return { file, locale: null };
    })
    .filter(({ locale }) => locale !== null);

  const localeFilesAndPatterns = potantialLocaleFilesAndPatterns.map(
    ({ file, locale }) => {
      const pattern = file
        .replaceAll(new RegExp(`/${locale}${ext}`, "g"), `/[locale]${ext}`)
        .replaceAll(new RegExp(`/${locale}/`, "g"), `/[locale]/`)
        .replaceAll(new RegExp(`/${locale}/`, "g"), `/[locale]/`); // for when there are 2 locales one after another
      return { pattern, file };
    },
  );

  const grouppedFilesAndPatterns = _.groupBy(localeFilesAndPatterns, "pattern");
  const patterns = Object.keys(grouppedFilesAndPatterns);
  const defaultPatterns = [`i18n/[locale]${ext}`];

  if (patterns.length > 0) {
    return { patterns, defaultPatterns };
  }

  return { patterns: [], defaultPatterns };
}

function findLocaleFilesForFilename(fileName: string) {
  const pattern = fileName;
  const localeFiles = glob.sync(`**/${fileName}`, {
    ignore: ["node_modules/**", "package*.json", "i18n.json", "lingo.json"],
  });

  const localeFilesAndPatterns = localeFiles.map((file: string) => ({
    file,
    pattern: path.join(path.dirname(file), pattern),
  }));
  const grouppedFilesAndPatterns = _.groupBy(localeFilesAndPatterns, "pattern");
  const patterns = Object.keys(grouppedFilesAndPatterns);
  const defaultPatterns = [fileName];

  if (patterns.length > 0) {
    return { patterns, defaultPatterns };
  }

  return { patterns: [], defaultPatterns };
}

```

--------------------------------------------------------------------------------
/packages/cli/src/cli/loaders/mdx.ts:
--------------------------------------------------------------------------------

```typescript
import _ from "lodash";
import { unified } from "unified";
import remarkParse from "remark-parse";
import remarkFrontmatter from "remark-frontmatter";
import remarkGfm from "remark-gfm";
import remarkStringify from "remark-stringify";
import remarkMdxFrontmatter from "remark-mdx-frontmatter";
import { VFile } from "vfile";
import { Root, RootContent, RootContentMap } from "mdast";
import { ILoader } from "./_types";
import { createLoader } from "./_utils";

const parser = unified()
  .use(remarkParse)
  .use(remarkFrontmatter, ["yaml"])
  .use(remarkGfm);
const serializer = unified()
  .use(remarkStringify)
  .use(remarkFrontmatter, ["yaml"])
  .use(remarkGfm);

export function createMdxFormatLoader(): ILoader<string, Record<string, any>> {
  const skippedTypes: (keyof RootContentMap | "root")[] = [
    "code",
    "inlineCode",
  ];
  return createLoader({
    async pull(locale, input) {
      const file = new VFile(input);
      const ast = parser.parse(file);

      const result = _.cloneDeep(ast);

      traverseMdast(result, (node) => {
        if (skippedTypes.includes(node.type)) {
          if ("value" in node) {
            node.value = "";
          }
        }
      });

      return result;
    },

    async push(
      locale,
      data,
      originalInput,
      originalLocale,
      pullInput,
      pullOutput,
    ) {
      const file = new VFile(originalInput);
      const ast = parser.parse(file);

      const result = _.cloneDeep(ast);

      traverseMdast(result, (node, indexPath) => {
        if ("value" in node) {
          const incomingValue = findNodeByIndexPath(data, indexPath);
          if (
            incomingValue &&
            "value" in incomingValue &&
            !_.isEmpty(incomingValue.value)
          ) {
            node.value = incomingValue.value;
          }
        }
      });

      return String(serializer.stringify(result));
    },
  });
}

export function createDoubleSerializationLoader(): ILoader<string, string> {
  return createLoader({
    async pull(locale, input) {
      return input;
    },

    async push(locale, data) {
      const file = new VFile(data);
      const ast = parser.parse(file);

      const finalContent = String(serializer.stringify(ast));
      return finalContent;
    },
  });
}

export function createMdxStructureLoader(): ILoader<
  Record<string, any>,
  Record<string, string>
> {
  return createLoader({
    async pull(locale, input) {
      const result = _.pickBy(input, (value, key) => _isValueKey(key));
      return result;
    },
    async push(locale, data, originalInput) {
      const nonValueKeys = _.pickBy(
        originalInput,
        (value, key) => !_isValueKey(key),
      );
      const result = _.merge({}, nonValueKeys, data);

      return result;
    },
  });
}

function _isValueKey(key: string) {
  return key.endsWith("/value");
}

function traverseMdast(
  ast: Root | RootContent,
  visitor: (node: Root | RootContent, path: number[]) => void,
  indexPath: number[] = [],
) {
  visitor(ast, indexPath);

  if ("children" in ast && Array.isArray(ast.children)) {
    for (let i = 0; i < ast.children.length; i++) {
      traverseMdast(ast.children[i], visitor, [...indexPath, i]);
    }
  }
}

function findNodeByIndexPath(
  ast: Root | RootContent,
  indexPath: number[],
): Root | RootContent | null {
  let result: Root | RootContent | null = null;

  const stringifiedIndexPath = indexPath.join(".");
  traverseMdast(ast, (node, path) => {
    if (result) {
      return;
    }

    const currentStringifiedPath = path.join(".");
    if (currentStringifiedPath === stringifiedIndexPath) {
      result = node;
    }
  });

  return result;
}

```

--------------------------------------------------------------------------------
/packages/compiler/src/utils/jsx-element.spec.ts:
--------------------------------------------------------------------------------

```typescript
import * as t from "@babel/types";
import traverse, { NodePath } from "@babel/traverse";
import { parse } from "@babel/parser";
import { getJsxElementName, getNestedJsxElements } from "./jsx-element";
import { describe, it, expect } from "vitest";
import generate from "@babel/generator";

function parseJSX(code: string): t.File {
  return parse(code, {
    sourceType: "module",
    plugins: ["jsx", "typescript"],
  });
}

function getJSXElementPath(code: string): NodePath<t.JSXElement> {
  const ast = parseJSX(code);
  let elementPath: NodePath<t.JSXElement> | null = null;

  traverse(ast, {
    JSXElement(path) {
      elementPath = path;
      path.stop();
    },
  });

  if (!elementPath) {
    throw new Error("No JSX element found in the code");
  }

  return elementPath;
}

describe("JSX Element Utils", () => {
  describe("getJsxElementName", () => {
    it("should return element name for simple elements", () => {
      const path = getJSXElementPath("<div>Hello</div>");
      expect(getJsxElementName(path)).toBe("div");
    });

    it("should return element name for custom elements", () => {
      const path = getJSXElementPath("<MyComponent>Hello</MyComponent>");
      expect(getJsxElementName(path)).toBe("MyComponent");
    });

    it("should return element name for elements with dots", () => {
      const path = getJSXElementPath("<My.Component>Hello</My.Component>");
      expect(getJsxElementName(path)).toBe("My.Component");
    });

    it("should return element name for elements with multiple dot", () => {
      const path = getJSXElementPath(
        "<My.Very.Custom.React.Component>Hello</My.Very.Custom.React.Component>",
      );
      expect(getJsxElementName(path)).toBe("My.Very.Custom.React.Component");
    });
  });

  describe("getNestedJsxElements", () => {
    it("should transform single nested element into a function", () => {
      const path = getJSXElementPath("<div>Hello <b>world</b></div>");
      const result = getNestedJsxElements(path);

      expect(result.elements).toHaveLength(1);
      const generatedCode = generate(result.elements[0]).code;
      expect(generatedCode).toBe(`({
  children
}) => <b>{children}</b>`);
    });

    it("should handle multiple nested elements", () => {
      const path = getJSXElementPath(
        "<div><strong>Hello</strong> and <em>welcome</em> to <code>my app</code></div>",
      );
      const result = getNestedJsxElements(path);

      expect(result.elements).toHaveLength(3);
      const generatedCodes = result.elements.map((fn) => generate(fn).code);
      expect(generatedCodes).toEqual([
        `({
  children
}) => <strong>{children}</strong>`,
        `({
  children
}) => <em>{children}</em>`,
        `({
  children
}) => <code>{children}</code>`,
      ]);
    });

    it("should handle deeply nested elements", () => {
      const path = getJSXElementPath(
        "<div><a>Hello <strong>wonderful <i><b>very</b>nested</i></strong> world</a> of the <u>universe</u></div>",
      );
      const result = getNestedJsxElements(path);

      // expect(result).toHaveLength(4);
      const generatedCodes = result.elements.map((fn) => generate(fn).code);
      expect(generatedCodes).toEqual([
        `({
  children
}) => <a>{children}</a>`,
        `({
  children
}) => <strong>{children}</strong>`,
        `({
  children
}) => <i>{children}</i>`,
        `({
  children
}) => <b>{children}</b>`,
        `({
  children
}) => <u>{children}</u>`,
      ]);
    });

    it("should return empty array for elements with no nested JSX", () => {
      const path = getJSXElementPath("<div>Hello world</div>");
      const result = getNestedJsxElements(path);
      expect(result.elements).toHaveLength(0);
    });
  });
});

```

--------------------------------------------------------------------------------
/packages/cli/src/cli/loaders/mdx.spec.ts:
--------------------------------------------------------------------------------

```typescript
import { describe, it, expect } from "vitest";
import {
  createMdxFormatLoader,
  createDoubleSerializationLoader,
  createMdxStructureLoader,
} from "./mdx";

// Helper to traverse mdast tree
function traverse(node: any, visitor: (n: any) => void) {
  visitor(node);
  if (node && Array.isArray(node.children)) {
    node.children.forEach((child: any) => traverse(child, visitor));
  }
}

describe("mdx loader", () => {
  const mdxSample = `\n# Heading\n\nHere is some code:\n\n\u0060\u0060\u0060js\nconsole.log("hello");\n\u0060\u0060\u0060\n\nSome inline \u0060world\u0060 and more text.\n`;

  describe("createMdxFormatLoader", () => {
    it("should strip values of code and inlineCode nodes on pull", async () => {
      const loader = createMdxFormatLoader();
      loader.setDefaultLocale("en");

      const ast = await loader.pull("en", mdxSample);

      // Assert that every code or inlineCode node now has an empty value
      traverse(ast, (node) => {
        if (node?.type === "code" || node?.type === "inlineCode") {
          expect(node.value).toBe("");
        }
      });
    });

    it("should preserve original code & inlineCode content on push when incoming value is empty", async () => {
      const loader = createMdxFormatLoader();
      loader.setDefaultLocale("en");

      const pulledAst = await loader.pull("en", mdxSample);
      const output = await loader.push("es", pulledAst);

      // The serialized output must still contain the original code and inline code content
      expect(output).toContain('console.log("hello");');
      expect(output).toMatch(/`world`/);
    });
  });

  describe("createDoubleSerializationLoader", () => {
    it("should return the same content on pull", async () => {
      const loader = createDoubleSerializationLoader();
      loader.setDefaultLocale("en");
      const input = "# Hello";
      const output = await loader.pull("en", input);
      expect(output).toBe(input);
    });

    it("should reformat markdown on push", async () => {
      const loader = createDoubleSerializationLoader();
      loader.setDefaultLocale("en");
      const input = "#  Hello   ";
      const expectedOutput = "# Hello\n";
      await loader.pull("en", input);
      const output = await loader.push("en", input);
      expect(output).toBe(expectedOutput);
    });
  });

  describe("createMdxStructureLoader", () => {
    it("should extract values from keys ending with /value on pull", async () => {
      const loader = createMdxStructureLoader();
      loader.setDefaultLocale("en");
      const input = {
        "title/value": "Hello",
        "title/type": "string",
        "content/value": "Some content",
        unrelated: "field",
      };
      const output = await loader.pull("en", input);
      expect(output).toEqual({
        "title/value": "Hello",
        "content/value": "Some content",
      });
    });

    it("should merge translated data with non-value keys on push, should not include untranslated keys from originalInput", async () => {
      const loader = createMdxStructureLoader();
      loader.setDefaultLocale("en");
      const originalInput = {
        "title/value": "Hello",
        "title/type": "string",
        "content/value": "Some content",
        "untranslated/value": "untranslated",
        unrelated: "field",
      };
      await loader.pull("en", originalInput);
      const translatedData = {
        "title/value": "Hola",
        "content/value": "Algun contenido",
      };
      const output = await loader.push("es", translatedData);
      expect(output).toEqual({
        "title/value": "Hola",
        "title/type": "string",
        "content/value": "Algun contenido",
        unrelated: "field",
      });
    });
  });
});

```

--------------------------------------------------------------------------------
/packages/cli/src/cli/processor/basic.ts:
--------------------------------------------------------------------------------

```typescript
import { generateText, LanguageModelV1 } from "ai";
import { LocalizerInput, LocalizerProgressFn } from "./_base";
import _ from "lodash";

type ModelSettings = {
  temperature?: number;
};

export function createBasicTranslator(
  model: LanguageModelV1,
  systemPrompt: string,
  settings: ModelSettings = {},
) {
  return async (input: LocalizerInput, onProgress: LocalizerProgressFn) => {
    const chunks = extractPayloadChunks(input.processableData);

    const subResults: Record<string, any>[] = [];
    for (let i = 0; i < chunks.length; i++) {
      const chunk = chunks[i];
      const result = await doJob({
        ...input,
        processableData: chunk,
      });
      subResults.push(result);
      onProgress((i / chunks.length) * 100, chunk, result);
    }

    const result = _.merge({}, ...subResults);

    return result;
  };

  async function doJob(input: LocalizerInput) {
    if (!Object.keys(input.processableData).length) {
      return input.processableData;
    }

    const response = await generateText({
      model,
      ...settings,
      messages: [
        {
          role: "system",
          content: JSON.stringify({
            role: "system",
            content: systemPrompt
              .replaceAll("{source}", input.sourceLocale)
              .replaceAll("{target}", input.targetLocale),
          }),
        },
        {
          role: "user",
          content: JSON.stringify({
            sourceLocale: "en",
            targetLocale: "es",
            data: {
              message: "Hello, world!",
            },
          }),
        },
        {
          role: "assistant",
          content: JSON.stringify({
            sourceLocale: "en",
            targetLocale: "es",
            data: {
              message: "Hola, mundo!",
            },
          }),
        },
        {
          role: "user",
          content: JSON.stringify({
            sourceLocale: input.sourceLocale,
            targetLocale: input.targetLocale,
            data: input.processableData,
          }),
        },
      ],
    });

    const result = JSON.parse(response.text);

    return result?.data || {};
  }
}

/**
 * Extract payload chunks based on the ideal chunk size
 * @param payload - The payload to be chunked
 * @returns An array of payload chunks
 */
function extractPayloadChunks(
  payload: Record<string, string>,
): Record<string, string>[] {
  const idealBatchItemSize = 250;
  const batchSize = 25;
  const result: Record<string, string>[] = [];
  let currentChunk: Record<string, string> = {};
  let currentChunkItemCount = 0;

  const payloadEntries = Object.entries(payload);
  for (let i = 0; i < payloadEntries.length; i++) {
    const [key, value] = payloadEntries[i];
    currentChunk[key] = value;
    currentChunkItemCount++;

    const currentChunkSize = countWordsInRecord(currentChunk);
    if (
      currentChunkSize > idealBatchItemSize ||
      currentChunkItemCount >= batchSize ||
      i === payloadEntries.length - 1
    ) {
      result.push(currentChunk);
      currentChunk = {};
      currentChunkItemCount = 0;
    }
  }

  return result;
}

/**
 * Count words in a record or array
 * @param payload - The payload to count words in
 * @returns The total number of words
 */
function countWordsInRecord(
  payload: any | Record<string, any> | Array<any>,
): number {
  if (Array.isArray(payload)) {
    return payload.reduce((acc, item) => acc + countWordsInRecord(item), 0);
  } else if (typeof payload === "object" && payload !== null) {
    return Object.values(payload).reduce(
      (acc: number, item) => acc + countWordsInRecord(item),
      0,
    );
  } else if (typeof payload === "string") {
    return payload.trim().split(/\s+/).filter(Boolean).length;
  } else {
    return 0;
  }
}

```
Page 4/16FirstPrevNextLast