Generate users.yaml from config wizard instead of ALLOWED_USER_IDS#204
Generate users.yaml from config wizard instead of ALLOWED_USER_IDS#204
Conversation
…ER_IDS - Update no-config error to point at 'make config' and users.yaml - Update ALLOWED_USER_IDS parse error to suggest migrating to users.yaml - Update comment to describe users.yaml as primary, ALLOWED_USER_IDS as legacy - Add log.info nudge when ALLOWED_USER_IDS is used without users.yaml - Update test match strings for new error messages - Update test_user_config.py docstring wording
Replace the ALLOWED_USER_IDS prompt in make config with a user setup flow that generates users.yaml directly. Three paths: - Minimal: Admin Telegram ID + display name + skip advanced options - Advanced: Also prompts for os_user and home_workspace - Reconfiguration: Detects existing users.yaml and skips user setup New helpers: _validate_telegram_id(), _validate_display_name(), _generate_users_yaml(). CLAUDE_USER prompt is skipped when advanced mode already set os_user. ALLOWED_USER_IDS removed from env dict. Delete users.yaml.example (wizard generates the file directly, full schema documented in README). Update README references. Fixes #193
Review by KaiReviewWarning:
|
- Add _validate_os_user() with regex for YAML-safe OS usernames - Quote home_workspace in generated YAML to prevent silent truncation from embedded YAML comment delimiters (e.g., paths containing ' #') - Fix stale docstring claiming PyYAML is not imported - Strip whitespace in _validate_telegram_id() and at the call site - Fix /etc/kai comment about Path.exists() behavior with file permissions - Add TestValidateOsUser test class (6 tests)
Review by KaiReviewAll three Warnings from the prior review are resolved: the docstring now gives the correct rationale, Warning:
|
Review by KaiBoth warnings from the prior review are fully resolved: One new finding: Suggestion:
|
Review by KaiReviewAll three warnings and the two suggestions from prior reviews are resolved. One new finding: Warning: YAML boolean/null keywords pass
|
yaml.dump() appends document end markers that must be stripped before embedding. Added _yaml_scalar() helper inside _generate_users_yaml() to handle this consistently for name, os_user, and home_workspace. Added test_yaml_boolean_keywords_roundtrip to verify that names like 'yes' and os_users like 'no' survive the generate-then-parse cycle as strings, not booleans.
Review by KaiReviewAll warnings from prior reviews are resolved. One new finding. Warning:
|
The comment incorrectly described when yaml.dump appends document end markers. Plain string scalars DO get the marker; quoted ones do not. Updated the comment and added a test proving os_user values ending in '...' are not corrupted by the removesuffix stripping.
Review by KaiReviewAll warnings from the prior review thread are resolved. The code is in good shape. One new finding: Suggestion: PR description test count is staleThe description says "18 new tests:
Total: ~26 new tests. Not a code issue, but the description should be updated before merge to avoid confusing Clean
|
… test - Update _DISPLAY_NAME_RE comment to acknowledge _yaml_scalar() handles boolean keyword quoting separately - Fix _validate_os_user docstring to describe OS-safety not YAML-safety - Add test_advanced_user_options integration test covering os_user, home_workspace, and CLAUDE_USER prompt skip wiring
Review by KaiReviewOne warning on the Warning:
|
Summary
make configwith a user setup flow that generatesusers.yamldirectlyusers.yaml.example(wizard generates the file, schema in README)_yaml_scalar()to handle YAML 1.1 boolean keywords and special charactersTest plan
TestValidateTelegramId(6),TestValidateDisplayName(7),TestValidateOsUser(6),TestGenerateUsersYaml(7 including roundtrip through_load_user_configs, YAML boolean keywords, and trailing-dots edge case)make configon a fresh tmp dir and verify users.yaml is generatedmake configwith existing users.yaml and verify it skips user setupFixes #193