Skip to content

fix(setup): correct agent install paths and rename cmd/deployhq -> cmd/dhq#8

Merged
facundofarias merged 2 commits into
mainfrom
fix/agent-setup-paths
May 11, 2026
Merged

fix(setup): correct agent install paths and rename cmd/deployhq -> cmd/dhq#8
facundofarias merged 2 commits into
mainfrom
fix/agent-setup-paths

Conversation

@facundofarias
Copy link
Copy Markdown
Contributor

@facundofarias facundofarias commented May 11, 2026

Summary

  • dhq setup <agent> was writing SKILL.md to paths none of the four agents auto-discover (~/.claude/SKILL.md, ~/.codex/SKILL.md, ~/.cursor/SKILL.md, ~/.windsurf/SKILL.md). Verified against each vendor's official docs. Each agent now writes to its canonical location.
  • Renamed cmd/deployhq/cmd/dhq/ so go install github.com/deployhq/deployhq-cli/cmd/dhq@latest produces a dhq binary, matching the Homebrew/Scoop install paths.

Path changes

Agent User-level Project-level Strategy
claude ~/.claude/skills/deployhq/SKILL.md ./.claude/skills/deployhq/SKILL.md overwrite
codex ~/.codex/AGENTS.md ./AGENTS.md marked block
cursor unsupported (errors with hint) ./.cursor/rules/deployhq.mdc overwrite
windsurf ~/.codeium/windsurf/memories/global_rules.md ./.windsurf/rules/deployhq.md marked block / overwrite

Shared files (AGENTS.md, global_rules.md) use <!-- BEGIN dhq --> / <!-- END dhq --> markers so reinstall is idempotent and uninstall removes only our block, preserving any pre-existing user content.

Cursor frontmatter (.mdc) added so the rule is recognized:

---
description: DeployHQ CLI usage guide — invoke when the user mentions deploys, ...
alwaysApply: false
---

Test plan

  • go build ./cmd/dhq/ produces dhq binary
  • dhq setup --help lists all four agents
  • dhq setup cursor (no --project) errors with "Cursor does not support user-level install; rerun with --project"
  • dhq setup cursor --project writes .cursor/rules/deployhq.mdc with Cursor frontmatter
  • dhq setup codex --project against an existing AGENTS.md appends a marker block; running again updates in place (still 1 block); uninstall removes the block, original content intact
  • dhq setup windsurf --project writes plain .windsurf/rules/deployhq.md (no markers — we own that file)
  • dhq setup windsurf (user) wraps content in markers inside ~/.codeium/windsurf/memories/global_rules.md
  • dhq setup claude --project writes .claude/skills/deployhq/SKILL.md with Anthropic skill frontmatter
  • go vet ./... and golangci-lint run ./internal/commands/... clean

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Setup command adds unified install/uninstall flow and supports per-scope installations.
    • Safer, atomic management of embedded integration blocks in shared config files.
  • Documentation

    • Updated build and installation instructions.
  • Chores

    • Adjusted build configuration to point to the revised CLI entrypoint.

Review Change Stack

…d/dhq

dhq setup was writing SKILL.md to paths none of the four agents
auto-discover (~/.claude/SKILL.md, ~/.codex/SKILL.md, ~/.cursor/SKILL.md,
~/.windsurf/SKILL.md). Each agent now writes to its canonical location:

- claude:   ~/.claude/skills/deployhq/SKILL.md (user) or .claude/skills/deployhq/SKILL.md (project)
- codex:    ~/.codex/AGENTS.md (user) or ./AGENTS.md (project), via marker block
- cursor:   .cursor/rules/deployhq.mdc with Cursor .mdc frontmatter; user-level errors with hint
- windsurf: ~/.codeium/windsurf/memories/global_rules.md (user, marker block) or .windsurf/rules/deployhq.md (project)

Shared files (AGENTS.md, global_rules.md) use BEGIN dhq / END dhq markers so
reinstall is idempotent and uninstall removes only our block.

Also rename cmd/deployhq/ -> cmd/dhq/ so `go install .../cmd/dhq@latest`
produces a binary named dhq (matching brew/scoop). Updates .goreleaser.yaml,
README install instructions, and CLAUDE.md build command accordingly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 340c64eb-bcda-4466-82e7-9847415f1854

📥 Commits

Reviewing files that changed from the base of the PR and between 94d0100 and c5c0559.

📒 Files selected for processing (1)
  • internal/commands/setup.go

Walkthrough

This PR renames the CLI entrypoint from ./cmd/deployhq to ./cmd/dhq across build config and docs, and refactors internal/commands/setup.go into a scope-aware, per-agent installer with full-file and marked-block write strategies and atomic block helpers.

Changes

