From fed4ba05cdc3558b162f852d8604fd278f28ed55 Mon Sep 17 00:00:00 2001 From: Marta Date: Fri, 10 Jul 2026 16:01:21 +0200 Subject: [PATCH 1/2] feat: add template sub-resources, hosted resources, and project/server actions Extend CLI coverage of the DeployHQ API (DHQ-639, phases 4-7): - project/server actions: regenerate-key, undeployed-changes, ai-overview, servers from-global, servers metrics, config-files/ssh-commands link-global - hosted resources & managed hosting: dhq hosted-resources, dhq managed-hosting - template sub-resources: dhq templates {config-files,servers,build-*,...} - long-tail: dhq ip-ranges, dhq plans, dhq invoices, dhq detect, dhq beta enroll Adds an unauthenticated SDK client path (NewPublic) so the public ip-ranges and plans endpoints work without credentials. Each resource ships an SDK client, cobra command, agent metadata, assist allowlist entry, and unit tests. Verified end-to-end against a live backend. --- internal/assist/prompt.go | 21 + internal/cli/context.go | 63 +- internal/commands/agent_metadata.go | 136 +- internal/commands/beta.go | 76 + internal/commands/config_files.go | 61 + internal/commands/detect.go | 88 ++ internal/commands/hosted_resources.go | 174 +++ internal/commands/hosted_resources_test.go | 48 + internal/commands/invoices.go | 103 ++ internal/commands/ip_ranges.go | 58 + internal/commands/launch.go | 96 +- internal/commands/launch_test.go | 30 +- internal/commands/managed_hosting.go | 119 ++ internal/commands/managed_hosting_test.go | 29 + internal/commands/packages.go | 49 + internal/commands/projects.go | 161 +- internal/commands/root.go | 7 + internal/commands/servers.go | 90 ++ internal/commands/ssh_commands.go | 61 + internal/commands/templates.go | 4 + internal/commands/templates_subresources.go | 1540 +++++++++++++++++++ pkg/sdk/client.go | 24 +- pkg/sdk/client_test.go | 59 + pkg/sdk/config_files.go | 33 +- pkg/sdk/config_files_test.go | 56 + pkg/sdk/hosted_resources.go | 106 ++ pkg/sdk/hosted_resources_test.go | 198 +++ pkg/sdk/invoices.go | 49 + pkg/sdk/invoices_test.go | 70 + pkg/sdk/ip_ranges.go | 52 + pkg/sdk/ip_ranges_test.go | 39 + pkg/sdk/managed_hosting.go | 66 +- pkg/sdk/managed_hosting_test.go | 107 +- pkg/sdk/packages.go | 33 + pkg/sdk/packages_test.go | 53 + pkg/sdk/projects.go | 77 + pkg/sdk/projects_test.go | 109 ++ pkg/sdk/servers.go | 50 + pkg/sdk/servers_test.go | 81 + pkg/sdk/ssh_commands.go | 41 +- pkg/sdk/ssh_commands_test.go | 44 + pkg/sdk/template_subresources.go | 421 +++++ pkg/sdk/template_subresources_test.go | 457 ++++++ pkg/sdk/types.go | 48 +- 44 files changed, 5142 insertions(+), 145 deletions(-) create mode 100644 internal/commands/beta.go create mode 100644 internal/commands/detect.go create mode 100644 internal/commands/hosted_resources.go create mode 100644 internal/commands/hosted_resources_test.go create mode 100644 internal/commands/invoices.go create mode 100644 internal/commands/ip_ranges.go create mode 100644 internal/commands/managed_hosting.go create mode 100644 internal/commands/managed_hosting_test.go create mode 100644 internal/commands/packages.go create mode 100644 internal/commands/templates_subresources.go create mode 100644 pkg/sdk/config_files_test.go create mode 100644 pkg/sdk/hosted_resources.go create mode 100644 pkg/sdk/hosted_resources_test.go create mode 100644 pkg/sdk/invoices.go create mode 100644 pkg/sdk/invoices_test.go create mode 100644 pkg/sdk/ip_ranges.go create mode 100644 pkg/sdk/ip_ranges_test.go create mode 100644 pkg/sdk/packages.go create mode 100644 pkg/sdk/packages_test.go create mode 100644 pkg/sdk/template_subresources.go create mode 100644 pkg/sdk/template_subresources_test.go diff --git a/internal/assist/prompt.go b/internal/assist/prompt.go index 3e07be3..9c9fcab 100644 --- a/internal/assist/prompt.go +++ b/internal/assist/prompt.go @@ -87,9 +87,14 @@ dhq signup — Create a new DeployHQ account Projects: dhq projects list|show|create|update|delete|star|insights dhq projects update --name|--permalink|--zone|--email-notify-on|--notification-email|--notify-pusher|--check-undeployed-changes|--store-artifacts +dhq projects regenerate-key [--key-type ED25519|RSA] (regenerates the SSH deploy key; prints the new public key) +dhq projects undeployed-changes (commits not yet deployed) +dhq projects ai-overview --end-ref [--start-ref ] (AI summary of changes) Servers & Groups: dhq servers list|show|create|update|delete|reset-host-key -p +dhq servers from-global -p (add a global server template to a project) +dhq servers metrics -p (point-in-time metrics snapshot; beta, SSH only, use --json) dhq server-groups list|show|create|update|delete -p Deployments: @@ -105,6 +110,7 @@ Configuration: dhq env-vars list|show|create|update|delete -p dhq global-env-vars list|show|create|update|delete dhq config-files list|show|create|update|delete -p +dhq config-files link-global|unlink-global -p (link/unlink an account-wide config file) dhq excluded-files list|show|create|update|delete -p Build Pipeline: @@ -114,6 +120,7 @@ dhq language-versions list -p (alias: dhq lv list) SSH & Deployment Commands: dhq ssh-commands list|show|create|update|delete -p +dhq ssh-commands link-global|unlink-global -p (link/unlink an account-wide SSH command) dhq ssh-keys list|create|delete Integrations & Automation: @@ -123,12 +130,26 @@ dhq scheduled-deploys list|show|create|update|delete -p Templates: dhq templates list|show|public|public-show|create|update|delete +dhq templates config-files|excluded-files|integrations|commands|build-commands|build-cache-files|build-known-hosts|servers|server-groups -t