codeplain 0.4.1.dev51__tar.gz → 0.4.2__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.
Files changed (206) hide show
  1. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/.github/dependabot.yml +9 -0
  2. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/PKG-INFO +2 -2
  3. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/docs/plain2code_cli.md +13 -2
  4. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/partial_rendering.py +17 -4
  5. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/plain2code.py +6 -4
  6. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/plain2code_arguments.py +13 -1
  7. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/plain2code_events.py +2 -0
  8. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/plain2code_state.py +5 -0
  9. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/plain2code_utils.py +12 -0
  10. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/pyproject.toml +1 -1
  11. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/actions/render_functional_requirement.py +16 -8
  12. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/render_context.py +9 -1
  13. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/requirements.txt +1 -1
  14. codeplain-0.4.2/tests/test_exit_when_done.py +151 -0
  15. codeplain-0.4.2/tests/test_functionality_position.py +90 -0
  16. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_partial_rendering.py +44 -0
  17. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_render_finished_report.py +37 -2
  18. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_terminal_attachment.py +1 -0
  19. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tui/components.py +11 -1
  20. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tui/plain2code_tui.py +18 -0
  21. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tui/state_handlers.py +3 -1
  22. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/.claude/settings.json +0 -0
  23. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/.flake8 +0 -0
  24. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/.github/workflows/e2e.yml +0 -0
  25. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/.github/workflows/lint-and-test.yml +0 -0
  26. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/.github/workflows/lint-powershell.yml +0 -0
  27. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/.github/workflows/notify-slack-on-main-merge.yml +0 -0
  28. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/.github/workflows/publish-dev-to-pypi.yml +0 -0
  29. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/.github/workflows/publish-install-script.yml +0 -0
  30. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/.github/workflows/publish-to-pypi.yml +0 -0
  31. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/.gitignore +0 -0
  32. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/.vscode/launch.json +0 -0
  33. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/.vscode/settings.json +0 -0
  34. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/CLAUDE.md +0 -0
  35. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/CONTRIBUTING.md +0 -0
  36. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/LICENSE +0 -0
  37. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/README.md +0 -0
  38. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/change_detection.py +0 -0
  39. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/cli_output/__init__.py +0 -0
  40. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/cli_output/dry_run.py +0 -0
  41. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/cli_output/render_summary.py +0 -0
  42. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/cli_output/status.py +0 -0
  43. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/codeplain_REST_api.py +0 -0
  44. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/concept_utils.py +0 -0
  45. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/config/__init__.py +0 -0
  46. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/config/system_config.yaml +0 -0
  47. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/conformance_fix_journal.py +0 -0
  48. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/diff_utils.py +0 -0
  49. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/docs/generate_cli.py +0 -0
  50. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/docs/starting_a_plain_project_from_scratch.md +0 -0
  51. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/event_bus.py +0 -0
  52. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/examples/example_hello_world_golang/config.yaml +0 -0
  53. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/examples/example_hello_world_golang/harness_tests/hello_world_test.go +0 -0
  54. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/examples/example_hello_world_golang/hello_world_golang.plain +0 -0
  55. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/examples/example_hello_world_golang/run.sh +0 -0
  56. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/examples/example_hello_world_golang/tests/hello_world_golang/display-hello-world.plain +0 -0
  57. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/examples/example_hello_world_python/config.yaml +0 -0
  58. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/examples/example_hello_world_python/harness_tests/hello_world_display/test_hello_world.py +0 -0
  59. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/examples/example_hello_world_python/hello_world_python.plain +0 -0
  60. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/examples/example_hello_world_python/run.sh +0 -0
  61. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/examples/example_hello_world_python/tests/hello_world_python/display-hello-world.plain +0 -0
  62. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/examples/example_hello_world_react/config.yaml +0 -0
  63. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/examples/example_hello_world_react/harness_tests/hello_world_display/cypress/e2e/hello_world.cy.ts +0 -0
  64. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/examples/example_hello_world_react/harness_tests/hello_world_display/cypress/support/e2e.ts +0 -0
  65. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/examples/example_hello_world_react/harness_tests/hello_world_display/cypress.config.ts +0 -0
  66. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/examples/example_hello_world_react/harness_tests/hello_world_display/package.json +0 -0
  67. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/examples/example_hello_world_react/harness_tests/hello_world_display/tsconfig.json +0 -0
  68. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/examples/example_hello_world_react/hello_world_react.plain +0 -0
  69. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/examples/example_hello_world_react/run.sh +0 -0
  70. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/examples/example_hello_world_react/tests/hello_world_react/display-hello-world.plain +0 -0
  71. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/examples/example_hello_world_react/tests/typescript-react-app-boilerplate/entry-point.plain +0 -0
  72. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/examples/run.sh +0 -0
  73. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/file_utils.py +0 -0
  74. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/git_preflight.py +0 -0
  75. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/git_utils.py +0 -0
  76. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/install/bash/examples.sh +0 -0
  77. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/install/bash/install.sh +0 -0
  78. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/install/bash/walkthrough.sh +0 -0
  79. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/install/powershell/examples.ps1 +0 -0
  80. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/install/powershell/install.ps1 +0 -0
  81. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/install/powershell/walkthrough.ps1 +0 -0
  82. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/memory_management.py +0 -0
  83. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/metadata_utils.py +0 -0
  84. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/module_renderer.py +0 -0
  85. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/path_resolution.py +0 -0
  86. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/plain2code_cli.md +0 -0
  87. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/plain2code_console.py +0 -0
  88. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/plain2code_exceptions.py +0 -0
  89. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/plain2code_logger.py +0 -0
  90. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/plain2code_nodes.py +0 -0
  91. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/plain2code_read_config.py +0 -0
  92. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/plain2code_telemetry.py +0 -0
  93. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/plain_file.py +0 -0
  94. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/plain_modules.py +0 -0
  95. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/plain_spec.py +0 -0
  96. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/pytest.ini +0 -0
  97. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/__init__.py +0 -0
  98. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/actions/analyze_specification_ambiguity.py +0 -0
  99. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/actions/base_action.py +0 -0
  100. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/actions/commit_conformance_tests_changes.py +0 -0
  101. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/actions/commit_implementation_code_changes.py +0 -0
  102. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/actions/create_dist.py +0 -0
  103. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/actions/distill_conformance_test_memory.py +0 -0
  104. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/actions/exit_with_error.py +0 -0
  105. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/actions/finish_functional_requirement.py +0 -0
  106. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/actions/fix_conformance_test.py +0 -0
  107. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/actions/fix_unit_tests.py +0 -0
  108. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/actions/prepare_repositories.py +0 -0
  109. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/actions/prepare_testing_environment.py +0 -0
  110. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/actions/refactor_code.py +0 -0
  111. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/actions/render_conformance_tests.py +0 -0
  112. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/actions/run_conformance_tests.py +0 -0
  113. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/actions/run_unit_tests.py +0 -0
  114. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/actions/summarize_conformance_tests.py +0 -0
  115. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/agent_tools.py +0 -0
  116. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/code_renderer.py +0 -0
  117. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/conformance_tests.py +0 -0
  118. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/implementation_code_helpers.py +0 -0
  119. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/render_types.py +0 -0
  120. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/render_utils.py +0 -0
  121. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/state_machine_config.py +0 -0
  122. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/states.py +0 -0
  123. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/render_machine/triggers.py +0 -0
  124. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/resources/codeplain_overview.png +0 -0
  125. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/resources/plain_example.png +0 -0
  126. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/standard_template_library/golang-console-app-template.plain +0 -0
  127. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/standard_template_library/python-console-app-template.plain +0 -0
  128. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/standard_template_library/typescript-react-app-boilerplate.plain +0 -0
  129. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/standard_template_library/typescript-react-app-template.plain +0 -0
  130. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/system_config.py +0 -0
  131. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/test_scripts/run_conformance_tests_cypress.ps1 +0 -0
  132. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/test_scripts/run_conformance_tests_cypress.sh +0 -0
  133. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/test_scripts/run_conformance_tests_golang.ps1 +0 -0
  134. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/test_scripts/run_conformance_tests_golang.sh +0 -0
  135. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/test_scripts/run_conformance_tests_python.ps1 +0 -0
  136. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/test_scripts/run_conformance_tests_python.sh +0 -0
  137. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/test_scripts/run_unittests_flutter.ps1 +0 -0
  138. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/test_scripts/run_unittests_flutter.sh +0 -0
  139. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/test_scripts/run_unittests_golang.ps1 +0 -0
  140. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/test_scripts/run_unittests_golang.sh +0 -0
  141. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/test_scripts/run_unittests_python.ps1 +0 -0
  142. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/test_scripts/run_unittests_python.sh +0 -0
  143. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/test_scripts/run_unittests_react.ps1 +0 -0
  144. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/test_scripts/run_unittests_react.sh +0 -0
  145. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/__init__.py +0 -0
  146. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/conftest.py +0 -0
  147. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/data/acceptance_tests_warning/main_requiring_acceptance_tests.plain +0 -0
  148. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/data/acceptance_tests_warning/required_with_acceptance_tests.plain +0 -0
  149. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/data/acceptance_tests_warning/tests/required_with_acceptance_tests/entry-point.plain +0 -0
  150. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/data/partial_rendering/pr_code_var.plain +0 -0
  151. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/data/partial_rendering/pr_implement.plain +0 -0
  152. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/data/partial_rendering/pr_leaf.plain +0 -0
  153. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/data/partial_rendering/pr_middle.plain +0 -0
  154. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/data/partial_rendering/pr_root.plain +0 -0
  155. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/data/partial_rendering/pr_solo.plain +0 -0
  156. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/e2e/Dockerfile +0 -0
  157. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/e2e/conftest.py +0 -0
  158. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/e2e/test_hello_world_python.py +0 -0
  159. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/e2e/test_hello_world_python_windows.py +0 -0
  160. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_acceptance_scenario_rendered_once.py +0 -0
  161. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_acceptance_scenarios_after_a_code_fix.py +0 -0
  162. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_agent_tools.py +0 -0
  163. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_arg_provenance.py +0 -0
  164. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_change_detection.py +0 -0
  165. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_cli_output.py +0 -0
  166. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_conformance_fix_journal.py +0 -0
  167. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_console_log_styles.py +0 -0
  168. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_dependency_pins.py +0 -0
  169. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_distill_conformance_test_memory.py +0 -0
  170. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_dry_run_link_validation.py +0 -0
  171. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_file_utils.py +0 -0
  172. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_fix_unit_tests_action.py +0 -0
  173. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_fix_unit_tests_conformance_context.py +0 -0
  174. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_folder_path_resolution.py +0 -0
  175. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_frid_arguments.py +0 -0
  176. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_functionality_without_scenarios.py +0 -0
  177. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_git_preflight.py +0 -0
  178. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_git_utils.py +0 -0
  179. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_headless_logging.py +0 -0
  180. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_log_file_name_resolution.py +0 -0
  181. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_logging_config_path_resolution.py +0 -0
  182. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_path_resolution.py +0 -0
  183. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_plain2code.py +0 -0
  184. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_plain2code_state.py +0 -0
  185. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_plain2code_utils.py +0 -0
  186. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_plain_modules.py +0 -0
  187. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_prepare_repositories_layout.py +0 -0
  188. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_render_range.py +0 -0
  189. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_render_stop_reason.py +0 -0
  190. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_resolve_config_file.py +0 -0
  191. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_script_path_resolution.py +0 -0
  192. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_system_config.py +0 -0
  193. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_telemetry.py +0 -0
  194. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_tests_folders.py +0 -0
  195. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_traceability_warnings.py +0 -0
  196. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_tui_components.py +0 -0
  197. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_tui_usage.py +0 -0
  198. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_usage_summary.py +0 -0
  199. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tests/test_user_error_message.py +0 -0
  200. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tui/__init__.py +0 -0
  201. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tui/models.py +0 -0
  202. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tui/plain_module_render_choice_tui.py +0 -0
  203. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tui/spinner.py +0 -0
  204. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tui/styles.css +0 -0
  205. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/tui/widget_helpers.py +0 -0
  206. {codeplain-0.4.1.dev51 → codeplain-0.4.2}/usage_summary.py +0 -0
