principles 0.1.3 → 0.1.5

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 (312) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +151 -1
  3. data/README.md +10 -6
  4. data/exe/principles +1 -1
  5. data/lib/principles/cli.rb +9 -10
  6. data/lib/principles/command_line.rb +15 -6
  7. data/lib/principles/command_routes.rb +18 -2
  8. data/lib/principles/controllers/acknowledgement.rb +19 -4
  9. data/lib/principles/controllers/acknowledgements.rb +43 -12
  10. data/lib/principles/controllers/after_commit_report.rb +15 -2
  11. data/lib/principles/controllers/assessment.rb +7 -3
  12. data/lib/principles/controllers/audit.rb +17 -8
  13. data/lib/principles/controllers/audit_completion.rb +34 -9
  14. data/lib/principles/controllers/carrier_edit_report.rb +40 -0
  15. data/lib/principles/controllers/carrier_practices.rb +26 -0
  16. data/lib/principles/controllers/command.rb +36 -5
  17. data/lib/principles/controllers/context_budget.rb +61 -0
  18. data/lib/principles/controllers/correction.rb +15 -5
  19. data/lib/principles/controllers/full_audit_request.rb +38 -42
  20. data/lib/principles/controllers/inventory.rb +78 -71
  21. data/lib/principles/controllers/last_record_notice_beside.rb +51 -0
  22. data/lib/principles/controllers/member_addition.rb +20 -5
  23. data/lib/principles/controllers/member_entries.rb +50 -39
  24. data/lib/principles/controllers/member_entry_changes.rb +71 -0
  25. data/lib/principles/controllers/member_problems_report.rb +26 -6
  26. data/lib/principles/controllers/members_a_commit_changed.rb +14 -5
  27. data/lib/principles/controllers/members_in_logged_requests.rb +52 -0
  28. data/lib/principles/controllers/members_to_assess.rb +35 -8
  29. data/lib/principles/controllers/meta_principle_setup.rb +12 -4
  30. data/lib/principles/controllers/open_correction.rb +3 -2
  31. data/lib/principles/controllers/parts_to_read.rb +48 -6
  32. data/lib/principles/controllers/plugin_member_addition.rb +48 -0
  33. data/lib/principles/controllers/principle_listing.rb +84 -0
  34. data/lib/principles/controllers/request_logging.rb +65 -0
  35. data/lib/principles/controllers/running_tool.rb +55 -15
  36. data/lib/principles/controllers/session_start_report.rb +26 -2
  37. data/lib/principles/data/branches_bringing_in.rb +52 -0
  38. data/lib/principles/data/captured_requests.rb +118 -0
  39. data/lib/principles/data/carrier_page_markers.rb +38 -0
  40. data/lib/principles/data/changes_since.rb +56 -0
  41. data/lib/principles/data/claude_code_home.rb +75 -0
  42. data/lib/principles/data/command-steps.json +139 -23
  43. data/lib/principles/data/decoded_leaf.rb +63 -0
  44. data/lib/principles/data/head_reflog.rb +13 -2
  45. data/lib/principles/data/kept_line.rb +39 -0
  46. data/lib/principles/data/known_marketplaces.rb +50 -0
  47. data/lib/principles/data/logged_request_matches.rb +144 -0
  48. data/lib/principles/data/logged_request_scan.rb +188 -0
  49. data/lib/principles/data/map_files.rb +18 -4
  50. data/lib/principles/data/plugin_folder.rb +85 -0
  51. data/lib/principles/data/plugin_registry.rb +73 -0
  52. data/lib/principles/data/principles_store.rb +49 -0
  53. data/lib/principles/data/project_files.rb +15 -0
  54. data/lib/principles/data/ran.rb +25 -0
  55. data/lib/principles/data/raw_request_filter.rb +61 -0
  56. data/lib/principles/data/repository.rb +29 -27
  57. data/lib/principles/data/request_logging_folder.rb +135 -0
  58. data/lib/principles/data/request_shape.rb +33 -0
  59. data/lib/principles/data/running_version.rb +1 -1
  60. data/lib/principles/data/schemas/acknowledgement-answer.schema.json +16 -1
  61. data/lib/principles/data/schemas/acknowledgements-answer.schema.json +16 -1
  62. data/lib/principles/data/schemas/assessment-answer.schema.json +8 -0
  63. data/lib/principles/data/schemas/command-steps.schema.json +1 -1
  64. data/lib/principles/data/schemas/correction-answer-guide.schema.json +2 -1
  65. data/lib/principles/data/schemas/correction-answer.schema.json +14 -0
  66. data/lib/principles/data/schemas/member-map.schema.json +12 -1
  67. data/lib/principles/data/settings_env_keys.rb +26 -0
  68. data/lib/principles/data/string_counts.rb +39 -0
  69. data/lib/principles/data/tools_on_path.rb +25 -0
  70. data/lib/principles/data/user_request_logging_folder.rb +73 -0
  71. data/lib/principles/invocation_options.rb +5 -3
  72. data/lib/principles/launch.rb +29 -10
  73. data/lib/principles/models/acknowledged_check.rb +11 -1
  74. data/lib/principles/models/acknowledgement.rb +5 -0
  75. data/lib/principles/models/acknowledgement_refusal.rb +20 -11
  76. data/lib/principles/models/acknowledgements_to_offer.rb +86 -0
  77. data/lib/principles/models/after_commit_input.rb +5 -0
  78. data/lib/principles/models/answer_fields.rb +3 -0
  79. data/lib/principles/models/assessment_basis.rb +10 -3
  80. data/lib/principles/models/audit.rb +10 -10
  81. data/lib/principles/models/audit_record.rb +10 -0
  82. data/lib/principles/models/audit_records.rb +4 -3
  83. data/lib/principles/models/audit_start.rb +9 -0
  84. data/lib/principles/models/authored_locator.rb +33 -0
  85. data/lib/principles/models/candidate_files.rb +23 -3
  86. data/lib/principles/models/candidate_outline.rb +18 -125
  87. data/lib/principles/models/captured_sessions.rb +166 -0
  88. data/lib/principles/models/carrier_edit_input.rb +56 -0
  89. data/lib/principles/models/carrier_kind.rb +79 -0
  90. data/lib/principles/models/carrier_pages_shown.rb +28 -0
  91. data/lib/principles/models/carved_message_bytes.rb +115 -0
  92. data/lib/principles/models/cited_files.rb +12 -3
  93. data/lib/principles/models/context_parts.rb +59 -0
  94. data/lib/principles/models/decided_prior_findings.rb +5 -0
  95. data/lib/principles/models/declared_map_changes.rb +22 -13
  96. data/lib/principles/models/disposition.rb +37 -6
  97. data/lib/principles/models/disposition_placeholders.rb +12 -0
  98. data/lib/principles/models/disposition_text_field.rb +4 -0
  99. data/lib/principles/models/dropped_thinking.rb +73 -0
  100. data/lib/principles/models/feature.rb +54 -0
  101. data/lib/principles/models/finding_outcomes.rb +55 -0
  102. data/lib/principles/models/findings_left_open.rb +9 -11
  103. data/lib/principles/models/head_moves.rb +27 -10
  104. data/lib/principles/models/installed_component.rb +55 -0
  105. data/lib/principles/models/installed_plugins.rb +174 -0
  106. data/lib/principles/models/kept_sessions.rb +34 -0
  107. data/lib/principles/models/locator.rb +8 -0
  108. data/lib/principles/models/logged_request_reach.rb +52 -0
  109. data/lib/principles/models/logged_request_scan_completeness.rb +43 -0
  110. data/lib/principles/models/map_format_raise.rb +28 -0
  111. data/lib/principles/models/mapped_baseline.rb +46 -0
  112. data/lib/principles/models/mapped_principles.rb +2 -1
  113. data/lib/principles/models/maps_holding_file_whole.rb +42 -0
  114. data/lib/principles/models/markdown_text.rb +143 -0
  115. data/lib/principles/models/member.rb +19 -1
  116. data/lib/principles/models/member_entry.rb +56 -0
  117. data/lib/principles/models/member_justification.rb +52 -0
  118. data/lib/principles/models/member_lines.rb +11 -0
  119. data/lib/principles/models/member_loads.rb +17 -2
  120. data/lib/principles/models/member_problems.rb +46 -42
  121. data/lib/principles/models/member_reach.rb +59 -0
  122. data/lib/principles/models/member_snapshots.rb +34 -4
  123. data/lib/principles/models/member_text_as_sent.rb +31 -0
  124. data/lib/principles/models/member_texts.rb +45 -0
  125. data/lib/principles/models/members_by_part.rb +67 -0
  126. data/lib/principles/models/members_in_logged_requests.rb +279 -0
  127. data/lib/principles/models/meta_principle.rb +4 -4
  128. data/lib/principles/models/missing_files.rb +41 -16
  129. data/lib/principles/models/nearly_matching_maps.rb +56 -0
  130. data/lib/principles/models/open_correction.rb +5 -0
  131. data/lib/principles/models/open_finding.rb +4 -3
  132. data/lib/principles/models/outline_budget.rb +10 -1
  133. data/lib/principles/models/outline_item.rb +25 -0
  134. data/lib/principles/models/outline_section.rb +15 -4
  135. data/lib/principles/models/part_named.rb +16 -2
  136. data/lib/principles/models/part_token_estimates.rb +60 -0
  137. data/lib/principles/models/plugin_component.rb +37 -0
  138. data/lib/principles/models/plugin_enabled_in_project_settings.rb +61 -0
  139. data/lib/principles/models/plugin_install.rb +33 -0
  140. data/lib/principles/models/plugin_name.rb +23 -0
  141. data/lib/principles/models/plugin_reference.rb +53 -0
  142. data/lib/principles/models/principle.rb +7 -4
  143. data/lib/principles/models/principle_members.rb +22 -0
  144. data/lib/principles/models/prior_finding_decision.rb +1 -1
  145. data/lib/principles/models/prior_finding_outcomes.rb +12 -1
  146. data/lib/principles/models/problem_report.rb +14 -25
  147. data/lib/principles/models/project.rb +51 -56
  148. data/lib/principles/models/project_harness.rb +48 -0
  149. data/lib/principles/models/project_history.rb +19 -5
  150. data/lib/principles/models/recorded_members.rb +7 -0
  151. data/lib/principles/models/report_hooks.rb +9 -4
  152. data/lib/principles/models/request_channel.rb +62 -0
  153. data/lib/principles/models/request_kind.rb +62 -0
  154. data/lib/principles/models/request_logging.rb +231 -0
  155. data/lib/principles/models/request_logging_guard.rb +84 -0
  156. data/lib/principles/models/request_time.rb +46 -0
  157. data/lib/principles/models/runs_from.rb +0 -5
  158. data/lib/principles/models/script_comments.rb +58 -0
  159. data/lib/principles/models/session_registry.rb +61 -0
  160. data/lib/principles/models/session_start_input.rb +11 -2
  161. data/lib/principles/models/session_trend.rb +36 -0
  162. data/lib/principles/models/stale_request.rb +9 -0
  163. data/lib/principles/models/turn_opening.rb +83 -0
  164. data/lib/principles/models/turn_position.rb +43 -0
  165. data/lib/principles/models/unfixed_part.rb +82 -0
  166. data/lib/principles/models/unresolved_plugin_members.rb +35 -0
  167. data/lib/principles/models/user_logged_requests.rb +90 -0
  168. data/lib/principles/models/user_settings_entries.rb +49 -0
  169. data/lib/principles/models/whole_file_member_read.rb +48 -0
  170. data/lib/principles/models/without_prose.rb +20 -0
  171. data/lib/principles/models/workflow_jobs.rb +92 -0
  172. data/lib/principles/show_members_in_logged_requests_options.rb +27 -0
  173. data/lib/principles/show_principle_options.rb +32 -0
  174. data/lib/principles/version.rb +2 -2
  175. data/lib/principles/views/acknowledged_result.rb +31 -12
  176. data/lib/principles/views/acknowledgement_result.rb +18 -13
  177. data/lib/principles/views/acknowledgement_template_alone.rb +55 -0
  178. data/lib/principles/views/acknowledgements_offered.rb +54 -0
  179. data/lib/principles/views/added_member.rb +22 -6
  180. data/lib/principles/views/answer_in_a_file.rb +15 -15
  181. data/lib/principles/views/assessed_members.rb +19 -8
  182. data/lib/principles/views/assessment_request.rb +14 -6
  183. data/lib/principles/views/audit_changes.rb +14 -8
  184. data/lib/principles/views/audit_findings.rb +34 -0
  185. data/lib/principles/views/audit_result.rb +26 -24
  186. data/lib/principles/views/candidate_files_result.rb +1 -1
  187. data/lib/principles/views/carrier_checks.rb +40 -0
  188. data/lib/principles/views/carrier_edit_denial.rb +36 -0
  189. data/lib/principles/views/carrier_practices_page.rb +49 -0
  190. data/lib/principles/views/completed_audit_findings.rb +33 -0
  191. data/lib/principles/views/completed_audit_next_step.rb +12 -4
  192. data/lib/principles/views/consecutive_sections_elsewhere.rb +4 -0
  193. data/lib/principles/views/context_budget_result.rb +99 -0
  194. data/lib/principles/views/context_parts.rb +129 -25
  195. data/lib/principles/views/correction_request.rb +32 -17
  196. data/lib/principles/views/disposition_template.rb +35 -0
  197. data/lib/principles/views/first_audit.rb +29 -15
  198. data/lib/principles/views/first_audit_line.rb +4 -5
  199. data/lib/principles/views/hook_setup_result.rb +3 -1
  200. data/lib/principles/views/invocation.rb +14 -5
  201. data/lib/principles/views/last_record_notice.rb +41 -0
  202. data/lib/principles/views/lines_shared_with_member.rb +16 -22
  203. data/lib/principles/views/logged_request_status_meanings.rb +29 -0
  204. data/lib/principles/views/logged_requests_evidence.rb +84 -0
  205. data/lib/principles/views/map_added_to.rb +14 -12
  206. data/lib/principles/views/map_format_raised.rb +28 -0
  207. data/lib/principles/views/map_result.rb +41 -18
  208. data/lib/principles/views/maps_needing_members_or_audit.rb +1 -1
  209. data/lib/principles/views/member_change_since_baseline.rb +4 -0
  210. data/lib/principles/views/member_row.rb +13 -4
  211. data/lib/principles/views/member_sets_overlap.rb +31 -0
  212. data/lib/principles/views/members_a_commit_changed.rb +42 -25
  213. data/lib/principles/views/members_changed_during_audit.rb +27 -0
  214. data/lib/principles/views/members_in_logged_requests_result.rb +123 -0
  215. data/lib/principles/views/members_too_short_to_scan.rb +45 -0
  216. data/lib/principles/views/members_with_no_baseline.rb +6 -6
  217. data/lib/principles/views/meta_principle_result.rb +52 -15
  218. data/lib/principles/views/open_findings_line.rb +31 -92
  219. data/lib/principles/views/parts_index_result.rb +9 -5
  220. data/lib/principles/views/principle_read_result.rb +52 -11
  221. data/lib/principles/views/prior_findings_result.rb +9 -1
  222. data/lib/principles/views/problem_facts.rb +5 -3
  223. data/lib/principles/views/problem_lines.rb +54 -6
  224. data/lib/principles/views/problem_result.rb +7 -15
  225. data/lib/principles/views/prompts/assess-every-member/ask-whether-a-member-seen-only-as-read-is-loaded.md +3 -0
  226. data/lib/principles/views/prompts/assess-every-member/ask-whether-each-reason-holds.md +2 -0
  227. data/lib/principles/views/prompts/assess-every-member/claim-an-earlier-first-raised-at.md +6 -6
  228. data/lib/principles/views/prompts/assess-every-member/judge-the-keeping-against-the-other-principles.md +2 -0
  229. data/lib/principles/views/prompts/assess-every-member/read-a-compact-carried-member.md +9 -8
  230. data/lib/principles/views/prompts/assess-every-member/read-a-flagged-member-s-text-whole.md +3 -0
  231. data/lib/principles/views/prompts/assess-every-member/read-a-judged-member-s-text-whole.md +3 -0
  232. data/lib/principles/views/prompts/assess-every-member/turn-on-request-logging-to-see-what-reaches-context.md +2 -0
  233. data/lib/principles/views/prompts/assess-every-member/weigh-what-reached-the-context.md +7 -0
  234. data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +1 -0
  235. data/lib/principles/views/prompts/dispose-of-each-finding/fix-or-record-each-finding.md +6 -1
  236. data/lib/principles/views/prompts/dispose-of-each-finding/read-the-carrier-page-before-fixing.md +1 -0
  237. data/lib/principles/views/prompts/edit-a-carrier/read-the-page-before-the-first-edit.md +2 -0
  238. data/lib/principles/views/prompts/find-a-principle-to-map/read-a-cut-section-back.md +1 -1
  239. data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-hook-configuration.md +41 -0
  240. data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-hook-scripts.md +35 -0
  241. data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-instruction-files.md +37 -0
  242. data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-other-text-an-agent-reads.md +38 -0
  243. data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-rule-files.md +34 -0
  244. data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-skills.md +35 -0
  245. data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-subagent-definitions.md +35 -0
  246. data/lib/principles/views/prompts/learn-what-a-command-does/add-member.md +49 -51
  247. data/lib/principles/views/prompts/learn-what-a-command-does/change-member-name.md +12 -0
  248. data/lib/principles/views/prompts/learn-what-a-command-does/change-member-reason.md +12 -0
  249. data/lib/principles/views/prompts/learn-what-a-command-does/change-member-role.md +2 -1
  250. data/lib/principles/views/prompts/learn-what-a-command-does/every-command-and-how-they-chain.md +1 -1
  251. data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +1 -1
  252. data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +32 -32
  253. data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +10 -11
  254. data/lib/principles/views/prompts/learn-what-a-command-does/move-member.md +7 -6
  255. data/lib/principles/views/prompts/learn-what-a-command-does/remove-logged-requests.md +22 -0
  256. data/lib/principles/views/prompts/learn-what-a-command-does/remove-member.md +2 -1
  257. data/lib/principles/views/prompts/learn-what-a-command-does/report-at-session-start.md +8 -4
  258. data/lib/principles/views/prompts/learn-what-a-command-does/report-before-carrier-edit.md +13 -0
  259. data/lib/principles/views/prompts/learn-what-a-command-does/show-audit.md +7 -0
  260. data/lib/principles/views/prompts/learn-what-a-command-does/show-candidate-outlines.md +8 -2
  261. data/lib/principles/views/prompts/learn-what-a-command-does/show-carrier-practices.md +13 -0
  262. data/lib/principles/views/prompts/learn-what-a-command-does/show-context-budget.md +69 -0
  263. data/lib/principles/views/prompts/learn-what-a-command-does/show-hook-setup.md +4 -4
  264. data/lib/principles/views/prompts/learn-what-a-command-does/show-logged-requests.md +22 -0
  265. data/lib/principles/views/prompts/learn-what-a-command-does/show-members-in-logged-requests.md +62 -0
  266. data/lib/principles/views/prompts/learn-what-a-command-does/show-meta-principle-passage.md +13 -10
  267. data/lib/principles/views/prompts/learn-what-a-command-does/show-principle.md +16 -16
  268. data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +27 -27
  269. data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +17 -17
  270. data/lib/principles/views/prompts/learn-what-a-command-does/turn-off-request-logging.md +18 -0
  271. data/lib/principles/views/prompts/learn-what-a-command-does/turn-on-request-logging.md +44 -0
  272. data/lib/principles/views/prompts/read-requested-outlines/continue-the-survey.md +3 -2
  273. data/lib/principles/views/prompts/read-what-reached-the-context/explain-request-logging-to-the-user.md +11 -0
  274. data/lib/principles/views/prompts/read-what-reached-the-context/explain-user-request-logging-to-the-user.md +10 -0
  275. data/lib/principles/views/prompts/read-what-reached-the-context/see-whether-members-reach-the-agent.md +2 -0
  276. data/lib/principles/views/prompts/read-what-reached-the-context/what-a-thread-continuation-holds.md +3 -0
  277. data/lib/principles/views/prompts/read-what-reached-the-context/what-absent-means.md +2 -0
  278. data/lib/principles/views/prompts/read-what-reached-the-context/what-each-context-budget-line-says.md +4 -0
  279. data/lib/principles/views/prompts/read-what-reached-the-context/what-each-member-line-says.md +2 -0
  280. data/lib/principles/views/prompts/read-what-reached-the-context/what-not-a-carrier-means.md +2 -0
  281. data/lib/principles/views/prompts/read-what-reached-the-context/what-present-but-not-loaded-means.md +2 -0
  282. data/lib/principles/views/prompts/read-what-reached-the-context/what-present-means.md +1 -0
  283. data/lib/principles/views/prompts/read-what-reached-the-context/what-unmeasurable-means.md +2 -0
  284. data/lib/principles/views/prompts/report-after-a-commit/a-row-ending-audit-asks-to-acknowledge-or-audit-again.md +1 -0
  285. data/lib/principles/views/prompts/report-after-a-commit/a-row-ending-mapping-commit-asks-for-an-audit.md +1 -0
  286. data/lib/principles/views/prompts/report-after-a-commit/a-row-ending-pinned-asks-for-an-audit.md +1 -0
  287. data/lib/principles/views/prompts/report-after-a-commit/plugin-members-are-still-listed.md +1 -0
  288. data/lib/principles/views/prompts/report-after-a-commit/the-commits-changed-these-members-waiting-on-an-upgrade.md +2 -2
  289. data/lib/principles/views/prompts/report-after-a-commit/the-commits-changed-these-members.md +2 -2
  290. data/lib/principles/views/prompts/report-after-a-commit/this-command-shows-what-each-needs-before-the-next-commit.md +1 -0
  291. data/lib/principles/views/prompts/run-a-first-audit-in-the-background/follow-the-brief.md +1 -0
  292. data/lib/principles/views/prompts/set-principles-up/ask-to-set-principles-up-after-an-audit.md +1 -0
  293. data/lib/principles/views/prompts/set-principles-up/entry-file-passage.md +1 -1
  294. data/lib/principles/views/prompts/set-principles-up/map-the-enabling-line-at-no-edit.md +3 -0
  295. data/lib/principles/views/prompts/set-principles-up/name-the-step-each-member-lacks.md +2 -2
  296. data/lib/principles/views/prompts/set-principles-up/place-the-passage-with-the-user.md +4 -2
  297. data/lib/principles/views/prompts/set-principles-up/what-the-passage-presumes.md +1 -1
  298. data/lib/principles/views/prompts/set-principles-up/why-set-principles-up.md +1 -0
  299. data/lib/principles/views/prompts/start-a-session/act-on-the-open-findings.md +2 -1
  300. data/lib/principles/views/prompts/start-a-session/ask-to-set-principles-up.md +2 -0
  301. data/lib/principles/views/prompts/start-a-session/hand-the-first-audit-to-a-subagent.md +2 -3
  302. data/lib/principles/views/prompts/start-a-session/name-the-principles-nothing-checks.md +1 -0
  303. data/lib/principles/views/prompts/start-a-session/raise-the-open-findings-waiting-on-no-one.md +1 -0
  304. data/lib/principles/views/request_logging_result.rb +108 -0
  305. data/lib/principles/views/request_part.rb +10 -4
  306. data/lib/principles/views/request_parts.rb +9 -0
  307. data/lib/principles/views/set_up_offer_line.rb +43 -0
  308. data/lib/principles/views/whole_file_elsewhere.rb +30 -0
  309. metadata +154 -5
  310. data/lib/principles/views/prompts/report-after-a-commit/the-principles-skill-is-where-to-start.md +0 -1
  311. data/lib/principles/views/prompts/report-after-a-commit/this-command-shows-each-one.md +0 -1
  312. data/lib/principles/views/prompts/set-principles-up/keep-them-held-between-audits.md +0 -2
