Compare commits

..

3 Commits

Author SHA1 Message Date
Martin Klein
2b847406dc docs(i18n): fix German quotation marks in de-DE docs
Per CodeRabbit review on PR #2029: pair the opening „ with the proper
closing “ in GLOSSARY.md (was closing with an ASCII straight quote).
Also normalise the one stray „..." in README.md to ASCII quotes,
consistent with the rest of that file (it quotes a literal error string).

Refs #1980
2026-05-21 01:12:31 +02:00
Martin Klein
613a196501 fix(manifests): add docs/de-DE to package.json publish surface
The npm-publish-surface test asserts package.json `files` aligns with
the install module graph. The new docs-de-de module requires docs/de-DE
in the published files list.

Refs #1980
2026-05-21 01:04:00 +02:00
Martin Klein
ef0c55c40f docs(i18n): add German (de-DE) localization scout
Adds the German locale per maintainer guidance in issue #1980.

- docs/de-DE/README.md: full translation of the English root README
- docs/de-DE/GLOSSARY.md: German terminology decisions (which ECC
  terms stay English vs. German)
- manifests: docs-de-de module + locale:de-de component, modelled on
  the existing docs-zh-tw / locale:zh-tw entries
- scripts/lib/install-manifests.js: de-DE in SUPPORTED_LOCALES, plus
  de-DE and de aliases so `--locale de` and `--locale de-DE` resolve
- tests/lib/locale-install.test.js: focused de-DE coverage
- Deutsch added to the language selector tables in all 10 existing
  READMEs (root + 9 localized)

Refs #1980
2026-05-21 00:50:39 +02:00
19 changed files with 1929 additions and 155 deletions

View File

@@ -1,4 +1,4 @@
**Language:** English | [Português (Brasil)](docs/pt-BR/README.md) | [简体中文](README.zh-CN.md) | [繁體中文](docs/zh-TW/README.md) | [日本語](docs/ja-JP/README.md) | [한국어](docs/ko-KR/README.md) | [Türkçe](docs/tr/README.md) | [Русский](docs/ru/README.md) | [Tiếng Việt](docs/vi-VN/README.md) | [ไทย](docs/th/README.md)
**Language:** English | [Português (Brasil)](docs/pt-BR/README.md) | [简体中文](README.zh-CN.md) | [繁體中文](docs/zh-TW/README.md) | [日本語](docs/ja-JP/README.md) | [한국어](docs/ko-KR/README.md) | [Türkçe](docs/tr/README.md) | [Русский](docs/ru/README.md) | [Tiếng Việt](docs/vi-VN/README.md) | [ไทย](docs/th/README.md) | [Deutsch](docs/de-DE/README.md)
# ECC
@@ -28,7 +28,7 @@
**Language / 语言 / 語言 / Dil / Язык / Ngôn ngữ**
[**English**](README.md) | [Português (Brasil)](docs/pt-BR/README.md) | [简体中文](README.zh-CN.md) | [繁體中文](docs/zh-TW/README.md) | [日本語](docs/ja-JP/README.md) | [한국어](docs/ko-KR/README.md)
| [Türkçe](docs/tr/README.md) | [Русский](docs/ru/README.md) | [Tiếng Việt](docs/vi-VN/README.md) | [ไทย](docs/th/README.md)
| [Türkçe](docs/tr/README.md) | [Русский](docs/ru/README.md) | [Tiếng Việt](docs/vi-VN/README.md) | [ไทย](docs/th/README.md) | [Deutsch](docs/de-DE/README.md)
</div>

View File

@@ -23,7 +23,7 @@
**Language / 语言 / 語言 / Dil / Язык / Ngôn ngữ**
[**English**](README.md) | [Português (Brasil)](docs/pt-BR/README.md) | [简体中文](README.zh-CN.md) | [繁體中文](docs/zh-TW/README.md) | [日本語](docs/ja-JP/README.md) | [한국어](docs/ko-KR/README.md) | [Türkçe](docs/tr/README.md) | [Русский](docs/ru/README.md) | [Tiếng Việt](docs/vi-VN/README.md) | [ไทย](docs/th/README.md)
[**English**](README.md) | [Português (Brasil)](docs/pt-BR/README.md) | [简体中文](README.zh-CN.md) | [繁體中文](docs/zh-TW/README.md) | [日本語](docs/ja-JP/README.md) | [한국어](docs/ko-KR/README.md) | [Türkçe](docs/tr/README.md) | [Русский](docs/ru/README.md) | [Tiếng Việt](docs/vi-VN/README.md) | [ไทย](docs/th/README.md) | [Deutsch](docs/de-DE/README.md)
</div>

