Skip to content

feature/WR-18897-onboarding-dotfiles-hardening#49

Merged
abarrows merged 7 commits into
productionfrom
feature/WR-18897-onboarding-dotfiles-hardening
Jun 28, 2026
Merged

feature/WR-18897-onboarding-dotfiles-hardening#49
abarrows merged 7 commits into
productionfrom
feature/WR-18897-onboarding-dotfiles-hardening

Conversation

@abarrows

@abarrows abarrows commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Description

Related Links

  • Jira Issue: JIRA-XXX

Summary by Sourcery

Introduce a documented plan and bootstrap script for setting up a 24/7 Mac mini local-AI agent host using Docker MCP Toolkit and Claude Code, aligned with existing dotfiles onboarding work.

New Features:

  • Add a mac-mini MCP bootstrap script to configure Docker MCP Toolkit servers, secrets, and Claude Code integration for a 24/7 Mac mini host.

Documentation:

  • Add a detailed dry-run plan for validating the local-AI agent stack on a MacBook before promoting it to the Mac mini, covering Ollama, Hermes, MCP, and rs-agents integration.

abarrows and others added 6 commits June 27, 2026 11:22
…nsions, quiet system_profiler

From the Mac Mini provisioning review (WR-18897):

- onboard.sh: add envrc_is_sourceable() so a malformed/old-template .envrc is
  backed up and regenerated instead of silently adopted — the bug that skipped
  the prompt and spammed "command not found" on every new shell. Prompt logic
  extracted into generate_envrc().
- extensions_base.txt: remove GitHub.copilot-chat (now a built-in extension,
  install conflicts), stkb.rewrap (fails marketplace signature verification),
  and ms-vscode-remote.remote-wsl (Windows-only, no-op on macOS).
- starship.zsh: redirect system_profiler stderr to /dev/null so its hw.cpufamily
  diagnostic stops leaking into every new shell.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…COMPANY path

resolve_repo used CURRENT_COMPANY from the calling shell's environment to
decide the clone path, then ensure_envrc prompted the user for the real value
— too late.  If the calling shell had a stale CURRENT_COMPANY (e.g. from a
prior job), the repo landed in the wrong directory and every alias derived
from it resolved to a corrupt path.

Fix: introduce collect_machine_vars, which runs before resolve_repo.  It
sources any existing valid .envrc (fast no-op on re-runs) or prompts the user
and writes ~/.envrc, then sources it so CURRENT_COMPANY is correct before any
path decision is made.  ensure_envrc (post-clone) then moves ~/.envrc into
$REPO_DIR as before.

Additional hardening:
- CURRENT_COMPANY prompt default is hardcoded to "Retail-Success" (the correct
  value for this repo), so a stale env var can never silently win.
- IDE_PATH defaults to "code" (VS Code CLI); stale "vscode" values are
  normalised at both init and post-prompt time.
- generate_envrc checks ~/.envrc first to prevent double-prompting on the
  malformed-repo-.envrc edge case.
- Generated .envrc now covers the full variable set from .envrc.example
  (adds JIRA_API_TOKEN placeholder and GIT_EMAIL_ADDRESS_PERSONAL).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…script

Stands up the Docker MCP gateway (stdio, no url/auth) and wires Claude Code
to it, replicating the default profile's enabled servers. Includes interactive
secret setup and a reboot-survival checklist (auto-login, Docker autostart,
sleep prevention, keychain).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@abarrows abarrows self-assigned this Jun 28, 2026
@abarrows abarrows added the Story label Jun 28, 2026
@sourcery-ai

sourcery-ai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

This PR hardens dotfiles onboarding and environment setup, improves macOS shell behavior, and adds documented workflows plus a bootstrap script for configuring a Mac mini as a 24/7 MCP/Claude agent host, including Docker MCP toolkit and Claude Code wiring.

Sequence diagram for mac-mini-mcp-bootstrap.sh wiring Docker MCP to Claude Code