@@ -0,0 +1,45 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Principles
5
+ # What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
6
+ module Views
7
+ # What list-member-problems adds, while requests are logged, for each member too short to find in a logged
8
+ # request: it lists each under too_short_to_scan, and its next_action asks for the move that widens each, after
9
+ # every other action, since the member's own text is as fresh as before.
10
+ class MembersTooShortToScan
11
+ # members is each such member by its principle, id and the move-member options that widen it, placeholders
12
+ # left to fill; invocation names the commands.
13
+ #: (Invocation, Array[Hash[String, String]]) -> void
14
+ def initialize(invocation, members)
15
+ @invocation = invocation
16
+ @members = members
17
+ freeze
18
+ end
19
+
20
+ # report, list-member-problems' result whose next_action names a command as names_a_command says, with these
21
+ # members added, and whether its next_action names a command now.
22
+ #: (Hash[String, untyped], bool, nothing_changed: String) -> [Hash[String, untyped], bool]
23
+ def added_to(report, names_a_command, nothing_changed:)
24
+ return [report, names_a_command] if @members.empty?
25
+
26
+ action = report.fetch("next_action")
27
+ earlier = action == nothing_changed ? [] : [action]
28
+ [report.merge("too_short_to_scan" => @members.map { it.slice("principle", "id") },
29
+ "next_action" => [*earlier, *@members.map { widen(it) }].join("\n")), true]
30
+ end
31
+
32
+ private
33
+
34
+ # The line asking to widen member, with the move that does it.
35
+ #: (Hash[String, String]) -> String
36
+ def widen(member)
37
+ principle = member.fetch("principle")
38
+ id = member.fetch("id")
39
+ "#{id} of #{principle} has no line long enough to find in a logged request, so the scan cannot show " \
40
+ "whether it reached the agent; widen it to take in a longer line: " \
41
+ "#{@invocation.in_project("move-member", principle, id, usage: member.fetch("move"))}"
42
+ end
43
+ end
44
+ end
45
+ end
@@ -39,18 +39,18 @@ module Principles
39
39
  #: () -> bool