67
docs/de-DE/GLOSSARY.md Normal file
View File

@@ -0,0 +1,67 @@
# Glossar / Glossary
Einheitliches Terminologie-Glossar für die deutsche (de-DE) Übersetzung von ECC.
Leitlinie: Etablierte englische Fachbegriffe und ECC-Oberflächennamen (`agents/`, `skills/`,
`commands/`, `hooks/`, `rules/`) bleiben **englisch** — sie sind im deutschsprachigen
Entwickleralltag Standard und entsprechen Verzeichnis-/Befehlsnamen im Repo. Begriffe mit
einer klaren, gebräuchlichen deutschen Entsprechung werden **übersetzt**.
| English | Deutsch | Notiz |
|---------|---------|-------|
| Agent | Agent | bleibt englisch — ECC-Oberfläche (`agents/`) |
| Skill | Skill | bleibt englisch — ECC-Oberfläche (`skills/`) |
| Hook | Hook | bleibt englisch — ECC-Oberfläche (`hooks/`) |
| Command | Command | bleibt englisch als ECC-Oberfläche (`commands/`); generisch sonst „Befehl“ |
| Rule | Rule | bleibt englisch als ECC-Oberfläche (`rules/`); generisch sonst „Regel“ |
| Harness | Harness | bleibt englisch — keine etablierte deutsche Entsprechung |
| Instinct | Instinct | bleibt englisch — ECC-Begriff aus Continuous Learning |
| Plugin | Plugin | bleibt englisch |
| Marketplace | Marketplace | bleibt englisch — Anthropic-Produktbegriff |
| Worktree | Worktree | bleibt englisch — Git-Fachbegriff |
| Subagent | Subagent | bleibt englisch |
| Frontmatter | Frontmatter | bleibt englisch; YAML-Feldnamen bleiben englisch |
| Continuous Learning | Continuous Learning | ECC-Feature-Name bleibt englisch; beschreibend „kontinuierliches Lernen“ |
| Memory | Memory | als ECC-Konzept englisch; generisch „Speicher“ |
| Context window | Kontextfenster | |
| Token | Token | |
| Coverage | Coverage | „Testabdeckung“, wo beschreibend |
| Test-Driven Development | testgetriebene Entwicklung | Kürzel TDD beibehalten |
| Code review | Code-Review | |
| Refactoring | Refactoring | |
| Pull request | Pull Request | |
| Commit | Commit | |
| Branch | Branch | |
| Merge | Merge / zusammenführen | je nach Kontext |
| Build | Build | |
| Deploy | Deployment / deployen | |
| Pipeline | Pipeline | |
| Orchestration | Orchestrierung | |
| Repository | Repository | kurz „Repo“ zulässig |
| Dependency | Abhängigkeit | |
| Edge case | Grenzfall | |
| Best practice | Best Practice | |
| Anti-pattern | Anti-Pattern | |
| Middleware | Middleware | |
| Endpoint | Endpoint | |
| Schema | Schema | |
| Payload | Payload | |
| Callback | Callback | |
| Checkpoint | Checkpoint | |
| Linter | Linter | |
| Formatter | Formatter | |
| Staging | Staging | |
| Production | Produktion / Produktivumgebung | je nach Kontext |
| Debugging | Debugging | |
| Logging | Logging | |
| Monitoring | Monitoring | |
| Rate limit | Rate-Limit | |
| Retry | Retry / Wiederholung | |
| Fallback | Fallback | |
| Graceful degradation | Graceful Degradation | |
| Sandboxing | Sandboxing | |
| Sanitization | Sanitisierung | |
| Selective install | selektive Installation | |
| Profile | Profil | Installationsprofil |
| Component | Komponente | Installationskomponente |
| Module | Modul | Installationsmodul |