@@ -16,6 +16,15 @@ updates:
16
16
  - "dependencies"
17
17
  # Routine bumps arrive as one weekly PR; majors stay separate.
18
18
  groups:
19
+ # These change the parsed spec text, so a bump can invalidate partial-render hashes
20
+ # and the API render cache. Listed first so they never land in the routine group;
21
+ # merge together with the matching codeplain-api PR.
22
+ spec-parsing:
23
+ patterns:
24
+ - "plain-parser"
25
+ - "mistletoe"
26
+ - "python-liquid2"
27
+ - "python-frontmatter"
19
28
  pip-minor-and-patch:
20
29
  update-types:
21
30
  - "minor"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: codeplain
3
- Version: 0.4.1.dev51
3
+ Version: 0.4.2
4
4
  Summary: Transform plain language specifications into working code
5
5
  License-File: LICENSE
6
6
  Classifier: Environment :: Console
@@ -25,7 +25,7 @@ Requires-Dist: black==26.10.1; extra == 'dev'
25
25
  Requires-Dist: flake8==7.4.1; extra == 'dev'
26
26
  Requires-Dist: isort==9.0.2; extra == 'dev'
27
27
  Requires-Dist: mypy==2.4.0; extra == 'dev'
28
- Requires-Dist: pytest==9.1.1; extra == 'dev'
28
+ Requires-Dist: pytest==9.2.0; extra == 'dev'
29
29
  Description-Content-Type: text/markdown