40
40
  def committing? = @because == "not_committed" && !@files.empty?
41
41
 
42
- # What gives the members a baseline: a completed audit outside git, or in git committing the files that
43
- # differ from HEAD, or an audit again when none does, since every file is committed already. The
44
- # audit command starts a line of its own, after its purpose.
42
+ # What the agent does to give the members a baseline, as one imperative: complete an audit outside git, or
43
+ # in git commit the files that differ from HEAD, or audit again when none does, since every file is
44
+ # committed already. The audit command starts a line of its own, after its purpose.
45
45
  #: () -> String
46
46
  def remedy
47
- return " Committing #{ProseList.new(@files)} #{gives}." if committing?
47
+ return " Commit #{ProseList.new(@files)} #{to_give}." if committing?
48
48
 
49
- "#{all_committed if @because == "not_committed"}\nA completed audit #{gives}: #{@audit}"
49
+ "#{all_committed if @because == "not_committed"}\nRun this audit #{to_give}: #{@audit}"
50
50
  end
51
51
 
52
52
  #: () -> String
53
- def gives = "gives #{one? ? "it" : "each"} one"
53
+ def to_give = "to give #{one? ? "it" : "each"} one"
54
54
 
55
55
  #: () -> String
56
56
  def all_committed
@@ -14,10 +14,13 @@ module Principles
14
14
  # files, the one passage any of them would take, and the commands that map the passage once the agent has placed