1762
docs/de-DE/README.md Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
**言語:** [English](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](README.md) | [한국어](../ko-KR/README.md) | [Türkçe](../tr/README.md) | [Русский](../ru/README.md) | [Tiếng Việt](../vi-VN/README.md) | [ไทย](../th/README.md)
**言語:** [English](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](README.md) | [한국어](../ko-KR/README.md) | [Türkçe](../tr/README.md) | [Русский](../ru/README.md) | [Tiếng Việt](../vi-VN/README.md) | [ไทย](../th/README.md) | [Deutsch](../de-DE/README.md)
# Everything Claude Code
@@ -21,7 +21,7 @@
**言語 / Language / 語言 / Dil / Язык / Ngôn ngữ**
[**English**](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](README.md) | [한국어](../ko-KR/README.md) | [Türkçe](../tr/README.md) | [Русский](../ru/README.md) | [Tiếng Việt](../vi-VN/README.md) | [ไทย](../th/README.md)
[**English**](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](README.md) | [한국어](../ko-KR/README.md) | [Türkçe](../tr/README.md) | [Русский](../ru/README.md) | [Tiếng Việt](../vi-VN/README.md) | [ไทย](../th/README.md) | [Deutsch](../de-DE/README.md)
</div>

View File

@@ -1,4 +1,4 @@
**언어:** [English](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](../ja-JP/README.md) | 한국어 | [Türkçe](../tr/README.md) | [Русский](../ru/README.md) | [Tiếng Việt](../vi-VN/README.md) | [ไทย](../th/README.md)
**언어:** [English](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](../ja-JP/README.md) | 한국어 | [Türkçe](../tr/README.md) | [Русский](../ru/README.md) | [Tiếng Việt](../vi-VN/README.md) | [ไทย](../th/README.md) | [Deutsch](../de-DE/README.md)
# Everything Claude Code
@@ -24,7 +24,7 @@
**Language / 语言 / 語言 / 언어 / Dil / Язык / Ngôn ngữ**
[**English**](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](../ja-JP/README.md) | [한국어](README.md) | [Türkçe](../tr/README.md) | [Русский](../ru/README.md) | [Tiếng Việt](../vi-VN/README.md) | [ไทย](../th/README.md)
[**English**](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](../ja-JP/README.md) | [한국어](README.md) | [Türkçe](../tr/README.md) | [Русский](../ru/README.md) | [Tiếng Việt](../vi-VN/README.md) | [ไทย](../th/README.md) | [Deutsch](../de-DE/README.md)
</div>

View File

@@ -1,4 +1,4 @@
**Idioma:** [English](../../README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](../ja-JP/README.md) | [한국어](../ko-KR/README.md) | Português (Brasil) | [Türkçe](../tr/README.md) | [Русский](../ru/README.md) | [Tiếng Việt](../vi-VN/README.md) | [ไทย](../th/README.md)
**Idioma:** [English](../../README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](../ja-JP/README.md) | [한국어](../ko-KR/README.md) | Português (Brasil) | [Türkçe](../tr/README.md) | [Русский](../ru/README.md) | [Tiếng Việt](../vi-VN/README.md) | [ไทย](../th/README.md) | [Deutsch](../de-DE/README.md)
# Everything Claude Code
@@ -24,7 +24,7 @@
**Idioma / Language / 语言 / Dil / Язык / Ngôn ngữ**
[**English**](../../README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](../ja-JP/README.md) | [한국어](../ko-KR/README.md) | [Português (Brasil)](README.md) | [Türkçe](../tr/README.md) | [Русский](../ru/README.md) | [Tiếng Việt](../vi-VN/README.md) | [ไทย](../th/README.md)
[**English**](../../README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](../ja-JP/README.md) | [한국어](../ko-KR/README.md) | [Português (Brasil)](README.md) | [Türkçe](../tr/README.md) | [Русский](../ru/README.md) | [Tiếng Việt](../vi-VN/README.md) | [ไทย](../th/README.md) | [Deutsch](../de-DE/README.md)
</div>

View File

