Skip to content

feat(cli): user-scoped public API — checkin, form, kudos, user commands#18

Merged
xergioalex merged 14 commits into
mainfrom
feat/user-scoped-public-api
May 22, 2026
Merged

feat(cli): user-scoped public API — checkin, form, kudos, user commands#18
xergioalex merged 14 commits into
mainfrom
feat/user-scoped-public-api

Conversation

@xergioalex
Copy link
Copy Markdown
Member

Summary

  • New commands: dailybot checkin list/complete, dailybot form list/submit, dailybot kudos give, dailybot user list — all scoped to the authenticated user's Bearer session (dailybot login)
  • Interactive menu overhaul: grouped sections (Check-ins / Forms / Team / Session), stable action IDs, Esc returns to menu without exiting, kudos skips confirmation in TUI mode, check-in UX aligned with form UX
  • Dev tooling: clitest refresh for hot-reload during development, DAILYBOT_CONFIG_DIR env override for isolated sandbox configs, docker network integration for local API testing

New commands

Command Description
dailybot checkin list List today's pending check-ins
dailybot checkin complete <uuid> Complete a check-in (interactive or -a index=answer flags)
dailybot form list List forms visible to the user (shows question count)
dailybot form submit <uuid> Submit a form (guided per-question prompts or --content JSON)
dailybot kudos give --to <name> --message <msg> Give kudos; receiver resolved by name or UUID
dailybot user list List org members (Name + UUID only — no email exposed)

All new commands support --json for machine-readable output and structured exit codes (2 usage error · 3 not authenticated · 4 permission denied · 5 quota exhausted · 6 rate limited · 7 user aborted).

Auth model

New commands use the Bearer token path (dailybot logincredentials.json) rather than the existing API-key path used by dailybot agent *. Acts as the logged-in user — same visibility and permissions as the webapp.

Key implementation decisions

  • list_users() paginates with _MAX_LIST_PAGES = 50 safety cap — prevents an infinite loop against a misbehaving backend
  • dailybot user list omits email addresses (PII minimization for open-source)
  • dailybot form list uses ?include=questions to get question counts in one request (N+1 avoided); backend prompt at tmp/backend-form-list-questions-prompt.md
  • dailybot form submit uses GET /v1/forms/{uuid}/ for guided prompts; backend prompt at tmp/backend-form-detail-prompt.md
  • DAILYBOT_CONFIG_DIR env var redirects all ~/.config/dailybot/ file access for sandbox isolation
  • Interactive menu refactored to stable action IDs + _HANDLER_MAP dispatch — adding future actions requires only one entry in the map

Security audit

  • No hardcoded secrets, tokens, or API keys in any new code
  • docker/local/cli/.env (which contains real dev tokens) is gitignored and not tracked
  • Bearer token never logged or printed; all credential writes use os.chmod(path, 0o600)
  • exit_for_api_error translates raw API errors to safe user-facing messages
  • Fixed one real vulnerability: unbounded pagination loop in list_users() → added _MAX_LIST_PAGES = 50 cap

Bugs fixed

Bug Fix
TestInteractiveLogin hung forever Mock returned old "Quit" value; after menu refactor only "exit" triggers the exit path
9 ruff violations (import order, f-string docstrings, unused import) Fixed via ruff --fix + manual inline of docstring text
1 mypy no-redef error in collect_checkin_answers Renamed duplicate answers variable to collected

Test plan

  • pytest tests/api_client_test.py — new methods + pagination cap test
  • pytest tests/public_api_commands_test.py — all new commands end-to-end (auth guard, JSON mode, all error exit codes, self-kudos rejection, ambiguous receiver)
  • pytest tests/commands_test.py — full existing suite including fixed interactive login test
  • pytest tests/config_test.pyDAILYBOT_CONFIG_DIR isolation
  • ruff check dailybot_cli tests → clean
  • mypy dailybot_cli → clean
  • 170 tests total, 0 failures

Made with Cursor

xergioalex and others added 14 commits May 21, 2026 22:25
Add HTTP client methods for check-in completion, forms, users, and kudos
so logged-in users can call the public API endpoints from the CLI.

Co-authored-by: Cursor <cursoragent@cursor.com>
Introduce user-scoped subcommands with shared auth helpers, confirmation
for writes, JSON output, and display helpers wired into the CLI entry point.