15
15
  # it with the user.
16
16
  class MetaPrincipleResult
17
+ # The placeholders each printed add-member leaves for the name and reason that justify its member.
18
+ JUSTIFYING = "--name NAME --reason REASON" #: String
19
+
17
20
  # How the printed add-member commands map the passage: heading is the passage's heading, which they name as
18
21
  # its member's section, beside role, the role they give that member; step_role is the role they give a
19
22
  # passage the project has that carries one of the passage's steps, and place_role the one they give any other
20
- # place that keeps the principles held, such as a timer or a settings line.
23
+ # place that has the principles checked, such as a timer or a settings line.
21
24
  class PassageMapping
22
25
  #: String
23
26
  attr_reader :heading, :role, :step_role, :place_role
@@ -76,12 +79,15 @@ module Principles
76
79
  # Where the passage can go, as the agent places it from: how this run was started and whether the plugin's
77
80
  # session-start hook runs in this session, each root entry file's facts, and the passage.
78
81
  class Placement
82
+ # enabled_in_project_settings is the project settings line that enables the plugin, by path and starting_at.
79
83
  #: (runs_from: String, session_start_hook_in_this_session: bool, entry_files: Array[Hash[String, untyped]],
80
- #| passage: Passage) -> void
81
- def initialize(runs_from:, session_start_hook_in_this_session:, entry_files:, passage:)
84
+ #| passage: Passage, ?enabled_in_project_settings: Hash[String, String]?) -> void
85
+ def initialize(runs_from:, session_start_hook_in_this_session:, entry_files:, passage:,
86
+ enabled_in_project_settings: nil)
82
87
  @fields = { "runs_from" => runs_from,
83
88
  "session_start_hook_in_this_session" => session_start_hook_in_this_session,
84
- "entry_files" => entry_files, "passage" => passage.to_h }.freeze #: Hash[String, untyped]
89
+ "entry_files" => entry_files, "passage" => passage.to_h,
90
+ "enabled_in_project_settings" => enabled_in_project_settings }.freeze #: Hash[String, untyped]
85
91
  @passage = passage