sequenceDiagram
  actor User
  participant Script as mac-mini-mcp-bootstrap.sh
  participant DockerCLI as docker
  participant ClaudeCLI as claude
  participant Keychain as MacOSKeychain

  User->>Script: bash mac-mini-mcp-bootstrap.sh
  Script->>DockerCLI: docker --version
  Script->>ClaudeCLI: claude --version
  Script->>DockerCLI: docker info
  Script->>DockerCLI: docker mcp profile server add default DEFAULT_SERVERS
  Script->>DockerCLI: docker mcp profile server ls
  Script->>Keychain: docker mcp secret set <key>
  Script->>DockerCLI: docker mcp secret set github.personal_access_token
  Script->>DockerCLI: docker mcp secret set github-chat.api_key
  Script->>DockerCLI: docker mcp secret set atlassian.jira.api_token
  Script->>DockerCLI: docker mcp secret set atlassian.confluence.api_token
  Script->>DockerCLI: docker mcp oauth authorize <name>
  Script->>DockerCLI: docker mcp client connect claude-code
  Script->>ClaudeCLI: claude mcp list
  ClaudeCLI-->>Script: MCP_DOCKER: docker mcp gateway run - Connected
  Script-->>User: Done. Mac mini wired for 24_7 MCP/Claude host
Loading

File-Level Changes

Change Details Files
Add a documented dry-run plan and workflow for standing up a local AI agent host and promoting it to a 24/7 Mac mini.
  • Introduce ai/workflows/mac-mini-agent/DRY-RUN-PLAN.md describing architecture, objectives, and a reversible dry-run procedure.
  • Document stepwise commands and pass/fail criteria for ephemeral setup of Ollama, Hermes, MCP toolkit, and rs-agents on the laptop.
  • Outline promotion steps and persistent configuration required when moving from dry run to the Mac mini host.
ai/workflows/mac-mini-agent/DRY-RUN-PLAN.md
Add a dedicated bootstrap script to wire Docker MCP Toolkit and Claude Code on the Mac mini and outline 24/7 survivability requirements.
  • Create mac-mini-mcp-bootstrap.sh with structured steps, logging helpers, and strict error handling.
  • Check prerequisites for Docker Desktop, Claude Code CLI, and MCP Toolkit availability, and verify Docker daemon readiness.
  • Enable a predefined set of MCP servers on the default profile and list active servers for verification.
  • Add interactive secret setup using docker mcp secret with values read securely from stdin and stored in Keychain.
  • Connect Claude Code to the Docker MCP gateway via docker mcp client connect and document equivalent manual configuration.
  • Embed a survival checklist for configuring auto-login, Docker autostart, sleep prevention, and keychain behavior on a 24/7 Mac mini.
ai/workflows/mac-mini-agent/mac-mini-mcp-bootstrap.sh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

…ardening

Signed-off-by: Andrew Barrows <acbarrows@gmail.com>

@sourcery-ai sourcery-ai Bot 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.

Hey - I've found 2 issues, and left some high level feedback:

  • Consider adding a --dry-run/DRY_RUN mode to mac-mini-mcp-bootstrap.sh so you can validate MCP wiring and prerequisites on new machines without mutating profiles or secrets during initial experimentation.
  • The hard-coded DEFAULT_SERVERS list in mac-mini-mcp-bootstrap.sh may not always match future profiles; consider making this configurable (e.g., via a config file or env var) and/or skipping servers that are already enabled to avoid unintended overwrites.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider adding a `--dry-run`/`DRY_RUN` mode to `mac-mini-mcp-bootstrap.sh` so you can validate MCP wiring and prerequisites on new machines without mutating profiles or secrets during initial experimentation.
- The hard-coded `DEFAULT_SERVERS` list in `mac-mini-mcp-bootstrap.sh` may not always match future profiles; consider making this configurable (e.g., via a config file or env var) and/or skipping servers that are already enabled to avoid unintended overwrites.

## Individual Comments

