// Project check: short report for the "projekt-check" skill - so Claude reads ~40 lines instead // of the code. Stack, size, biggest files, kit status vs Library, re-implementations of kit // features, Library candidates, hygiene (git, README, CLAUDE.md, release age, TODOs, credits/Discord). // node D:\Oculusquest\Projekt\_Tools\Library\tools\project-check.mjs [projectPath] [--all] // --all lists every finding instead of the top entries. import fs from 'node:fs'; import path from 'node:path'; import { execFileSync } from 'node:child_process'; import { createHash } from 'node:crypto'; import { fileURLToPath } from 'node:url'; const LIB = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); const args = process.argv.slice(2); const ALL = args.includes('--all'); const root = path.resolve(args.find(a => !a.startsWith('--')) || process.cwd()); const name = path.basename(root); const TOP = ALL ? 1e9 : 6; const SKIP = /^(node_modules|\.git|dist|build|builds|bin|obj|out|target|Library|Temp|Logs|output|release|publish.*|\.gradle|\.idea|\.vscode|\.vs|__pycache__|\.venv.*|venv|env|\.expo|\.cache|\.claude|ThirdParty|third_party|vendor|Packages|coverage|test-results|playwright-report|_archiv|archive|backup)$/i; const SRC = /\.(js|mjs|cjs|ts|tsx|jsx|cs|cpp|cc|hpp|h|py|kt|java|dart|gd|html|css|ps1)$/i; // ---- walk --------------------------------------------------------------------------------- const files = []; (function walk(dir, depth) { let ents = []; try { ents = fs.readdirSync(dir, { withFileTypes: true }); } catch { return; } for (const e of ents) { const p = path.join(dir, e.name); if (e.isDirectory()) { if (depth < 8 && !SKIP.test(e.name) && !(e.name === 'android' && fs.existsSync(path.join(root, 'capacitor.config.json')))) walk(p, depth + 1); } else if (SRC.test(e.name) && files.length < 6000) { let st; try { st = fs.statSync(p); } catch { continue; } if (st.size > 3e6) continue; // generated bundles, data dumps files.push({ p, rel: path.relative(root, p), size: st.size, mtime: st.mtimeMs }); } } })(root, 0); const isKit = f => /(^|\\)(game|src)\\kit\\/.test(f.rel); const isGen = f => /(^|\\)(sprite-?gen(erator)?|spritegenerator|design-gen|tools?|scripts?|tests?)\\/i.test(f.rel); for (const f of files) { try { f.text = fs.readFileSync(f.p, 'utf8'); } catch { f.text = ''; } f.lines = f.text ? f.text.split('\n').length : 0; } const own = files.filter(f => !isKit(f)); const code = own.filter(f => !/\.(html|css)$/i.test(f.rel) || f.lines > 300); // big inline-script html counts // ---- stack -------------------------------------------------------------------------------- const has = p => fs.existsSync(path.join(root, p)); const pkg = (() => { try { return JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8')); } catch { return null; } })(); const deps = pkg ? { ...pkg.dependencies, ...pkg.devDependencies } : {}; const ext = {}; for (const f of code) { const e = path.extname(f.rel).slice(1).toLowerCase(); ext[e] = (ext[e] || 0) + f.lines; } const stack = []; if (deps['@capacitor/core']) stack.push('Capacitor'); if (deps.vite) stack.push('Vite'); if (deps.react) stack.push('React'); if (deps.electron) stack.push('Electron'); if (deps.expo) stack.push('Expo'); if (has('game/index.html') || (has('index.html') && !pkg)) stack.push('HTML-Spiel'); if (files.some(f => /\.csproj$/i.test(f.rel)) || own.some(f => f.rel.endsWith('.cs'))) stack.push('.NET'); if (has('CMakeLists.txt')) stack.push('C++/CMake'); if (has('pubspec.yaml')) stack.push('Flutter'); if (has('ProjectSettings')) stack.push('Unity'); if (own.some(f => f.rel.endsWith('.py')) && !stack.length) stack.push('Python'); const kind = has('game/kit') || stack.includes('HTML-Spiel') ? 'web' : deps['@capacitor/core'] ? 'mobile' : null; // ---- kit status --------------------------------------------------------------------------- const hash = s => createHash('sha1').update(s.replace(/\r\n/g, '\n')).digest('hex'); const ver = s => +((s.match(/\(v(\d+)\)/) || [])[1] || 0); const kitLines = []; for (const [projDir, libDir] of [['game/kit', 'web/kit'], ['src/kit', 'mobile/kit']]) { const pd = path.join(root, projDir), ld = path.join(LIB, libDir); if (!fs.existsSync(pd)) continue; const libFiles = fs.readdirSync(ld); const st = { same: 0, old: [], changed: [], missing: [], extra: [] }; for (const f of libFiles) { const pf = path.join(pd, f); if (!fs.existsSync(pf)) { st.missing.push(f); continue; } const a = fs.readFileSync(pf, 'utf8'), b = fs.readFileSync(path.join(ld, f), 'utf8'); if (hash(a) === hash(b)) st.same++; else if (ver(a) < ver(b)) st.old.push(`${f} v${ver(a)}→v${ver(b)}`); else st.changed.push(f); } for (const f of fs.readdirSync(pd)) if (!libFiles.includes(f)) st.extra.push(f); kitLines.push(`${projDir}: ${st.same} aktuell` + (st.old.length ? ` · VERALTET ${st.old.join(', ')}` : '') + (st.changed.length ? ` · IM PROJEKT GEÄNDERT ${st.changed.join(', ')} (→ in Library übernehmen?)` : '') + (st.missing.length ? ` · fehlt ${st.missing.join(', ')}` : '') + (st.extra.length ? ` · nur hier ${st.extra.join(', ')}` : '')); } // ---- own code doing what the kit already does --------------------------------------------- const REINVENT = kind === 'mobile' ? [ [/new AudioContext|webkitAudioContext/, 'eigenes WebAudio', 'kit/audio.ts'], [/localStorage\.setItem\([^)]*save/i, 'eigener Spielstand', 'kit/save.ts createSaveStore'], [/AdMob\./, 'AdMob direkt', 'kit/ads.ts'], [/CdvPurchase|store\.register\(/, 'Käufe direkt', 'kit/iap.ts'], [/Haptics\.impact/, 'Haptics direkt', 'kit/haptics.ts'], [/addListener\(\s*["']backButton/, 'Zurück-Taste direkt', 'kit/lifecycle.ts'], ] : [ [/new \(?window\.AudioContext|new AudioContext|webkitAudioContext/, 'eigenes WebAudio', 'Kit.createAudio'], [/localStorage\.(get|set)Item/, 'localStorage direkt', 'Kit.store / Kit.saveSlot'], [/firebasedatabase\.app|firebaseio\.com/, 'Firebase-REST direkt', 'Kit.scores'], [/chrome\.webview/, 'WebView2-Bridge direkt', 'Kit.host'], [/requestAnimationFrame\(/, 'eigene Spielschleife', 'Kit.loop'], [/devicePixelRatio/, 'eigene HiDPI-Skalierung', 'Kit.fit / Kit.setRes'], [/addEventListener\(\s*['"]keydown/, 'eigene Tastatur-Abfrage', 'Kit.input'], ]; const reinvent = []; if (kind) { const web = code.filter(f => /\.(js|mjs|ts|tsx|jsx|html)$/i.test(f.rel) && !isGen(f)); for (const [re, what, use] of REINVENT) { // a file that already calls the kit piece is fine (e.g. Kit.input + one keydown for a text field) const usesKit = new RegExp(use.split(' ')[0].replace(/^kit\//, 'kit/').replace(/[.*+?^${}()|[\]\\]/g, '\\$&').replace(/\\\.ts$/, '')); const hits = web.filter(f => re.test(f.text) && !usesKit.test(f.text)).map(f => f.rel); if (hits.length) reinvent.push(`${what} in ${hits.slice(0, 3).join(', ')}${hits.length > 3 ? ` +${hits.length - 3}` : ''} → ${use}`); } } // ---- Library candidates: generic-looking modules ------------------------------------------ const GENERIC = [ [/achiev/i, 'Achievements', null], [/tutorial|onboard/i, 'Tutorial', null], [/solve|solver/i, 'Level-Löser', null], [/verify|selftest/i, 'Selbsttest/Verifier', null], [/i18n|lang|locali|translat/i, 'Übersetzung', kind === 'mobile' ? 'i18n.ts' : null], [/leaderboard|highscore|scores?\b/i, 'Bestenliste', 'Kit.scores'], [/audio|sound|music/i, 'Audio', 'Kit.createAudio / audio.ts'], [/save|storage|persist/i, 'Speichern', 'Kit.saveSlot / save.ts'], [/particle|fx|tween|ease|juice/i, 'Effekte', 'Kit.fx'], [/input|controls?|keys?\b|gamepad/i, 'Eingabe', 'Kit.input'], [/online|cloud|auth|firebase/i, 'Online/Cloud', null], [/mission|daily|quest/i, 'Missionen/Daily', null], [/settings?|options|config/i, 'Einstellungen', null], [/wiki|help/i, 'Hilfe/Wiki', null], [/debug|devshot|cheat/i, 'Debug-Werkzeug', null], [/number|format/i, 'Zahlenformat', 'Kit.fmt'], [/rng|random/i, 'Zufall', 'Kit.rng'], [/window|layered/i, 'Fenster-Helfer (Desktop)', null], [/screenshot|store.?screen|itch|make_images/i, 'Store-/itch-Bilder', '_Tools/Itch'], ]; const cands = []; for (const f of own) { if (isKit(f) || f.lines < 40 || /(^|\\)(sprite-?gen(erator)?|spritegenerator|design-gen)\\/i.test(f.rel)) continue; const base = path.basename(f.rel, path.extname(f.rel)); const g = GENERIC.find(([re]) => re.test(base)); if (!g) continue; cands.push(`${f.rel} (${f.lines} Z.) ${g[1]}: ${g[2] ? `Library hat ${g[2]} – vergleichen` : 'FEHLT in Library → Kandidat'}`); } cands.sort((a, b) => (b.includes('FEHLT') - a.includes('FEHLT'))); // ---- hygiene ------------------------------------------------------------------------------ const git = (...a) => { try { return execFileSync('git', ['-C', root, ...a], { encoding: 'utf8', timeout: 8000, stdio: ['ignore', 'pipe', 'ignore'] }).trim(); } catch { return null; } }; const issues = []; const isRepo = git('rev-parse', '--is-inside-work-tree') === 'true'; if (!isRepo) issues.push('kein git-Repository'); else { const dirty = (git('status', '--porcelain') || '').split('\n').filter(Boolean).length; const last = git('log', '-1', '--format=%cr'); // no remote check: local git is enough (Michael's decision) if (dirty) issues.push(`${dirty} ungesicherte Änderungen (letzter Commit ${last || '–'})`); const tracked = (git('ls-files', '-z') || '').split('\0').filter(Boolean); const big = tracked.map(t => { try { return [t, fs.statSync(path.join(root, t)).size]; } catch { return [t, 0]; } }) .filter(([, s]) => s > 10e6).sort((a, b) => b[1] - a[1]); if (big.length) issues.push(`große Dateien in git: ${big.slice(0, 3).map(([t, s]) => `${t} ${(s / 1e6).toFixed(0)} MB`).join(', ')}`); } for (const f of ['README.md', 'CLAUDE.md', '.gitignore']) if (!has(f)) issues.push(`${f} fehlt`); // credits standard: "Michael Media" + Discord link visible in the app (source or language files) { const appSrc = own.filter(f => !isGen(f) && !/(^|\\)docs\\/i.test(f.rel)); let langText = ''; for (const d of ['Languages', 'lang', 'locales', 'i18n']) { if (!has(d)) continue; try { for (const n of fs.readdirSync(path.join(root, d))) if (n.endsWith('.json')) langText += fs.readFileSync(path.join(root, d, n), 'utf8'); } catch { /* unreadable */ } } const inApp = re => re.test(langText) || appSrc.some(f => re.test(f.text)); const discordInApp = inApp(/discord\.gg\//i); if (!inApp(/michael\s*media/i)) issues.push('Credits fehlen im Spiel ("© Jahr Michael Media")'); if (!discordInApp) issues.push('Discord-Link fehlt im Spiel (https://discord.gg/Ej4JPmCZva)'); if (has('README.md') && !/michael\s*media/i.test(fs.readFileSync(path.join(root, 'README.md'), 'utf8'))) issues.push('README ohne "Michael Media"'); } if (!has('.dashboard.json')) issues.push('.dashboard.json fehlt (Projekt-Dashboard)'); if (pkg && Object.keys(deps).length && !has('node_modules')) issues.push('node_modules fehlt (npm install)'); if (has('.gitignore')) { const gi = fs.readFileSync(path.join(root, '.gitignore'), 'utf8'); for (const [dir, pat] of [['node_modules', /node_modules/], ['sprite-generator/output', /output/], ['release', /release/], ['bin', /\bbin\b/]]) { if (has(dir.split('/')[0]) && has(dir) && !pat.test(gi)) issues.push(`${dir}/ nicht in .gitignore`); } } // generator: own copy of the ComfyGen scripts? for (const g of ['sprite-generator', 'Spritegenerator', 'design-gen', 'sprite-gen']) { if (!has(g)) continue; const gen = path.join(root, g); const cmd = path.join(gen, 'gen.cmd'); const usesTools = fs.existsSync(cmd) && /_Tools\\ComfyGen/i.test(fs.readFileSync(cmd, 'utf8')); const pyCount = fs.readdirSync(gen).filter(f => f.endsWith('.py')).length; if (!usesTools && pyCount > 3) issues.push(`${g}: eigene Generator-Kopie (${pyCount} .py) statt _Tools\\ComfyGen`); } // ---- ComfyUI: could graphics / sound / icon come from ComfyGen? ------------------------------ const comfy = []; { const MEDIA_IMG = /\.(png|jpe?g|webp|gif|bmp)$/i, MEDIA_SND = /\.(mp3|ogg|wav|flac)$/i; let imgs = 0, snds = 0, icon = false; (function walk(dir, depth) { let ents = []; try { ents = fs.readdirSync(dir, { withFileTypes: true }); } catch { return; } for (const e of ents) { if (e.isDirectory()) { if (depth < 7 && !SKIP.test(e.name) && !/^(sprite-?gen(erator)?|spritegenerator|design-gen|docs|screenshots|android|ios)$/i.test(e.name)) walk(path.join(dir, e.name), depth + 1); } else if (MEDIA_IMG.test(e.name)) { imgs++; if (/^(app[_-]?)?icon|^ic_launcher|^logo/i.test(e.name)) icon = true; } else if (MEDIA_SND.test(e.name)) snds++; else if (/\.ico$/i.test(e.name)) icon = true; } })(root, 0); const genDir = ['sprite-generator', 'Spritegenerator', 'design-gen', 'sprite-gen'].find(has); const app = code.filter(f => !isGen(f)); const count = re => app.reduce((n, f) => n + (f.text.match(re) || []).length, 0); const drawn = count(/\b(fillRect|strokeRect|arc|ellipse|bezierCurveTo|FillRectangle|FillEllipse|DrawRectangle|DrawEllipse|pygame\.draw\.\w+|DrawCircle|DrawRect)\s*\(/g); const synth = count(/createOscillator|\btone\(|OscillatorNode|winsound\.Beep|Console\.Beep|pygame\.sndarray|SineWave|SignalGenerator/g); const voiceText = app.some(f => /\b(dialog|dialogue|story|narrat|speech|voice)\b/i.test(f.rel)); if (!genDir) comfy.push(`kein ComfyGen-Generator – \`_Tools\\ComfyGen\\template\` → \`sprite-generator\\\` (gen generate/adopt/generate_audio)`); else { let prompts = 0, audio = 0; try { prompts = (fs.readFileSync(path.join(root, genDir, 'prompts.py'), 'utf8').match(/^\s*\(\s*["']/gm) || []).length; } catch { /* none */ } try { audio = (fs.readFileSync(path.join(root, genDir, fs.readdirSync(path.join(root, genDir)).find(n => /^audio.*\.py$/i.test(n)) || 'audio.py'), 'utf8').match(/^\s*\(\s*["']/gm) || []).length; } catch { /* none */ } comfy.push(`Generator ${genDir}: ${prompts} Bild-Prompts, ${audio} Audio-Einträge · im Projekt ${imgs} Bilder, ${snds} Sounds`); } if (!icon) comfy.push('kein App-Icon → `gen generate icon` + `gen adopt --size 512 icon`'); if (drawn > 40 && imgs < 10) comfy.push(`Grafik meist gezeichnet (${drawn} Zeichenbefehle, ${imgs} Bilder) → Sprites/Hintergründe per ComfyUI`); if (snds === 0 && (synth || stack.some(s => /HTML|Capacitor|Unity|C\+\+|Python/.test(s)))) comfy.push(`keine Sounddateien${synth ? ` (${synth}× Synth-Ton im Code)` : ''} → Musik/SFX mit \`gen generate_audio\``); else if (synth > 5 && snds < 5) comfy.push(`${synth}× Synth-Ton, nur ${snds} Sounddateien → echte SFX per \`gen generate_audio\``); if (voiceText) comfy.push('Story/Dialog-Dateien gefunden → Erzählstimmen mit `gen generate_voice` möglich'); // is the server up? (only informative, 800 ms) try { const r = await fetch('http://127.0.0.1:8188/system_stats', { signal: AbortSignal.timeout(800) }); comfy.push(`ComfyUI-Server: ${r.ok ? 'läuft' : 'antwortet nicht richtig'}`); } catch { comfy.push('ComfyUI-Server: aus (bei Bedarf `D:\\ComfyUI` starten)'); } } // release older than the code const newestSrc = Math.max(0, ...own.filter(f => !isGen(f)).map(f => f.mtime)); for (const d of ['release', 'dist']) { const dp = path.join(root, d); if (!fs.existsSync(dp)) continue; let newest = 0; (function w(x, depth) { for (const e of fs.readdirSync(x, { withFileTypes: true })) { const p = path.join(x, e.name); if (e.isDirectory()) { if (depth < 3) w(p, depth + 1); } else newest = Math.max(newest, fs.statSync(p).mtimeMs); } })(dp, 0); const days = (newestSrc - newest) / 864e5; if (newest && days > 1) issues.push(`${d}/ ist ${Math.round(days)} Tage älter als der Code (neu bauen?)`); } const todo = own.reduce((n, f) => n + (f.text.match(/\b(TODO|FIXME|HACK|XXX)\b/g) || []).length, 0); const logs = code.filter(f => /\.(js|ts|tsx|jsx)$/.test(f.rel) && !isGen(f)).reduce((n, f) => n + (f.text.match(/console\.log\(/g) || []).length, 0); if (todo) issues.push(`${todo}× TODO/FIXME im Code`); if (logs > 10) issues.push(`${logs}× console.log`); const testDir = ['tests', 'test', 'tools', '__tests__'].some(has) || own.some(f => /\.(test|spec)\.|selftest|verify/i.test(f.rel)); if (!testDir && code.length > 5) issues.push('keine Tests/Selbsttests gefunden'); if (kind === 'web' && !has('game/kit') && !has('kit')) issues.push('nutzt web/kit nicht (Vorlage webgame: Release-Kette, Highscores, exe)'); if (kind === 'mobile' && !has('src/kit')) issues.push('nutzt mobile/kit nicht'); // ---- report ------------------------------------------------------------------------------- const total = code.reduce((n, f) => n + f.lines, 0); const big = [...code].filter(f => !isGen(f)).sort((a, b) => b.lines - a.lines).filter(f => f.lines > 800); const out = []; out.push(`# ${name} [${stack.join(', ') || '?'}] ${code.length} Dateien, ${total.toLocaleString('de-DE')} Zeilen (${Object.entries(ext).sort((a, b) => b[1] - a[1]).slice(0, 4).map(([e, n]) => `${e} ${n}`).join(', ')})`); if (big.length) out.push(`Groß (>800 Z., aufteilen?): ${big.slice(0, TOP).map(f => `${f.rel} ${f.lines}`).join(' · ')}`); if (kitLines.length) out.push('Kit: ' + kitLines.join(' | ')); const ORIGIN = { 'xp-battleship': 'mobile/kit', pipefix: 'web/kit + web/template', 'byte path': 'web/kit (Audio, Eingabe, Loop)' }; if (ORIGIN[name.toLowerCase()]) out.push(`Hinweis: Ursprung von ${ORIGIN[name.toLowerCase()]} – Umstellung aufs Kit nur bei Bedarf, eher Neues von hier in die Library holen.`); if (comfy.length) { out.push('ComfyUI:'); for (const c of comfy) out.push('- ' + c); } if (reinvent.length) { out.push('Selbst gebaut, Kit kann es:'); for (const r of reinvent.slice(0, TOP)) out.push('- ' + r); } if (cands.length && !kind) { // stacks without a Library kit (C++, C#, Kotlin, Python): one line, details with --all const missing = cands.filter(c => c.includes('FEHLT')); const groups = [...new Set(missing.map(c => c.split(': ')[0].replace(/^.*\) /, '')))]; out.push(`Library hat kein Kit für ${stack.join('/') || 'diesen Stack'}: ${missing.length} allgemein wirkende Module (${groups.slice(0, 6).join(', ')}), z. B. ${missing.slice(0, 3).map(c => c.split(' (')[0]).join(', ')}${ALL ? '' : ' (--all = Liste)'}`); if (ALL) for (const c of cands) out.push('- ' + c); } else if (cands.length) { out.push('Library-Kandidaten:'); for (const c of cands.slice(0, TOP)) out.push('- ' + c); if (cands.length > TOP) out.push(` (+${cands.length - TOP} weitere, --all)`); } if (issues.length) { out.push('Hygiene:'); for (const i of issues) out.push('- ' + i); } if (!reinvent.length && !cands.length && !issues.length) out.push('Keine Auffälligkeiten.'); console.log(out.join('\n'));