---
name: dx-hub-config
description: View and edit hub configuration — add repos, adjust terminal delay. Use to manage hub settings. Trigger on "hub config", "add repo to hub", "terminal delay".
when_to_use: "Use to view and edit hub configuration — add repos, adjust terminal delay. Trigger on 'hub config', 'add repo to hub', 'terminal delay', 'configure hub', or 'edit hub settings'."
argument-hint: "[show | add-repo <path> | terminal-delay <seconds>]"
allowed-tools: ["Read", "Edit", "Glob", "Grep", "Write", "Bash"]
---

You view and edit the hub configuration in `.ai/config.yaml`.

## Pre-flight

Read `.ai/config.yaml`. If a `hub:` section is absent, STOP:

> Hub mode is not configured. Run `/dx-hub-init` first.

## 1. Parse Subcommand

Inspect `$ARGUMENTS` and route to the matching section:

| Subcommand | Action |
|---|---|
| *(none)* or `show` | Display current hub config |
| `add-repo <path>` | Discover and add a repo |
| `terminal-delay <seconds>` | Set seconds to wait for Claude to start in terminal |

## 2. show

Print hub settings in readable format:

```
Hub Configuration
─────────────────────────────────
Enabled:         <hub.enabled>
Terminal delay:  <hub.terminal-delay>s
State TTL:       <hub.state-ttl>

Repos (<count>):
  - <name>  <path>  [capabilities: <caps>]  [base: <base-branch>]  [project: <project>]
  ...
```

## 3. add-repo <path>

1. Resolve the path (expand `~`, make absolute).
2. Check that `<path>/.ai/config.yaml` exists. If not, STOP: "No `.ai/config.yaml` found at `<path>`. Is this a dx-enabled project?"
3. Read `<path>/.ai/config.yaml` and extract:
   - `name` (or derive from directory name)
   - `scm.base-branch` (default `main` if absent)
   - `scm.project` (optional)
4. Check for a duplicate: if `hub.repos` already contains an entry with the same `name`, STOP: "Repo `<name>` is already in the hub. Use `show` to review current repos."
5. Append to `hub.repos` in `.ai/config.yaml`:
   ```yaml
   - name: <name>
     path: <resolved-path>
     base-branch: <base-branch>
     project: <project>       # omit if absent
   ```
6. Print confirmation:
   > Added `<name>` (`<resolved-path>`) to hub. Total repos: <new count>.

## 4. terminal-delay <seconds>

1. Validate `<seconds>` is a positive integer between 1 and 30. If not, STOP: "Invalid delay `<seconds>`. Use a number between 1 and 30."
2. Update `hub.terminal-delay` in `.ai/config.yaml`.
3. Print: > Terminal delay set to `<seconds>`s.

## Examples

```
/dx-hub-config
/dx-hub-config show
```
Prints current hub settings and all registered repos.

```
/dx-hub-config add-repo ../my-other-repo
```
Reads `../my-other-repo/.ai/config.yaml`, extracts metadata, and adds the repo to the hub.

```
/dx-hub-config terminal-delay 8
```
Updates the terminal startup delay and confirms the change.

## Troubleshooting

### "Hub mode is not configured"
**Cause:** `.ai/config.yaml` has no `hub:` section.
**Fix:** Run `/dx-hub-init` to initialise hub mode first.

### "No `.ai/config.yaml` found at `<path>`"
**Cause:** The target directory is not a dx-enabled project, or the path is wrong.
**Fix:** Run `/dx-init` in the target repo, then retry.

### "Repo `<name>` is already in the hub"
**Cause:** A repo with that name is already registered.
**Fix:** Run `/dx-hub-config show` to review existing entries.
