L2 v0.4.0 source

config-parse

Bir Edit ya da Write'ın dokunduğu her JSON, YAML, TOML ve .env dosyasını parse eden ve parse hatasını bir sonraki build'de değil, o anda not eden bir Claude Code Mod'u.

Ne yapar

  1. Engine'in çalıştırdığı her Edit ve Write'tan sonra mod path'i okur. .json, .yml, .yaml, .toml, .env ya da .env.<name> dosyası parse edilir; diğer her dosyaya dokunulmaz.

  2. JSON'ı mod kendisi parse eder, .env dosyası satır satır okunur: boş olmayan, comment olmayan ve KEY=value olmayan bir satır bulgudur, numarasıyla birlikte.

  3. YAML ve TOML python3 ile parse edilir (yaml.safe_load ve tomllib.load), dosya path'i tek bir argv değeri olarak. python ya da modül yoksa o tür session boyunca atlanır ve bir satır bunu söyler.

  4. Parse edilmeyen bir dosya iki kanala yazılır: model dosyayı ve hatayı adlandıran bir context notu alır, kişi ortak sidebar'ın stream'inde kırmızı bir kayıt alır, sidebar kapalıyken bir transcript satırı.

  5. Sonraki bir edit aynı dosyayı tekrar parse edilir hale getirdiğinde duran kayıt temizlenir ve bir yeşil satır bunu söyler. O satır yalnız kişiye gider, çünkü düzeltmeyi model kendisi yapmıştır.

  6. Mod hiçbir edit'i reddetmez. Dosya önce yazılır, sonra okunur.

  7. Modelin kapatmadığı bir bulgu her main-loop turn sonunda tekrar ölçülür ve geriye kalan, bir sonraki prompt ile modele tek not olarak ulaşır:

    config-parse: 1 file(s) still do not parse: package.json. Fix them.
    

    Turn başına bir not, prompt başına değil. Bu olmasa bulgu bir kere, edit anında söylenir ve model onu unutmuşken pane'de dururdu. Siz yeni bir şey okumazsınız: pane zaten aynı bulguyu taşır.

  8. deny modunda mod ayrıca, bir dosya parse edilmiyorken git commit, git push ve git merge komutlarını durdurur. Bir komutu durdurmadan önce her açık dosyayı tekrar parse eder, yani model onları düzelttiğinde komut kendiliğinden çalışır. Bir git commit yalnız kendi dosyalarından sorumludur: mod index'i okur (git diff --cached --name-only) ve commit açık dosyalardan hiçbirini tutmuyorsa çalışmasına izin verir, kaç bulgunun durduğunu söyleyen bir satırla. push ve merge hiçbir index okumaz, bu yüzden orada her bulgu durur. Kaçış yolu yoktur: --dry-run, --help ve diğer her komut geçer, ama bozuk bir dosyanın gerçek commit'i düzeltmeyi bekler. note varsayılandır ve hiçbir şeyi durdurmaz.

Canlı testte sondaki virgülle bozulmuş bir JSON dosyası notu aldı (Property name must be a string literal), a: 1: 2 ile bozulmuş bir YAML dosyası python hatasını aldı ve a: 1 yazan sonraki Write bulguyu parses as YAML again ile kapattı.

Komut

/config-parse                 on ya da off, mod ve parse edilmeyen dosyalar
/config-parse on | off        varsayılan on
/config-parse mode note       sadece not; varsayılan
/config-parse mode deny       bir dosya parse edilmiyorken commit, push ve merge de durur

Kurulum

claude plugin marketplace add KilimcininKorOglu/claude-code-mods
claude plugin install config-parse@kilimcininkoroglu-mods

Function hook'lar early access. Flag olmadan hiçbir şey yüklenmez. Flag'i kalıcı yapmak için ~/.claude/settings.json dosyasına ekleyin:

{ "env": { "CLAUDE_CODE_ENABLE_FUNCTION_HOOKS": "1" } }

Kurulumdan sonra

  1. YAML kontrolü için PyYAML ile python3 kurun (python3 -m pip install pyyaml). TOML yalnız python 3.11 ya da üstünü ister. Bunlar olmadan o iki tür atlanır, JSON ve .env çalışmaya devam eder.
  2. Claude Code'u yeniden başlatın.

