@hagicode/hagi18n 0.1.0-dev.1.1.45d0d2f → 0.1.0-dev.3.1.5b3b044
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 +13 -0
- package/README_cn.md +13 -0
- package/package.json +2 -1
- package/skills/hagi18n/SKILL.md +39 -0
- package/skills/hagi18n/agents/openai.yaml +7 -0
- package/skills/hagi18n/references/cli-workflows.md +62 -0
- package/skills/hagi18n/references/config-and-layout.md +116 -0
- package/skills/hagi18n/references/development-and-validation.md +50 -0
package/README.md
CHANGED
|
@@ -9,6 +9,19 @@ It supports:
|
|
|
9
9
|
- Safe `sync` and `prune` mutations with dry-run defaults.
|
|
10
10
|
- Optional `hagi18n.yaml` defaults so each project can define its own locale layout.
|
|
11
11
|
|
|
12
|
+
## AI Skill
|
|
13
|
+
|
|
14
|
+
This repository now ships a local Codex-style skill at [`skills/hagi18n/SKILL.md`](skills/hagi18n/SKILL.md).
|
|
15
|
+
|
|
16
|
+
Use it when an AI agent needs to:
|
|
17
|
+
|
|
18
|
+
- run or explain `hagi18n audit`, `doctor`, `sync`, or `prune`
|
|
19
|
+
- add or review a `hagi18n.yaml` file
|
|
20
|
+
- inspect or modify the source in `repos/hagi18n`
|
|
21
|
+
- validate locale maintenance workflows against a consumer repository
|
|
22
|
+
|
|
23
|
+
The skill includes focused references for command usage, configuration, and package development.
|
|
24
|
+
|
|
12
25
|
## Requirements
|
|
13
26
|
|
|
14
27
|
- Node.js 20 or newer
|
package/README_cn.md
CHANGED
|
@@ -9,6 +9,19 @@
|
|
|
9
9
|
- 安全的 `sync` / `prune` 变更流程,默认 dry-run
|
|
10
10
|
- 可选的 `hagi18n.yaml` 项目配置,适配不同仓库目录结构
|
|
11
11
|
|
|
12
|
+
## AI Skill
|
|
13
|
+
|
|
14
|
+
仓库现在内置了一套本地 Codex 风格 skill,位置在 [`skills/hagi18n/SKILL.md`](skills/hagi18n/SKILL.md)。
|
|
15
|
+
|
|
16
|
+
当 AI 代理需要完成以下任务时,可以直接使用这套 skill:
|
|
17
|
+
|
|
18
|
+
- 执行或解释 `hagi18n audit`、`doctor`、`sync`、`prune`
|
|
19
|
+
- 新增或审查 `hagi18n.yaml`
|
|
20
|
+
- 检查或修改 `repos/hagi18n` 内源码
|
|
21
|
+
- 在消费方仓库中验证语言包维护流程
|
|
22
|
+
|
|
23
|
+
skill 内还附带了命令使用、配置结构和包开发流程的拆分参考文档。
|
|
24
|
+
|
|
12
25
|
## 前提
|
|
13
26
|
|
|
14
27
|
- Node.js 20 或更高版本
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hagicode/hagi18n",
|
|
3
|
-
"version": "0.1.0-dev.
|
|
3
|
+
"version": "0.1.0-dev.3.1.5b3b044",
|
|
4
4
|
"description": "Scoped npm package foundation for HagiCode internationalization tooling.",
|
|
5
5
|
"homepage": "https://github.com/HagiCode-org/hagi18n#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"dist",
|
|
26
|
+
"skills",
|
|
26
27
|
"README.md",
|
|
27
28
|
"README_cn.md"
|
|
28
29
|
],
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hagi18n
|
|
3
|
+
description: Use when the user wants to audit, doctor, sync, prune, configure, or modify YAML locale maintenance workflows powered by @hagicode/hagi18n, including package usage in other repositories and source changes in repos/hagi18n.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Hagi18n
|
|
7
|
+
|
|
8
|
+
Use this skill when the task is to:
|
|
9
|
+
|
|
10
|
+
- run or explain the `hagi18n` CLI
|
|
11
|
+
- add, review, or fix a `hagi18n.yaml` configuration
|
|
12
|
+
- inspect locale drift, placeholder mismatches, or legacy locale references
|
|
13
|
+
- modify `@hagicode/hagi18n` source, tests, or release packaging in `repos/hagi18n`
|
|
14
|
+
|
|
15
|
+
## Core rules
|
|
16
|
+
|
|
17
|
+
- Prefer package-first usage for consumer repositories: `npx @hagicode/hagi18n <command>` or the installed `hagi18n` binary.
|
|
18
|
+
- Run build, test, and development commands with the working directory set to `repos/hagi18n`.
|
|
19
|
+
- `sync` and `prune` are dry-run by default. Only add `--write` when the user explicitly wants file mutations.
|
|
20
|
+
- Prefer canonical locale names such as `en-US` and `zh-CN`; aliases like `en`, `en-us`, `zh`, and `zh-cn` are normalized by the toolkit, but new code and docs should use canonical names.
|
|
21
|
+
- Use this package for locale maintenance and repository hygiene. Do not treat it as a runtime translation loader or UI i18n framework.
|
|
22
|
+
|
|
23
|
+
## Choose the workflow
|
|
24
|
+
|
|
25
|
+
1. Command usage in a consumer repository -> read [`references/cli-workflows.md`](references/cli-workflows.md)
|
|
26
|
+
2. Locale layout, config shape, or doctor scan behavior -> read [`references/config-and-layout.md`](references/config-and-layout.md)
|
|
27
|
+
3. Source changes, tests, or package validation in `repos/hagi18n` -> read [`references/development-and-validation.md`](references/development-and-validation.md)
|
|
28
|
+
|
|
29
|
+
## Source of truth
|
|
30
|
+
|
|
31
|
+
- CLI entry point: `src/cli.ts`
|
|
32
|
+
- Config loading and default rules: `src/config.ts`
|
|
33
|
+
- Audit, doctor, sync, and prune behavior: `src/locale-toolkit.ts`
|
|
34
|
+
|
|
35
|
+
## References
|
|
36
|
+
|
|
37
|
+
- [`references/cli-workflows.md`](references/cli-workflows.md) - package usage, command intent, exit code expectations, and mutation safety
|
|
38
|
+
- [`references/config-and-layout.md`](references/config-and-layout.md) - supported locale tree layout, `hagi18n.yaml` shape, aliases, and doctor defaults
|
|
39
|
+
- [`references/development-and-validation.md`](references/development-and-validation.md) - repository-local scripts, source map, and expected validation after edits
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "Hagi18n"
|
|
3
|
+
short_description: "Operate and modify the HagiCode YAML locale maintenance toolkit."
|
|
4
|
+
default_prompt: "Use $hagi18n to inspect, run, configure, or update the locale maintenance toolkit in repos/hagi18n."
|
|
5
|
+
|
|
6
|
+
policy:
|
|
7
|
+
allow_implicit_invocation: true
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# CLI Workflows
|
|
2
|
+
|
|
3
|
+
## Use cases
|
|
4
|
+
|
|
5
|
+
Use `@hagicode/hagi18n` when a repository stores locale files as YAML trees and needs a maintenance workflow instead of ad hoc scripts.
|
|
6
|
+
|
|
7
|
+
Common goals:
|
|
8
|
+
|
|
9
|
+
- audit locale drift against a canonical base locale
|
|
10
|
+
- scan the repository for legacy locale references
|
|
11
|
+
- fill in missing files or keys safely
|
|
12
|
+
- prune files or keys that no longer exist in the base locale
|
|
13
|
+
|
|
14
|
+
## Preferred invocation
|
|
15
|
+
|
|
16
|
+
In a consumer repository:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npx @hagicode/hagi18n audit --config hagi18n.yaml
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
If the package is already installed:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
hagi18n doctor --config hagi18n.yaml
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
For development against the local source tree in `repos/hagi18n`:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
cd repos/hagi18n
|
|
32
|
+
npm run dev -- audit --locales-root ../some-app/src/locales --base-locale en-US
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Command intent
|
|
36
|
+
|
|
37
|
+
- `info`: print package metadata and foundation status
|
|
38
|
+
- `audit`: compare locale files against a base locale and report drift
|
|
39
|
+
- `report`: run the audit flow and always print JSON
|
|
40
|
+
- `doctor`: run the audit flow and scan text files for legacy locale references
|
|
41
|
+
- `sync`: add missing files and keys from the base locale
|
|
42
|
+
- `prune`: remove files and keys that no longer exist in the base locale
|
|
43
|
+
|
|
44
|
+
## Mutation safety
|
|
45
|
+
|
|
46
|
+
- `sync` and `prune` default to dry-run behavior.
|
|
47
|
+
- Add `--write` only when the user clearly wants files changed.
|
|
48
|
+
- `--dry-run` wins over `--write` if both are present.
|
|
49
|
+
- `--to` can be repeated to limit mutations to specific target locales.
|
|
50
|
+
|
|
51
|
+
## Exit code expectations
|
|
52
|
+
|
|
53
|
+
- `audit`: `0` when clean, `1` when issues exist
|
|
54
|
+
- `report`: same behavior as `audit`, but always JSON
|
|
55
|
+
- `doctor`: `1` when audit issues or legacy reference issues exist
|
|
56
|
+
- `sync` and `prune`: `1` for parse or processing errors; planned or applied mutations still produce a structured summary
|
|
57
|
+
|
|
58
|
+
## Working assumptions
|
|
59
|
+
|
|
60
|
+
- The toolkit expects a base locale such as `en-US`.
|
|
61
|
+
- Locale aliases are accepted, but output and new config should prefer canonical locale names.
|
|
62
|
+
- JSON mode is appropriate when another tool or agent needs machine-readable results.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Config And Layout
|
|
2
|
+
|
|
3
|
+
## Expected locale tree
|
|
4
|
+
|
|
5
|
+
The package works on a locale root containing per-locale directories:
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
src/locales/
|
|
9
|
+
en-US/
|
|
10
|
+
common.yml
|
|
11
|
+
features/editor.yml
|
|
12
|
+
zh-CN/
|
|
13
|
+
common.yml
|
|
14
|
+
features/editor.yml
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Supported files:
|
|
18
|
+
|
|
19
|
+
- `.yml`
|
|
20
|
+
- `.yaml`
|
|
21
|
+
|
|
22
|
+
Supported documents:
|
|
23
|
+
|
|
24
|
+
- top-level YAML mappings only
|
|
25
|
+
- nested objects
|
|
26
|
+
- arrays
|
|
27
|
+
- scalar translation leaves
|
|
28
|
+
- `{{placeholder}}` interpolation tokens
|
|
29
|
+
|
|
30
|
+
## Locale normalization
|
|
31
|
+
|
|
32
|
+
The toolkit currently normalizes these aliases:
|
|
33
|
+
|
|
34
|
+
- `en`, `en-us` -> `en-US`
|
|
35
|
+
- `zh`, `zh-cn` -> `zh-CN`
|
|
36
|
+
|
|
37
|
+
Prefer canonical values in code, tests, and docs even though aliases resolve correctly.
|
|
38
|
+
|
|
39
|
+
## Config file
|
|
40
|
+
|
|
41
|
+
By default the CLI looks for `hagi18n.yaml` or `hagi18n.yml` in the current working directory. Relative paths are resolved from the config file directory.
|
|
42
|
+
|
|
43
|
+
Minimal example:
|
|
44
|
+
|
|
45
|
+
```yaml
|
|
46
|
+
localesRoot: src/locales
|
|
47
|
+
repoRoot: .
|
|
48
|
+
baseLocale: en-US
|
|
49
|
+
targetLocales:
|
|
50
|
+
- zh-CN
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Extended example:
|
|
54
|
+
|
|
55
|
+
```yaml
|
|
56
|
+
localesRoot: src/locales
|
|
57
|
+
repoRoot: .
|
|
58
|
+
baseLocale: en-US
|
|
59
|
+
targetLocales:
|
|
60
|
+
- zh-CN
|
|
61
|
+
doctor:
|
|
62
|
+
excludedDirectories:
|
|
63
|
+
- .git
|
|
64
|
+
- dist
|
|
65
|
+
- node_modules
|
|
66
|
+
textFileExtensions:
|
|
67
|
+
- .ts
|
|
68
|
+
- .tsx
|
|
69
|
+
- .js
|
|
70
|
+
- .md
|
|
71
|
+
excludedPathPrefixes:
|
|
72
|
+
- src/generated/
|
|
73
|
+
allowlist:
|
|
74
|
+
legacy-language-change-call:
|
|
75
|
+
- src/legacy-test.ts
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Config precedence
|
|
79
|
+
|
|
80
|
+
1. CLI flags or direct API options
|
|
81
|
+
2. `hagi18n.yaml` or `hagi18n.yml`
|
|
82
|
+
3. package defaults
|
|
83
|
+
|
|
84
|
+
## Current doctor defaults
|
|
85
|
+
|
|
86
|
+
Default excluded directories:
|
|
87
|
+
|
|
88
|
+
- `.git`
|
|
89
|
+
- `coverage`
|
|
90
|
+
- `dist`
|
|
91
|
+
- `indexGenerator`
|
|
92
|
+
- `node_modules`
|
|
93
|
+
- `public`
|
|
94
|
+
|
|
95
|
+
Default text file extensions:
|
|
96
|
+
|
|
97
|
+
- `.cjs`
|
|
98
|
+
- `.js`
|
|
99
|
+
- `.jsx`
|
|
100
|
+
- `.md`
|
|
101
|
+
- `.mjs`
|
|
102
|
+
- `.ts`
|
|
103
|
+
- `.tsx`
|
|
104
|
+
|
|
105
|
+
Default excluded path prefixes:
|
|
106
|
+
|
|
107
|
+
- `src/generated/`
|
|
108
|
+
|
|
109
|
+
Default built-in scan rules look for:
|
|
110
|
+
|
|
111
|
+
- legacy `src/locales/en/` style paths
|
|
112
|
+
- `changeLanguage("en")` style canonical language switches
|
|
113
|
+
- `language: "en"` style canonical language literals
|
|
114
|
+
- `'en' | 'zh-CN'` style unions and casts
|
|
115
|
+
|
|
116
|
+
When the user needs exact behavior, inspect `src/config.ts` and use that file as the source of truth.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Development And Validation
|
|
2
|
+
|
|
3
|
+
## Repository-local commands
|
|
4
|
+
|
|
5
|
+
Run these from `repos/hagi18n`:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm test
|
|
9
|
+
npm run build
|
|
10
|
+
npm run lint
|
|
11
|
+
npm run pack:check
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Useful package maintenance helpers:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm run publish:check-prereqs
|
|
18
|
+
npm run publish:prepare-dev-version
|
|
19
|
+
npm run publish:verify-release
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Source map
|
|
23
|
+
|
|
24
|
+
- `src/cli.ts`: command registration, option parsing, summary output, and exit code wiring
|
|
25
|
+
- `src/config.ts`: config discovery, YAML parsing, defaults, doctor rules, and config resolution
|
|
26
|
+
- `src/locale-toolkit.ts`: file walking, YAML reads, placeholder checks, doctor scanning, and mutation planning
|
|
27
|
+
- `src/index.ts`: public exports for API consumers
|
|
28
|
+
- `src/__tests__/`: CLI, config, index, and locale toolkit coverage
|
|
29
|
+
|
|
30
|
+
## Packaging notes
|
|
31
|
+
|
|
32
|
+
- Published files are controlled by `package.json`.
|
|
33
|
+
- When adding AI-facing skill content or other runtime-relevant docs, keep package contents aligned with the `files` allowlist.
|
|
34
|
+
- The package is ESM and exports the CLI binary from `dist/cli.js`.
|
|
35
|
+
|
|
36
|
+
## Validation expectations after edits
|
|
37
|
+
|
|
38
|
+
- Run the narrowest relevant tests first if the change is isolated.
|
|
39
|
+
- Run `npm test` after source or skill-related packaging changes.
|
|
40
|
+
- Run `npm run build` after TypeScript or export changes.
|
|
41
|
+
- Run `npm run pack:check` when package contents or publish-facing files change.
|
|
42
|
+
|
|
43
|
+
## Behavior references
|
|
44
|
+
|
|
45
|
+
The package preserves the Web maintenance model:
|
|
46
|
+
|
|
47
|
+
- `repos/web/buildTools/lib/i18nLocaleToolkit.mjs` -> `src/locale-toolkit.ts`
|
|
48
|
+
- `repos/web/buildTools/i18n-locale-cli.mjs` -> `src/cli.ts`
|
|
49
|
+
|
|
50
|
+
Use the local source tree as the writable source of truth and treat the Web mapping as historical context only.
|