CLI Entrypoint Rename

Layer / File(s) Summary
Build Configuration and Documentation Updates
.goreleaser.yaml, CLAUDE.md, README.md
GoReleaser build entrypoint, development build instructions, and README/CLAUDE docs updated to reference ./cmd/dhq instead of ./cmd/deployhq.

Setup Command Installer Refactoring

Layer / File(s) Summary
Constants & writeStrategy
internal/commands/setup.go
Adds managed-block delimiters, errUnsupportedScope, scope type, and writeStrategy enum.
Agent registry (function-based)
internal/commands/setup.go
Replaces static agent model with function-based PathFor, Content, StrategyFor and updates the agents registry.
Agent subcommand registration
internal/commands/setup.go
newSetupCmd iterates the agent registry to register subcommands.
Unified RunE handler and scope handling
internal/commands/setup.go
newAgentSetupCmd refactored to unified RunE that selects scope, resolves paths with explicit unsupported-scope errors, picks strategy, and routes to install/uninstall.
Dynamic help generation
internal/commands/setup.go
longHelp renders help text based on user-global support and project install path.
Install implementation
internal/commands/setup.go
runInstall ensures parent directory, overwrites files or upserts managed blocks, and updates status messaging including uninstall hints.
Uninstall implementation
internal/commands/setup.go
runUninstall removes files or managed blocks, performs best-effort parent-dir cleanup, and reports not-found states.
Scoped path resolvers
internal/commands/setup.go
pathClaude, pathCodex, pathCursor, pathWindsurf implement user vs project install rules and return errUnsupportedScope when invalid.
Atomic write helper
internal/commands/setup.go
writeFileAtomic implements temp-file + rename crash-safe writes.
Upsert managed block
internal/commands/setup.go
upsertBlock creates, replaces, or appends managed <!-- BEGIN dhq -->...<!-- END dhq --> blocks using atomic writes.
Remove managed block
internal/commands/setup.go
removeBlock deletes managed block, cleans surrounding whitespace, deletes file if empty, and returns whether a block existed.
Embedded skill frontmatter and body
internal/commands/setup.go
Introduces skillFrontmatter and cursorFrontmatter and updates generation to combine frontmatter with skillBody per-agent.

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main changes: fixing agent install paths and renaming cmd/deployhq to cmd/dhq, matching the primary objectives of the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/agent-setup-paths

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/commands/setup.go`:
- Around line 115-147: The cobra command defined by variable cmd for the setup
subcommand currently lacks an Args validator and therefore silently accepts
unexpected positional arguments; update the cmd declaration to include Args:
cobra.NoArgs so the command immediately rejects any extra positional parameters
(e.g., when RunE is invoked for the cobra.Command created in
internal/commands/setup.go), ensuring unexpected inputs like "dhq setup foo"
return an error before mutating operations in RunE.
- Around line 280-306: The current upsertBlock (and similarly removeBlock)
rewrites shared files directly with os.WriteFile which can corrupt files on
failure; change these to use an atomic write: implement a helper
writeFileAtomic(path, data []byte, perm os.FileMode) that writes to a temp file
in the same directory, fsyncs the temp, then rename to the target, and replace
all os.WriteFile(...) calls in upsertBlock and removeBlock with
writeFileAtomic(...) so updates of files containing the blockBegin/blockEnd
markers are atomic and safe.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6bc0a3c3-b4ca-41c8-95bd-eb29549b57bb

📥 Commits

Reviewing files that changed from the base of the PR and between 11c173b and 94d0100.

📒 Files selected for processing (5)
  • .goreleaser.yaml
  • CLAUDE.md
  • README.md
  • cmd/dhq/main.go
  • internal/commands/setup.go

Comment thread internal/commands/setup.go
Comment thread internal/commands/setup.go Outdated
Two follow-ups from CodeRabbit review on PR #8:

1. Add `Args: cobra.NoArgs` to setup subcommands so `dhq setup claude foo`
   errors instead of silently ignoring the stray argument. Mutating commands
   should fail fast on unexpected input.

2. Write shared files (AGENTS.md, ~/.codeium/.../global_rules.md) atomically
   via a temp file + rename. Previously a crash mid-write could lose user
   content outside the dhq-managed block. The new writeFileAtomic helper
   replaces direct os.WriteFile calls in upsertBlock / removeBlock.

Dedicated files we own (Claude SKILL.md, Cursor .mdc, Windsurf project rule)
still use os.WriteFile — they're recoverable by rerunning `dhq setup`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@facundofarias facundofarias merged commit 712236b into main May 11, 2026
3 checks passed
@facundofarias facundofarias deleted the fix/agent-setup-paths branch May 11, 2026 14:02
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.

1 participant