{
  "tests": {
    "cleanup_removes_unused_npm_packages": {
      "tempDir": true,
      "steps": [
        {
          // Initial install with two packages
          "args": "install",
          "output": "install.out"
        },
        {
          // Verify both packages exist in node_modules/.deno
          "args": [
            "eval",
            "const entries = Array.from(Deno.readDirSync('node_modules/.deno')).filter(e => !e.name.startsWith('.')).map(e => e.name); const hasChalk = entries.some(e => e.includes('chalk@5.0.1')); const hasCowsay = entries.some(e => e.includes('cowsay@1.5.0')); console.log(`chalk: ${hasChalk}, cowsay: ${hasCowsay}`);"
          ],
          "output": "initial_packages.out"
        },
        {
          // Update package.json to remove cowsay
          "args": [
            "eval",
            "Deno.writeTextFileSync('package.json', Deno.readTextFileSync('package_updated.json'));"
          ],
          "output": ""
        },
        {
          // Run install again - should clean up unused packages
          "args": "install --log-level=debug",
          "output": "[WILDCARD]"
        },
        {
          // Verify only chalk remains, cowsay is cleaned up
          "args": [
            "eval",
            "const entries = Array.from(Deno.readDirSync('node_modules/.deno')).filter(e => !e.name.startsWith('.')).map(e => e.name); const hasChalk = entries.some(e => e.includes('chalk@5.0.1')); const hasCowsay = entries.some(e => e.includes('cowsay@1.5.0')); console.log(`chalk: ${hasChalk}, cowsay: ${hasCowsay}`);"
          ],
          "output": "final_packages.out"
        },
        {
          // Verify cowsay symlink is removed from root node_modules
          "args": [
            "eval",
            "try { Deno.statSync('node_modules/cowsay'); console.log('EXISTS'); } catch { console.log('NOT_FOUND'); }"
          ],
          "output": "cowsay_removed.out"
        }
      ]
    }
  }
}