30
30
 
31
31
  # *codeplain renderer
@@ -19,7 +19,8 @@ usage: generate_cli.py [-h] [--verbose] [--base-folder BASE_FOLDER]
19
19
  [--conformance-tests-dest CONFORMANCE_TESTS_DEST]
20
20
  [--render-machine-graph]
21
21
  [--logging-config-path LOGGING_CONFIG_PATH]
22
- [--headless] [--status] [--version]
22
+ [--headless] [--exit-when-done | --no-exit-when-done]
23
+ [--status] [--version]
23
24
  [filename]
24
25
 
25
26
  Render plain code to target code. Path arguments resolve based on where they
@@ -62,7 +63,9 @@ options:
62
63
  with this ID will be included in the output. The
63
64
  functionality ID must match one of the functionalities
64
65
  in your plain file.
65
- --force-render Force re-render of all the required modules.
66
+ --force-render Render every module of the project again, from the
67
+ first one. The client does not ask where to start and
68
+ the code rendered before is replaced.
66
69
  --unittests-script UNITTESTS_SCRIPT
67
70
  Shell script to run unit tests on generated code.
68
71
  Receives the module's code folder path as its first
@@ -129,6 +132,14 @@ options:
129
132
  specification text itself stays in the log file only.
130
133
  Used automatically when stdin, stdout or stderr is not
131
134
  a terminal.
135
+ --exit-when-done, --no-exit-when-done
136
+ Close the terminal interface as soon as rendering
137
+ stops, instead of keeping it open until you press
138
+ Enter. The render summary is printed to the terminal
139
+ as usual. Use --no-exit-when-done to keep the
140
+ interface open when config.yaml turns this on.
141
+ Headless rendering always ends by itself, so the
142
+ option changes nothing there.
132
143
  --status Display account status including user information, API
133
144
  key label, and rendering credits. Does not render any
134
145
  code.