@@ -1,4 +1,4 @@
**Язык:** [English](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](../ja-JP/README.md) | [한국어](../ko-KR/README.md) | [Türkçe](../tr/README.md) | **Русский** | [Tiếng Việt](../vi-VN/README.md) | [ไทย](../th/README.md)
**Язык:** [English](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](../ja-JP/README.md) | [한국어](../ko-KR/README.md) | [Türkçe](../tr/README.md) | **Русский** | [Tiếng Việt](../vi-VN/README.md) | [ไทย](../th/README.md) | [Deutsch](../de-DE/README.md)
# Everything Claude Code
@@ -27,7 +27,7 @@
**Язык / 语言 / 語言 / Dil / Ngôn ngữ**
[**English**](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](../ja-JP/README.md) | [한국어](../ko-KR/README.md) | [Türkçe](../tr/README.md) | **Русский** | [Tiếng Việt](../vi-VN/README.md) | [ไทย](../th/README.md)
[**English**](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](../ja-JP/README.md) | [한국어](../ko-KR/README.md) | [Türkçe](../tr/README.md) | **Русский** | [Tiếng Việt](../vi-VN/README.md) | [ไทย](../th/README.md) | [Deutsch](../de-DE/README.md)
</div>

View File

@@ -1,4 +1,4 @@
**ภาษา:** [English](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](../ja-JP/README.md) | [한국어](../ko-KR/README.md) | [Türkçe](../tr/README.md) | [Русский](../ru/README.md) | [Tiếng Việt](../vi-VN/README.md) | **ไทย**
**ภาษา:** [English](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](../ja-JP/README.md) | [한국어](../ko-KR/README.md) | [Türkçe](../tr/README.md) | [Русский](../ru/README.md) | [Tiếng Việt](../vi-VN/README.md) | **ไทย** | [Deutsch](../de-DE/README.md)
# Everything Claude Code
@@ -18,7 +18,7 @@
**ภาษา / Language / 语言 / 語言 / Dil / Язык / Ngôn ngữ**
[English](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](../ja-JP/README.md) | [한국어](../ko-KR/README.md) | [Türkçe](../tr/README.md) | [Русский](../ru/README.md) | [Tiếng Việt](../vi-VN/README.md) | **ไทย**
[English](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](../ja-JP/README.md) | [한국어](../ko-KR/README.md) | [Türkçe](../tr/README.md) | [Русский](../ru/README.md) | [Tiếng Việt](../vi-VN/README.md) | **ไทย** | [Deutsch](../de-DE/README.md)
</div>

View File

@@ -23,7 +23,7 @@
**Dil / Language / 语言 / 語言 / Язык / Ngôn ngữ**
[**English**](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](../ja-JP/README.md) | [한국어](../ko-KR/README.md) | [**Türkçe**](README.md) | [Русский](../ru/README.md) | [Tiếng Việt](../vi-VN/README.md) | [ไทย](../th/README.md)
[**English**](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](../ja-JP/README.md) | [한국어](../ko-KR/README.md) | [**Türkçe**](README.md) | [Русский](../ru/README.md) | [Tiếng Việt](../vi-VN/README.md) | [ไทย](../th/README.md) | [Deutsch](../de-DE/README.md)
</div>

View File

@@ -1,4 +1,4 @@
**Ngôn ngữ:** [English](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](../ja-JP/README.md) | [한국어](../ko-KR/README.md) | [Türkçe](../tr/README.md) | [Русский](../ru/README.md) | **Tiếng Việt** | [ไทย](../th/README.md)
**Ngôn ngữ:** [English](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](../ja-JP/README.md) | [한국어](../ko-KR/README.md) | [Türkçe](../tr/README.md) | [Русский](../ru/README.md) | **Tiếng Việt** | [ไทย](../th/README.md) | [Deutsch](../de-DE/README.md)
# Everything Claude Code
@@ -18,7 +18,7 @@
**Ngôn ngữ / Language / 语言 / 語言 / Dil / Язык**
[English](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](../ja-JP/README.md) | [한국어](../ko-KR/README.md) | [Türkçe](../tr/README.md) | [Русский](../ru/README.md) | **Tiếng Việt** | [ไทย](../th/README.md)
[English](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | [繁體中文](../zh-TW/README.md) | [日本語](../ja-JP/README.md) | [한국어](../ko-KR/README.md) | [Türkçe](../tr/README.md) | [Русский](../ru/README.md) | **Tiếng Việt** | [ไทย](../th/README.md) | [Deutsch](../de-DE/README.md)
</div>

View File

@@ -13,7 +13,7 @@
**Language / 语言 / 語言 / Dil / Язык / Ngôn ngữ**
[**English**](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | **繁體中文** | [日本語](../ja-JP/README.md) | [한국어](../ko-KR/README.md) | [Türkçe](../tr/README.md) | [Русский](../ru/README.md) | [Tiếng Việt](../vi-VN/README.md) | [ไทย](../th/README.md)
[**English**](../../README.md) | [Português (Brasil)](../pt-BR/README.md) | [简体中文](../../README.zh-CN.md) | **繁體中文** | [日本語](../ja-JP/README.md) | [한국어](../ko-KR/README.md) | [Türkçe](../tr/README.md) | [Русский](../ru/README.md) | [Tiếng Việt](../vi-VN/README.md) | [ไทย](../th/README.md) | [Deutsch](../de-DE/README.md)
</div>

View File

@@ -589,6 +589,14 @@
"modules": [
"docs-zh-tw"
]
},
{
"id": "locale:de-de",
"family": "locale",
"description": "German (de-DE) translated reference docs installed to ~/.claude/docs/de-DE/.",
"modules": [
"docs-de-de"
]
}
]
}

