Skip to content

fix: add code--zh-tw.json mode file for Traditional Chinese (#1364)#1669

Closed
ousamabenyounes wants to merge 5 commits intothedotmack:mainfrom
ousamabenyounes:fix/issue-1364
Closed

fix: add code--zh-tw.json mode file for Traditional Chinese (#1364)#1669
ousamabenyounes wants to merge 5 commits intothedotmack:mainfrom
ousamabenyounes:fix/issue-1364

Conversation

@ousamabenyounes
Copy link
Copy Markdown
Contributor

Summary

Fixes #1364

Setting CLAUDE_MEM_MODE to code--zh-TW (or code--zh-tw) fell back silently to code--zh (Simplified Chinese) because code--zh-tw.json was missing from plugin/modes/. The new file:

  • Uses Traditional Chinese characters throughout (設定、檔案、開發, NOT 设定、档案、开发)
  • Explicitly states 繁體中文 (Traditional Chinese) in all language requirement sections
  • Follows the same structure as other language mode files (code--zh.json, code--ja.json)

Usage: set "CLAUDE_MEM_MODE": "code--zh-tw" in ~/.claude-mem/settings.json (lowercase, consistent with other language modes).

Verification

  • Baseline tests: 1106 pass, 0 pre-existing failures
  • Post-fix tests: 1110 pass, 0 regressions, +4 new tests
  • New tests: 4 in tests/utils/mode-zh-tw.test.ts verifying file exists, Traditional Chinese characters present, 繁體中文 language requirement, valid JSON structure
  • All prompts keys present: footer, xml_title_placeholder, xml_narrative_placeholder, continuation_instruction, summary_footer

Files changed

File Change
plugin/modes/code--zh-tw.json New — Traditional Chinese mode file
tests/utils/mode-zh-tw.test.ts New — regression tests for #1364

Generated by Claude Code
Vibe coded by ousamabenyounes

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 9, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e4492d12-55ce-43ba-a3b9-73bf1735ccee

📥 Commits

Reviewing files that changed from the base of the PR and between d099a91 and 873ead3.

📒 Files selected for processing (2)
  • src/services/domain/ModeManager.ts
  • src/services/worker-service.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/services/domain/ModeManager.ts

Summary by CodeRabbit

  • New Features

    • Added a Traditional Chinese "Code Development" mode with localized prompts, XML-formatted output guidelines, and continuation instructions in Traditional Chinese.
  • Bug Fixes

    • Mode ID handling is now canonicalized to lowercase so differently cased IDs reliably load the same mode.
    • Normalized the memory-mode setting check used during background initialization to ensure consistent behavior.
  • Tests

    • Added tests validating the Traditional Chinese mode content and case-insensitive loading behavior.

Walkthrough

Adds a Traditional Chinese mode file and tests, normalizes mode IDs to lowercase in ModeManager (with a new helper), and updates worker-service to use the normalized mode ID when deciding a one-time Chroma wipe.

Changes

Cohort / File(s) Summary
Traditional Chinese Mode Configuration
plugin/modes/code--zh-tw.json
New "Code Development (Traditional Chinese)" mode file with prompts (including footer, summary_footer, continuation_instruction) and multiple XML placeholder fields; requires output in 繁體中文 and enforces specific XML structure and phrasing rules.
Mode File Regression Tests
tests/utils/mode-zh-tw.test.ts
New tests verifying presence and JSON validity of code--zh-tw.json, presence of Traditional Chinese characters and 繁體中文, required prompt keys exist, case-insensitive loading via ModeManager, and that no mixed-case filename (code--zh-TW.json) exists.
Mode ID normalization
src/services/domain/ModeManager.ts
Added static normalizeModeId(modeId: string): string; loadMode now lowercases the requested mode ID for inheritance, file loading, recursion guards, and logging (uses normalized ID in warnings/fallback messages).
Worker init decision
src/services/worker-service.ts
Normalizes settings.CLAUDE_MEM_MODE via ModeManager.normalizeModeId(...) before comparing to 'local' to decide the one-time Chroma wipe during background initialization.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Client
participant ModeManager
participant Filesystem
participant JSONParser
participant WorkerService
participant Settings

Client->>ModeManager: loadMode("code--zh-TW")
ModeManager->>ModeManager: normalizeModeId -> "code--zh-tw"
ModeManager->>Filesystem: read plugin/modes/code--zh-tw.json
alt file exists
Filesystem-->>ModeManager: file contents
ModeManager->>JSONParser: parse JSON
JSONParser-->>ModeManager: mode object
ModeManager-->>Client: return mode (Traditional Chinese)
else file missing
ModeManager->>Filesystem: read fallback plugin/modes/code--zh.json
Filesystem-->>ModeManager: fallback contents / not found
ModeManager-->>Client: warn/return fallback based on normalized id
end

Settings->>WorkerService: provide CLAUDE_MEM_MODE
WorkerService->>ModeManager: ModeManager.normalizeModeId(CLAUDE_MEM_MODE)
ModeManager-->>WorkerService: normalized id
alt normalized id != "local"
WorkerService->>WorkerService: skip one-time Chroma wipe
else normalized id == "local"
WorkerService->>WorkerService: perform one-time Chroma wipe
end

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 新檔落地繁體吟,
提示排列像月光清,
測試來訪把路尋,
模式正名不再混,
小兔跳躍,改動成。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely describes the main change: adding a code--zh-tw.json mode file for Traditional Chinese support, with direct reference to the issue number.
Description check ✅ Passed The PR description provides comprehensive context about the problem, solution, and verification steps, directly addressing the missing Traditional Chinese mode file issue.
Linked Issues check ✅ Passed The PR fully addresses issue #1364 by adding the missing code--zh-tw.json file with Traditional Chinese characters, explicit language requirements, and comprehensive test coverage.
Out of Scope Changes check ✅ Passed All changes are in-scope: the new mode file addresses #1364, tests validate the fix, and ModeManager updates support case-insensitive mode ID normalization needed for the Traditional Chinese mode to work properly.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@plugin/modes/code--zh-tw.json`:
- Around line 1-24: The mode ID casing mismatch allows a configured modeId like
code--zh-TW to miss the existing file code--zh-tw.json because loadModeFile
resolves `${modeId}.json` verbatim; update the lookup in loadModeFile to
normalize mode IDs (e.g., toLowerCase() or a canonical form) before building the
filename or add a compatibility alias lookup (try `${modeId}.json` then
`${normalizedModeId}.json` and also check for common variants such as swapping
region case) so both code--zh-tw.json and code--zh-TW.json map correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c3704b64-9647-4f08-a95b-dfbb452cea34

📥 Commits

Reviewing files that changed from the base of the PR and between cde4faa and 23bda78.

📒 Files selected for processing (2)
  • plugin/modes/code--zh-tw.json
  • tests/utils/mode-zh-tw.test.ts

Comment thread plugin/modes/code--zh-tw.json
ousamabenyounes and others added 2 commits April 10, 2026 08:26
…ck#1364)

code--zh-TW mode was silently falling back to code--zh (Simplified Chinese)
because code--zh-tw.json did not exist. Added the mode file with Traditional
Chinese placeholders and explicit 繁體中文 language requirements, using traditional
characters like 設定、檔案、開發 rather than simplified equivalents.

Generated by Claude Code
Vibe coded by ousamabenyounes

Co-Authored-By: Claude <noreply@anthropic.com>
…ck (thedotmack#1364)

On case-sensitive filesystems, CLAUDE_MEM_MODE=code--zh-TW failed to find
code--zh-tw.json and silently fell back to code--zh (Simplified Chinese).

- ModeManager.loadMode() now normalizes modeId to lowercase before any
  file lookup, so code--zh-TW, code--zh-Tw, and code--zh-tw all resolve
  to code--zh-tw.json
- Added 4 regression tests: confirms no mixed-case alias file exists, and
  that ModeManager handles uppercase/mixed-case mode IDs correctly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/services/domain/ModeManager.ts`:
- Around line 134-136: The code currently lowercases mode IDs inside
ModeManager.loadMode (normalizedId = modeId.toLowerCase()), which causes
inconsistent behavior when callers compare raw mode strings before calling
loadMode; add a single public utility (e.g., ModeManager.normalizeModeId) that
performs the normalization (lowercasing and any canonicalization) and update all
call sites (for example where worker-service checks 'local') to call
ModeManager.normalizeModeId(...) before any comparisons, and keep loadMode
calling normalizeModeId internally for safety; update usages of
parseInheritance/normalizedId to use the new normalizeModeId so behavior is
consistent across the codebase.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4a40c7fd-9d55-406d-8b99-cfca21236138

📥 Commits

Reviewing files that changed from the base of the PR and between 23bda78 and c1452f3.

📒 Files selected for processing (3)
  • plugin/modes/code--zh-tw.json
  • src/services/domain/ModeManager.ts
  • tests/utils/mode-zh-tw.test.ts
✅ Files skipped from review due to trivial changes (1)
  • plugin/modes/code--zh-tw.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/utils/mode-zh-tw.test.ts

Comment thread src/services/domain/ModeManager.ts Outdated
…tw suite

Removes repeated join(MODES_DIR, ...) and readFileSync calls across 4 it blocks
by hoisting modePath as a const and populating content via beforeEach.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/utils/mode-zh-tw.test.ts`:
- Around line 22-27: The existsSync assertion is currently masked by the
beforeEach reading the file (readFileSync(modePath, 'utf-8')) which throws if
the file is missing; move the file read out of the global beforeEach so the
existence test can run independently: keep or create a beforeEach for tests that
need file content (assigning content = readFileSync(modePath, 'utf-8')) but
remove that read from the global setup used by the 'code--zh-tw.json exists in
plugin/modes/' test, leaving that test to only call existsSync(modePath) and
only read into the content variable inside tests that require the file.
- Around line 55-59: The test 'code--zh-TW.json does NOT exist (only lowercase
filename is canonical)' uses existsSync(upperPath) which is unreliable on
case-insensitive filesystems; update the assertion to read the directory entries
via readdirSync(MODES_DIR) and assert that the exact filename 'code--zh-TW.json'
is not present (e.g., entries.includes('code--zh-TW.json') is false),
referencing MODES_DIR, join, and the test name to locate and replace the
existsSync check.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 506e731e-1318-4c58-bc01-f1da6e070c14

📥 Commits

Reviewing files that changed from the base of the PR and between c1452f3 and 64cb7c6.

📒 Files selected for processing (1)
  • tests/utils/mode-zh-tw.test.ts

Comment thread tests/utils/mode-zh-tw.test.ts
Comment thread tests/utils/mode-zh-tw.test.ts
…ync for case check

- Guard readFileSync in beforeEach with existsSync so the file-existence test
  can assert independently without throwing first
- Replace existsSync(upperPath) with readdirSync exact-name check — existsSync
  is unreliable on case-insensitive filesystems (macOS/Windows)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ousamabenyounes
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 10, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

CodeRabbit review request: centralise lowercase normalisation behind a
public static so all call sites share the same canonicalisation logic.

- Add ModeManager.normalizeModeId(modeId) → modeId.toLowerCase()
- loadMode() delegates to normalizeModeId instead of inline .toLowerCase()
- worker-service.ts 'local' comparison now uses normalizeModeId so LOCAL
  or Local settings values are handled consistently

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@thedotmack
Copy link
Copy Markdown
Owner

Closed during the April 2026 backlog cleanup. The underlying bug is now tracked in #1961, which is the single canonical issue being addressed by the maintainer. Thanks for taking the time to report — your symptoms and repro are captured in the consolidated ticket.

@thedotmack thedotmack closed this Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing mode file for zh-TW (Traditional Chinese)

2 participants