86
92
  freeze
87
93
  end
@@ -93,6 +99,10 @@ module Principles
93
99
  #: () -> Integer
94
100
  def estimated_tokens = @passage.estimated_tokens
95
101
 
102
+ # The project settings line that enables the plugin, or nil.
103
+ #: () -> Hash[String, String]?
104
+ def enabling_line = @fields.fetch("enabled_in_project_settings")
105
+
96
106
  # Whether the plugin's hooks report in this session, so its hook entries need no offer.
97
107
  #: () -> bool
98
108
  def hooks_run? = @fields.fetch("session_start_hook_in_this_session")
@@ -104,11 +114,14 @@ module Principles
104
114
  class MapInProject
105
115
  #: bool
106
116
  attr_reader :set_up
117
+ #: bool
118
+ attr_reader :already_mapped
107
119
 
108
120
  #: (already_mapped: bool, members_in_entry_files: Array[Hash[String, String]], set_up: bool) -> void
109
121
  def initialize(already_mapped:, members_in_entry_files:, set_up:)
110
122
  @fields = { "already_mapped" => already_mapped,
111
123
  "members_in_entry_files" => members_in_entry_files }.freeze #: Hash[String, untyped]
124
+ @already_mapped = already_mapped
112
125
  @set_up = set_up
113
126
  freeze
114
127
  end
@@ -122,22 +135,44 @@ module Principles
122
135
  #: (PrintedPrinciple, Placement, MapInProject, existing_principles: Array[Hash[String, untyped]])
123
136
  #| -> Hash[String, untyped]
124
137
  def proposal(principle, placement, map_in_project, existing_principles:)
125
- hook_setup = placement.hooks_run? ? {} : { "hook_setup" => ReportHooksOffer.new(@invocation).to_s }
126
138
  { "status" => "question", "principle_id" => principle.id, "map_file" => principle.file,
127
- "map" => principle.map, **map_in_project.to_h, **placement.to_h, **hook_setup,
139
+ "map" => principle.map, **map_in_project.to_h, **placement.to_h,
140
+ **hook_setup(placement, mapped: map_in_project.already_mapped || existing_principles.any?),
128
141
  "existing_principles" => existing_principles,
129
- "question" => map_in_project.set_up ? steps_lacking(principle, placement) : question(principle.id),
142
+ "question" => map_in_project.set_up ? steps_lacking(principle, placement) : question(principle.id, placement),
130
143
  "answer_with" => add_member(principle.id), "next_action" => next_action(principle.id, existing_principles) }
131
144
  end
132
145
 
133
146
  private
134
147
 
148
+ # The hook entries that report changed members, offered only while the plugin's hooks do not run and once a map
149
+ # exists, since before any map they report nothing.
150
+ #: (Placement, mapped: bool) -> Hash[String, String]
151
+ def hook_setup(placement, mapped:)
152
+ return {} if placement.hooks_run? || !mapped
153
+
154
+ { "hook_setup" => ReportHooksOffer.new(@invocation).to_s }
155
+ end
156
+
135
157
  # What to agree with the user and place, with the command that maps a passage the project has in a step's
136
158
  # place, and the one that maps the passage once it is placed.
137
- #: (String) -> String
138
- def question(id)
139
- Prompts.text("set-principles-up/place-the-passage-with-the-user",
140
- command: add_member(id), existing: add_existing(id), any_place: add_place(id))
159
+ #: (String, Placement) -> String
160
+ def question(id, placement)
161
+ place = Prompts.text("set-principles-up/place-the-passage-with-the-user",
162
+ command: add_member(id), existing: add_existing(id), any_place: add_place(id),
163
+ why: Prompts.text("set-principles-up/why-set-principles-up"))
164
+ line = placement.enabling_line or return place
165
+
166
+ "#{Prompts.text("set-principles-up/map-the-enabling-line-at-no-edit",
167
+ path: line.fetch("path"), command: add_enabling_line(id, line))}\n\n#{place}"
168
+ end
169
+
170
+ # The add-member that maps the project settings line enabling the plugin, located by its literal opening.
171
+ #: (String, Hash[String, String]) -> String
172
+ def add_enabling_line(id, line)
173
+ @invocation.in_project("add-member", id, line.fetch("path"),
174
+ options: ["--starting-at", line.fetch("starting_at"), "--role", @mapping.place_role,
175
+ *JUSTIFYING.split])
141
176
  end
142
177
 
143
178
  # Each mapped member's place and role, and which keeping step each lacks, with the passage as one way to add a
@@ -150,23 +185,25 @@ module Principles
150
185
  estimated_tokens: placement.estimated_tokens.to_s)
151
186
  end
152
187
 
153
- # The add-member that maps any other place that keeps the principles held, by its path and a role naming the
188
+ # The add-member that maps any other place that has the principles checked, by its path and a role naming the
154
189
  # step it runs and what starts it.
155
190
  #: (String) -> String
156
191
  def add_place(id)
157
- @invocation.in_project("add-member", id, usage: "PATH --role \"#{@mapping.place_role}\"")
192
+ @invocation.in_project("add-member", id, usage: "PATH --role \"#{@mapping.place_role}\" #{JUSTIFYING}")
158
193
  end
159
194
 
160
195
  # The add-member that maps a passage the project already has, which carries one of the passage's steps.
161
196
  #: (String) -> String
162
197
  def add_existing(id)
163
- @invocation.in_project("add-member", id, usage: "PATH --section \"HEADING\" --role \"#{@mapping.step_role}\"")
198
+ @invocation.in_project("add-member", id,
199
+ usage: "PATH --section \"HEADING\" --role \"#{@mapping.step_role}\" #{JUSTIFYING}")
164
200
  end
165
201
 
166
202
  #: (String) -> String
167
203
  def add_member(id)
168
204
  @invocation.in_project("add-member", id,
169
- usage: "ENTRY_FILE --section \"#{@mapping.heading}\" --role \"#{@mapping.role}\"")
205
+ usage: "ENTRY_FILE --section \"#{@mapping.heading}\" --role \"#{@mapping.role}\" " \
206
+ "#{JUSTIFYING}")
170
207
  end
171
208
 