### Comment 1
<location path="ai/workflows/mac-mini-agent/mac-mini-mcp-bootstrap.sh" line_range="67-71" />
<code_context>
+# ── 3. Secrets — these do NOT transfer from the other Mac ────────────────────
+# Secrets live in the macOS Keychain on each machine. Set them here once.
+# Re-run any line as needed; value is read from stdin so it won't hit shell history.
+step "3. Secrets (set the ones you use; skip with Ctrl-D)"
+warn "These are stored in this Mac mini's keychain. They were NOT copied from your laptop."
+set_secret() {
+  local key="$1" label="$2"
+  read -r -s -p "  ${label} (Enter to skip): " val; echo
+  if [[ -n "${val}" ]]; then
+    printf '%s' "${val}" | docker mcp secret set "${key}"
</code_context>
<issue_to_address>
**issue (bug_risk):** Ctrl-D behavior with `read` conflicts with `set -e` and will terminate the script.

The prompt advertises Ctrl-D as a way to skip, but with `set -e` a failed `read` on EOF (Ctrl-D) returns non-zero and exits the script. To preserve the intended skip behavior, make `read` non-fatal (e.g. `read -r -s -p ... val || val=""`) or gate the subsequent logic on `[[ -n $val ]]` so Ctrl-D/EOF is treated like a skip rather than aborting the bootstrap.
</issue_to_address>

### Comment 2
<location path="ai/workflows/mac-mini-agent/mac-mini-mcp-bootstrap.sh" line_range="89-94" />
<code_context>
+
+# ── 4. Connect Claude Code to the gateway (the easy way) ─────────────────────
+step "4. Wiring Claude Code to the Docker MCP gateway"
+docker mcp client connect claude-code
+# Equivalent manual form (stdio, no url/auth):
+#   claude mcp add MCP_DOCKER -- docker mcp gateway run
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Making `docker mcp client connect claude-code` idempotent would avoid failures on re-run.

With `set -euo pipefail`, a second run will exit if the client is already connected. Please make this step tolerant of the "already connected" case (e.g. `docker mcp client connect claude-code || warn "Claude client already connected"`) so the script is safely re-runnable.

```suggestion
# ── 4. Connect Claude Code to the gateway (the easy way) ─────────────────────
step "4. Wiring Claude Code to the Docker MCP gateway"
docker mcp client connect claude-code || warn "Claude client already connected; continuing"
# Equivalent manual form (stdio, no url/auth):
#   claude mcp add MCP_DOCKER -- docker mcp gateway run
bold "  Connected. Verify with: claude mcp list"
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +67 to +71
step "3. Secrets (set the ones you use; skip with Ctrl-D)"
warn "These are stored in this Mac mini's keychain. They were NOT copied from your laptop."
set_secret() {
local key="$1" label="$2"
read -r -s -p " ${label} (Enter to skip): " val; echo

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.

issue (bug_risk): Ctrl-D behavior with read conflicts with set -e and will terminate the script.

The prompt advertises Ctrl-D as a way to skip, but with set -e a failed read on EOF (Ctrl-D) returns non-zero and exits the script. To preserve the intended skip behavior, make read non-fatal (e.g. read -r -s -p ... val || val="") or gate the subsequent logic on [[ -n $val ]] so Ctrl-D/EOF is treated like a skip rather than aborting the bootstrap.

Comment on lines +89 to +94
# ── 4. Connect Claude Code to the gateway (the easy way) ─────────────────────
step "4. Wiring Claude Code to the Docker MCP gateway"
docker mcp client connect claude-code
# Equivalent manual form (stdio, no url/auth):
# claude mcp add MCP_DOCKER -- docker mcp gateway run
bold " Connected. Verify with: claude mcp list"

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.

suggestion (bug_risk): Making docker mcp client connect claude-code idempotent would avoid failures on re-run.

With set -euo pipefail, a second run will exit if the client is already connected. Please make this step tolerant of the "already connected" case (e.g. docker mcp client connect claude-code || warn "Claude client already connected") so the script is safely re-runnable.

Suggested change
# ── 4. Connect Claude Code to the gateway (the easy way) ─────────────────────
step "4. Wiring Claude Code to the Docker MCP gateway"
docker mcp client connect claude-code
# Equivalent manual form (stdio, no url/auth):
# claude mcp add MCP_DOCKER -- docker mcp gateway run
bold " Connected. Verify with: claude mcp list"
# ── 4. Connect Claude Code to the gateway (the easy way) ─────────────────────
step "4. Wiring Claude Code to the Docker MCP gateway"
docker mcp client connect claude-code || warn "Claude client already connected; continuing"
# Equivalent manual form (stdio, no url/auth):
# claude mcp add MCP_DOCKER -- docker mcp gateway run
bold " Connected. Verify with: claude mcp list"

@abarrows abarrows merged commit 0fd120b into production Jun 28, 2026
1 of 2 checks passed
@abarrows abarrows deleted the feature/WR-18897-onboarding-dotfiles-hardening branch June 28, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant