recala-cli 0.6.7__tar.gz → 0.6.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {recala_cli-0.6.7 → recala_cli-0.6.9}/CHANGELOG.md +8 -1
- {recala_cli-0.6.7 → recala_cli-0.6.9}/PKG-INFO +1 -1
- {recala_cli-0.6.7 → recala_cli-0.6.9}/pyproject.toml +1 -1
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/__init__.py +1 -1
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/article_runs.py +36 -9
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/auth.py +6 -6
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/onboard.py +2 -1
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/shell.py +7 -8
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/status.py +9 -3
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/topics.py +22 -8
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/display.py +7 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/polling.py +8 -6
- recala_cli-0.6.9/src/recala_cli/stages.py +53 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/ui.py +28 -12
- recala_cli-0.6.9/tests/fixtures/run_states_from_the_api.json +228 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_connect_and_status.py +1 -1
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_core_release.py +1 -1
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_core_root.py +0 -7
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_dogfood_fixes.py +6 -14
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_empty_scan_next.py +3 -3
- recala_cli-0.6.9/tests/test_first_run_findings.py +123 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_onboard_free_plan.py +3 -3
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_org_readable.py +1 -1
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_review_round3.py +1 -1
- recala_cli-0.6.9/tests/test_stages.py +207 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_topics_one_call.py +1 -1
- recala_cli-0.6.9/uv.lock +172 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/.gitignore +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/README.md +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/scripts/check-dogfood.sh +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/scripts/publish_pypi.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/scripts/release.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/__main__.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/analytics.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/auth.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/client.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/__init__.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/article.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/billing.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/bing.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/cadence.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/connect.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/credits.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/export.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/faithful_translations.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/gsc.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/index.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/keys.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/knowledge.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/languages.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/monthly_report.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/notifications.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/org.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/profile.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/questions.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/reads.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/refresh.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/refusals.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/schema.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/skills.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/commands/slot_topic.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/config.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/confirm.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/endpoints.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/errors.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/human.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/ids.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/labels.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/main.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/onboarding.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/organizations.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/output.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/parallel.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/prompts.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/runtime.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/search_numbers.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/skills/recala/SKILL.md +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/skills/recala/references/apply-revision-notes.md +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/skills/recala/references/article-signoff.md +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/skills/recala/references/connect-search-console.md +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/skills/recala/references/first-hand-evidence.md +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/skills/recala/references/onboard.md +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/skills/recala/references/plan-month.md +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/skills/recala/references/recala-cli-contract.md +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/skills/recala/references/schedule-approved.md +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/skills/recala/references/weekly-authority-report.md +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/stop_next_steps.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/updates.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/src/recala_cli/views.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/conftest.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/distribution/test_public_install.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/fixtures/hold_text_json.json +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/fixtures/human_output_pass1_json.json +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/fixtures/machine_contract_main.json +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_agent_error_next_steps.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_agent_onboarding.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_analytics.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_analytics_security.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_approve_read_receipt.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_approve_reconfirm.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_article_cover.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_article_export.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_article_id_output.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_article_portal_link.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_billing_invoices.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_billing_link.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_billing_top_up.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_bing.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_blank_author.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_c2_onboarding.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_cadence.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_calendar_matches_plan.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_calendar_slots.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_cms_skip.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_company_name_in_prompts.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_confirm.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_content_commands.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_core_errors.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_core_short_ids.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_core_speed.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_core_status_speed.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_credits.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_declined_setup_is_not_an_error.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_dogfood_status.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_edit_link_warnings.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_empty_scan_replay.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_errors.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_failed_scan_ends_softly.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_faithful_translation_settings.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_free_article_tries.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_free_company_topics_step.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_free_plan_wording.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_free_scout_refusal.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_free_topics.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_gsc.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_help_listing.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_hold_finding_sentences.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_hold_text.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_human_output_pass1.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_human_readable.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_index.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_keys.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_knowledge_admit.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_knowledge_show_ideas.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_languages.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_login.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_login_json_org.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_machine_contract.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_monthly_report.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_no_endings_say_what_is_true.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_notifications.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_onboard_defaults.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_onboarding_channel.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_onboarding_commands.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_org.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_org_describe.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_poll_pacing.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_profile.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_publish_commands.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_publish_pypi.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_questions.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_questions_in_words.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_recheck_findings.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_refresh.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_rerun_refusal.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_review_hardening.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_run_progress.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_scan_reports_what_was_found.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_scene.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_scout_count.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_search_numbers.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_second_company_and_refused_details.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_short_id_selectors.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_signed_in_writes.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_skills.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_slot_topic.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_stop_next_steps.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_submit_review_state.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_times_in_company_zone.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_topics.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_topics_add.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_ui.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_view_surface.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_whoami.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_will_retry.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.9}/tests/test_write_flags.py +0 -0
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# CLI changes
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 0.6.9
|
|
4
|
+
|
|
5
|
+
- `recala update` now upgrades a plain pip install with the same Python. Topics are listed once while an article is written, and `status` says which. The signed-in address is masked or left out of plain output. An empty topic list points to `recala topics scout`.
|
|
6
|
+
- The writing stages now come from the server's `stage` field, so a run started from the terminal moves from Researching to Drafting, Checking and Saving as it really does. An older server that sends no stage keeps the stage already shown.
|
|
7
|
+
|
|
8
|
+
## 0.6.8
|
|
9
|
+
|
|
10
|
+
- `recala article create` names four stages while it writes (Researching, Drafting, Checking, Saving), says once that a good article takes about 10 minutes, and ends with "The light found you." A raw server step name is no longer shown. `--json` output and exit codes are unchanged.
|
|
4
11
|
|
|
5
12
|
## 0.6.7
|
|
6
13
|
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
"""Short status reads and actionable outcomes for article work that outlives a request."""
|
|
2
2
|
|
|
3
3
|
import re
|
|
4
|
+
import sys
|
|
4
5
|
from datetime import UTC, datetime, timedelta
|
|
5
6
|
from shlex import quote
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
import click
|
|
9
|
+
|
|
10
|
+
from recala_cli import config, ui
|
|
8
11
|
from recala_cli.display import display_name
|
|
9
12
|
from recala_cli.endpoints import ARTICLE_SHOW, GENERATION_STATUS, CADENCE_SHOW
|
|
10
13
|
from recala_cli.errors import CliError, ExitCode
|
|
11
14
|
from recala_cli.human import describe_fields, finding_sentences, recheck_findings
|
|
12
15
|
from recala_cli.polling import poll_until
|
|
16
|
+
from recala_cli.stages import WAITING_LINE, StageTracker, finish_headline, stage_line
|
|
13
17
|
from recala_cli.stop_next_steps import needs_input_message
|
|
14
18
|
from recala_cli.views import company_timezone, moment_in
|
|
15
19
|
|
|
@@ -229,6 +233,15 @@ def wait_for_article(ctx, client, identifier, *, regeneration=False, regenerate_
|
|
|
229
233
|
return result
|
|
230
234
|
|
|
231
235
|
retry_reads: list[bool] = []
|
|
236
|
+
stages = StageTracker()
|
|
237
|
+
|
|
238
|
+
def describe(run):
|
|
239
|
+
title = run.get("title") or run.get("topic") or "Article"
|
|
240
|
+
if run.get("state") == "failed" and run.get("will_retry"):
|
|
241
|
+
return f"{title}: taking another careful pass"
|
|
242
|
+
if regeneration: # read from the article row: it has a state and no node
|
|
243
|
+
return f"{title}: {run.get('state')}"
|
|
244
|
+
return stages.observe(run)
|
|
232
245
|
|
|
233
246
|
def finished(result):
|
|
234
247
|
state = result.get("state")
|
|
@@ -250,6 +263,9 @@ def wait_for_article(ctx, client, identifier, *, regeneration=False, regenerate_
|
|
|
250
263
|
"running",
|
|
251
264
|
}
|
|
252
265
|
|
|
266
|
+
watched_by_a_person = not regeneration and not ctx.find_root().obj.get("as_json")
|
|
267
|
+
if watched_by_a_person:
|
|
268
|
+
click.echo(WAITING_LINE, err=True)
|
|
253
269
|
try:
|
|
254
270
|
result = poll_until(
|
|
255
271
|
ctx,
|
|
@@ -257,11 +273,8 @@ def wait_for_article(ctx, client, identifier, *, regeneration=False, regenerate_
|
|
|
257
273
|
finished,
|
|
258
274
|
label="Waiting for article",
|
|
259
275
|
timeout_seconds=7200,
|
|
260
|
-
describe=
|
|
261
|
-
|
|
262
|
-
+ ("taking another careful pass" if r.get("state") == "failed" and r.get("will_retry")
|
|
263
|
-
else r.get("current_node") or r.get("state"))
|
|
264
|
-
),
|
|
276
|
+
describe=describe,
|
|
277
|
+
announce=None if regeneration else stage_line,
|
|
265
278
|
heartbeat=None if regeneration else _still_writing,
|
|
266
279
|
scene=True,
|
|
267
280
|
)
|
|
@@ -291,7 +304,15 @@ def wait_for_article(ctx, client, identifier, *, regeneration=False, regenerate_
|
|
|
291
304
|
)
|
|
292
305
|
if regeneration:
|
|
293
306
|
ensure_rerun_ran(result, regenerate_id, ctx=ctx)
|
|
294
|
-
|
|
307
|
+
outcome = ensure_outcome(result, client, ctx=ctx)
|
|
308
|
+
if watched_by_a_person:
|
|
309
|
+
say_finish()
|
|
310
|
+
return outcome
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
def say_finish():
|
|
314
|
+
"""On stderr, where the wait was shown, before stdout names the article."""
|
|
315
|
+
click.echo(finish_headline(ui.Style.for_stream(sys.stderr)), err=True)
|
|
295
316
|
|
|
296
317
|
|
|
297
318
|
def failed_rerun(recovery):
|
|
@@ -390,11 +411,17 @@ def portal_link(result, ctx=None):
|
|
|
390
411
|
"""The article's page in the portal, where its cover and signer are checked; nothing for a run with no article.
|
|
391
412
|
|
|
392
413
|
The portal opens the person's oldest company unless the link names one, so the link carries the run's company."""
|
|
414
|
+
url = portal_url(result, ctx)
|
|
415
|
+
return f"\nOpen it in the portal: {url}" if url else ""
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
def portal_url(result, ctx=None):
|
|
419
|
+
"""The address of the article's portal page, or None for a run with no article."""
|
|
393
420
|
if not result.get("article_id"):
|
|
394
|
-
return
|
|
421
|
+
return None
|
|
395
422
|
org_id = getattr((ctx.meta.get("org_client") if ctx else None), "org_id", None)
|
|
396
423
|
scope = f"?org={org_id}" if org_id else ""
|
|
397
|
-
return f"
|
|
424
|
+
return f"{config.web_url()}/portal/article/{result['article_id']}{scope}"
|
|
398
425
|
|
|
399
426
|
|
|
400
427
|
def review_next_step(result):
|
|
@@ -13,7 +13,7 @@ from recala_cli.auth import credential_kind
|
|
|
13
13
|
from recala_cli.client import RecalaClient
|
|
14
14
|
from recala_cli.confirm import signin_status
|
|
15
15
|
from recala_cli.endpoints import ME, SIGN_OUT
|
|
16
|
-
from recala_cli.display import display_name
|
|
16
|
+
from recala_cli.display import display_name, masked_email
|
|
17
17
|
from recala_cli.errors import CliError
|
|
18
18
|
from recala_cli.output import notify
|
|
19
19
|
from recala_cli.organizations import (
|
|
@@ -29,7 +29,7 @@ from recala_cli.runtime import command_runner, common_options, interactive_human
|
|
|
29
29
|
def _describe_sign_in(result: dict[str, Any]) -> str:
|
|
30
30
|
if not result.get("signed_in"):
|
|
31
31
|
return "Signed out."
|
|
32
|
-
who = result.get("email") or result.get("kind", "token")
|
|
32
|
+
who = masked_email(result.get("email")) or result.get("kind", "token")
|
|
33
33
|
return f"Signed in ({who})."
|
|
34
34
|
|
|
35
35
|
|
|
@@ -58,11 +58,11 @@ class SignInScreen:
|
|
|
58
58
|
return nullcontext()
|
|
59
59
|
return ui.Spinner("Waiting for you to approve the code in your browser", style=self.style)
|
|
60
60
|
|
|
61
|
-
def signed_in(self
|
|
61
|
+
def signed_in(self) -> None:
|
|
62
62
|
if self.as_json:
|
|
63
63
|
return
|
|
64
64
|
if self.within_onboarding:
|
|
65
|
-
notify(f"\n {self.style.accent('*')} {self.style.bold('Signed in')}
|
|
65
|
+
notify(f"\n {self.style.accent('*')} {self.style.bold('Signed in')}\n") # the address stays out of onboarding transcripts
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
def _describe_login(ctx: click.Context, result: dict[str, Any]) -> str:
|
|
@@ -70,7 +70,7 @@ def _describe_login(ctx: click.Context, result: dict[str, Any]) -> str:
|
|
|
70
70
|
return _describe_sign_in(result)
|
|
71
71
|
me = ctx.meta.get("login_identity") or {}
|
|
72
72
|
user = me.get("user") if isinstance(me.get("user"), dict) else {}
|
|
73
|
-
name = display_name(user.get("name") or user.get("display_name") or user.get("email") or result.get("email"))
|
|
73
|
+
name = display_name(user.get("name") or user.get("display_name")) or masked_email(user.get("email") or result.get("email"))
|
|
74
74
|
lines = [f"Signed in as {name or result.get('kind') or 'you'}."]
|
|
75
75
|
if "login_identity" not in ctx.meta:
|
|
76
76
|
return "\n".join([*lines, ORGANIZATION_LOOKUP_FAILED])
|
|
@@ -135,7 +135,7 @@ def sign_in(ctx: click.Context, *, no_browser: bool = False, within_onboarding:
|
|
|
135
135
|
present_code=screen.present_code,
|
|
136
136
|
waiting=screen.waiting,
|
|
137
137
|
)
|
|
138
|
-
screen.signed_in(
|
|
138
|
+
screen.signed_in()
|
|
139
139
|
return result
|
|
140
140
|
|
|
141
141
|
|
|
@@ -278,8 +278,9 @@ def _complete_setup(ctx: click.Context, client: RecalaClient, facts: Facts, *, r
|
|
|
278
278
|
|
|
279
279
|
def describe_onboarding(report: dict[str, Any]) -> str:
|
|
280
280
|
report = human_data(report)
|
|
281
|
+
steps = [{**row, "detail": ""} if row["key"] == "login" else row for row in report["steps"]] # no address in transcripts
|
|
281
282
|
lines = ["", *credit_lines(report.get("plan") or {}, None, None), "",
|
|
282
|
-
ui.checklist(checklist_rows(
|
|
283
|
+
ui.checklist(checklist_rows(steps), style=ui.Style.for_stream(sys.stdout)), ""]
|
|
283
284
|
upcoming = report.get("next")
|
|
284
285
|
if upcoming:
|
|
285
286
|
lines.append(f" Next: {upcoming['title']} -> {upcoming['command']}")
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import shlex
|
|
5
6
|
import subprocess
|
|
6
7
|
import sys
|
|
7
8
|
from collections.abc import Callable
|
|
@@ -15,6 +16,7 @@ from recala_cli.runtime import command_runner, json_option
|
|
|
15
16
|
SHELLS = ("bash", "zsh", "fish")
|
|
16
17
|
UV_UPGRADE = ["uv", "tool", "install", "--force", "recala-cli"]
|
|
17
18
|
PIPX_UPGRADE = ["pipx", "install", "--force", "recala-cli"]
|
|
19
|
+
PIP_UPGRADE_ARGS = ["-m", "pip", "install", "--upgrade", "recala-cli"]
|
|
18
20
|
|
|
19
21
|
|
|
20
22
|
@click.command()
|
|
@@ -61,17 +63,14 @@ def _run_command(command: list[str]) -> int:
|
|
|
61
63
|
@click.option("--dry-run", is_flag=True, help="Only print the command that would run.")
|
|
62
64
|
@command_runner(human=lambda result: result["message"])
|
|
63
65
|
def update(ctx: click.Context, dry_run: bool) -> dict[str, object]:
|
|
64
|
-
"""Install the newest CLI with uv or
|
|
66
|
+
"""Install the newest CLI with uv, pipx or pip.
|
|
65
67
|
|
|
66
|
-
Uses the tool that installed Recala
|
|
68
|
+
Uses the tool that installed Recala; any other install (plain pip) is upgraded with pip, using the Python that runs this program.
|
|
69
|
+
A failed upgrade exits with an error and prints the exact command to run yourself."""
|
|
67
70
|
seams = ctx.find_root().obj
|
|
68
71
|
manager = installed_by(seams.get("install_prefix") or sys.prefix)
|
|
69
|
-
command = {"uv": UV_UPGRADE, "pipx": PIPX_UPGRADE}.get(manager or "")
|
|
70
|
-
|
|
71
|
-
return {"updated": False, "command": None, "message":
|
|
72
|
-
f"Recala was not installed with uv or pipx, so it will not guess. Run one of:\n"
|
|
73
|
-
f" {' '.join(UV_UPGRADE)}\n {' '.join(PIPX_UPGRADE)}"}
|
|
74
|
-
text = " ".join(command)
|
|
72
|
+
command = {"uv": UV_UPGRADE, "pipx": PIPX_UPGRADE}.get(manager or "") or [sys.executable, *PIP_UPGRADE_ARGS]
|
|
73
|
+
text = shlex.join(command)
|
|
75
74
|
if dry_run:
|
|
76
75
|
return {"updated": False, "command": text, "message": f"Would run: {text}"}
|
|
77
76
|
run: Callable[[list[str]], int] = seams.get("run_command") or _run_command
|
|
@@ -17,6 +17,7 @@ from recala_cli import ui
|
|
|
17
17
|
from recala_cli.endpoints import BILLING_MANAGED_USAGE, ENTITLEMENTS, CADENCE_SHOW, PUBLICATION_PLAN, AUTOAPPROVE_SHOW
|
|
18
18
|
from recala_cli.onboarding import Facts, evaluate, free_articles_left, gather, next_step, with_plan_optional
|
|
19
19
|
from recala_cli.commands.index import is_indexed, read_indexing
|
|
20
|
+
from recala_cli.display import display_name
|
|
20
21
|
from recala_cli.errors import CliError
|
|
21
22
|
from recala_cli.parallel import run_parallel
|
|
22
23
|
from recala_cli.human import publish_state_words
|
|
@@ -49,7 +50,8 @@ def dashboard(facts: Facts, *, entitlements: dict[str, Any] | None, managed: dic
|
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
|
|
52
|
-
def describe_dashboard(board: dict[str, Any], *, cadence: dict[str, Any] | None = None
|
|
53
|
+
def describe_dashboard(board: dict[str, Any], *, cadence: dict[str, Any] | None = None,
|
|
54
|
+
being_written: tuple[str, ...] = ()) -> str:
|
|
53
55
|
style = ui.Style.for_stream(sys.stdout) # the dashboard is printed on stdout
|
|
54
56
|
org = board.get("org") or {}
|
|
55
57
|
calendar = board.get("calendar") or {}
|
|
@@ -73,8 +75,10 @@ def describe_dashboard(board: dict[str, Any], *, cadence: dict[str, Any] | None
|
|
|
73
75
|
in_words[publish_state_words(state)] += count
|
|
74
76
|
counts = ", ".join(f"{n} {state}" for state, n in sorted(in_words.items()))
|
|
75
77
|
total = articles.get("total", 0)
|
|
78
|
+
waiting = max(0, articles.get("topics_waiting", 0) - len(being_written)) # a topic being written is not waiting
|
|
76
79
|
lines.append(f" {total} article{'' if total == 1 else 's'}" + (f" ({counts})" if counts else "")
|
|
77
|
-
+ f"; {
|
|
80
|
+
+ f"; {waiting} topics waiting -> recala topics list")
|
|
81
|
+
lines.extend(f' Being written now: "{display_name(topic)}"' for topic in being_written)
|
|
78
82
|
lines.append(" " + indexing_line(board.get("indexing")))
|
|
79
83
|
if calendar:
|
|
80
84
|
calendar = {**calendar, "timezone": zone}
|
|
@@ -114,7 +118,8 @@ def autopilot_blockers(facts):
|
|
|
114
118
|
|
|
115
119
|
@click.command()
|
|
116
120
|
@common_options
|
|
117
|
-
@command_runner(contextual_human=lambda ctx, board: describe_dashboard(
|
|
121
|
+
@command_runner(contextual_human=lambda ctx, board: describe_dashboard(
|
|
122
|
+
board, cadence=ctx.meta.get("status_cadence"), being_written=ctx.meta.get("status_being_written", ())))
|
|
118
123
|
def status(ctx: click.Context, org_flag: str | None) -> dict[str, Any]:
|
|
119
124
|
"""The active company at a glance.
|
|
120
125
|
|
|
@@ -132,6 +137,7 @@ def status(ctx: click.Context, org_flag: str | None) -> dict[str, Any]:
|
|
|
132
137
|
facts = answers["facts"]
|
|
133
138
|
facts.cadence, facts.approval, facts.publication_plan = answers["cadence"], answers["approval"], answers["plan"]
|
|
134
139
|
ctx.meta["status_cadence"] = (facts.publication_plan.get("cadence") or facts.cadence.get("cadence") or {})
|
|
140
|
+
ctx.meta["status_being_written"] = tuple(str(row.get("topic")) for row in facts.topics.get("processing") or [])
|
|
135
141
|
entitlements = answers["entitlements"]
|
|
136
142
|
return dashboard(facts, entitlements=entitlements if (entitlements or {}).get("enabled") else None,
|
|
137
143
|
managed=answers["managed"], indexing=indexing_of_listed(client, facts.articles))
|
|
@@ -54,10 +54,22 @@ def read_queue(client, *, limit: int | None = None, offset: int = 0) -> dict[str
|
|
|
54
54
|
return queue
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
#:
|
|
58
|
-
#:
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
#: Live check 24 Nov 2026: no topic arrived 5.5 minutes after a scan, and `recala topics scout` found one in 22 seconds.
|
|
58
|
+
#: The scan route starts no topic search (apps/api/src/routers/onboarding.py: its only background task is competitor intel).
|
|
59
|
+
NO_TOPICS_YET = ("No topics yet. Ask Recala to look for some now: recala topics scout. "
|
|
60
|
+
"Or write your own: recala topics add \"<a question your buyers ask>\"")
|
|
61
|
+
|
|
62
|
+
#: A topic that is being written is also in Up next and Other in the API's answer; it is shown where it is true for it.
|
|
63
|
+
_MOST_TRUE_FIRST = ("processing", "queued", "up_next", "backlog", "other")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _each_topic_once(result: dict[str, Any]) -> dict[str, list[dict[str, Any]]]:
|
|
67
|
+
shown: set[Any] = set()
|
|
68
|
+
sections: dict[str, list[dict[str, Any]]] = {}
|
|
69
|
+
for section in _MOST_TRUE_FIRST:
|
|
70
|
+
sections[section] = [row for row in result.get(section) or [] if row.get("id") not in shown]
|
|
71
|
+
shown.update(row.get("id") for row in sections[section])
|
|
72
|
+
return sections
|
|
61
73
|
|
|
62
74
|
|
|
63
75
|
def _no_topic_can_come(client: RecalaClient) -> bool:
|
|
@@ -75,20 +87,22 @@ def _no_topic_can_come(client: RecalaClient) -> bool:
|
|
|
75
87
|
def _describe_topics(ctx: click.Context, result: dict[str, Any]) -> str:
|
|
76
88
|
show_all = ctx.meta.get("topics_show_all", False)
|
|
77
89
|
lines = []
|
|
90
|
+
sections = _each_topic_once(result)
|
|
78
91
|
for section in SECTIONS:
|
|
79
|
-
rows =
|
|
92
|
+
rows = sections[section]
|
|
80
93
|
if rows:
|
|
81
94
|
shown = rows if show_all else rows[:PEOPLE_SECTION_ROWS]
|
|
82
95
|
lines.append(f"{section.replace('_', ' ').capitalize()} ({len(rows)})")
|
|
83
96
|
lines.extend(f" {row['topic']} [{str(row['id'])[:8]}]" for row in shown)
|
|
84
97
|
if len(shown) < len(rows):
|
|
85
98
|
lines.append(f" {len(rows) - len(shown)} more: recala topics list --limit 0")
|
|
86
|
-
|
|
87
|
-
if
|
|
99
|
+
total = result.get("total", 0)
|
|
100
|
+
lines.append(f"{total} topic{'' if total == 1 else 's'} in total")
|
|
101
|
+
if not any(sections.values()):
|
|
88
102
|
client = ctx.meta.get("org_client")
|
|
89
103
|
none_are_coming = client is not None and _no_topic_can_come(client)
|
|
90
104
|
lines.append(f"Your site's scan gave nothing to prepare topics from, so none are coming. "
|
|
91
|
-
f"Add the first one yourself: {ADD_FIRST_TOPIC_COMMAND}" if none_are_coming else
|
|
105
|
+
f"Add the first one yourself: {ADD_FIRST_TOPIC_COMMAND}" if none_are_coming else NO_TOPICS_YET)
|
|
92
106
|
return "\n".join(lines)
|
|
93
107
|
|
|
94
108
|
|
|
@@ -27,6 +27,13 @@ def display_name(value: Any) -> str:
|
|
|
27
27
|
return " ".join(terminal_text(value).split()) if isinstance(value, str) else ""
|
|
28
28
|
|
|
29
29
|
|
|
30
|
+
def masked_email(value: Any) -> str:
|
|
31
|
+
""""you@company.example" as "y…@company.example": enough to recognise the account, not to copy it into a log."""
|
|
32
|
+
text = display_name(value)
|
|
33
|
+
local, at, domain = text.partition("@")
|
|
34
|
+
return f"{local[:1]}…@{domain}" if at and local else text
|
|
35
|
+
|
|
36
|
+
|
|
30
37
|
def human_data(value: Any, *, field: str = "") -> Any:
|
|
31
38
|
"""A sanitized presentation copy; the API data still goes unchanged to JSON."""
|
|
32
39
|
if isinstance(value, str):
|
|
@@ -40,12 +40,13 @@ def next_wait(interval_seconds: int, read_seconds: float, now: float, *, outside
|
|
|
40
40
|
return wait
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
def indicator(ctx: click.Context, label: str, *, tty_only: bool = False, scene: bool = False
|
|
43
|
+
def indicator(ctx: click.Context, label: str, *, tty_only: bool = False, scene: bool = False,
|
|
44
|
+
bookends: bool = True) -> Any:
|
|
44
45
|
"""A Spinner for people, nothing for --json. ``tty_only`` also draws nothing on a pipe or in a log;
|
|
45
46
|
``scene`` is for waits of minutes: a colour terminal also gets the harbour (lighthouse, ship, sea)."""
|
|
46
47
|
if (ctx.find_root().obj or {}).get("as_json"):
|
|
47
48
|
return contextlib.nullcontext(None)
|
|
48
|
-
return ui.Spinner(label, tty_only=tty_only, scene=scene)
|
|
49
|
+
return ui.Spinner(label, tty_only=tty_only, scene=scene, bookends=bookends)
|
|
49
50
|
|
|
50
51
|
|
|
51
52
|
def open_in_browser(ctx: click.Context, url: str, *, why: str) -> None:
|
|
@@ -69,9 +70,10 @@ def poll_until(ctx: click.Context, read: Callable[[], T], finished: Callable[[T]
|
|
|
69
70
|
timeout_seconds: int, interval_seconds: int = JOB_POLL_SECONDS, outside_ticks: bool = True,
|
|
70
71
|
describe: Callable[[T], str] | None = None, done: Callable[[T], str] | None = None,
|
|
71
72
|
heartbeat: Callable[[int], str] | None = None, scene: bool = False,
|
|
72
|
-
on_timeout: Callable[[T], str] | None = None) -> T:
|
|
73
|
+
announce: Callable[[str], str | None] | None = None, on_timeout: Callable[[T], str] | None = None) -> T:
|
|
73
74
|
"""Read until ``finished``. With ``heartbeat`` (seconds waited so far -> a line), every wait is cut into pieces of at
|
|
74
|
-
most a minute and each ends with that line: on the spinner for a person, on stderr under --json (stdout stays JSON).
|
|
75
|
+
most a minute and each ends with that line: on the spinner for a person, on stderr under --json (stdout stays JSON).
|
|
76
|
+
``announce`` turns a new ``describe`` label into the line that stays on screen for it (None: no line); with it the wait prints no opening or closing line, only those."""
|
|
75
77
|
seams = ctx.find_root().obj
|
|
76
78
|
sleep, clock = seams["sleep"], seams["clock"]
|
|
77
79
|
waited, shown, misses = 0.0, label, 0
|
|
@@ -94,7 +96,7 @@ def poll_until(ctx: click.Context, read: Callable[[], T], finished: Callable[[T]
|
|
|
94
96
|
else:
|
|
95
97
|
spinner.update(f"{shown}: {line}")
|
|
96
98
|
|
|
97
|
-
with indicator(ctx, label, scene=scene) as spinner:
|
|
99
|
+
with indicator(ctx, label, scene=scene, bookends=announce is None) as spinner:
|
|
98
100
|
while True:
|
|
99
101
|
started = clock()
|
|
100
102
|
try:
|
|
@@ -120,5 +122,5 @@ def poll_until(ctx: click.Context, read: Callable[[], T], finished: Callable[[T]
|
|
|
120
122
|
"to keep waiting; nothing was lost.")
|
|
121
123
|
if spinner is not None and describe is not None and describe(value) != shown:
|
|
122
124
|
shown = describe(value)
|
|
123
|
-
spinner.update(shown)
|
|
125
|
+
spinner.update(shown, announce(shown) if announce else None)
|
|
124
126
|
pause(started)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""The four stages of writing an article, as the terminal says them: the same four the web wizard shows.
|
|
2
|
+
|
|
3
|
+
The server says which stage a run has reached (apps/api GET /api/v1/runs/{id}, field ``stage``, computed in
|
|
4
|
+
apps/api/src/authority/run_stage.py); this module only turns it into Researching, Drafting, Checking and Saving.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Any
|
|
10
|
+
|
|
11
|
+
from recala_cli import ui
|
|
12
|
+
|
|
13
|
+
STAGES = ("Researching", "Drafting", "Checking", "Saving")
|
|
14
|
+
|
|
15
|
+
#: One true sentence per stage, short enough that "Stage: sentence" fits a 40-column window.
|
|
16
|
+
_SENTENCES = {
|
|
17
|
+
"Researching": "Reading about your field.",
|
|
18
|
+
"Drafting": "Writing it in your voice.",
|
|
19
|
+
"Checking": "Matching facts to sources.",
|
|
20
|
+
"Saving": "Adding a cover and saving.",
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#: Measured on five live first-article runs (23 Nov 2026): 7 to 14 minutes. Said once, when the wait starts.
|
|
24
|
+
WAITING_LINE = "A good article takes about 10 minutes."
|
|
25
|
+
|
|
26
|
+
#: The server's stage names, as the terminal says them.
|
|
27
|
+
_LABEL_OF_STAGE = {"researching": "Researching", "writing": "Drafting", "checking": "Checking", "saving": "Saving"}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def stage_line(label: str) -> str | None:
|
|
31
|
+
""""Drafting: Writing it in your voice." for a stage name; None for any other label."""
|
|
32
|
+
return f"{label}: {_SENTENCES[label]}" if label in _SENTENCES else None
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class StageTracker:
|
|
36
|
+
"""Reads run states in order and answers with the stage reached: never raw, never earlier than one already shown.
|
|
37
|
+
|
|
38
|
+
A state with no stage the terminal knows (an older server, a run not started yet) keeps the stage last shown.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
def __init__(self) -> None:
|
|
42
|
+
self._reached = 0
|
|
43
|
+
|
|
44
|
+
def observe(self, run: dict[str, Any]) -> str:
|
|
45
|
+
label = _LABEL_OF_STAGE.get(str(run.get("stage") or ""))
|
|
46
|
+
if label:
|
|
47
|
+
self._reached = max(self._reached, STAGES.index(label))
|
|
48
|
+
return STAGES[self._reached]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def finish_headline(style: ui.Style) -> str:
|
|
52
|
+
"""The line that marks the end of a wait that ended with an article; stdout then says which."""
|
|
53
|
+
return style.bold(style.accent("The light found you."))
|
|
@@ -239,17 +239,19 @@ class Spinner:
|
|
|
239
239
|
"""
|
|
240
240
|
|
|
241
241
|
def __init__(self, label: str, *, stream: IO[str] | None = None, style: Style | None = None,
|
|
242
|
-
columns: Callable[[], int | None] | None = None, tty_only: bool = False, scene: bool = False) -> None:
|
|
242
|
+
columns: Callable[[], int | None] | None = None, tty_only: bool = False, scene: bool = False, bookends: bool = True) -> None:
|
|
243
243
|
self.label = label
|
|
244
244
|
self._scene_wanted = scene # a long wait: draw the harbour over the status line, on a colour terminal only
|
|
245
245
|
self._scene = False
|
|
246
246
|
self._scene_drawn = False
|
|
247
|
+
self._bookends = bookends # False: off a terminal, no opening line and no closing line, only what update() is given
|
|
247
248
|
self._tty_only = tty_only # on a pipe or in a log: no progress lines at all
|
|
248
249
|
self._stream = sys.stderr if stream is None else stream
|
|
249
250
|
self._style = style or Style.for_stream(self._stream)
|
|
250
251
|
self._columns = columns or (lambda: terminal_columns(self._stream))
|
|
251
252
|
self._animate = False
|
|
252
253
|
self._finished = False
|
|
254
|
+
self._lock = threading.Lock() # a frame and a permanent line never interleave
|
|
253
255
|
self._stop = threading.Event()
|
|
254
256
|
self._thread: threading.Thread | None = None
|
|
255
257
|
self._started = time.monotonic()
|
|
@@ -261,17 +263,28 @@ class Spinner:
|
|
|
261
263
|
if self._animate:
|
|
262
264
|
self._thread = threading.Thread(target=self._spin, daemon=True)
|
|
263
265
|
self._thread.start()
|
|
264
|
-
elif not self._tty_only:
|
|
266
|
+
elif not self._tty_only and self._bookends:
|
|
265
267
|
self._write(f"{self.label} ...\n")
|
|
266
268
|
return self
|
|
267
269
|
|
|
268
|
-
def update(self, label: str) -> None:
|
|
270
|
+
def update(self, label: str, note: str | None = None) -> None:
|
|
271
|
+
"""The live label changes. ``note`` is the line that stays in the scrollback: one per call, in every mode."""
|
|
269
272
|
self.label = label
|
|
270
|
-
if not self._animate
|
|
271
|
-
self.
|
|
273
|
+
if not self._animate:
|
|
274
|
+
if not self._tty_only:
|
|
275
|
+
self._write(f"{note or label}\n")
|
|
276
|
+
elif note:
|
|
277
|
+
self._leave_line(note)
|
|
278
|
+
|
|
279
|
+
def _leave_line(self, note: str) -> None:
|
|
280
|
+
"""Erase the live rows, print ``note`` where they were; the next frame draws below it."""
|
|
281
|
+
with self._lock:
|
|
282
|
+
self._write(self._clear_scene() if self._scene_drawn else "\r\x1b[K")
|
|
283
|
+
self._scene_drawn = False
|
|
284
|
+
self._write(f"{note}\n")
|
|
272
285
|
|
|
273
286
|
def done(self, message: str) -> None:
|
|
274
|
-
self._finish(f" {self._style.mark('done')} {message}" if self._animate else message)
|
|
287
|
+
self._finish(f" {self._style.mark('done')} {message}" if self._animate else message if self._bookends else None)
|
|
275
288
|
|
|
276
289
|
def fail(self, message: str) -> None:
|
|
277
290
|
self._finish(f" {self._style.mark('fail')} {message}" if self._animate else message)
|
|
@@ -283,7 +296,7 @@ class Spinner:
|
|
|
283
296
|
else:
|
|
284
297
|
self.fail(f"{self.label}: stopped")
|
|
285
298
|
|
|
286
|
-
def _finish(self, line: str) -> None:
|
|
299
|
+
def _finish(self, line: str | None) -> None:
|
|
287
300
|
self._finished = True
|
|
288
301
|
if self._tty_only and not self._animate:
|
|
289
302
|
return
|
|
@@ -293,7 +306,8 @@ class Spinner:
|
|
|
293
306
|
self._write(self._clear_scene() if self._scene_drawn else "\r\x1b[K")
|
|
294
307
|
if self._scene:
|
|
295
308
|
self._write("\x1b[?25h") # the cursor comes back
|
|
296
|
-
|
|
309
|
+
if line is not None:
|
|
310
|
+
self._write(f"{line}\n")
|
|
297
311
|
|
|
298
312
|
def _clear_scene(self) -> str:
|
|
299
313
|
return f"\x1b[{SCENE_ROWS + 1}A\r\x1b[J"
|
|
@@ -308,9 +322,10 @@ class Spinner:
|
|
|
308
322
|
elapsed = int(time.monotonic() - self._started)
|
|
309
323
|
status = status_line(frames[tick % len(frames)], self.label, elapsed, columns=columns, style=self._style)
|
|
310
324
|
rows = [*scene_rows(tick, width=columns, style=self._style), status]
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
325
|
+
with self._lock:
|
|
326
|
+
back = f"\x1b[{SCENE_ROWS + 1}A" if self._scene_drawn else ""
|
|
327
|
+
self._write(back + "".join(f"\r\x1b[K{row}\n" for row in rows))
|
|
328
|
+
self._scene_drawn = True
|
|
314
329
|
tick += 1
|
|
315
330
|
self._stop.wait(_FRAME_SECONDS)
|
|
316
331
|
|
|
@@ -326,7 +341,8 @@ class Spinner:
|
|
|
326
341
|
elapsed = int(time.monotonic() - self._started)
|
|
327
342
|
frame = frames[index % len(frames)]
|
|
328
343
|
line = status_line(frame, self.label, elapsed, columns=columns, style=self._style)
|
|
329
|
-
self.
|
|
344
|
+
with self._lock:
|
|
345
|
+
self._write(f"\r\x1b[K{line}")
|
|
330
346
|
index += 1
|
|
331
347
|
self._stop.wait(_FRAME_SECONDS)
|
|
332
348
|
|