172
209
  # What follows placing the passage: committing it, which outside git is not the member's baseline, and the
@@ -10,14 +10,11 @@ module Principles
10
10
  # What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
11
11
  module Views
12
12
  # list-open-findings --short: the one line a session-start hook puts into the agent's context while any
13
- # finding is open that someone should raise, and nothing when none is. It states the facts the agent judges
14
- # from, how many wait on someone named or on no one, whom the oldest of the former waits on and for how long,
15
- # and git's user name, then says to raise each that waits on its user, and why, with the command that lists
16
- # them all.
13
+ # finding is open that someone should raise, and nothing when none is. It says first to act on each that waits
14
+ # on the agent and to raise each that waits on a person, and why, then states the facts the agent judges from,
15
+ # how many wait on someone named or on no one and how long the oldest has, with the command that lists whom
16
+ # each waits on.
17
17
  class OpenFindingsLine
18
- # A waits_on longer than this is cut, so the line stays one short line.
19
- WAITS_ON_LIMIT = 80
20
-
21
18
  # The session's start the line is worded for, as Claude Code's SessionStart hook names it: startup, resume,
22
19
  # clear or compact. It says what the context holds already, and so which reply raises the findings.
23
20
  class SessionStart
@@ -59,20 +56,9 @@ module Principles
59
56
  #: () -> Integer
60
57
  def unnamed = @fields.fetch("waiting_on_no_one_named")
61
58
 
62
- #: () -> Integer
63
- def to_raise = @fields.fetch("to_raise")
64
-
65
- # Whether the one finding to raise is one waiting on someone named, whose own line names its need.
66
- #: () -> bool
67
- def alone? = to_raise == 1 && named == 1
68
-
69
59
  # The oldest open finding of all, by principle and finding_id.
70
60
  #: () -> Hash[String, untyped]
71
61
  def oldest = @fields.slice("principle", "finding_id")
72
-
73
- # The oldest finding waiting on someone named, by principle, finding_id and waits_on, or nil.
74
- #: () -> Hash[String, untyped]?
75
- def oldest_named = @fields["oldest_waiting_on_someone"]
76
62
  end
77
63
 
78
64
  #: (Invocation) -> void
@@ -84,77 +70,61 @@ module Principles
84
70
  # waiting is nil when no finding is open, or the count of open findings with the oldest one's principle,
85
71
  # finding_id, days_open, how many wait on someone named and the oldest of those, or nil. not_found is each
86
72
  # open finding, by principle and finding_id, whose write-up can no longer be found where its recorded_at
87
- # points. source is the session's start: startup, resume, clear or compact. user_name is git's, or nil.
88
- #: (Hash[String, untyped]?, ?Array[Hash[String, untyped]], ?source: String, ?user_name: String?) -> Lines
89
- def short(waiting, not_found = [], source: "startup", user_name: nil)
90
- Lines.new(stdout: lines(waiting, not_found, source:, user_name:).map { "#{it}\n" }.join, stderr: "", status: 0)
73
+ # points. source is the session's start: startup, resume, clear or compact.
74
+ #: (Hash[String, untyped]?, ?Array[Hash[String, untyped]], ?source: String) -> Lines
75
+ def short(waiting, not_found = [], source: "startup")
76
+ Lines.new(stdout: lines(waiting, not_found, source:).map { "#{it}\n" }.join, stderr: "", status: 0)
91
77
  end
92
78
 
93
79
  # short's line, as a list of none or one, which report-at-session-start prints among its own.
94
- #: (Hash[String, untyped]?, ?Array[Hash[String, untyped]], ?source: String, ?user_name: String?) -> Array[String]
95
- def lines(waiting, not_found = [], source: "startup", user_name: nil)
80
+ #: (Hash[String, untyped]?, ?Array[Hash[String, untyped]], ?source: String) -> Array[String]
81
+ def lines(waiting, not_found = [], source: "startup")
96
82
  start = SessionStart.new(source)
97
83
  return [] unless waiting
98
84
 
99
85
  waiting = Waiting.new(waiting)
100
86
  return [resumed("#{how_long(waiting)} (#{oldest(waiting.oldest)})", not_found)] if start.resumed?
101
- return [] if waiting.to_raise.zero?
102
87
 
103
- [whole(waiting, not_found, start, user_name)]
88
+ [whole(waiting, not_found, start)]
104
89
  end
105
90
 
106
91
  private
107
92
 
108
- # The line with what to do about the findings, for a context that does not hold it yet: the facts, then the
109
- # reply that raises them and why, then the command listing them all, which one finding's own need replaces.
110
- #: (Waiting, Array[Hash[String, untyped]], SessionStart, String?) -> String
111
- def whole(waiting, not_found, start, user_name)
112
- Prompts.text("start-a-session/act-on-the-open-findings",
113
- facts: "#{waiting_on_someone(waiting)}#{no_one_named(waiting)}#{write_ups(not_found)}" \
114
- "#{git_user(user_name) unless waiting.named.zero?}",
115
- raise: raise_which(waiting), reply: start.reply, command: waiting.alone? ? "" : " All: #{all}")
93
+ # The line with what to do about the findings, for a context that does not hold it yet: the reply that raises
94
+ # them and why, then the facts, then the command listing them all with whom each waits on. With none naming
95
+ # anyone, none can wait on the agent, so it says only to raise them.
96
+ #: (Waiting, Array[Hash[String, untyped]], SessionStart) -> String
97
+ def whole(waiting, not_found, start)
98
+ values = { reply: start.reply, command: all,
99
+ facts: "#{counts(waiting)}, the oldest #{age(waiting.days_open)}.#{write_ups(not_found)}" }
100
+ return Prompts.text("start-a-session/raise-the-open-findings-waiting-on-no-one", **values) \
101
+ if waiting.named.zero?
102
+
103
+ Prompts.text("start-a-session/act-on-the-open-findings", whom: whom(waiting), **values)
116
104
  end
117
105
 
118
106
  # The command listing every open finding, a line each.
119
107
  #: () -> String
120
108
  def all = @invocation.in_project("list-open-findings", options: ["--lines"])
121
109
 
122
- # Which findings the agent raises: the one, if it waits on its user, or each that does, with those waiting on
123
- # no one, or each when none names anyone.
110
+ # Whom the findings the agent raises wait on, while some name someone, once it acts on those that wait on
111
+ # itself: a person, and no one, if any names none, since nothing else will raise those either.
124
112
  #: (Waiting) -> String
125
- def raise_which(waiting)
126
- return "If it waits on your user, raise it" if waiting.alone?
127
- return "Raise each" if waiting.named.zero?
113
+ def whom(waiting) = "a person#{" or on no one" if waiting.unnamed.positive?}"
128
114
 
129
- "Raise each that waits on your user#{" or on no one" if waiting.unnamed.positive?}"
130
- end
131
-
132
- # The sentence naming the oldest finding that waits on someone named, and whom, counting them when several do.
115
+ # How many wait on someone named and on no one, the first counted as the sentence's subject.
133
116
  #: (Waiting) -> String
