[bug] MergeSettings.ts leaves { "__merge": "append" } wrappers under hooks in the…

Aperta Adatta ai principianti
#2,886 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 5 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
bun, typescript
Ambito
tooling

Direzione di ricerca

Leggi LIFEOS/TOOLS/MergeSettings.ts, in particolare mergeSettings, e segui come vengono gestite le chiavi di oggetto presenti solo nell’utente quando il livello di sistema omette il loro genitore. Riproduci il caso con i JSON di sistema e utente forniti, poi verifica che le annotazioni di aggiunta annidate vengano risolte in array e che le altre chiavi di output rimangano invariate. Aggiungi il test di regressione suggerito ed eseguilo insieme al comando di merge con --check.

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

Descrizione

What happened

MergeSettings.ts leaves { "__merge": "append" } wrappers under hooks in the generated settings.json when settings.system.json has no hooks key, so Claude Code ignores PostToolUse, SessionStart, Stop and UserPromptSubmit hooks

Summary

What happens

LIFEOS/TOOLS/MergeSettings.ts writes { "__merge": "append", "values": [...] } wrappers into the generated settings.json when the annotated key sits under a parent that the system layer does not define.

Claude Code then rejects each affected hook event:

Hook event "PostToolUse" must be an array of matchers; received object. This entry was ignored.

Every hook under those events stops running. The SessionStart hook that reruns the merge is one of them, so the install does not repair itself.

Cause

In mergeSettings(system, user), a key that exists only in the user overlay is merged as mergeSettings(undefined, user[key]). When that value is a plain object, neither the annotation branch nor the object-merge branch matches, and the function returns cloneJsonValue(user). The object is copied whole, so append annotations nested inside it are never resolved.

settings.system.json ships without a hooks key (hooks are installer-owned), so hooks always takes this path. SettingsBackport.ts writes append annotations into the user overlay for appended hooks, which is what puts them there. permissions.allow is unaffected because permissions exists in the system layer.

validateRoundTripOrThrow and --check both pass on the broken output.

Reproduce

  1. System layer: any valid file with no hooks key.
  2. User overlay:
{ "hooks": { "Stop": { "__merge": "append", "values": [ { "hooks": [ { "type": "command", "command": "true" } ] } ] } } }
  1. Run the merge to a scratch path:
bun LIFEOS/TOOLS/MergeSettings.ts --system system.json --user user.json --output out.json
  1. hooks.Stop in out.json is the wrapper object. Expected: the array from values.

Fix verified locally

Before the final return cloneJsonValue(user); in mergeSettings:

if (isObjectRecord(user)) {
  const merged: Record<string, any> = {};
  for (const key of Object.keys(user)) {
    if (isRemoveAnnotation(user[key])) continue;
    merged[key] = mergeSettings(undefined, user[key]);
  }
  return merged;
}

With this patch the four affected events (PostToolUse, SessionStart, Stop, UserPromptSubmit) come out as arrays with the same content, every other key in the output is unchanged, and --check reports no differences.

Suggested follow-ups

  • A regression test for an append annotation nested under a parent the system layer omits.
  • Make the round-trip validation fail when any __merge key survives in the output.

Versions

LifeOS 8.761.0, MergeSettings 1.3.16 (file header), macOS.

Details

  • Kind: bug
  • LifeOS version: 8.761.0

Filed with the LifeOS /feedback command. The reporter approved this exact text before it was sent; paths, secrets and personal details were stripped locally.

Lingua principale
TypeScript
Stelle
19.9k
Fork
2.5k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 danielmiessler/LifeOS

Tutte le issue di danielmiessler/LifeOS

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.