feat(cli): hf user create --agent-id/--claw-identifier + hf user bind-agent #6

Merged
hzhang merged 1 commits from feat/user-bind-agent into main 2026-05-22 19:02:03 +00:00
Contributor

Implements NEXT_WAVE_DEV_DIRECTION.md §7.3 — never shipped before. Backend POST /users has accepted agent_id+claw_identifier since BE-CAL-003 but the cli never sent them, so historically every agent user (zhi/lyn/mirror/sherlock/orion/nav on prod today) ended up with only a user row — agents table empty, all downstream calendar/heartbeat/schedule-type flows that go through _require_agent() 404.

hf user create — new flags

--agent-id <id>
--claw-identifier <id>

Both required together (matches backend invariant). Either can come from pcexec env: AGENT_ID env for agent-id, openclaw config get plugins.harbor-forge.identifier for claw-identifier. Partial pair → treated as "neither" so plain user creation (no binding intended) still works without a 400.

hf user bind-agent <username> — NEW

Backfills agents row for an existing user. PATCH /users/{username}/bind-agent. Same flags + pcexec env fallback. Errors out if pair can't be resolved (the binding is the whole point of this command).

Pairs with HF.Backend PR #20 (the bind-agent endpoint).

🤖 Generated with Claude Code

Implements NEXT_WAVE_DEV_DIRECTION.md §7.3 — never shipped before. Backend `POST /users` has accepted `agent_id`+`claw_identifier` since BE-CAL-003 but the cli never sent them, so historically every agent user (zhi/lyn/mirror/sherlock/orion/nav on prod today) ended up with only a user row — agents table empty, all downstream calendar/heartbeat/schedule-type flows that go through `_require_agent()` 404. ## `hf user create` — new flags ``` --agent-id <id> --claw-identifier <id> ``` Both required together (matches backend invariant). Either can come from pcexec env: `AGENT_ID` env for agent-id, `openclaw config get plugins.harbor-forge.identifier` for claw-identifier. Partial pair → treated as "neither" so plain user creation (no binding intended) still works without a 400. ## `hf user bind-agent <username>` — NEW Backfills agents row for an existing user. `PATCH /users/{username}/bind-agent`. Same flags + pcexec env fallback. Errors out if pair can't be resolved (the binding is the whole point of this command). Pairs with HF.Backend PR #20 (the bind-agent endpoint). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
hzhang added 1 commit 2026-05-22 19:01:59 +00:00
Implements NEXT_WAVE_DEV_DIRECTION.md §7.3 (was 4 lines of spec, never
shipped). Backend's POST /users has accepted agent_id+claw_identifier
since BE-CAL-003 but the cli never sent them, so historically every
agent user (zhi/lyn/mirror/sherlock/orion/nav on prod today) was
created with only the user row — agents table left empty, and all
downstream calendar/heartbeat/schedule-type flows that go through
_require_agent() returned 404.

## hf user create — new flags

  --agent-id <id>
  --claw-identifier <id>

Both required together (matches backend invariant). Either can come
from pcexec env: AGENT_ID env for agent-id, `openclaw config get
plugins.harbor-forge.identifier` for claw-identifier. Partial pair is
treated as "neither" so plain user creation (no binding intended) still
works without a 400.

## hf user bind-agent <username> — NEW subcommand

Backfills agents row for an existing user. PATCH
/users/{username}/bind-agent. Same accept --agent-id/--claw-identifier
flags + pcexec env fallback. requireBoth=true here — fail loudly if
the pair can't be resolved since the whole command is the binding.

## Wiring

- userCreatePayload gains AgentID + ClawIdentifier omitempty fields
- new userBindAgentPayload struct (both required)
- resolveAgentBinding helper shared by both commands
- main.go user create case parses --agent-id/--claw-identifier;
  new user bind-agent case parses positional username + the same flags
- surface.go lists bind-agent so `hf user` and `hf --help` show it

Build: clean. Smoke-tested both subcommand usage strings.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
hzhang merged commit b0f4aa286b into main 2026-05-22 19:02:03 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: zhi/HarborForge.Cli#6