Claude Code needs a lightweight package manager that installs requested packages only after all of their dependencies are installed. Given a package dependency graph and requested package names, return a valid installation order, or None if a dependency is missing or the graph contains a cycle.
Dependencies must appear before the package that requires them. Preserve the order of dependencies listed in the input, and process requested packages in the order provided. Each package should appear at most once in the result.
Implement resolve_dependencies(packages, requested), where packages is a dictionary mapping a package name to a list of dependency names, and requested is a list of package names. Return a list of package names in installation order, or None when resolution is impossible.
def resolve_dependencies(packages, requested):