134
- def waiting_on_someone(waiting)
135
- oldest = waiting.oldest_named or return ""
136
- need = need(oldest.fetch("waits_on"))
137
- need = "#{need}." unless need.end_with?(".")
138
- named = "#{oldest(oldest)}, #{age(oldest.fetch("days_open"))},"
139
- return "Open finding #{named} waits on: #{need}" if waiting.named == 1
140
-
141
- "#{counted(waiting.named)} on someone; the oldest, #{named} waits on: #{need}"
117
+ def counts(waiting)
118
+ unnamed = waiting.unnamed
119
+ return "#{counted(unnamed)} on no one named" if waiting.named.zero?
120
+
121
+ "#{counted(waiting.named)} on someone named#{", #{unnamed} on no one" if unnamed.positive?}"
142
122
  end
143
123
 
144
124
  # How long a finding has gone unraised, in whole days.
145
125
  #: (Integer) -> String
146
126
  def age(days) = "open #{days} #{days == 1 ? "day" : "days"}"
147
127
 
148
- # The sentence counting the findings deferred with no waits_on, after any naming someone.
149
- #: (Waiting) -> String
150
- def no_one_named(waiting)
151
- unnamed = waiting.unnamed
152
- return "" if unnamed.zero?
153
- return " #{unnamed} #{unnamed == 1 ? "waits" : "wait"} on no one named." if waiting.named.positive?
154
-
155
- "#{counted(unnamed)} on no one named."
156
- end
157
-
158
128
  # How many open findings wait, as the subject of the sentence saying on whom.
159
129
  #: (Integer) -> String
160
130
  def counted(count) = count == 1 ? "1 open finding waits" : "#{count} open findings wait"
@@ -168,14 +138,6 @@ module Principles
168
138
  command: @invocation.in_project("list-open-findings", options: ["--short"]))
169
139
  end
170
140
 
171
- # git's user name as a fact, for the agent to judge whether the person a finding waits on is its user.
172
- #: (String?) -> String
173
- def git_user(name)
174
- return " git has no user.name set." unless name
175
-
176
- " git's user.name is #{VisibleText.new(name)}."
177
- end
178
-
179
141
  # The sentence naming the write-ups that can no longer be found, the first by its principle and id, or
180
142
  # nothing when every pointer resolves, so the usual line is unchanged.
181
143
  #: (Array[Hash[String, untyped]]) -> String
@@ -206,32 +168,9 @@ module Principles
206
168
  "for #{days} #{days == 1 ? "day" : "days"}"
207
169
  end
208
170
 
209
- # A finding's waits_on, cut when long. It is free text, so it is cut by characters first and then escaped,
210
- # which may run past the limit to show it.
211
- #: (String) -> String
212
- def need(waits_on)
213
- waits_on = closed("#{whole_words(waits_on[0, WAITS_ON_LIMIT - 3].to_s)}...") if waits_on.length > WAITS_ON_LIMIT
214
- VisibleText.new(waits_on).to_s
215
- end
216
-
217
- # A cut waits_on up to its last whole word, so it never ends in part of one, or as cut when it is one
218
- # word, which has no boundary to cut at.
219
- #: (String) -> String
220
- def whole_words(cut)
221
- boundary = cut.rindex(" ") or return cut
222
- cut[0, boundary].to_s
223
- end
224
-
225
171
  # The oldest finding's principle and id, which is free text and so escaped.
226
172
  #: (Hash[String, untyped]) -> String
227
173
  def oldest(waiting) = "#{waiting.fetch("principle")} #{VisibleText.new(waiting.fetch("finding_id"))}"
228
-
229
- # A cut waits_on with a ")" for each "(" the cut left open, so the line's own parenthesis still reads as
230
- # closing the finding's name.
231
- #: (String) -> String
232
- def closed(cut)
233
- cut + (")" * [cut.count("(") - cut.count(")"), 0].max)
234
- end
235
174
  end
236
175
  end
237
176
  end
@@ -31,7 +31,7 @@ module Principles
31
31
  "unless you judge it again. --as template prints the same answer long, with each slot's help. " \
32
32
  "Then fill in the answer the response_template part prints"
33
33
  fill = AnswerInAFile.new(@invocation).assessment(request.principle_id, request_id:)
34
- listed(index, request.principle_id)
34
+ listed(index, request.principle_id, request.bytes_unknown)
35
35
  .merge(TrimmedInstructionsNote.new(request.trimmed_instruction_fields).to_h)
36
36
  .merge("answer_with" => @invocation.submit_answer(request_id),
37
37
  "next_action" => "#{read}, #{carried(request)}. #{fill}")
@@ -49,10 +49,14 @@ module Principles
49
49
  # The index under its request id, after the command that prints a part named after it, each entry's part as a
50
50
  # shell reads it, quoted where a shell would split or expand it, so it runs as printed; the answer's template
51
51
  # names each member by its id unquoted. One command rather than one an entry, since an entry's would repeat it
52
- # and cost more than reading the whole request.
53
- #: (Hash[String, untyped], String) -> Hash[String, untyped]
54
- def listed(index, principle_id)
55
- entries = index.fetch("index").map { it.merge("part" => ShellWord.new(it.fetch("part")).to_s) }
52
+ # and cost more than reading the whole request. Each part bytes_unknown names gives why it has no bytes instead.
53
+ #: (Hash[String, untyped], String, Hash[String, String]) -> Hash[String, untyped]
54
+ def listed(index, principle_id, bytes_unknown)
55
+ entries = index.fetch("index").map do |entry|
56
+ part = entry.fetch("part")
57
+ sized = bytes_unknown.key?(part) ? entry.except("bytes").merge("bytes_unknown" => bytes_unknown[part]) : entry
58
+ sized.merge("part" => ShellWord.new(part).to_s)
59
+ end
56
60
  { "request_id" => index.fetch("request_id"),
57
61
  "part_command" => @invocation.in_project("start-audit", principle_id, options: ["--part"]),
58
62
  "index" => entries }
@@ -15,6 +15,10 @@ module Principles
15
15
  # The JSON results of reading principles, show-principle and list-principles, with commands for the invocation
16
16
  # running now. They change with what a read reports, such as freshness and repairs; MapResult prints the writes.
17
17
  class PrincipleReadResult
18
+ # The fields of a kept assessment show-principle --member prints: the judgement and its sighting, not what it
19
+ # was judged on.
20
+ ASSESSMENT_SHOWN = %w[assessed_at assessment delivery observation observed_at].freeze
21
+
18
22
  #: (Invocation) -> void
19
23
  def initialize(invocation)
20
24
  @invocation = invocation
@@ -25,14 +29,36 @@ module Principles
25
29
  # an audit would refuse, with its repair_with commands, from the moves repairs gives it.
26
30
  # hook_settings_not_read names each project settings file whose hooks this tool could not read.
27
31
  # loaded_files lists each file the members load once, with the total of those loading at session start.
32
+ # unresolved names each plugin member no installed plugin gives, which no repair is offered for.
28
33
  #: (PrintedPrinciple, repairs: Hash[String, Array[MemberRepairs::Move]],
