Skip to content

Add auto-bootstrap in apm install when no apm.yml exists#19

Merged
danielmeppiel merged 5 commits intomainfrom
copilot/add-auto-bootstrap-apm-install
Oct 29, 2025
Merged

Add auto-bootstrap in apm install when no apm.yml exists#19
danielmeppiel merged 5 commits intomainfrom
copilot/add-auto-bootstrap-apm-install

Conversation

Copy link
Contributor

Copilot AI commented Oct 29, 2025

Enables apm install <package> to work in any directory without requiring apm init first, matching npm's brownfield adoption pattern.

Changes

CLI behavior (src/apm_cli/cli.py)

  • Auto-creates minimal apm.yml when packages specified but no manifest exists
  • Enhanced error message when invoked without packages or manifest to suggest both apm init and apm install <package>
  • Reuses existing _create_minimal_apm_yml() from issue Refactor apm init to minimal-only mode (breaking change) #13 for consistency

Test coverage (tests/unit/test_install_command.py)

  • 7 test cases covering: auto-bootstrap with packages, error without packages, existing manifest preservation, multiple packages, metadata detection, invalid formats, dry-run

Documentation (docs/cli-reference.md)

  • Updated examples and behavioral documentation

Example

# Before: Required apm init first
$ apm install danielmeppiel/design-guidelines
Error: No apm.yml found. Run 'apm init' first.

# After: Auto-creates minimal apm.yml
$ apm install danielmeppiel/design-guidelines
✨ Created apm.yml
✓ Added danielmeppiel/design-guidelines to apm.yml
✓ Installed danielmeppiel/design-guidelines

No breaking changes—existing workflows with apm.yml already present behave identically.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • demo.registry.azure-mcp.net
    • Triggering command: /home/REDACTED/work/apm/apm/.venv/bin/python3 /home/REDACTED/work/apm/apm/.venv/bin/pytest tests/ -v --tb=short (dns block)
  • github.com (HTTP Only)
    • Triggering command: /usr/bin/ssh -o SendEnv=GIT_PROTOCOL git@github.com git-upload-pack &#39;danielmeppiel/design-guidelines.git&#39; (packet block)
  • https://api.github.com/repos/openai/codex/releases/latest
    • Triggering command: curl -s REDACTED (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Add auto-bootstrap in apm install when no apm.yml exists</issue_title>
<issue_description>## Summary
Enable apm install <package> to automatically create a minimal apm.yml when none exists, matching npm's behavior where npm install <package> works in any directory.

Current Behavior

$ apm install danielmeppiel/design-guidelines
Error: No apm.yml found. Run 'apm init' first.

Target Behavior

$ apm install danielmeppiel/design-guidelines
✨ Created apm.yml
✓ Added danielmeppiel/design-guidelines to apm.yml
✓ Installed danielmeppiel/design-guidelines

# apm.yml is now created with minimal config + the installed package

Implementation Requirements

Logic Flow

def install(ctx, packages, ...):
    apm_yml_exists = Path('apm.yml').exists()
    
    # NEW: Auto-bootstrap when packages specified but no apm.yml
    if not apm_yml_exists and packages:
        _create_minimal_apm_yml()  # Reuse from issue danielmeppiel/apm#13
        _rich_success("Created apm.yml", symbol="sparkles")
    
    # Error only when NO apm.yml AND NO packages
    if not apm_yml_exists and not packages:
        _rich_error("No apm.yml found")
        _rich_info("💡 Run 'apm init' to create one, or:")
        _rich_info("   apm install <org/repo> to auto-create + install")
        sys.exit(1)
    
    # Continue with existing install logic...

Integration with Issue #13

  • Reuse the minimal apm.yml generator from apm init refactor
  • Same auto-detection logic for project metadata
  • Consistent output format

Scenarios

Scenario 1: No apm.yml, WITH packages

cd existing-repo
apm install myorg/standards myorg/chatmodes
# ✨ Creates minimal apm.yml
# ✓ Adds both packages to dependencies
# ✓ Installs both packages

Scenario 2: No apm.yml, NO packages

cd existing-repo
apm install
# ❌ Error with helpful message pointing to:
#    - apm init (create empty manifest)
#    - apm install <package> (create + install)

Scenario 3: Has apm.yml (existing behavior preserved)

cd project-with-apm-yml
apm install                  # Install existing deps
apm install myorg/new-pkg    # Add to apm.yml + install

Acceptance Criteria

  • apm install org/pkg in directory without apm.yml creates minimal manifest
  • Auto-created apm.yml includes the specified package in dependencies
  • Success message clearly indicates apm.yml was created
  • apm install without packages and without apm.yml shows helpful error
  • Error message suggests both apm init and apm install <package> options
  • Existing behavior preserved when apm.yml already exists
  • Tests cover all scenarios (with/without manifest, with/without packages)
  • Integration with minimal init generator from issue Refactor apm init to minimal-only mode (breaking change) #13

Dependencies

Related

Part of npm-parity redesign for brownfield adoption</issue_description>

<agent_instructions>Ensure unit, integration and release validation tests are adjusted to the new behaviour so that they do not fail in CI</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits October 29, 2025 10:40
Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
Copilot AI changed the title [WIP] Add auto-bootstrap for apm install when no apm.yml exists Add auto-bootstrap in apm install when no apm.yml exists Oct 29, 2025
Copilot AI requested a review from danielmeppiel October 29, 2025 10:51
@danielmeppiel
Copy link
Collaborator

This will close #5

@danielmeppiel danielmeppiel marked this pull request as ready for review October 29, 2025 11:00
@danielmeppiel danielmeppiel merged commit 893b1a1 into main Oct 29, 2025
19 checks passed
@danielmeppiel danielmeppiel mentioned this pull request Oct 29, 2025
12 tasks
@danielmeppiel danielmeppiel deleted the copilot/add-auto-bootstrap-apm-install branch February 27, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add auto-bootstrap in apm install when no apm.yml exists

2 participants