shallok 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,72 +2,186 @@
2
2
 
3
3
  > AI-Powered, Versioned Localization Tool for Developers & AI Coding Agents.
4
4
 
5
- Shallok is a developer tool and AI agent skill system that enables developers and AI coding agents (Antigravity, Cursor, Claude Code, GitHub Copilot) to add, configure, extract, translate, and maintain localization across existing codebases.
5
+ [![npm version](https://img.shields.io/npm/v/shallok.svg)](https://www.npmjs.com/package/shallok)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ **Shallok** is a developer tool and AI agent skill system that enables developers and AI coding agents (Antigravity, Cursor, Claude Code, GitHub Copilot) to add, configure, extract, translate, and maintain localization across existing codebases with **AST-based transformations**, **deterministic per-key versioning**, and **agent-native incremental translations**.
9
+
10
+ ---
6
11
 
7
12
  ## Features
8
13
 
9
- - **AST-Based Extraction**: Deterministic AST parsing (Babel) safely extracts user-facing text and attributes into stable semantic keys.
10
14
  - **Agent-Native Translation**: **Zero external API keys required**. AI coding agents translate missing and stale keys directly with natural cultural fluency.
11
- - **AI-Enriched Semantic Context**: Context notes are enriched by AI agents and strictly preserved across extractions.
12
- - **Per-Key Versioning & Content Hashing**: SHA-256 content hashes detect source modifications and mark translations stale on a granular, per-key basis.
13
- - **Framework Adapters**:
15
+ - **AST-Based Code Transformations**: Parses TSX/JSX and TypeScript safely with Babel; replaces hardcoded strings with framework hook/function calls without fragile regexes.
16
+ - **Per-Key Versioning & SHA-256 Content Hashing**: Granular content hashing detects source modifications; changing one string increments only its version while preserving all other translations.
17
+ - **AI-Enriched Semantic Context**: Context notes are enriched by AI agents and developers, strictly preserved across extractions.
18
+ - **Framework Adapters**: First-class support for:
14
19
  - **React**: `react-i18next` with `src/i18n.ts`
15
- - **Next.js**: `next-intl` (App Router `routing.ts`, `request.ts`, `middleware.ts`)
20
+ - **Next.js**: `next-intl` (App Router `routing.ts`, `request.ts`, `middleware.ts` & Pages Router)
16
21
  - **Expo / React Native**: `expo-localization` + `i18next` with native device locale detection
17
- - **Astro**: `astro:i18n` with dynamic message compilation
22
+ - **Astro**: `astro:i18n` with dynamic message compilation and UI island support
23
+ - **Vue**: `vue-i18n` with Vue composition API setup
18
24
  - **Placeholder & Integrity Validation**: Validates 0 missing keys, 0 stale versions, and 0 corrupted placeholder tokens (`{count}`, `{name}`).
25
+ - **Interactive Ink Terminal UI**: Beautiful interactive console screens with automatic non-TTY and `--json` fallback for AI agent orchestration.
26
+ - **5 Pre-Packaged Agent Skills**: Tailored skills for general i18n, React, Next.js, Expo, and Astro.
19
27
 
20
28
  ---
21
29
 
22
- ## Quickstart
30
+ ## Two Ways to Use Shallok
23
31
 
24
- ### 1. Developer CLI Quickstart
25
- Run in any React, Next.js, Expo, or Astro project:
32
+ ### 1. Developer CLI Quickstart (`npx shallok setup`)
33
+
34
+ Run in any React, Next.js, Expo, Astro, or Vue project:
26
35
  ```bash
27
- npx shallok init
36
+ npx shallok setup
28
37
  ```
29
38
  This command automatically:
30
- 1. Analyzes project architecture, detected framework, and router.
31
- 2. Scaffolds `localization.json`, `localization_base/`, `messages/`, and framework files.
32
- 3. Installs `shallok` into `devDependencies` using your project's package manager.
33
- 4. Installs AI agent skills directly into `.agents/skills/` and `skills/`.
39
+ 1. Detects project framework and architecture.
40
+ 2. Installs `shallok` into `devDependencies` using your detected package manager (pnpm, npm, yarn, or bun).
41
+ 3. Installs the matching AI agent skill directly into `.agents/skills/` and `skills/` (e.g. Next.js, React, Expo, Astro, or general fallback).
42
+ 4. Displays the next-step prompt to give to your AI coding agent: *"Add localization and translations for a, b, c, d languages"*.
43
+
44
+ > **Note for AI Agents**: `shallok setup` is intended only for human developers. AI Agents should never run `shallok setup`; instead, agents run `shallok init`, `shallok extract`, `shallok translate`, etc.
34
45
 
35
46
  ### 2. Direct AI Agent Skill Usage
36
- Copy any of the skills from `skills/` into your AI agent's skills directory (e.g. `.agents/skills/`), then tell your agent:
47
+
48
+ Alternatively, install or copy any of the skills from `skills/` into your AI coding agent (e.g. `.agents/skills/` or Claude/Cursor/Copilot), then tell your agent:
37
49
  > *"Add localization to this application with Kannada and Hindi"*
38
50
 
39
- The agent automatically verifies `shallok` is present, installs it if needed, and executes the complete 6-phase localization workflow.
51
+ The AI agent will:
52
+ 1. Check if `shallok` CLI is present in the project.
53
+ 2. If not present, install `shallok` into `devDependencies` automatically.
54
+ 3. Execute the 6-phase staged workflow (**Analyze → Plan → Init → Extract & Enrich Context → Translate → Build & Validate**) with **0 external API keys required**.
40
55
 
41
56
  ---
42
57
 
43
- ## CLI Commands
58
+ ## CLI Commands Reference
59
+
60
+ > Run via your package runner (`npx shallok`, `pnpm shallok`) or global install (`npm i -g shallok`).
44
61
 
62
+ ### Project Setup & Analysis
45
63
  ```bash
46
- # Analyze project architecture
64
+ # Setup Shallok in project (install devDependency + copy AI agent skill) - For developers only
65
+ shallok setup
66
+ shallok setup --framework nextjs
67
+
68
+ # Analyze repository architecture without modifying files
69
+ shallok analyze
47
70
  shallok analyze --json
48
71
 
49
- # Initialize configuration and framework files
72
+ # Initialize configuration and framework files (used by AI agents or developers)
73
+ shallok init
50
74
  shallok init --source en --locales kn,hi,fr --framework react --yes
75
+ ```
51
76
 
52
- # Extract strings and preview changes
77
+ ### Extraction & Code Transformation
78
+ ```bash
79
+ # Preview proposed keys and transformations without modifying files
53
80
  shallok extract --dry-run
81
+
82
+ # Reconcile canonical catalog without modifying source code
54
83
  shallok extract
55
84
 
56
- # Apply AST transformations to source code
85
+ # Apply AST transformations to source code (replaces hardcoded strings with t(...) calls)
57
86
  shallok extract --apply
87
+ ```
88
+
89
+ ### Translation & Context
90
+ ```bash
91
+ # Generate missing or stale translations
92
+ shallok translate
93
+ shallok translate --locale kn
94
+ shallok translate --force
95
+
96
+ # Update semantic context for a key in canonical catalog (preserved across future extractions)
97
+ shallok context set app.pay_now "Primary CTA button in checkout flow to trigger payment modal"
98
+
99
+ # Directly update a translated entry in a locale catalog
100
+ shallok entry set kn app.pay_now "ಈಗ ಪಾವತಿಸಿ"
101
+ ```
58
102
 
59
- # Check localization status
103
+ ### Health, Validation & Build
104
+ ```bash
105
+ # Check localization status & translation completeness
60
106
  shallok status
107
+ shallok status --json
61
108
 
62
- # Compile runtime message bundles
63
- shallok build
109
+ # Produce a full localization health report
110
+ shallok report
111
+ shallok report --json
64
112
 
65
- # Validate placeholder and catalog integrity
113
+ # Validate placeholder parity ({name}) and catalog integrity
66
114
  shallok validate
115
+
116
+ # Compile runtime-compatible message bundles
117
+ shallok build
118
+ shallok build --format nested
119
+ ```
120
+
121
+ ### Management & Automation
122
+ ```bash
123
+ # Add or remove target locales
124
+ shallok locale add de
125
+ shallok locale remove fr
126
+
127
+ # Rename a key across canonical catalog, locale catalogs, and source references
128
+ shallok key rename old.key auth.login
129
+
130
+ # Full end-to-end sync pipeline (extract, translate, build, and validate)
131
+ shallok sync --dry-run
132
+ shallok sync --yes
67
133
  ```
68
134
 
69
135
  ---
70
136
 
137
+ ## Manifest Schema: `localization.json`
138
+
139
+ Located at the root of the target project:
140
+ ```json
141
+ {
142
+ "schema_version": 1,
143
+ "localization_version": 1,
144
+ "source_locale": "en",
145
+ "supported_locales": ["en", "kn", "hi", "fr", "de"],
146
+ "framework": {
147
+ "name": "nextjs",
148
+ "router": "app",
149
+ "localization_library": "next-intl",
150
+ "library_version": null
151
+ },
152
+ "paths": {
153
+ "source_directories": ["src"],
154
+ "base_directory": "localization_base",
155
+ "translations_directory": "messages"
156
+ },
157
+ "key_strategy": "semantic",
158
+ "translation": {
159
+ "provider": "mock",
160
+ "model": null,
161
+ "batch_size": 25
162
+ },
163
+ "options": {
164
+ "include_accessibility_text": true,
165
+ "preserve_obsolete_keys": true,
166
+ "require_review_for_ambiguous_strings": true,
167
+ "require_review_for_stale_translations": true
168
+ }
169
+ }
170
+ ```
171
+
172
+ ---
173
+
174
+ ## Agent Skills Included
175
+
176
+ Shallok ships with 5 tailored skills for AI coding agents:
177
+ - `skills/localization-and-translation-i18n/`: Framework-independent core workflow
178
+ - `skills/react-localization-and-translation-i18n/`: React (`react-i18next`)
179
+ - `skills/nextjs-localization-and-translation-i18n/`: Next.js (`next-intl`)
180
+ - `skills/expo-localization-and-translation-i18n/`: Expo & React Native (`expo-localization` + `i18next`)
181
+ - `skills/astro-localization-and-translation-i18n/`: Astro (`astro:i18n`)
182
+
183
+ ---
184
+
71
185
  ## License
72
186
 
73
- MIT © Shallok Contributors
187
+ MIT © [Shallok Contributors](https://github.com/Hypermona/Shallok)