Skip to content

feat(registry): registry remove command, RegistryManager module & auto-update on init/run#564

Open
OgnjenGligoric wants to merge 9 commits into
andresharpe:mainfrom
OgnjenGligoric:fix/550-registry-remove-namespace-stack-auto-update
Open

feat(registry): registry remove command, RegistryManager module & auto-update on init/run#564
OgnjenGligoric wants to merge 9 commits into
andresharpe:mainfrom
OgnjenGligoric:fix/550-registry-remove-namespace-stack-auto-update

Conversation

@OgnjenGligoric

Copy link
Copy Markdown
Contributor

Linked issue

Closes #550

Summary of changes

Implements three missing deliverables from the Phase 11 enterprise registry feature: a registry remove command, a RegistryManager module for registry state management, and auto-update of stale git-based registries on dotbot init and dotbot run.

New dotbot registry remove (src/cli/registry-remove.ps1):
removes a registry by name — reads registries.json to confirm the registry exists, prompts for confirmation (skippable with -Force), safely removes the local directory or junction/symlink without deleting symlink target contents (detects ReparsePoint attribute), then strips the entry from registries.json. Mirrors the structure of registry-add.ps1.

New RegistryManager.psm1 (src/cli/RegistryManager.psm1):
module for registry state management, exporting two functions:

  • Get-DotbotRegistries — reads all entries from registries.json as an array; returns empty array if file is absent.
  • Update-StaleRegistries — git fetch + fast-forward merge for all git-based registries with auto_update: true; honours a MaxAgeSecs threshold (default 3600s) to avoid hammering git on every run; failures are non-fatal (warning emitted, stale local copy used); records updated_at timestamp in registries.json on success.

Auto-update wired into bin/dotbot.ps1:
both Invoke-Init and Invoke-Run now call Update-StaleRegistries before executing, so registries stay fresh on normal usage without a manual dotbot registry update.

namespace:stack resolution in init-project.ps1: already implemented — Resolve-FrameworkSource handles namespace:name for both workflows and stacks via the same code path. No change needed.

Testing notes

Manual inspection confirms the routing for dotbot registry remove was already wired in bin/dotbot.ps1 (Invoke-Registry switch). The remove script follows the same validation and output patterns as the existing registry commands.

Checklist

  • Tests added or updated
  • Docs updated (if behaviour changed)
  • Linked issue exists
  • Follows the contribution guide

github-actions Bot and others added 3 commits June 25, 2026 09:37
Introduce a RegistryManager PowerShell module to manage registries.json and auto-update git-based registries (Update-StaleRegistries, Get-DotbotRegistries). The module fetches and fast-forward merges registries (honors auto_update, branch, MaxAgeSecs and skips local symlinked registries), and updates updated_at timestamps. Add registry-remove.ps1 to remove a named registry (deletes local directory or symlink, updates registries.json, and includes user confirmation/force flag). Wire the new RegistryManager into bin/dotbot.ps1 so Invoke-Init and Invoke-Run import the module and call Update-StaleRegistries before proceeding.
@DKuleshov

Copy link
Copy Markdown
Collaborator

@OgnjenGligoric do we rely need to bump version to v4.0.1? CC: @carlospedreira

@DKuleshov

Copy link
Copy Markdown
Collaborator

@OgnjenGligoric Is it possible to add some tests for removal?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the missing “registry remove” deliverable plus a small registry-state helper module, and wires registry auto-update into the main dotbot entrypoint so git-based registries can stay fresh during normal init/run usage.

Changes:

  • Introduces dotbot registry remove to delete a registry’s local cache/link and remove its entry from registries.json.
  • Adds RegistryManager.psm1 with Get-DotbotRegistries and Update-StaleRegistries for stale git registry fast-forward updates.
  • Calls Update-StaleRegistries automatically from dotbot init and dotbot run.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 6 comments.

File Description
src/cli/RegistryManager.psm1 New helper module for reading registries + auto-updating stale git registries.
src/cli/registry-remove.ps1 New CLI command to remove a registry from disk and registries.json.
bin/dotbot.ps1 Wires registry auto-update into Invoke-Init and Invoke-Run.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/cli/RegistryManager.psm1 Outdated
Comment thread src/cli/RegistryManager.psm1 Outdated
Comment thread src/cli/RegistryManager.psm1 Outdated
Comment thread src/cli/RegistryManager.psm1
Comment thread src/cli/RegistryManager.psm1 Outdated
Comment thread src/cli/registry-remove.ps1
Improve error reporting and registry update handling, and harden the registry removal script. Swap generic Write-Warning calls for Write-DotbotWarning and surface JSON parse errors when loading registries.json. Update logic that records updated_at to use UTC timestamps and a safer ForEach-Object update so changes are tracked correctly. Add validation to registry-remove.ps1 to prevent path traversal: validate registry names, resolve full paths, and ensure the target is inside the registries directory, exiting with an error on invalid input.
@OgnjenGligoric

Copy link
Copy Markdown
Contributor Author

@DKuleshov could we do the GitHub Copilot review now?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

Comment thread src/cli/RegistryManager.psm1 Outdated
Comment thread src/cli/RegistryManager.psm1
Comment thread src/cli/registry-remove.ps1
Add validation and safety checks when auto-updating registries: sanitize and validate registry names, resolve absolute paths and ensure they remain inside the registries root to prevent path traversal, and require the registry path be an existing container. Suppress git output, check that git exists on PATH before attempting fetch/merge, and update warning messages to use the sanitized name. Also replace a Read-Host confirmation in registry-remove with Read-DotbotConfirmation for a consistent, safer prompt and abort handling.
@OgnjenGligoric OgnjenGligoric marked this pull request as ready for review July 1, 2026 09:04
@OgnjenGligoric

Copy link
Copy Markdown
Contributor Author

@DKuleshov Can we run GitHub Copilot review?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

Comment thread src/cli/registry-remove.ps1
@OgnjenGligoric

Copy link
Copy Markdown
Contributor Author

@andresharpe Its ready for review.

Add tests/Test-RegistryCLI.ps1 containing Layer 2 tests for registry-remove.ps1 and RegistryManager.psm1 (Get-DotbotRegistries, Update-StaleRegistries, path-traversal/name validation, removal behavior and registries.json cleanup). Update tests/Run-Tests.ps1 to invoke the new Test-RegistryCLI.ps1 and include its exit code in the layer/overall test results.
Update Test-RegistryCLI.ps1 to run registry-remove tests against the real DOTBOT_HOME/registries instead of a test-only config. Add functions to backup/restore registries.json and to write real registries entries, create a temporary test registry dir with a random name, and assert removal/retention against the real config. Restore original registries.json after each scenario and adjust assertion messages/output variables accordingly.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Comment thread tests/Test-RegistryCLI.ps1
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Inbox

Development

Successfully merging this pull request may close these issues.

Registry: remove command, namespace:stack resolution & auto-update

3 participants