31 Commits

Author SHA1 Message Date
729365ca46 Merge fix/security-audit: CLI credential hardening 2026-06-01 09:23:52 +01:00
4125a4c102 fix(security): keep credentials off argv and plaintext transports
- M7: ResolveToken accepts the token via the HF_TOKEN env var (so it need
  not appear in argv, where it's visible in ps/shell history); the HTTP
  client refuses to send a token / API key over plaintext http:// to a
  non-loopback host (use https://). Loopback http is still allowed for
  local dev.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-31 20:16:36 +01:00
4df6e1bd5f feat(knowledge-base): wrap KnowledgeBase API in the CLI
Add `hf knowledge-base` group: list/get/tree/topics, create/update/delete,
link/unlink to projects, and add/update/delete for topics, categories and
facts. Mirrors the project command style (flag parsing, JSON/table output,
token resolution). Registered in the dispatcher and the help surface, gated
on the knowledge-base.* permissions.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-31 15:03:22 +01:00
2176383729 fix(cli): send api-keys via X-API-Key in client.New + help surface
passmgr.GetToken returns an api-key in padded-cell mode (provisioned by
scripts/provision-hf-accounts.sh via 'hf user reset-apikey'), but every
call site funneled that through client.New which sent it as a
'Authorization: Bearer <hex>'. The HF backend's HTTPBearer middleware
expects JWT shape there and rejects hex strings as 'Could not validate
credentials'. The d2b83ad backend fix added a Bearer-fallback that tries
the value as an api-key, which masked the issue against current prod;
older backends or any future change in that fallback still 401.

Two changes:
- client.New auto-detects shape: 'eyJ'-prefix + two dots == JWT (Bearer),
  anything else == api-key (X-API-Key). Empty token sets neither header.
- internal/help/surface.go's loadPermissionState (called by hf --help
  introspection) switches to client.NewWithAPIKey explicitly so the
  command-discovery path doesn't depend on the heuristic at all. When
  that path failed silently (Known:false), agents would see only the
  always-permitted commands ('user.*', 'agent.status', 'config',
  'health', 'version') and conclude they had no project permission.

Adds internal/client/client_test.go covering both header paths plus
empty-token, isLikelyJWT cases, and NewWithAPIKey precedence.

Verified end-to-end in sim against a rebuilt hf-backend matching prod
(commit d2b83ad): cli with --token <api-key> sends X-Api-Key header,
backend returns 200 on /projects + /auth/me/permissions.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 12:43:04 +01:00
a42ba6f880 fix(cli): gate hf project create on project.create (was project.write)
surface.go declared project/create as Permitted: has(perms, "project.write"),
but the backend now (and the user-facing role editor's intent) uses
`project.create` as the dedicated create gate. Switching CLI and backend
to agree on the same perm so a role granted just `project.create` (e.g.
mgr in the new seed) can run `hf project create` without needing the
broader project.write.

Companion change to HarborForge.Backend@HEAD which adds project.create to
DEFAULT_PERMISSIONS, gives it to mgr by default, and rewrites the
POST /projects gate to consult it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-24 22:09:41 +01:00
hanghang zhang
46d928782b feat(cli): hf user create --agent-id/--claw-identifier + hf user bind-agent
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>
2026-05-22 20:01:37 +01:00
hanghang zhang
6ace6f2594 feat(cli): add 'hf agent status' wrapper for POST /calendar/agent/status
The plan-schedule workflow needs to report agent runtime status
(idle/busy/on_call/exhausted/offline) at the end of planning, but the
cli had no wrapper for this — workflows were dropping inline curl in
the middle of their procedure to hit the backend.

This adds 'hf agent status --set <status> [--reason ...] [--recovery-at ...]'.
The endpoint identifies the agent purely from X-Agent-ID + X-Claw-Identifier
headers (no token), so the cli reads AGENT_ID from env and falls back
to hostname() for CLAW_IDENTIFIER if it isn't set — same convention
the openclaw plugin uses. Refuses to send if AGENT_ID env is missing,
since this only makes sense from a pcexec/agent runtime context.

Surface entry added so 'hf --help' lists it.

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

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 19:08:27 +01:00
h z
ce532bdf15 Merge branch 'main' into zhi-2026-04-18 2026-05-01 07:25:35 +00:00
zhi
dbc599171f feat: schedule-type CLI commands
- hf schedule-type list
- hf schedule-type create <name> --work <from>-<to> --entertainment <from>-<to>
- hf schedule-type delete <id>
- hf assign-schedule-type <agent-id> <schedule-type-name>

Requires schedule_type.read / schedule_type.manage permissions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-21 09:25:39 +00:00
f1ebc52cca fix: allow reset-apikey command without user.manage permission
The reset-apikey command has its own auth mechanism via --acc-mgr-token,
so it should not be gated by permission introspection. This matches the
behavior of "user create" which is also Permitted: true.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-16 22:32:30 +01:00
6dae490257 refactor: rename pass_mgr to secret-mgr
The secret manager binary was renamed from pass_mgr to secret-mgr.
Update all references in CLI code, mode detection, and help text.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-16 21:15:58 +00:00
53b5b88fc2 feat: user reset-apikey supports acc-mgr-token auth
Allows reset-apikey to use --acc-mgr-token or auto-resolve from
secret-mgr in padded-cell mode, enabling API key provisioning
without an existing user Bearer token.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-16 21:15:58 +00:00
6252039fc5 feat: add user reset-apikey command
Adds `hf user reset-apikey <username>` to regenerate a user API key.
Requires user.manage permission. Returns the new key (shown once only).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-16 21:15:58 +00:00
5ac90408f3 feat: support discord id account updates 2026-04-04 20:16:59 +00:00
ad0e123666 fix: send account-manager token as x-api-key 2026-04-03 19:12:34 +00:00
e2177521e0 feat: switch cli indexing to code-first identifiers 2026-04-03 16:25:11 +00:00
84150df4d5 fix: align cli routes with backend routers 2026-04-03 13:58:15 +00:00
b287b1ff17 fix: align health endpoint with backend 2026-04-03 13:45:36 +00:00
zhi
0280f2c327 TEST-CLI-CAL-001 TEST-CLI-PR-001 add CLI integration tests 2026-04-01 12:03:24 +00:00
zhi
0fe62ed430 CLI-CAL-001/002/003/004/005/006/007/008/009/010: Add calendar command group and CRUD plan commands
- Add hf calendar command group to command surface and router
- Implement schedule/show/edit/cancel/date-list commands
- Implement plan-schedule/plan-list/plan-edit/plan-cancel commands
- Add leaf help for all calendar commands
- Align CLI with backend calendar routes and response envelopes
- Support virtual slot ids for edit/cancel
- Validate with go build and go test ./...
2026-04-01 07:02:36 +00:00
zhi
97af3d3177 CLI-PR-001/002/003/004: Rename propose->proposal, add essential commands, improve accept, restrict story
- Rename 'propose' group to 'proposal' in surface, leaf help, and routing
- Keep 'hf propose' as backward-compatible alias via groupAliases
- Add essential subcommand group: list, create, update, delete
- Accept command now shows generated story tasks in output
- Accept command supports --json output
- Task create blocks story/* types with helpful error message
- All help text updated to use 'proposal' terminology
2026-04-01 06:56:10 +00:00
zhi
9b3edc0ede Add comment and worklog CLI commands 2026-03-21 17:11:20 +00:00
zhi
1e8437d0b1 Improve nested CLI help coverage 2026-03-21 16:37:47 +00:00
zhi
eaf4f215b5 Add detailed leaf help output 2026-03-21 15:37:13 +00:00
zhi
34f52cb9e3 feat: implement meeting, support, propose, and monitor command groups
- Added meeting.go: list, get, create, update, attend, delete
- Added support.go: list, get, create, update, take, transition, delete
- Added propose.go: list, get, create, update, accept, reject, reopen
- Added monitor.go: overview, server list/get/create/delete, api-key generate/revoke
- Updated main.go with dispatch handlers for all four new groups
- All commands follow existing patterns (token resolution, --json, table output)

Covers TODO items 1.12, 1.13, 1.14, 1.15 from hf-cross-project-todo.md
2026-03-21 15:24:43 +00:00
zhi
a01e602118 Align role commands with current backend API 2026-03-21 15:06:57 +00:00
zhi
57af1512d1 feat: implement role, permission, project, milestone, and task command groups
- Add role commands: list, get, create, update, delete, set/add/remove-permissions
- Add permission list command
- Add project commands: list, get, create, update, delete, members, add/remove-member
- Add milestone commands: list, get, create, update, delete, progress
- Add task commands: list, get, create, update, transition, take, delete, search
- Wire all new command groups into main.go dispatcher
- All commands support --json output mode and --token manual auth
- Passes go build and go vet cleanly
2026-03-21 14:50:43 +00:00
zhi
69287d5a49 Add permission-aware help surface 2026-03-21 14:37:42 +00:00
zhi
25114aa17c feat: implement user commands (list, get, create, update, activate, deactivate, delete)
- Add internal/commands/user.go with full user CRUD implementation
- Wire user subcommands in main.go dispatch
- Mark user subcommands as Permitted: true
- Support both padded-cell and manual mode for all user commands
- user create uses account-manager token flow per plan
2026-03-21 14:22:19 +00:00
zhi
7d3cff7d95 feat: implement core CLI packages and Phase 3 commands
- config: resolve binary dir, load/save .hf-config.json
- mode: detect padded-cell vs manual mode via pass_mgr
- client: HTTP client wrapper with auth header support
- passmgr: pass_mgr integration (get-secret, set, generate)
- output: human-readable + JSON output formatting with tables
- help: help and help-brief renderer for groups/commands
- commands: version, health, config (--url, --acc-mgr-token, show)
- auth: token resolution helper (padded-cell auto / manual explicit)
- main: command dispatcher with --json global flag support
- README: updated with current package layout and status
2026-03-21 13:50:29 +00:00
zhi
cb0b7669b3 feat: scaffold Go-based hf CLI 2026-03-21 13:34:41 +00:00