View File

@@ -843,6 +843,22 @@
"defaultInstall": false,
"cost": "heavy",
"stability": "stable"
},
{
"id": "docs-de-de",
"kind": "docs",
"description": "German (de-DE) translated reference docs for agents, commands, skills, and rules.",
"paths": [
"docs/de-DE"
],
"targets": [
"claude",
"claude-project"
],
"dependencies": [],
"defaultInstall": false,
"cost": "heavy",
"stability": "stable"
}
]
}

View File

@@ -56,6 +56,7 @@
"agent.yaml",
"agents/",
"commands/",
"docs/de-DE/",
"docs/ja-JP/",
"docs/ko-KR/",
"docs/pt-BR/",

View File

@@ -20,54 +20,15 @@
* Each row therefore represents the cumulative session total up to that point.
* To get per-session cost, take the last row per session_id. To get per-day
* spend, aggregate.
*
* Harness-cost contract (optional, opt-in by the statusline):
* If the user's statusline (which receives `cost.total_cost_usd` directly
* from Claude Code) writes `{ts, cost_usd}` to
* `<os.tmpdir()>/harness-cost-<session_id>.json` on each render, this hook
* prefers that authoritative value over the transcript-sum estimate when
* the cache is fresh (≤ 300s). The transcript-sum is kept as a safe
* fallback because:
* - the hard-coded rate table cannot represent Opus 4.7's >200K-token
* 2x tier or the 1h-cache 2x tier (under-counts on long sessions);
* - summing the full transcript double-counts work done across
* `--resume` boundaries while `cost.total_cost_usd` is per-process.
* Absent a writer, behavior is unchanged.
*/
'use strict';
const fs = require('fs');
const os = require('os');
const path = require('path');
const { ensureDir, appendFile, getClaudeDir } = require('../lib/utils');
const { sanitizeSessionId } = require('../lib/session-bridge');
const HARNESS_COST_MAX_AGE_SECONDS = 300;
/**
* Read authoritative harness cost from the per-session cache file.
* @param {string} sessionId
* @param {number} maxAgeSeconds
* @returns {number|null} cost in USD, or null on miss / stale / parse error
*/
function readHarnessCost(sessionId, maxAgeSeconds) {
if (!sessionId) return null;
try {
const fp = path.join(os.tmpdir(), `harness-cost-${sessionId}.json`);
if (!fs.existsSync(fp)) return null;
const obj = JSON.parse(fs.readFileSync(fp, 'utf8'));
const ts = Number(obj && obj.ts);
const cost = Number(obj && obj.cost_usd);
if (!Number.isFinite(ts) || !Number.isFinite(cost) || cost < 0) return null;
const age = Math.floor(Date.now() / 1000) - ts;
if (age < 0 || age > maxAgeSeconds) return null;
return cost;
} catch {
return null;
}
}
// Approximate per-1M-token billing rates (USD).
// Cache creation: 1.25x input rate. Cache read: 0.1x input rate.
const RATE_TABLE = {
@@ -164,23 +125,13 @@ process.stdin.on('end', () => {
} = usageTotals || {};
const rates = getRates(model);
const transcriptCostUsd = Math.round((
const estimatedCostUsd = Math.round((
(inputTokens / 1e6) * rates.in +
(outputTokens / 1e6) * rates.out +
(cacheWriteTokens / 1e6) * rates.cacheWrite +
(cacheReadTokens / 1e6) * rates.cacheRead
) * 1e6) / 1e6;
// Prefer the harness's authoritative `cost.total_cost_usd` when the
// statusline has written it to the per-session cache (see contract in
// the file header). The harness number reflects API-billed truth
// (correct rates, 1h-cache 2x, >200K tier 2x) and is per-process so it
// does not drift across `--resume`. Cache miss → transcript-sum.
const harnessCost = readHarnessCost(sessionId, HARNESS_COST_MAX_AGE_SECONDS);
const estimatedCostUsd = harnessCost !== null
? Math.round(harnessCost * 1e6) / 1e6
: transcriptCostUsd;
const metricsDir = path.join(getClaudeDir(), 'metrics');
ensureDir(metricsDir);

View File

@@ -14,7 +14,7 @@ const COMPONENT_FAMILY_PREFIXES = {
skill: 'skill:',
locale: 'locale:',
};
const SUPPORTED_LOCALES = Object.freeze(['ja', 'zh-CN', 'ko-KR', 'pt-BR', 'ru', 'tr', 'vi-VN', 'zh-TW']);
const SUPPORTED_LOCALES = Object.freeze(['ja', 'zh-CN', 'ko-KR', 'pt-BR', 'ru', 'tr', 'vi-VN', 'zh-TW', 'de-DE']);
const LOCALE_ALIAS_TO_COMPONENT_ID = Object.freeze({
'ja': 'locale:ja',
'ja-JP': 'locale:ja',
@@ -29,6 +29,8 @@ const LOCALE_ALIAS_TO_COMPONENT_ID = Object.freeze({
'vi-VN': 'locale:vi-vn',
'vi': 'locale:vi-vn',
'zh-TW': 'locale:zh-tw',
'de-DE': 'locale:de-de',
'de': 'locale:de-de',
});
function listSupportedLocales() {

View File

@@ -215,93 +215,6 @@ function runTests() {
fs.rmSync(tmpHome, { recursive: true, force: true });
}) ? passed++ : failed++);
// 8. Prefers harness-cost cache value over transcript-sum when fresh
(test('prefers fresh harness-cost cache over transcript estimate', () => {
const tmpHome = makeTempDir();
const sessionId = 'harness-fresh-' + Date.now();
const transcriptPath = path.join(tmpHome, 'session.jsonl');
writeTranscript(transcriptPath, [
{
type: 'assistant',
message: {
model: 'claude-opus-4-20250514',
usage: {
input_tokens: 10000,
output_tokens: 5000,
cache_creation_input_tokens: 200000,
cache_read_input_tokens: 1000000,
},
},
},
]);
const harnessCachePath = path.join(os.tmpdir(), `harness-cost-${sessionId}.json`);
const nowEpoch = Math.floor(Date.now() / 1000);
fs.writeFileSync(
harnessCachePath,
JSON.stringify({ ts: nowEpoch, cost_usd: 1.23 }),
'utf8'
);
try {
const result = runScript(
{ session_id: sessionId, transcript_path: transcriptPath },
withTempHome(tmpHome)
);
assert.strictEqual(result.code, 0, `Expected exit code 0, got ${result.code}`);
const metricsFile = path.join(tmpHome, '.claude', 'metrics', 'costs.jsonl');
const row = JSON.parse(fs.readFileSync(metricsFile, 'utf8').trim());
assert.strictEqual(row.estimated_cost_usd, 1.23, 'Expected harness cost to win');
// Token totals still reflect the transcript scan
assert.strictEqual(row.input_tokens, 10000, 'Token totals should still come from transcript');
assert.strictEqual(row.output_tokens, 5000, 'Token totals should still come from transcript');
} finally {
try { fs.unlinkSync(harnessCachePath); } catch { /* best-effort */ }
fs.rmSync(tmpHome, { recursive: true, force: true });
}
}) ? passed++ : failed++);
// 9. Ignores stale harness-cost cache and falls back to transcript estimate
(test('ignores stale harness-cost cache (>300s) and uses transcript estimate', () => {
const tmpHome = makeTempDir();
const sessionId = 'harness-stale-' + Date.now();
const transcriptPath = path.join(tmpHome, 'session.jsonl');
writeTranscript(transcriptPath, [
{
type: 'assistant',
message: {
model: 'claude-sonnet-4-20250514',
usage: { input_tokens: 1000, output_tokens: 500 },
},
},
]);
const harnessCachePath = path.join(os.tmpdir(), `harness-cost-${sessionId}.json`);
const staleEpoch = Math.floor(Date.now() / 1000) - 3600;
fs.writeFileSync(
harnessCachePath,
JSON.stringify({ ts: staleEpoch, cost_usd: 999.99 }),
'utf8'
);
try {
const result = runScript(
{ session_id: sessionId, transcript_path: transcriptPath },
withTempHome(tmpHome)
);
assert.strictEqual(result.code, 0, `Expected exit code 0, got ${result.code}`);
const metricsFile = path.join(tmpHome, '.claude', 'metrics', 'costs.jsonl');
const row = JSON.parse(fs.readFileSync(metricsFile, 'utf8').trim());
assert.notStrictEqual(row.estimated_cost_usd, 999.99, 'Stale cache must not win');
assert.ok(row.estimated_cost_usd > 0, 'Expected fallback transcript estimate to be positive');
// Sonnet rates: 1000/1e6*3 + 500/1e6*15 ≈ $0.011 — well below the 999.99 stale value
assert.ok(row.estimated_cost_usd < 1, 'Expected small transcript estimate, not the stale 999.99');
} finally {
try { fs.unlinkSync(harnessCachePath); } catch { /* best-effort */ }
fs.rmSync(tmpHome, { recursive: true, force: true });
}
}) ? passed++ : failed++);
console.log(`\nResults: Passed: ${passed}, Failed: ${failed}`);
process.exit(failed > 0 ? 1 : 0);
}

View File

@@ -50,6 +50,7 @@ function runTests() {
const components = listInstallComponents({ family: 'locale' });
assert.ok(components.some(component => component.id === 'locale:ja'));
assert.ok(components.some(component => component.id === 'locale:zh-cn'));
assert.ok(components.some(component => component.id === 'locale:de-de'));
assert.ok(components.every(component => component.family === 'locale'));
})) passed++; else failed++;
@@ -75,6 +76,59 @@ function runTests() {
}
})) passed++; else failed++;
if (test('locale:de-de resolves to the German translated docs module', () => {
const homeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'locale-plan-de-'));
try {
const plan = resolveInstallPlan({
includeComponentIds: ['locale:de-de'],
target: 'claude',
homeDir,
});
assert.deepStrictEqual(plan.selectedModuleIds, ['docs-de-de']);
assert.ok(
plan.operations.some(operation => (
normalizePlanPath(operation.sourceRelativePath) === 'docs/de-DE'
&& normalizePlanPath(operation.destinationPath).endsWith('/.claude/docs/de-DE')
)),
'Should map docs/de-DE to ~/.claude/docs/de-DE'
);
} finally {
fs.rmSync(homeDir, { recursive: true, force: true });
}
})) passed++; else failed++;
if (test('end-to-end: --locale de dry-run includes docs-de-de operations', () => {
const homeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'locale-dry-run-de-'));
const projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'locale-dry-run-de-project-'));
try {
const output = runInstallApply([
'--locale', 'de',
'--dry-run',
'--json',
], {
cwd: projectDir,
env: { HOME: homeDir },
});
const json = JSON.parse(output);
assert.strictEqual(json.plan.mode, 'manifest');
assert.deepStrictEqual(json.plan.includedComponentIds, ['locale:de-de']);
assert.deepStrictEqual(json.plan.selectedModuleIds, ['docs-de-de']);
assert.ok(
json.plan.operations.some(operation => (
normalizePlanPath(operation.sourceRelativePath) === 'docs/de-DE/README.md'
&& normalizePlanPath(operation.destinationPath).endsWith('/.claude/docs/de-DE/README.md')
)),
'Should copy translated README into ~/.claude/docs/de-DE'
);
} finally {
fs.rmSync(homeDir, { recursive: true, force: true });
fs.rmSync(projectDir, { recursive: true, force: true });
}
})) passed++; else failed++;
if (test('end-to-end: --locale ja dry-run includes docs-ja-jp operations', () => {
const homeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'locale-dry-run-'));
const projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'locale-dry-run-project-'));