Nereye uzanır

Claude Code 2.1.278 üzerinde claude plugin validate ile doğrulandı:

❯ ./register.ts hooks: session.start, command.run{command=config-parse}, tool.call{tool=Edit}, tool.call{tool=Write}, turn.complete, prompt.submit, tool.call{tool=Bash}
❯ ./register.ts calls: $.command.register, $.fs.read (via fileText), $.process.run (via pythonCheck, stagedPaths), $.session.cwd, $.sidebar.clear (via closeOne), $.sidebar.set (via toPerson), $.store.get, $.store.set (via runCommand, setMode), $.ui.log

Reach L2, dosya okur ve process çalıştırır.

1. Okur:     her Edit ve Write'ın path'ini, her Bash çağrısının komutunu, düzenlenen JSON ve .env dosyalarının metnini, ve turn sonunda her açık dosyayı tekrar
2. Çalıştırır: python3 -c, argv ile, YAML ve TOML dosyalarında; deny modunda bir commit anında git rev-parse --show-toplevel ve git diff --cached --name-only
3. Gönderir: dosya adını ve parse hatasını modele, bulgu dururken bir sonraki prompt ile bir not daha; makineden hiçbir şey çıkmaz
4. Saklar:   $.store içinde on/off ayarını ve modu
5. Düşman girdi: path tool çağrısından gelir ve python'a tek bir argv değeri olarak ulaşır, hiçbir zaman shell üzerinden geçmez; python programı sabit metindir ve sys.argv[1] okur

Sınırlar

  • Kontrol write'tan sonra çalışır, yani bozuk dosya bir sonraki edit onu düzeltene kadar durur. Hiçbir edit reddedilmez; deny modunda yalnız commit, push ve merge durur.
  • deny modunun kaçış yolu yoktur. Bulgu düzeltilemiyorsa kişi gate'i /config-parse mode note ile kapatır.
  • Bir wrapper, alias ya da script üzerinden çalışan ve mod'un git commit|push|merge olarak okuyamadığı bir git komutu gate'ten geçer.
  • git commit -a, -am ve -- sonrası pathspec taşıyan bir commit index'e göre daraltılmaz, çünkü bunlar index'in henüz tutmadığı dosyaları commit eder. Onlar için her açık bulgu durur.
  • Index komut çalışmadan önce okunur. Dosyaları okuma ile çalışma arasında değişen bir commit, okuma anındaki index'e göre ölçülür.
  • Bir .env satırı yalnız şekli için kontrol edilir. Yanlış bir değer, eksik bir tırnak ya da tekrarlanan bir key bulgu değildir.
  • Comment taşıyan bir JSON dosyası (.json adı altındaki .jsonc) bozuk raporlanır, çünkü parser JSON.parse'tır.
  • YAML ve TOML python3 ister; o olmayan bir makinede bu dosyalar hiç kontrol edilmez.
  • Edit ve Write dışında yapılan bir düzenleme, örneğin Bash sed, görülmez.

Geliştirme

make install     # eslint, typescript-eslint, typescript
make lint        # complexity limiti 10, üstünde build'i düşürür
make typecheck   # /plugin-types ile üretilen .claude/types/ gerekir
make validate
make test        # claude plugin test

config-parse

A Claude Code Mod that parses each JSON, YAML, TOML or .env file an Edit or Write touches, and notes the parse error at once instead of at the next build.

What it does

  1. After each Edit or Write that the engine ran, the mod reads the path. A .json, .yml, .yaml, .toml, .env or .env.<name> file is parsed; every other file is left alone.

  2. JSON is parsed by the mod itself, and a .env file is read line by line: a line that is not empty, a comment or KEY=value is the finding, with its number.

  3. YAML and TOML are parsed by python3 (yaml.safe_load and tomllib.load), the file path as one argv item. When python or the module is missing, that kind is skipped for the session and one line says so.

  4. A file that does not parse is written to two channels: the model gets a context note naming the file and the error, and the person gets a red entry in the shared sidebar's stream, or a transcript line where the sidebar is closed.

  5. When a later edit makes the same file parse again, the standing entry is cleared and one green line says so. That line goes to the person only, because the model fixed it itself.

  6. The mod never denies an edit. The file is written, then read.

  7. A finding the model did not close is measured again at the end of each main-loop turn, and what is left reaches the model as one note with its next prompt:

    config-parse: 1 file(s) still do not parse: package.json. Fix them.
    

    One note per turn, not one per prompt. Without this the finding would be said once, at the edit, and then stand in the pane while the model forgot it. You read nothing new: the pane already carries the same finding.

  8. In deny mode the mod also stops git commit, git push and git merge while a file does not parse. Before it stops one it parses every open file again, so the command runs by itself once the model fixed them. A git commit answers for its own files alone: the mod reads the index (git diff --cached --name-only) and lets the commit run when it holds none of the open files, with one line to you naming how many still stand. A push and a merge hold no index to read, so every finding stands there. There is no bypass: a --dry-run, a --help and every other command pass, but a real commit of a broken file waits for the fix. note mode is the default and stops nothing.