Co-authored-by: Cursor <cursoragent@cursor.com>
Exercise auth resolution, JSON output, confirmations, and API error paths
with mocked HTTP so the new public API commands stay regression-safe.

Co-authored-by: Cursor <cursoragent@cursor.com>
Route credentials and config file paths through get_config_dir() so clitest
sandboxes do not read or overwrite the user's production ~/.config/dailybot/.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add clitest-local, persistent API URL selection, isolated config dir per
venv, and attach the CLI devcontainer to the Dailybot project network.

Co-authored-by: Cursor <cursoragent@cursor.com>
Pick the organization before the OTP prompt, drop misleading --org hints in
interactive mode, and fall back to a numbered list when questionary fails.

Co-authored-by: Cursor <cursoragent@cursor.com>
Surface the active API endpoint on startup, re-prompt when credentials target
a different API, and avoid crashing the menu when login exits with an error.

Co-authored-by: Cursor <cursoragent@cursor.com>
Move check-in, form, and user list logic into reusable handlers with
pick_from_list helper so headless commands and interactive mode share flows.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add user list command, kudos teammate picker, forms/members menu items,
and merge pending check-ins into a fill-in flow that prompts for answers.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add tests for dailybot user list and the interactive give-kudos flow with
mocked teammate selection and confirmation.

Co-authored-by: Cursor <cursoragent@cursor.com>
… API

## Summary
- Add _MAX_LIST_PAGES cap (50) to list_users() to prevent unbounded pagination loops
- Add pagination cap test (test_list_users_page_cap) to api_client_test.py
- Fix B021 f-string-as-docstring linter errors in checkin, form, kudos, user commands
- Fix UP032/I001 ruff import ordering issues (kudos.py, api_client.py)
- Fix no-redef mypy error in collect_checkin_answers (answers → collected)
- Fix infinite loop in TestInteractiveLogin test: mock returned old "Quit" value
  instead of the new "exit" action ID after menu refactor
- Remove unused EXIT_USER_ABORTED import from user_scoped_actions.py

## Risks
- None; all 170 tests pass, ruff clean, mypy clean

Co-authored-by: Cursor <cursoragent@cursor.com>
## Summary
Add full documentation for the new user-scoped public API commands to
README.md (the PyPI landing page for dailybot-cli).

## Change Log
- New sections: Check-ins, Forms, Kudos, Team — each with examples,
  flag reference tables, and usage notes
- Added User-scoped exit codes table (2/3/4/5/6/7)
- Updated Commands table: split into Session / Check-ins / Forms /
  Kudos / Team / Agent sections for discoverability
- Updated 'For humans' intro to mention the new capabilities
- Added guided form submit explanation (type-aware prompts table)
- Added kudos ambiguity / UUID targeting note

Co-authored-by: Cursor <cursoragent@cursor.com>
… user)

## Summary
Comprehensive update across 10 documentation files to reflect the new
user-scoped public API features added in this branch.

## Change Log
- API_REFERENCE.md: added checkin/form/kudos/user commands, flags, exit codes, and HTTP endpoints
- ARCHITECTURE.md: added user-scoped modules, updated diagrams, expanded "Where to Add Things"
- PRODUCT_SPEC.md: expanded human-facing feature table with all new commands
- CONFIGURATION.md: documented DAILYBOT_CONFIG_DIR env var, updated auth resolution scope
- ECOSYSTEM_CONTEXT.md: introduced user-scoped endpoint family alongside human and agent
- TESTING_GUIDE.md: documented public_api_commands_test.py and form_question_types_test.py
- SECURITY.md: added user-scoped privacy considerations (PII, pagination cap, self-kudos)
- CLI_COMMAND_BEST_PRACTICES.md: documented shared action module pattern and new short flags
- DISPLAY_OUTPUT_BEST_PRACTICES.md: listed new display helpers and spinner messages
- AI_AGENT_ONBOARDING.md: updated source reading order with new modules

Co-authored-by: Cursor <cursoragent@cursor.com>
Apply ruff format to 5 files that failed CI's format check, and update
the agent_init_test fixture to use DAILYBOT_CONFIG_DIR env var so
save_agent_profile writes to the isolated tmp_path via get_config_dir().

Co-authored-by: Cursor <cursoragent@cursor.com>
@xergioalex xergioalex merged commit ad57af3 into main May 22, 2026
4 checks passed
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