[BUG] apm install escapes non-ASCII text in .claude/settings.json

Aperta Adatta ai principianti
#5,823 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
1-3 ore
Idoneità per principianti
84/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
json, python
Ambito
cli

Direzione di ricerca

Inizia da src/apm_cli/native_plugins/settings.py e leggi write_settings_document e write_declaration, poi confronta la loro serializzazione JSON con quella degli scrittori citati nell’issue. Mantieni leggibile il testo non ASCII in entrambi i percorsi del codice. Il lavoro è completato quando l’installazione di un plugin Claude nativo conserva i caratteri originali in .claude/settings.json.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug
When apm install deploys a native plugin for the claude target, it rewrites .claude/settings.json with json.dumps(document, indent=2) and no ensure_ascii=False. Any non-ASCII text the user already had in that file is turned into \uXXXX escapes. The values stay the same, but the file is no longer readable for people who write settings in a non-English language (for example, a Japanese hook statusMessage).

The code that writes it is in src/apm_cli/native_plugins/settings.py (write_settings_document and write_declaration, both present in v0.39.4 and on main):

https://github.com/microsoft/apm/blob/v0.39.4/src/apm_cli/native_plugins/settings.py#L212-L227

Other writers in APM already keep non-ASCII text:

  • native_plugins/claude_marketplaces.py uses ensure_ascii=False
  • utils/json_config.py keeps the file's existing style with ensure_ascii=text.isascii()

To Reproduce

  1. Create .claude/settings.json that contains non-ASCII text, e.g.
    {
      "hooks": {
        "Stop": [
          { "hooks": [{ "type": "command", "command": "./check.sh", "statusMessage": "型チェックを実行中" }] }
        ]
      }
    }
    
  2. Add a dependency that installs as a native Claude Code plugin (e.g. a plugin from anthropics/claude-plugins-official) to apm.yml with targets: [claude]
  3. Run apm install
  4. statusMessage is now "型チェックを実行中"

Expected behavior
APM leaves existing non-ASCII text as it is, like the other JSON writers do. Passing ensure_ascii=False (or reusing the json_config style detection) in both places in settings.py would fix it.

Environment

  • OS: macOS 27.2
  • APM Version: 0.39.3 (code unchanged in 0.39.4 and main at 641743f)
  • Installed via mise (github:microsoft/apm)

Additional context
Because .claude/settings.json is committed and shared by a team, the escaped text also shows up in code review. As a workaround we switched our statusMessage values to English.

Lingua principale
Python
Stelle
4.5k
Fork
440
Merge medio
7h 29m
PR unite (30g)
843

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/apm

Tutte le issue di microsoft/apm

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.