Skip to main content

cmd_adopt

Function cmd_adopt 

Source
pub fn cmd_adopt(
    beans_dir: &Path,
    parent_id: &str,
    child_ids: &[String],
) -> Result<HashMap<String, String>>
Expand description

Adopt existing beans as children of a parent bean.

This command:

  1. Validates that the parent bean exists
  2. For each child ID:
    • Loads the bean
    • Assigns a new ID: {parent_id}.{N} (where N is sequential)
    • Sets the bean’s parent field to parent_id
    • Renames the file to match the new ID
  3. Updates all dependency references across ALL beans
  4. Rebuilds the index

§Arguments

  • beans_dir - Path to the .beans/ directory
  • parent_id - The ID of the parent bean
  • child_ids - List of bean IDs to adopt as children

§Returns

A map of old_id -> new_id for the adopted beans