# Task 2 Report: Projekterkennung Implemented runner/src/detect.js (detectProject, detectFromDir) + runner/test/detect.test.js (19 tests). TDD: RED = ERR_ASSERTION / module not found (detect.js missing); first GREEN attempt had 1 failure (devCmd null for build kind) -> fixed; final: runner npm test 27/27 pass. ## Return shape { kind, pm, install, buildCmd, devCmd, outputDirs, devPort, [index], [hint], [error] } - buildCmd/devCmd are set whenever the script exists (also for kind 'build' -> devCmd = dev fallback after failed build, per spec). - static: install [], buildCmd/devCmd null, outputDirs [], `index` = start file (opts.index > previewJson.index > 'index.html'); `hint` (German) when neither index nor scripts found. - Forced mode without script: `{ kind:'build', ..., buildCmd:null, error:'Kein build-Skript in package.json' }` / `{ kind:'dev', ..., devCmd:null, error:'Kein dev-Skript in package.json' }`. - auto: index && !build => static; build => build; dev => dev; else static + hint. - Invalid package.json JSON => no scripts, never throws. devPort int 1024-65535 else 5173; output/index must be relative without '..' else ignored. ## Commands npm: ci --include=dev (package-lock/npm-shrinkwrap) or install --include=dev --no-audit --no-fund; pnpm/yarn/bun: ` install --frozen-lockfile`; build ` run build`. dev: npm/pnpm `run dev -- --host 0.0.0.0 --port N`; yarn/bun `run dev --host 0.0.0.0 --port N` (no `--`, they pass args through). Note: pnpm/yarn in node:20 need corepack (`corepack enable`) — not handled here (later task). ## detectFromDir(dir, opts) fs adapter (has = isFile); reads .webklar-preview.json as previewJson unless opts.previewJson given; tested with temp dir.