recala-cli 0.6.7__tar.gz → 0.6.8__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.8}/CHANGELOG.md +3 -1
- {recala_cli-0.6.7 → recala_cli-0.6.8}/PKG-INFO +1 -1
- {recala_cli-0.6.7 → recala_cli-0.6.8}/pyproject.toml +1 -1
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/__init__.py +1 -1
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/article_runs.py +36 -9
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/polling.py +8 -6
- recala_cli-0.6.8/src/recala_cli/stages.py +73 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/ui.py +28 -12
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_core_release.py +1 -1
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_dogfood_fixes.py +3 -4
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_org_readable.py +1 -1
- recala_cli-0.6.8/tests/test_stages.py +201 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/.gitignore +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/README.md +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/scripts/check-dogfood.sh +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/scripts/publish_pypi.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/scripts/release.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/__main__.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/analytics.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/auth.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/client.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/__init__.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/article.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/auth.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/billing.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/bing.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/cadence.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/connect.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/credits.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/export.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/faithful_translations.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/gsc.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/index.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/keys.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/knowledge.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/languages.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/monthly_report.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/notifications.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/onboard.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/org.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/profile.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/questions.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/reads.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/refresh.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/refusals.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/schema.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/shell.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/skills.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/slot_topic.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/status.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/commands/topics.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/config.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/confirm.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/display.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/endpoints.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/errors.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/human.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/ids.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/labels.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/main.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/onboarding.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/organizations.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/output.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/parallel.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/prompts.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/runtime.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/search_numbers.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/skills/recala/SKILL.md +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/skills/recala/references/apply-revision-notes.md +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/skills/recala/references/article-signoff.md +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/skills/recala/references/connect-search-console.md +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/skills/recala/references/first-hand-evidence.md +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/skills/recala/references/onboard.md +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/skills/recala/references/plan-month.md +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/skills/recala/references/recala-cli-contract.md +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/skills/recala/references/schedule-approved.md +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/skills/recala/references/weekly-authority-report.md +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/stop_next_steps.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/updates.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/src/recala_cli/views.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/conftest.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/distribution/test_public_install.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/fixtures/hold_text_json.json +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/fixtures/human_output_pass1_json.json +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/fixtures/machine_contract_main.json +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_agent_error_next_steps.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_agent_onboarding.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_analytics.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_analytics_security.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_approve_read_receipt.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_approve_reconfirm.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_article_cover.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_article_export.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_article_id_output.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_article_portal_link.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_billing_invoices.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_billing_link.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_billing_top_up.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_bing.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_blank_author.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_c2_onboarding.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_cadence.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_calendar_matches_plan.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_calendar_slots.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_cms_skip.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_company_name_in_prompts.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_confirm.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_connect_and_status.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_content_commands.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_core_errors.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_core_root.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_core_short_ids.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_core_speed.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_core_status_speed.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_credits.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_declined_setup_is_not_an_error.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_dogfood_status.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_edit_link_warnings.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_empty_scan_next.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_empty_scan_replay.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_errors.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_failed_scan_ends_softly.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_faithful_translation_settings.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_free_article_tries.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_free_company_topics_step.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_free_plan_wording.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_free_scout_refusal.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_free_topics.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_gsc.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_help_listing.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_hold_finding_sentences.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_hold_text.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_human_output_pass1.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_human_readable.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_index.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_keys.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_knowledge_admit.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_knowledge_show_ideas.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_languages.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_login.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_login_json_org.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_machine_contract.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_monthly_report.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_no_endings_say_what_is_true.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_notifications.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_onboard_defaults.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_onboard_free_plan.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_onboarding_channel.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_onboarding_commands.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_org.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_org_describe.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_poll_pacing.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_profile.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_publish_commands.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_publish_pypi.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_questions.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_questions_in_words.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_recheck_findings.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_refresh.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_rerun_refusal.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_review_hardening.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_review_round3.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_run_progress.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_scan_reports_what_was_found.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_scene.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_scout_count.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_search_numbers.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_second_company_and_refused_details.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_short_id_selectors.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_signed_in_writes.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_skills.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_slot_topic.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_stop_next_steps.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_submit_review_state.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_times_in_company_zone.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_topics.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_topics_add.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_topics_one_call.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_ui.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_view_surface.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_whoami.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_will_retry.py +0 -0
- {recala_cli-0.6.7 → recala_cli-0.6.8}/tests/test_write_flags.py +0 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CLI changes
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 0.6.8
|
|
4
|
+
|
|
5
|
+
- `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
6
|
|
|
5
7
|
## 0.6.7
|
|
6
8
|
|
|
@@ -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):
|
|
@@ -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,73 @@
|
|
|
1
|
+
"""The four stages of writing an article, as the terminal says them: the same four the web wizard shows.
|
|
2
|
+
|
|
3
|
+
The server reports raw node names (apps/api GET /api/v1/runs/{id}); this module is the one place that turns them
|
|
4
|
+
into Researching, Drafting, Checking and Saving. The mapping mirrors the wizard's STAGE_OF_NODE
|
|
5
|
+
(apps/web/src/lib/voyage/onboardingFlow.ts): change the two together.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
from recala_cli import ui
|
|
13
|
+
|
|
14
|
+
STAGES = ("Researching", "Drafting", "Checking", "Saving")
|
|
15
|
+
|
|
16
|
+
#: One true sentence per stage, short enough that "Stage: sentence" fits a 40-column window.
|
|
17
|
+
_SENTENCES = {
|
|
18
|
+
"Researching": "Reading about your field.",
|
|
19
|
+
"Drafting": "Writing it in your voice.",
|
|
20
|
+
"Checking": "Matching facts to sources.",
|
|
21
|
+
"Saving": "Adding a cover and saving.",
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
#: Measured on five live first-article runs (23 Nov 2026): 7 to 14 minutes. Said once, when the wait starts.
|
|
25
|
+
WAITING_LINE = "A good article takes about 10 minutes."
|
|
26
|
+
|
|
27
|
+
_NODES_OF_STAGE = {
|
|
28
|
+
"Researching": ("search",),
|
|
29
|
+
"Drafting": ("generate", "gap_analysis", "serp_analysis", "strategy", "manager_plan", "citation_injector",
|
|
30
|
+
"validate_citations", "rewrite", "premium_editor", "section_auditor", "generate_targeted"),
|
|
31
|
+
"Checking": ("fact_check", "verify", "visual_strategy", "thumbnail", "infographic", "parallel_visuals",
|
|
32
|
+
"visual_qa", "proof_gate", "evaluate", "manager_review"),
|
|
33
|
+
"Saving": ("post_approval", "linkedin_post", "embed_knowledge", "extract_entities", "publish_cms"),
|
|
34
|
+
}
|
|
35
|
+
_STAGE_OF_NODE = {node: STAGES.index(stage) for stage, nodes in _NODES_OF_STAGE.items() for node in nodes}
|
|
36
|
+
#: Nodes that end their stage: once one has finished, the next stage is under way.
|
|
37
|
+
_LAST_NODES = {"search", "generate", "evaluate"}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def stage_line(label: str) -> str | None:
|
|
41
|
+
""""Drafting: Writing it in your voice." for a stage name; None for any other label."""
|
|
42
|
+
return f"{label}: {_SENTENCES[label]}" if label in _SENTENCES else None
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class StageTracker:
|
|
46
|
+
"""Reads run states in order and answers with the stage reached: never raw, never earlier than one already shown."""
|
|
47
|
+
|
|
48
|
+
def __init__(self) -> None:
|
|
49
|
+
self._reached = 0
|
|
50
|
+
|
|
51
|
+
def observe(self, run: dict[str, Any]) -> str:
|
|
52
|
+
self._reached = max(self._reached, *self._stages_in(run))
|
|
53
|
+
return STAGES[self._reached]
|
|
54
|
+
|
|
55
|
+
@staticmethod
|
|
56
|
+
def _stages_in(run: dict[str, Any]) -> list[int]:
|
|
57
|
+
running = _STAGE_OF_NODE.get(run.get("current_node") or "", 0)
|
|
58
|
+
finished = [_after(entry.get("node_name")) for entry in run.get("timeline") or []
|
|
59
|
+
if isinstance(entry, dict) and entry.get("status") == "completed"]
|
|
60
|
+
return [running, *finished]
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _after(node: str | None) -> int:
|
|
64
|
+
"""The stage a finished node leaves the run in; 0 (no news) for a node this table does not know."""
|
|
65
|
+
stage = _STAGE_OF_NODE.get(node or "")
|
|
66
|
+
if stage is None:
|
|
67
|
+
return 0
|
|
68
|
+
return min(stage + 1, len(STAGES) - 1) if node in _LAST_NODES else stage
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def finish_headline(style: ui.Style) -> str:
|
|
72
|
+
"""The line that marks the end of a wait that ended with an article; stdout then says which."""
|
|
73
|
+
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
|
|
|
@@ -12,7 +12,7 @@ PROJECT = tomllib.loads((CLI / "pyproject.toml").read_text())["project"]
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def test_the_version_is_065_in_the_package_and_in_pyproject():
|
|
15
|
-
assert __version__ == PROJECT["version"] == "0.6.
|
|
15
|
+
assert __version__ == PROJECT["version"] == "0.6.8"
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
def test_pypi_metadata_is_complete():
|
|
@@ -858,7 +858,7 @@ def test_create_shows_server_progress_steps(api, run, granted):
|
|
|
858
858
|
{"run_id": TOPIC_ID, "state": "processing"},
|
|
859
859
|
202,
|
|
860
860
|
)
|
|
861
|
-
for node in ["
|
|
861
|
+
for node in ["search", "generate"]:
|
|
862
862
|
api.json(
|
|
863
863
|
"GET",
|
|
864
864
|
f"/api/v1/runs/{TOPIC_ID}",
|
|
@@ -876,9 +876,8 @@ def test_create_shows_server_progress_steps(api, run, granted):
|
|
|
876
876
|
)
|
|
877
877
|
result = run("article", "create", "--topic", TOPIC_ID, "--org", ORG_ID)
|
|
878
878
|
assert result.exit_code == 6
|
|
879
|
-
assert
|
|
880
|
-
|
|
881
|
-
)
|
|
879
|
+
assert "Researching: " in result.stderr and "Drafting: " in result.stderr # the stages, never the server's node names
|
|
880
|
+
assert ": search" not in result.stderr and ": generate" not in result.stderr
|
|
882
881
|
|
|
883
882
|
|
|
884
883
|
def test_calendar_combines_slots_and_appointments_chronologically():
|
|
@@ -260,4 +260,4 @@ def test_every_org_option_help_describes_names_slugs_and_ids(run):
|
|
|
260
260
|
|
|
261
261
|
def test_cli_version_is_065_and_matches_package_metadata():
|
|
262
262
|
pyproject = Path(__file__).parents[1] / "pyproject.toml"
|
|
263
|
-
assert __version__ == tomllib.loads(pyproject.read_text())["project"]["version"] == "0.6.
|
|
263
|
+
assert __version__ == tomllib.loads(pyproject.read_text())["project"]["version"] == "0.6.8"
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"""The terminal's wait speaks the web wizard's four stages: Researching, Drafting, Checking, Saving.
|
|
2
|
+
|
|
3
|
+
One mapping turns the server's node names into those stages; a name it does not know is never shown, and
|
|
4
|
+
the stage never moves backwards. A finish block names the real article and where to read it.
|
|
5
|
+
"""
|
|
6
|
+
import io
|
|
7
|
+
import json
|
|
8
|
+
import re
|
|
9
|
+
|
|
10
|
+
import pytest
|
|
11
|
+
from conftest import ORG_ID
|
|
12
|
+
|
|
13
|
+
from recala_cli import stages, ui
|
|
14
|
+
|
|
15
|
+
RUN_ID = "ae0c36b3-0000-4000-8000-000000000001"
|
|
16
|
+
ARTICLE_ID = "1a2b3c4d-0000-4000-8000-000000000001"
|
|
17
|
+
_ANSI = re.compile(r"\x1b\[[0-9;?]*[A-Za-z]")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def run_state(current_node=None, completed=()):
|
|
21
|
+
"""The shape of GET /api/v1/runs/{id} (apps/api/src/routers/ops.py): current_node and an ordered timeline."""
|
|
22
|
+
return {"queue_id": RUN_ID, "status": "processing", "current_node": current_node,
|
|
23
|
+
"timeline": [{"node_name": node, "status": "completed"} for node in completed]
|
|
24
|
+
+ ([{"node_name": current_node, "status": "running"}] if current_node else [])}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@pytest.mark.parametrize("node, stage", [
|
|
28
|
+
("search", "Researching"), ("generate", "Drafting"), ("rewrite", "Drafting"), ("fact_check", "Checking"),
|
|
29
|
+
("thumbnail", "Checking"), ("evaluate", "Checking"), ("post_approval", "Saving"), ("publish_cms", "Saving"),
|
|
30
|
+
])
|
|
31
|
+
def test_a_node_reads_as_its_stage(node, stage):
|
|
32
|
+
assert stages.StageTracker().observe(run_state(node)) == stage
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_a_run_that_has_not_reported_a_node_starts_at_researching():
|
|
36
|
+
assert stages.StageTracker().observe({"queue_id": RUN_ID, "status": "queued"}) == "Researching"
|
|
37
|
+
assert stages.StageTracker().observe(run_state(None)) == "Researching"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def test_an_unknown_node_is_never_shown_and_keeps_the_stage_last_shown():
|
|
41
|
+
tracker = stages.StageTracker()
|
|
42
|
+
assert tracker.observe(run_state("brand_new_node")) == "Researching"
|
|
43
|
+
assert tracker.observe(run_state("generate")) == "Drafting"
|
|
44
|
+
shown = tracker.observe(run_state("brand_new_node", completed=["search", "generate"]))
|
|
45
|
+
assert shown == "Checking" # the finished search and generate still count; the new node is ignored
|
|
46
|
+
assert "brand_new_node" not in shown
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_the_stage_never_moves_backwards():
|
|
50
|
+
tracker = stages.StageTracker()
|
|
51
|
+
assert tracker.observe(run_state("fact_check")) == "Checking"
|
|
52
|
+
assert tracker.observe(run_state("rewrite")) == "Checking" # a node of an earlier stage runs again
|
|
53
|
+
assert tracker.observe(run_state("search")) == "Checking"
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def test_finishing_the_last_node_of_a_stage_starts_the_next_one():
|
|
57
|
+
tracker = stages.StageTracker()
|
|
58
|
+
assert tracker.observe(run_state(None, completed=["search"])) == "Drafting"
|
|
59
|
+
assert tracker.observe(run_state(None, completed=["search", "generate"])) == "Checking"
|
|
60
|
+
assert tracker.observe(run_state(None, completed=["search", "generate", "evaluate"])) == "Saving"
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@pytest.mark.parametrize("columns", [40, 80, 120])
|
|
64
|
+
def test_every_stage_line_and_the_waiting_line_fit_the_window(columns):
|
|
65
|
+
assert ui.cell_width(stages.WAITING_LINE) <= columns - 1
|
|
66
|
+
for name in stages.STAGES:
|
|
67
|
+
line = stages.stage_line(name)
|
|
68
|
+
assert line.startswith(f"{name}: ") and ui.cell_width(line) <= columns - 1
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def test_a_label_that_is_not_a_stage_has_no_stage_line():
|
|
72
|
+
assert stages.stage_line("Evidence: taking another careful pass") is None
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def test_the_waiting_line_says_ten_minutes_and_promises_nothing_else():
|
|
76
|
+
assert stages.WAITING_LINE == "A good article takes about 10 minutes."
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def test_the_finish_is_one_headline_line():
|
|
80
|
+
assert stages.finish_headline(ui.Style.plain()) == "The light found you."
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# The Spinner: a stage change is one permanent line in every mode, then the live row goes on.
|
|
84
|
+
|
|
85
|
+
def test_a_pipe_prints_each_stage_change_once_as_its_stage_line():
|
|
86
|
+
pipe = io.StringIO()
|
|
87
|
+
with ui.Spinner("Waiting", stream=pipe) as spinner:
|
|
88
|
+
spinner.update("Researching", stages.stage_line("Researching"))
|
|
89
|
+
spinner.update("Drafting", stages.stage_line("Drafting"))
|
|
90
|
+
spinner.done("Waiting")
|
|
91
|
+
assert pipe.getvalue().splitlines() == ["Waiting ...", stages.stage_line("Researching"), stages.stage_line("Drafting"), "Waiting"]
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_a_spinner_without_bookends_prints_only_the_lines_it_is_given():
|
|
95
|
+
pipe = io.StringIO()
|
|
96
|
+
with ui.Spinner("Waiting", stream=pipe, bookends=False) as spinner:
|
|
97
|
+
spinner.update("Drafting", stages.stage_line("Drafting"))
|
|
98
|
+
spinner.done("Waiting")
|
|
99
|
+
assert pipe.getvalue().splitlines() == [stages.stage_line("Drafting")]
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def test_a_spinner_without_bookends_still_says_when_it_stopped():
|
|
103
|
+
pipe = io.StringIO()
|
|
104
|
+
with pytest.raises(RuntimeError), ui.Spinner("Waiting", stream=pipe, bookends=False):
|
|
105
|
+
raise RuntimeError
|
|
106
|
+
assert pipe.getvalue().splitlines() == ["Waiting: stopped"]
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class FakeTty(io.StringIO):
|
|
110
|
+
def isatty(self):
|
|
111
|
+
return True
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def test_a_live_terminal_leaves_the_stage_line_in_the_scrollback(monkeypatch):
|
|
115
|
+
monkeypatch.setattr(ui, "_FRAME_SECONDS", 0.01)
|
|
116
|
+
out = FakeTty()
|
|
117
|
+
with ui.Spinner("Waiting", stream=out, columns=lambda: 80, style=ui.Style(color=True, animate=True, unicode=True),
|
|
118
|
+
scene=True) as spinner:
|
|
119
|
+
spinner.update("Drafting", stages.stage_line("Drafting"))
|
|
120
|
+
import time
|
|
121
|
+
time.sleep(0.15)
|
|
122
|
+
spinner.done("Waiting")
|
|
123
|
+
text = _ANSI.sub("", out.getvalue())
|
|
124
|
+
assert text.count(stages.stage_line("Drafting")) == 1
|
|
125
|
+
assert "Drafting" in text and "◉" in text
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
# The whole command, off a terminal: the same lines, once each; --json untouched.
|
|
129
|
+
|
|
130
|
+
def script_run(api, *states):
|
|
131
|
+
for state in states:
|
|
132
|
+
api.json("GET", f"/api/v1/runs/{RUN_ID}", state)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def ready_state():
|
|
136
|
+
return {"queue_id": RUN_ID, "status": "published", "article_id": ARTICLE_ID, "current_node": None, "timeline": []}
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def script_ready_article(api):
|
|
140
|
+
script_run(api, run_state("search"), run_state("search"), run_state("generate", ["search"]), run_state("mystery_node", ["search"]),
|
|
141
|
+
run_state("fact_check", ["search", "generate"]), run_state("post_approval", ["search", "generate", "evaluate"]),
|
|
142
|
+
ready_state())
|
|
143
|
+
api.json("GET", f"/api/v1/articles/{ARTICLE_ID}", {"article": {"id": ARTICLE_ID, "article_title": "Evidence",
|
|
144
|
+
"cms_publish_status": "published", "evaluation_grade": "B"}})
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def test_a_ready_run_reads_top_to_bottom_in_one_shape(api, run, granted, monkeypatch):
|
|
148
|
+
"""Plain mode, the real label: ten-minute line, each stage once, the headline, then stdout. Nothing twice."""
|
|
149
|
+
monkeypatch.setenv("RECALA_WEB_URL", "https://recala.co")
|
|
150
|
+
script_ready_article(api)
|
|
151
|
+
|
|
152
|
+
result = run("article", "run", RUN_ID, "--org", ORG_ID)
|
|
153
|
+
|
|
154
|
+
assert result.exit_code == 0, result.stderr
|
|
155
|
+
lines = [line for line in result.stderr.splitlines() if "still writing" not in line] # the minute heartbeat is its own feature
|
|
156
|
+
assert lines == [
|
|
157
|
+
stages.WAITING_LINE, stages.stage_line("Researching"), stages.stage_line("Drafting"),
|
|
158
|
+
stages.stage_line("Checking"), stages.stage_line("Saving"), "The light found you."]
|
|
159
|
+
merged = result.stderr + result.stdout
|
|
160
|
+
assert merged.count("Evidence") == 1
|
|
161
|
+
assert merged.count(f"https://recala.co/portal/article/{ARTICLE_ID}") == 1
|
|
162
|
+
assert result.stdout.splitlines()[0] == "Evidence [1a2b3c4d]: published." # stdout is the answer, as before
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def test_a_regeneration_wait_shows_no_node_name_and_no_stages(api, run, granted):
|
|
166
|
+
"""A re-run is read from the article row, which has no node: it says the article's state, never a stage."""
|
|
167
|
+
import httpx
|
|
168
|
+
api.json("POST", "/api/v1/cost-previews", {"allowed": True, "preview_id": "preview", "action": "create_article",
|
|
169
|
+
"target": ARTICLE_ID, "payment": {"how": "credit", "available": 1}})
|
|
170
|
+
api.on("GET", f"/api/v1/articles/{ARTICLE_ID}", *[httpx.Response(200, json={"article": {
|
|
171
|
+
"id": ARTICLE_ID, "article_title": "Evidence", "cms_publish_status": state}}) for state in ("held", "regenerating", "draft")])
|
|
172
|
+
api.json("POST", f"/api/v1/articles/{ARTICLE_ID}/regenerate", {"ok": True, "regenerate_id": "r", "charge_mode": "free", "status": "queued"})
|
|
173
|
+
result = run("article", "regenerate", ARTICLE_ID, "--org", ORG_ID)
|
|
174
|
+
assert result.exit_code == 0, result.stderr
|
|
175
|
+
assert stages.WAITING_LINE not in result.stderr and "The light found you." not in result.stderr
|
|
176
|
+
assert "Evidence: regenerating" in result.stderr
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def test_json_output_for_a_ready_run_is_byte_identical_and_stderr_has_no_stage_talk(api, run, granted):
|
|
180
|
+
script_run(api, run_state("generate", ["search"]), ready_state())
|
|
181
|
+
api.json("GET", f"/api/v1/articles/{ARTICLE_ID}", {"article": {"id": ARTICLE_ID, "article_title": "Evidence",
|
|
182
|
+
"cms_publish_status": "published", "evaluation_grade": "B"}})
|
|
183
|
+
|
|
184
|
+
result = run("article", "run", RUN_ID, "--org", ORG_ID, "--json")
|
|
185
|
+
|
|
186
|
+
assert result.exit_code == 0
|
|
187
|
+
assert result.stdout == (
|
|
188
|
+
'{\n "queue_id": "ae0c36b3-0000-4000-8000-000000000001",\n "status": "published",\n'
|
|
189
|
+
' "article_id": "1a2b3c4d-0000-4000-8000-000000000001",\n "current_node": null,\n "timeline": [],\n'
|
|
190
|
+
' "state": "published",\n "hold": null,\n "title": "Evidence",\n "cms_status": "published",\n "grade": "B"\n}\n')
|
|
191
|
+
assert result.stderr == "still writing… 1m00s\n" # exactly what it was before this change
|
|
192
|
+
json.loads(result.stdout)
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def test_a_failed_run_keeps_its_wording_and_gets_no_finish_block(api, run, granted):
|
|
196
|
+
script_run(api, run_state("generate", ["search"]), {"queue_id": RUN_ID, "status": "failed", "failure_code": "proof_contract",
|
|
197
|
+
"failure_reason": "unsupported_claims"})
|
|
198
|
+
result = run("article", "run", RUN_ID, "--org", ORG_ID)
|
|
199
|
+
assert result.exit_code == 6
|
|
200
|
+
assert "The light found you." not in result.stderr
|
|
201
|
+
assert "Article generation failed (proof_contract: unsupported_claims)." in result.stderr
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|