29
- #| ?hook_settings_not_read: Array[Hash[String, String]], ?loaded_files: Hash[String, untyped])
30
- #| -> Hash[String, untyped]
31
- def shown(principle, repairs:, hook_settings_not_read: [], loaded_files: {})
34
+ #| ?hook_settings_not_read: Array[Hash[String, String]], ?loaded_files: Hash[String, untyped],
35
+ #| ?unresolved: Array[String]) -> Hash[String, untyped]
36
+ def shown(principle, repairs:, hook_settings_not_read: [], loaded_files: {}, unresolved: [])
32
37
  unread = hook_settings_not_read.empty? ? {} : { "hook_settings_not_read" => hook_settings_not_read }
33
38
  { "id" => principle.id, "map_file" => principle.file, **principle.declared,
34
39
  "members" => principle.members.map { |member| repaired(principle.id, member, repairs) },
35
- **loaded_files, **unread, "next_action" => shown_next_action(principle, repairs.keys) }
40
+ **loaded_files, **unread, "next_action" => shown_next_action(principle, repairs.keys, unresolved) }
41
+ end
42
+
43
+ # show-principle --member: one member of principle_id, where it is now and how fresh, beside the assessment the
44
+ # last completed audit kept for it and the last acknowledgement since, without what either was judged on, and
45
+ # nothing of the other members.
46
+ #: (String, Hash[String, untyped], Hash[String, untyped]?, Hash[String, untyped]?) -> Hash[String, untyped]
47
+ def one_member(principle_id, member, assessment, acknowledgement)
48
+ judged = { "last_assessment" => assessment&.slice(*ASSESSMENT_SHOWN),
49
+ "last_acknowledgement" => acknowledgement&.slice("acknowledged_at", "reason", "commit") }
50
+ { "id" => principle_id, "member" => member.merge(judged.compact),
51
+ "next_action" => "To see every member of #{principle_id}: " \
52
+ "#{@invocation.in_project("show-principle", principle_id)}" }
53
+ end
54
+
55
+ # shown, show-principle's result for principle_id printed without when each member's file loads, its next_action
56
+ # naming --loads, which prints that too.
57
+ #: (Hash[String, untyped], String) -> Hash[String, untyped]
58
+ def without_loads(shown, principle_id)
59
+ asked = @invocation.in_project("show-principle", principle_id, usage: "--loads")
60
+ shown.merge("next_action" => "#{shown.fetch("next_action")}\nTo see when each member's file loads, and its " \
61
+ "size: #{asked}")
36
62
  end
37
63
 
38
64
  # list-principles: each entry is { "id", "description", "members_by_freshness" }. waiting is each principle whose
@@ -97,17 +123,32 @@ module Principles
97
123
  MemberRepairs.new(@invocation).beside(id, member, repairs[member.fetch("id")])
98
124
  end
99
125
 
100
- # Repair each member in broken, the ids of those an audit would refuse; otherwise audit when one changed or was
101
- # never assessed.
102
- #: (PrintedPrinciple, Array[String]) -> String
103
- def shown_next_action(principle, broken)
104
- unless broken.empty?
105
- return "Repair each member that cannot be found or read before auditing, with one of the commands in " \
106
- "its repair_with: #{broken.join(", ")}."
126
+ # Repair each member in broken, the ids of those an audit would refuse, and say which plugin members in
127
+ # unresolved no installed plugin gives; otherwise audit when one changed or was never assessed.
128
+ #: (PrintedPrinciple, Array[String], Array[String]) -> String
129
+ def shown_next_action(principle, broken, unresolved)
130
+ unless broken.empty? && unresolved.empty?
131
+ return [repair_broken(broken), unresolved_plugin_members(unresolved)].compact.join(" ")
107
132
  end
108
133
 
109
134
  "Audit when a member is changed or unassessed: #{@invocation.in_project("start-audit", principle.id)}"
110
135
  end
136
+
137
+ #: (Array[String]) -> String?
138
+ def repair_broken(broken)
139
+ return if broken.empty?
140
+
141
+ "Repair each member that cannot be found or read before auditing, with one of the commands in its " \
142
+ "repair_with: #{broken.join(", ")}."
143
+ end
144
+
145
+ #: (Array[String]) -> String?
146
+ def unresolved_plugin_members(unresolved)
147
+ return if unresolved.empty?
148
+
149
+ "No plugin installed for this project gives #{ProseList.new(unresolved)}; each one's error says why and " \
150
+ "how to resolve it."
151
+ end
111
152
  end
112
153
  end
113
154
  end
@@ -33,7 +33,8 @@ module Principles
33
33
  RequestPart.new(shown: { PART => @prior.map { |finding| shown(finding) } },
34
34
  instructions: [Instruction.new("prior_findings_instruction", instruction)],
35
35
  slots: { "prior_finding_decisions" => @prior.map { |finding| decision(finding) } },
36
- help: { "prior_finding_decisions" => @placeholders })
36
+ help: { "prior_finding_decisions" => @placeholders },
37
+ alone: { "prior_finding_decisions" => @prior.map { |finding| decision_alone(finding) } })
37
38
  end
38
39
 
39
40
  private
@@ -55,6 +56,13 @@ module Principles
55
56
  evidence_not_kept?(finding) ? decision.merge("problem_evidence" => []) : decision
56
57
  end
57
58
 
59
+ # The decision to fill in on finding in the answer printed alone, which no list of prior findings stands beside,
60
+ # with the finding's problem after its id, so the agent deciding it can tell what it is.
61
+ #: (Hash[String, untyped]) -> Hash[String, untyped]
62
+ def decision_alone(finding)
63
+ { "finding_id" => nil, "finding_problem" => finding.fetch("problem"), **decision(finding) }
64
+ end
65
+
58
66
  # How to decide the prior findings, naming each one's id, so a new finding is given another, each paragraph with
59
67
  # whether its case holds: how to keep what a deferral waits on holds only when one carries waits_on, how to
60
68
  # claim an earlier first_raised_at never, since no fact marks a finding dated late, so it is read whole, and how
@@ -1,6 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
+ require_relative "acknowledgements_offered"
4
5
  require_relative "record_waiting_on_an_upgrade"
5
6
 
6
7
  module Principles
@@ -20,16 +21,17 @@ module Principles
20
21
  #: Hash[String, Array[String]]
21
22
  attr_reader :audit_files
22
23
 
23
- #: Hash[Array[String], Array[String]]
24
+ #: AcknowledgementsOffered
24
25
  attr_reader :acknowledgeable
25
26
 
26
27
  #: Array[RecordWaitingOnAnUpgrade]
27
28
  attr_reader :waiting
28
29
 
29
30
  #: (?not_read: Array[String], ?no_baseline_files: Hash[String, Array[String]],
30
- #| ?audit_files: Hash[String, Array[String]], ?acknowledgeable: Hash[Array[String], Array[String]],
31
+ #| ?audit_files: Hash[String, Array[String]], ?acknowledgeable: AcknowledgementsOffered,
31
32
  #| ?waiting: Array[RecordWaitingOnAnUpgrade]) -> void
32
- def initialize(not_read: [], no_baseline_files: {}, audit_files: {}, acknowledgeable: {}, waiting: [])
33
+ def initialize(not_read: [], no_baseline_files: {}, audit_files: {}, acknowledgeable: AcknowledgementsOffered::NONE,
34
+ waiting: [])
33
35
  @not_read = not_read
34
36
  @no_baseline_files = no_baseline_files
35
37
  @audit_files = audit_files