@@ -237,7 +237,6 @@ def change_is_only_future_work(
237
237
  def _resume_render_choice(
238
238
  plain_module: PlainModule,
239
239
  plain_module_render_state: PlainModuleRenderState,
240
- force_render: bool,
241
240
  ) -> RenderChoice:
242
241
  """The natural next step from the last-rendered position when no decision is needed:
243
242
  start an unrendered module, continue a partially-rendered one, or advance to the next.
@@ -261,8 +260,7 @@ def _resume_render_choice(
261
260
  render_range = plain_spec.get_render_range_from(next_frid, next_module.plain_source)
262
261
  return RenderChoice(
263
262
  module=next_module,
264
- render_range=None if force_render else render_range,
265
- wipe_later_modules=force_render,
263
+ render_range=render_range,
266
264
  choice_type="continue_from_frid",
267
265
  )
268
266
 
@@ -280,6 +278,21 @@ def get_render_choices(
280
278
  plain_module_render_state: PlainModuleRenderState,
281
279
  force_render: bool = False,
282
280
  ) -> dict[str, RenderChoice]:
281
+ if force_render:
282
+ # --force-render re-renders the whole chain from the first module, whatever changed and
283
+ # wherever the last render stopped. There is nothing to decide, so a single choice is
284
+ # returned and the user is not asked.
285
+ first_module = plain_module.all_required_modules[0] if plain_module.all_required_modules else plain_module
286
+ return {
287
+ "1": RenderChoice(
288
+ module=first_module,
289
+ render_range=None,
290
+ choice_type="rerender_from_first",
291
+ wipe_later_modules=True,
292
+ is_destructive=True,
293
+ )
294
+ }
295
+
283
296
  render_choices = list[RenderChoice]()
284
297
  module_start_points = list[str]()
285
298
 
@@ -298,7 +311,7 @@ def get_render_choices(
298
311
  # Continue / resume from the last-rendered position. The change-driven blocks below decide
299
312
  # the start otherwise — once a change touches already-rendered work, resuming from the old
300
313
  # position would build on stale code.
301
- render_choices.append(_resume_render_choice(plain_module, plain_module_render_state, force_render))
314
+ render_choices.append(_resume_render_choice(plain_module, plain_module_render_state))
302
315
 
303
316
  else:
304
317
  # change is set here (otherwise treat_as_continue would be True), so change_type is always
@@ -375,10 +375,11 @@ def render( # noqa: C901
375
375
  render_choices = get_render_choices(plain_module, plain_module_render_state, args.force_render)
376
376
  ask_user = True
377
377
  render_choice = None
378
- if len(render_choices) <= 2:
379
- # Last choice is Quit, first choice is the only other actionable choice
378
+ if args.force_render or len(render_choices) <= 2:
379
+ # With --force-render there is a single choice. Otherwise the last choice is Quit,
380
+ # so the first choice is the only other actionable one.
380
381
  render_choice = render_choices[list(render_choices.keys())[0]]
381
- ask_user = render_choice.is_destructive
382
+ ask_user = render_choice.is_destructive and not args.force_render
382
383
 
383
384
  if ask_user and not args.headless:
384
385
  app = PlainModuleRenderChoiceTUI(
@@ -452,6 +453,7 @@ def render( # noqa: C901
452
453
  enter_pause_event=enter_pause_event,
453
454
  on_cancel=run_state.set_render_cancelled,
454
455
  default_log_level=default_log_level,
456
+ exit_when_done=args.exit_when_done,
455
457
  css_path="styles.css",
456
458
  )
457
459
  app.run()
@@ -590,7 +592,7 @@ def main(): # noqa: C901
590
592
  print_exit_summary(
591
593
  run_state,
592
594
  args.filename,
593
- error_message=error_message,
595
+ error_message=error_message or run_state.render_error_message,
594
596
  )
595
597
  # Remove any scratch extractions created for archive-only ("<module>.module") modules.
596
598
  for module in plain_module.all_required_modules + [plain_module]:
@@ -352,7 +352,8 @@ def create_parser():
352
352
  "--force-render",
353
353
  action="store_true",
354
354
  default=False,
355
- help="Force re-render of all the required modules.",
355
+ help="Render every module of the project again, from the first one. "
356
+ "The client does not ask where to start and the code rendered before is replaced.",
356
357
  )
357
358
 
358
359
  _add_arg(
@@ -510,6 +511,17 @@ def create_parser():
510
511
  "Used automatically when stdin, stdout or stderr is not a terminal.",
511
512
  )
512
513
 
514
+ _add_arg(
515
+ parser,
516
+ "--exit-when-done",
517
+ action=argparse.BooleanOptionalAction,
518
+ default=False,
519
+ help="Close the terminal interface as soon as rendering stops, instead of keeping it open "
520
+ "until you press Enter. The render summary is printed to the terminal as usual. "
521
+ "Use --no-exit-when-done to keep the interface open when config.yaml turns this on. "
522
+ "Headless rendering always ends by itself, so the option changes nothing there.",
523
+ )
524
+
513
525
  parser.add_argument(
514
526
  "--status",
515
527
  action="store_true",
@@ -22,6 +22,8 @@ class RenderContextSnapshot:
22
22
  unit_tests_running_context: Optional[UnitTestsRunningContext]
23
23
  script_execution_history: Optional[ScriptExecutionHistory]
24
24
  module_name: str
25
+ # Where the functionality stands among those of its module, as "3/12". None before one is picked.
26
+ functionality_position: Optional[str] = None
25
27
 
26
28
 
27
29
  @dataclass
@@ -12,6 +12,8 @@ class RunState:
12
12
  self.replay: bool = replay_with is not None
13
13
  self.render_succeeded: bool = False
14
14
  self.render_cancelled: bool = False
15
+ # Why the render failed, as the TUI showed it; printed in the summary after the TUI closes.
16
+ self.render_error_message: Optional[str] = None
15
17
  self.render_generated_code_path: Optional[str] = None
16
18
  self.rendered_functionalities: int = 0
17
19
  if replay_with:
@@ -39,6 +41,9 @@ class RunState:
39
41
  def set_render_succeeded(self, succeeded: bool):
40
42
  self.render_succeeded = succeeded
41
43
 
44
+ def set_render_error_message(self, error_message: str):
45
+ self.render_error_message = error_message
46
+
42
47
  def set_render_cancelled(self):
43
48
  self.render_cancelled = True
44
49
 
@@ -31,6 +31,18 @@ AMBIGUITY_CAUSES = {
31
31
  }
32
32
 
33
33
 
34
+ def functionality_position(frids: list[str], frid: Optional[str]) -> Optional[str]:
35
+ """Where a functionality stands among the functionalities of its module, as "3/12".
36
+
37
+ The count is over every functionality of the module, not over a render range, so the number
38
+ says where the render is in the specification whatever part of it was asked for.
39
+ """
40
+ if frid is None or frid not in frids:
41
+ return None
42
+
43
+ return f"{frids.index(frid) + 1}/{len(frids)}"
44
+
45
+
34
46
  def qualified_frid(module_name: Optional[str], frid: Optional[str]) -> Optional[str]:
35
47
  """A functionality named as `<module>:<func-id>`.
36
48
 
@@ -34,7 +34,7 @@ dependencies = [
34
34
 
35
35
  [project.optional-dependencies]
36
36
  dev = [
37
- "pytest==9.1.1",
37
+ "pytest==9.2.0",
38
38
  "flake8==7.4.1",
39
39
  "black==26.10.1",
40
40
  "isort==9.0.2",
@@ -19,6 +19,21 @@ class RenderFunctionalRequirement(BaseAction):
19
19
  FUNCTIONAL_REQUIREMENT_TOO_COMPLEX_OUTCOME = "functional_requirement_too_complex"
20
20
  ITERATION_LIMIT_EXCEEDED_OUTCOME = "frid_iteration_limit_exceeded"
21
21
 
22
+ @staticmethod
23
+ def functionality_heading(render_context) -> str:
24
+ """The block logged when a functionality starts: its module, its ID, and where it stands."""
25
+ msg = "-------------------------------------\n"
26
+ msg += f"Module: {render_context.module_name}\n"
27
+ msg += f"Rendering functionality {render_context.frid_context.frid}"
28
+ position = render_context.current_functionality_position()
29
+ if position:
30
+ msg += f" ({position})"
31
+ if render_context.frid_context.functional_requirement_render_attempts > 1:
32
+ msg += f", attempt number {render_context.frid_context.functional_requirement_render_attempts}/{MAX_CODE_GENERATION_RETRIES}"
33
+ msg += f":\n{render_context.frid_context.functional_requirement_text}\n"
34
+ msg += "-------------------------------------"
35
+ return msg
36
+
22
37
  def execute(self, render_context: RenderContext, _previous_action_payload: Any | None):
23
38
  if render_context.frid_context.functional_requirement_render_attempts >= MAX_CODE_GENERATION_RETRIES:
24
39
  # A render attempt is only restarted once its unit tests used up every fix round.
@@ -49,14 +64,7 @@ class RenderFunctionalRequirement(BaseAction):
49
64
  )
50
65
  _, memory_files_content = MemoryManager.fetch_memory_files(render_context.memory_manager.memory_folder)
51
66
 
52
- msg = "-------------------------------------\n"
53
- msg += f"Module: {render_context.module_name}\n"
54
- msg += f"Rendering functionality {render_context.frid_context.frid}"
55
- if render_context.frid_context.functional_requirement_render_attempts > 1:
56
- msg += f", attempt number {render_context.frid_context.functional_requirement_render_attempts}/{MAX_CODE_GENERATION_RETRIES}"
57
- msg += f":\n{render_context.frid_context.functional_requirement_text}\n"
58
- msg += "-------------------------------------"
59
- console.info(msg)
67
+ console.info(self.functionality_heading(render_context))
60
68
 
61
69
  try:
62
70
  render_utils.print_inputs(render_context, existing_files_content, "Files sent as input to code generation:")
@@ -10,7 +10,7 @@ from event_bus import EventBus
10
10
  from plain2code_console import RETRY_COLOR, console
11
11
  from plain2code_events import RenderContextSnapshot
12
12
  from plain2code_state import RunState
13
- from plain2code_utils import qualified_frid
13
+ from plain2code_utils import functionality_position, qualified_frid
14
14
  from plain_modules import PlainModule
15
15
  from render_machine import triggers
16
16
  from render_machine.conformance_tests import CONFORMANCE_TESTS_DEFINITION_FILE_NAME, ConformanceTests
@@ -122,6 +122,13 @@ class RenderContext:
122
122
  self.last_error_message = error_message
123
123
  self.machine.dispatch(triggers.HANDLE_ERROR)
124
124
 
125
+ def current_functionality_position(self) -> Optional[str]:
126
+ """Where the functionality being implemented stands among those of its module, as "3/12"."""
127
+ return functionality_position(
128
+ list(plain_spec.get_frids(self.plain_source_tree)),
129
+ self.frid_context.frid if self.frid_context else None,
130
+ )
131
+
125
132
  def create_snapshot(self) -> RenderContextSnapshot:
126
133
  return RenderContextSnapshot(
127
134
  frid_context=deepcopy(self.frid_context) if self.frid_context else None,
@@ -133,6 +140,7 @@ class RenderContext:
133
140
  ),
134
141
  script_execution_history=deepcopy(self.script_execution_history),
135
142
  module_name=self.module_name,
143
+ functionality_position=self.current_functionality_position(),
136
144
  )
137
145
 
138
146
  def get_required_modules_functionalities(self):
@@ -10,7 +10,7 @@ rich==15.0.0
10
10
  tiktoken==0.14.0
11
11
  PyYAML==6.0.3
12
12
  gitpython==3.2.1
13
- pytest==9.1.1
13
+ pytest==9.2.0
14
14
  textual>=7.5.0
15
15
  transitions==0.9.3
16
16
  sentry-sdk==2.73.0
@@ -0,0 +1,151 @@
1
+ """Tests for --exit-when-done: the TUI closes by itself once rendering has stopped."""
2
+
3
+ import asyncio
4
+ import threading
5
+
6
+ import pytest
7
+
8
+ from event_bus import EventBus
9
+ from plain2code_arguments import create_parser, parse_arguments
10
+ from plain2code_events import LogMessageEmitted, RenderCompleted, RenderFailed
11
+ from plain2code_state import RunState
12
+ from tui.plain2code_tui import Plain2CodeTUI
13
+
14
+
15
+ def _make_app(run_state: RunState, event_bus: EventBus, exit_when_done: bool, on_ready=lambda: None) -> Plain2CodeTUI:
16
+ return Plain2CodeTUI(
17
+ event_bus=event_bus,
18
+ run_state=run_state,
19
+ on_ready=on_ready,
20
+ render_id="test-render-id",
21
+ unittests_script=None,
22
+ conformance_tests_script=None,
23
+ prepare_environment_script=None,
24
+ state_machine_version="0.0.0",
25
+ exit_when_done=exit_when_done,
26
+ css_path="styles.css",
27
+ )
28
+
29
+
30
+ def _run(exit_when_done: bool, event) -> bool:
31
+ """Publish ``event`` to a mounted TUI and report whether the TUI closed itself."""
32
+
33
+ async def scenario() -> bool:
34
+ event_bus = EventBus()
35
+ run_state = RunState(spec_filename="x.plain")
36
+ app = _make_app(run_state, event_bus, exit_when_done)
37
+ async with app.run_test() as pilot:
38
+ event_bus.publish(event)
39
+ await pilot.pause()
40
+ return app._exit
41
+
42
+ return asyncio.run(scenario())
43
+
44
+
45
+ def test_tui_closes_itself_when_rendering_completes():
46
+ assert _run(True, RenderCompleted(rendered_code_path="plain_modules/x/")) is True
47
+
48
+
49
+ def test_tui_closes_itself_when_rendering_fails():
50
+ assert _run(True, RenderFailed(error_message="Conformance tests failed")) is True
51
+
52
+
53
+ def test_tui_keeps_the_failure_reason_for_the_summary():
54
+ """The TUI closes right away, so the reason it showed must survive on the run state."""
55
+
56
+ async def scenario() -> RunState:
57
+ event_bus = EventBus()
58
+ run_state = RunState(spec_filename="x.plain")
59
+ app = _make_app(run_state, event_bus, True)
60
+ async with app.run_test() as pilot:
61
+ event_bus.publish(RenderFailed(error_message="Conformance tests failed"))
62
+ await pilot.pause()
63
+ return run_state
64
+
65
+ assert asyncio.run(scenario()).render_error_message == "Conformance tests failed"
66
+
67
+
68
+ def test_tui_waits_for_the_user_without_the_option():
69
+ assert _run(False, RenderCompleted(rendered_code_path="plain_modules/x/")) is False
70
+ assert _run(False, RenderFailed(error_message="Conformance tests failed")) is False
71
+
72
+
73
+ def test_tui_closes_itself_when_the_render_thread_reports_completion():
74
+ """The render runs in its own thread, so the completion event reaches the TUI from there."""
75
+
76
+ async def scenario() -> bool:
77
+ event_bus = EventBus()
78
+ run_state = RunState(spec_filename="x.plain")
79
+ app = _make_app(run_state, event_bus, True)
80
+ async with app.run_test() as pilot:
81
+ thread = threading.Thread(
82
+ target=lambda: event_bus.publish(RenderCompleted(rendered_code_path="plain_modules/x/"))
83
+ )
84
+ thread.start()
85
+ thread.join()
86
+ await pilot.pause()
87
+ return app._exit
88
+
89
+ assert asyncio.run(scenario()) is True
90
+
91
+
92
+ def _log(message: str) -> LogMessageEmitted:
93
+ return LogMessageEmitted(logger_name="codeplain", level="INFO", message=message, timestamp="00:00:01")
94
+
95
+
96
+ @pytest.mark.parametrize(
97
+ "event", [RenderCompleted(rendered_code_path="plain_modules/x/"), RenderFailed(error_message="x")]
98
+ )
99
+ def test_tui_closes_cleanly_while_log_lines_are_still_arriving(event):
100
+ """Log lines reach the TUI from the render thread right up to (and past) the final event.
101
+
102
+ Entries still waiting to be drawn when the TUI closes must not crash it: before the fix,
103
+ mounting them into the torn-down log view raised MountError, which run_test re-raises.
104
+ """
105
+
106
+ async def scenario() -> bool:
107
+ event_bus = EventBus()
108
+ run_state = RunState(spec_filename="x.plain")
109
+
110
+ def render():
111
+ for i in range(20):
112
+ event_bus.publish(_log(f"step {i}"))
113
+ event_bus.publish(event)
114
+ for i in range(20):
115
+ event_bus.publish(_log(f"after {i}"))
116
+
117
+ # Started from on_ready, exactly as plain2code.render() starts the render thread.
118
+ render_thread = threading.Thread(target=render, daemon=True)
119
+ app = _make_app(run_state, event_bus, True, on_ready=render_thread.start)
120
+ async with app.run_test() as pilot:
121
+ for _ in range(100):
122
+ if app._exit and not render_thread.is_alive():
123
+ break
124
+ await pilot.pause(0.01)
125
+ return app._exit
126
+
127
+ assert asyncio.run(scenario()) is True
128
+
129
+
130
+ def test_option_is_off_by_default():
131
+ args = create_parser().parse_args(["x.plain"])
132
+ assert args.exit_when_done is False
133
+
134
+
135
+ def test_option_turns_on_from_the_command_line():
136
+ args = create_parser().parse_args(["x.plain", "--exit-when-done"])
137
+ assert args.exit_when_done is True
138
+
139
+
140
+ def test_option_turns_off_from_the_command_line():
141
+ args = create_parser().parse_args(["x.plain", "--no-exit-when-done"])
142
+ assert args.exit_when_done is False
143
+
144
+
145
+ def test_command_line_turns_off_an_exit_configured_in_config_yaml(tmp_path, monkeypatch):
146
+ (tmp_path / "x.plain").write_text("")
147
+ (tmp_path / "config.yaml").write_text("exit-when-done: true\n")
148
+ monkeypatch.chdir(tmp_path)
149
+
150
+ assert parse_arguments([str(tmp_path / "x.plain")]).exit_when_done is True
151
+ assert parse_arguments([str(tmp_path / "x.plain"), "--no-exit-when-done"]).exit_when_done is False
@@ -0,0 +1,90 @@
1
+ """The TUI names the functionality being implemented and where it stands in its module.
2
+
3
+ The func-id says which functionality it is. It does not say how far the module has come, which the
4
+ number before the renderer took func-ids used to say.
5
+ """
6
+
7
+ from types import SimpleNamespace
8
+ from unittest.mock import MagicMock, patch
9
+
10
+ import pytest
11
+
12
+ import file_utils # noqa: F401 # imported before plain_modules, which it imports back from
13
+ from plain2code_events import RenderContextSnapshot
14
+ from plain2code_utils import functionality_position
15
+ from render_machine.actions.render_functional_requirement import RenderFunctionalRequirement
16
+ from tui.state_handlers import FridReadyHandler
17
+
18
+ FRIDS = ["add-login-button", "add-logout-button", "remember-the-session"]
19
+
20
+
21
+ class TestFunctionalityPosition:
22
+ def test_the_first_functionality(self):
23
+ assert functionality_position(FRIDS, "add-login-button") == "1/3"
24
+
25
+ def test_the_last_functionality(self):
26
+ assert functionality_position(FRIDS, "remember-the-session") == "3/3"
27
+
28
+ @pytest.mark.parametrize("frid", [None, "no-such-functionality"], ids=["none", "unknown"])
29
+ def test_nothing_to_place(self, frid):
30
+ assert functionality_position(FRIDS, frid) is None
31
+
32
+ def test_a_module_with_one_functionality(self):
33
+ assert functionality_position(["only-one"], "only-one") == "1/1"
34
+
35
+
36
+ def _snapshot(position):
37
+ return RenderContextSnapshot(
38
+ frid_context=SimpleNamespace(frid="add-login-button", functional_requirement_text="Add a login button."),
39
+ conformance_tests_running_context=None,
40
+ unit_tests_running_context=None,
41
+ script_execution_history=None,
42
+ module_name="",
43
+ functionality_position=position,
44
+ )
45
+
46
+
47
+ def _functionality_line(position):
48
+ handler = FridReadyHandler(MagicMock(), unittests_script=None, conformance_tests_script=None)
49
+ with (
50
+ patch("tui.state_handlers.get_frid_progress") as get_progress,
51
+ patch("tui.state_handlers.update_progress_item_status"),
52
+ ):
53
+ handler.handle([], _snapshot(position), [])
54
+ return get_progress.return_value.update_functionality_text.call_args.args[0]
55
+
56
+
57
+ def test_the_tui_line_carries_the_position():
58
+ assert _functionality_line("3/12") == "Functionality add-login-button (3/12): Add a login button."
59
+
60
+
61
+ def test_the_tui_line_without_a_position_reads_as_before():
62
+ assert _functionality_line(None) == "Functionality add-login-button: Add a login button."
63
+
64
+
65
+ def _log_heading(frids, frid, attempts=1):
66
+ """The heading the renderer logs when it starts a functionality."""
67
+ render_context = SimpleNamespace(
68
+ module_name="shop",
69
+ frid_context=SimpleNamespace(
70
+ frid=frid,
71
+ functional_requirement_text="Add a login button.",
72
+ functional_requirement_render_attempts=attempts,
73
+ ),
74
+ current_functionality_position=lambda: functionality_position(frids, frid),
75
+ )
76
+ return RenderFunctionalRequirement.functionality_heading(render_context)
77
+
78
+
79
+ def test_the_log_heading_carries_the_position():
80
+ assert "Rendering functionality add-login-button (1/3):" in _log_heading(FRIDS, "add-login-button")
81
+
82
+
83
+ def test_the_log_heading_keeps_the_attempt_after_the_position():
84
+ heading = _log_heading(FRIDS, "add-login-button", attempts=2)
85
+
86
+ assert "Rendering functionality add-login-button (1/3), attempt number 2/" in heading
87
+
88
+
89
+ def test_the_log_heading_without_a_position_reads_as_before():
90
+ assert "Rendering functionality add-login-button:" in _log_heading([], "add-login-button")
@@ -569,6 +569,50 @@ def test_render_choices_always_ends_with_quit():
569
569
  assert choices[last_key].module is None
570
570
 
571
571
 
572
+ # --- Block 3: --force-render leaves nothing to choose ---
573
+
574
+
575
+ def test_render_choices_force_render_rerenders_whole_chain_without_a_choice():
576
+ """--force-render renders the whole chain again from the first module, so a single,
577
+ non-interactive choice is returned (no Quit, because the user is never asked)."""
578
+ root, _, leaf = _build_choices_tree(fully_rendered=True)
579
+ pr = PlainModuleRenderState(last_render_module=root, last_render_frid="fr-e")
580
+
581
+ choices = get_render_choices(root, pr, force_render=True)
582
+
583
+ assert _choice_types(choices) == ["rerender_from_first"]
584
+ assert choices["1"].module is leaf
585
+ assert choices["1"].render_range is None
586
+ assert choices["1"].wipe_later_modules is True
587
+
588
+
589
+ def test_render_choices_force_render_ignores_a_detected_change(monkeypatch):
590
+ """A change that would otherwise be offered as a partial render is ignored: the chain is
591
+ rendered again from the first module."""
592
+ root, middle, leaf = _build_choices_tree(fully_rendered=True)
593
+ monkeypatch.setattr(
594
+ partial_rendering, "determine_partial_render_start", lambda pm: PartialRenderStart(module=middle, frid="fr-c")
595
+ )
596
+ pr = PlainModuleRenderState(
597
+ last_render_module=root, last_render_frid="fr-e", change=middle, change_type="spec_change"
598
+ )
599
+
600
+ choices = get_render_choices(root, pr, force_render=True)
601
+
602
+ assert _choice_types(choices) == ["rerender_from_first"]
603
+ assert choices["1"].module is leaf
604
+
605
+
606
+ def test_render_choices_force_render_on_a_module_without_required_modules():
607
+ root = FakeModule("root", fully_rendered=True)
608
+ pr = PlainModuleRenderState(last_render_module=root, last_render_frid="fr-e")
609
+
610
+ choices = get_render_choices(root, pr, force_render=True)
611
+
612
+ assert _choice_types(choices) == ["rerender_from_first"]
613
+ assert choices["1"].module is root
614
+
615
+
572
616
  # -------------------------
573
617
  # change_is_only_future_work
574
618
  # -------------------------
@@ -108,7 +108,7 @@ def make_args(api_key="test-key", headless=False):
108
108
  )