In the live check a JSON file broken with a trailing comma got the note (Property name must be a string literal), a YAML file broken with a: 1: 2 got the python error, and the next Write of a: 1 closed the finding with parses as YAML again.

Command

/config-parse                 on or off, the mode, and the files that do not parse
/config-parse on | off        on by default
/config-parse mode note       note only; the default
/config-parse mode deny       a commit, a push and a merge also stop while a file does not parse

Install

claude plugin marketplace add KilimcininKorOglu/claude-code-mods
claude plugin install config-parse@kilimcininkoroglu-mods

Function hooks are early access. Nothing loads without the flag. To keep it on, add this to ~/.claude/settings.json:

{ "env": { "CLAUDE_CODE_ENABLE_FUNCTION_HOOKS": "1" } }

After installing

  1. Install python3 with PyYAML for the YAML check (python3 -m pip install pyyaml). TOML needs python 3.11 or newer only. Without them those two kinds are skipped and JSON and .env still work.
  2. Restart Claude Code.

What it can reach

Validated with claude plugin validate on Claude Code 2.1.278:

❯ ./register.ts hooks: session.start, command.run{command=config-parse}, tool.call{tool=Edit}, tool.call{tool=Write}, turn.complete, prompt.submit, tool.call{tool=Bash}
❯ ./register.ts calls: $.command.register, $.fs.read (via fileText), $.process.run (via pythonCheck, stagedPaths), $.session.cwd, $.sidebar.clear (via closeOne), $.sidebar.set (via toPerson), $.store.get, $.store.set (via runCommand, setMode), $.ui.log

Reach L2, reads files and runs a process.

1. Reads:    the path of each Edit and Write, the command of each Bash call, and the text of the edited JSON and .env files, and each open file again at the turn's end
2. Runs:     python3 -c, by argv, on YAML and TOML files, and git rev-parse --show-toplevel plus git diff --cached --name-only at a commit in deny mode
3. Sends:    the file name and the parse error to the model, and one more note with the next prompt while a finding stands; nothing leaves the machine
4. Persists: the on/off setting and the mode in $.store
5. Hostile input: the path comes from the tool call and reaches python as one argv item, never through a shell; the python program is fixed text and reads sys.argv[1]

Limits

  • The check runs after the write, so a broken file exists until the next edit fixes it. No edit is ever denied; in deny mode only a commit, a push and a merge stop.
  • The deny mode has no bypass. When a finding cannot be fixed, the person turns the gate off with /config-parse mode note.
  • A git command run through a wrapper, an alias or a script the mod cannot read as git commit|push|merge passes the gate.
  • A git commit -a, a -am and a commit with a pathspec after -- are not narrowed to the index, because they commit files the index does not hold yet. Every open finding stands for those.
  • The index is read before the command runs. A commit whose files change between the read and the run is measured against what the index held at the read.
  • A .env line is checked for its shape only. A wrong value, a missing quote or a duplicate key is not a finding.
  • A JSON file with comments (.jsonc in a .json name) is reported as broken, because JSON.parse is the parser.
  • YAML and TOML need python3; on a machine without it those files are never checked.
  • An edit made outside Edit and Write, for example by a Bash sed, is not seen.

Development

make install     # eslint, typescript-eslint, typescript
make lint        # complexity limit 10, fails the build above it
make typecheck   # needs .claude/types/ from /plugin-types
make validate
make test        # claude plugin test