Dir2md + Spicy: LLM के लिए Markdown/JSONL context और security report एक साथ निकालने वाला repository scanner
(github.com/flamehaven01)नमस्कार। लगभग तीन महीने पहले मैंने पहली बार Dir2md का परिचय कराया था।
उसके बाद इसे अलग-अलग प्रोजेक्ट्स में लागू करते हुए इसकी संरचनात्मक सीमाएँ सामने आईं, और उसी के अनुसार एल्गोरिदम, security, और पूरी output pipeline को फिर से व्यवस्थित किया गया।
❔Dir2md क्या है
Dir2md एक ऐसा टूल है जो जटिल directory structure को smart sampling, security masking, और token budget control के साथ AI-friendly Markdown·JSONL context में बदलता है। यह repo को AI-assisted development के लिए अनुकूल रूप में अपने-आप व्यवस्थित कर देता है।
🔧 क्या बदला है — 3 महीनों के पूर्ण पुनर्गठन का परिणाम
1) AI optimization engine का redesign
- फ़ाइल स्तर पर head/tail smart sampling जोड़ा गया
- token budget का automatic allocation logic और अधिक परिष्कृत किया गया
- महत्वपूर्ण फ़ाइलों को प्राथमिकता से चुनने वाली संरचना को व्यवस्थित किया गया
- Markdown, JSON, JSONL, manifest के लिए multi-output pipeline तैयार की गई
2) Spicy (security·risk analyzer) जोड़ा गया
- execution के समय default रूप से सक्रिय होने वाला built-in risk scanner शामिल
- ok → critical 5-स्तरीय severity system लागू
- repo स्तर पर 0~100 risk score तैयार
- file/line/category/response guide सहित Actionable Risk Table output
3) security masking engine को मजबूत किया गया
- API key, JWT, OAuth, DB URL, PEM जैसे प्रमुख patterns का automatic masking
- user-defined regex और pattern file loading feature जोड़ा गया
4) SimHash-आधारित deduplication जोड़ा गया
- समान फ़ाइलें और build outputs हटाए गए
- LLM input context में duplicate tokens की बर्बादी को न्यूनतम किया गया
5) Preset system का विस्तार
raw,pro,ai,fastचार modes उपलब्धaimode में 6000 token budget + query-based file ranking शामिल
🌶️ Spicy क्या है?
Spicy को एक वाक्य में कहें तो यह “security पर कभी ढील न देने वाले, बेहद पैनी नज़र वाले senior developer जैसा automatic reviewer” है।
Dir2md सिर्फ “directory को document” करने वाला टूल नहीं है, बल्कि repo को AI में देने से पहले ज़रूरी security और quality checks भी एक साथ कर देता है।
1) sensitive information detection
- API Key, OAuth Client Secret, JWT, DB URL, PEM key जैसे ऐसे patterns की पहचान जो वास्तविक incident तक ले जा सकते हैं
2) weak encryption और कमजोर security usage का analysis
- vulnerable algorithms, unsafe key handling आदि जैसे security समस्याओं वाले code का पता लगाना
3) injection possibility diagnosis
- SQL/Command/Code Injection जैसे patterns की पहचान
4) log·debug के जरिए data exposure
- ऐसे code/configuration का पता लगाना जहाँ sensitive information output हो रही हो
5) access control issues
- authentication और permission से जुड़ी कमज़ोरियों वाले patterns का analysis
- README में उल्लेखित configuration संबंधी risk signals भी साथ में detect किए जाते हैं
📊 internal production के 9 repos पर आधारित वास्तविक माप
Dir2md + Spicy के redesign के बाद, कल तक मापे गए वास्तविक आँकड़े इस प्रकार हैं:
- प्रति repo औसतन 2.4 high·critical स्तर की sensitive information detections
- API key, PEM private key, DB URL, bearer token आदि
- context size में औसतन 68% की कमी
- 128k → ~41k tokens (सभी अर्थपूर्ण फ़ाइलें बनाए रखते हुए)
- security review समय: पहले 3.5 घंटे → 11 सेकंड
- अपनाने के बाद LLM prompt के जरिए लीक हुई secret information: 0 मामले
यह परिणाम smart sampling · SimHash deduplication · Spicy risk analysis · masking engine के संयोजन से वास्तविक संचालन वातावरण में प्राप्त प्रदर्शन है।
⭐ अगर इस प्रोजेक्ट से मदद मिली हो
Dir2md + Spicy open source है।
अभी जो अधिकांश features आप देख रहे हैं, वे user feedback और stars (⭐) की बदौलत विकसित हो पाए हैं। एक बार फिर धन्यवाद।
- 👉 GitHub Star का एक क्लिक बहुत मददगार होगा!
- 👉 bugs और idea suggestions भी हमेशा स्वागत योग्य हैं।
2 टिप्पणियां
📌 dir2md v1.1.2 के बाद के प्रमुख अपडेट का सारांश
v1.2.1 (सुरक्षा/विश्वसनीयता पैच)
vulture) subprocess हटाया गया → RCE vector ब्लॉकdefaults.jsonमें अलग किया गया + priority system जोड़ा गयाv1.2.0 (बुद्धिमान auto optimization)
बिना किसी configuration के काम करने वाली token 60~70% reduction pipeline
--queryइस्तेमाल करने पर automatic typo correction + search expansionpreset-केंद्रित design के साथ flags में बड़ा reduction (raw/fast/pro/ai)
external NLP/LLM dependency के बिना implementation
v1.1.3
👉 सारांश में, 1.2.x से यह “configuration घटाने, security·determinism·AI-friendliness” पर केंद्रित release है।
(backward compatibility बरकरार, CLI breaking नहीं)
स्रोत: CHANGELOG
🚂 dir2md 1.1.2 रिलीज़!
यह अपडेट ऊपर से छोटा लग सकता है, लेकिन इसमें सिर्फ वही बदलाव शामिल किए गए हैं जो वास्तविक उपयोग की स्थिरता से सीधे जुड़े हैं।
🛡 Security
🔸डिफ़ॉल्ट/एडवांस्ड masking regex को पहले से compile किया गया → ReDoS जोखिम कम
🔸1MB से बड़ी फ़ाइलें पढ़ने से पहले skip की जाती हैं और manifest में सिर्फ रिकॉर्ड छोड़ा जाता है
⚙️ Performance
🔸token estimation में LRU cache (2048) लागू → बड़े repo में बेहतर गति
🔸खाली string को भी न्यूनतम 1 token माना गया → “0 token” की अस्पष्टता समाप्त
🧩 UX / Behavior
🔸skip की गई फ़ाइलों के लिए placeholder hash/summary छोड़ा जाता है, जिससे transparency बढ़ती है
🔸custom masking pattern compile न हो तो warning के बाद उसे ignore किया जाता है (silent failure से बचाव)
✅ Tests
🔸22 passed, 2 skipped
यह एक छोटा रिलीज़ है, लेकिन सभी tests चलाए गए हैं.
इस version का लक्ष्य सिर्फ एक है:
“क्या इसे हर दिन CI और वास्तविक production code पर चलाया जा सकता है?”
अब हम उस लक्ष्य के एक कदम और करीब आ गए हैं।
https://github.com/flamehaven01/Dir2md/releases/tag/v1.1.2