109
109
 
110
110
 
111
- def run_main(render_side_effect=None, api_key="test-key"):
111
+ def run_main(render_side_effect=None, api_key="test-key", print_exit_summary=None):
112
112
  """Drive main() with everything but the reporting path stubbed out.
113
113
 
114
114
  render() is replaced, so the stub is what decides how the render "ended" -
@@ -134,7 +134,7 @@ def run_main(render_side_effect=None, api_key="test-key"):
134
134
  patch("plain2code.setup_logging", return_value="INFO"),
135
135
  patch("plain2code.initialize_telemetry"),
136
136
  patch("plain2code.stop_narrating"),
137
- patch("plain2code.print_exit_summary"),
137
+ patch("plain2code.print_exit_summary", print_exit_summary or MagicMock()),
138
138
  patch("plain2code.dump_crash_logs"),
139
139
  patch("plain2code.capture_crash"),
140
140
  patch("plain2code.codeplain_api.CodeplainAPI", return_value=api),
@@ -204,3 +204,38 @@ class TestMainReportsEveryEnding:
204
204
  api = run_main(api_key=None)
205
205
 
206
206
  api.render_finished.assert_not_called()
207
+
208
+
209
+ class TestSummaryShowsWhyTheRenderFailed:
210
+ """A failure inside the render machine reaches main() only through the run state.
211
+
212
+ The state machine publishes RenderFailed without raising, so render() returns normally
213
+ and main() has no error of its own. The TUI keeps the reason on the run state; with
214
+ --exit-when-done the summary is the only place the user still sees it.
215
+ """
216
+
217
+ def test_the_reason_the_tui_kept_is_printed(self):
218
+ def fail_inside_the_render_machine(run_state):
219
+ run_state.set_render_succeeded(False)
220
+ run_state.set_render_error_message("Conformance tests still fail after 20 attempts.")
221
+
222
+ summary = MagicMock()
223
+ run_main(fail_inside_the_render_machine, print_exit_summary=summary)
224
+
225
+ assert summary.call_args.kwargs["error_message"] == "Conformance tests still fail after 20 attempts."
226
+
227
+ def test_a_raised_error_still_wins(self):
228
+ def fail(run_state):
229
+ run_state.set_render_error_message("reason the TUI kept")
230
+ raise Exception("rendering blew up")
231
+
232
+ summary = MagicMock()
233
+ run_main(fail, print_exit_summary=summary)
234
+
235
+ assert summary.call_args.kwargs["error_message"] == "rendering blew up"
236
+
237
+ def test_a_successful_render_has_no_error_message(self):
238
+ summary = MagicMock()
239
+ run_main(lambda run_state: run_state.set_render_succeeded(True), print_exit_summary=summary)
240
+
241
+ assert summary.call_args.kwargs["error_message"] is None