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,52 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "command"
5
+ require_relative "../models/members_in_logged_requests"
6
+ require_relative "../models/request_kind"
7
+ require_relative "../views/members_in_logged_requests_result"
8
+
9
+ module Principles
10
+ # Each runs one command: reads models, applies their rules and prints through a view.
11
+ # controllers/CLAUDE.md owns the boundary.
12
+ module Controllers
13
+ # show-members-in-logged-requests: which mapped members' text reached each request the host captured under
14
+ # .principles/request-logging/requests/, so a principle is tuned from what reached the context. It
15
+ # writes nothing.
16
+ class MembersInLoggedRequests < Command
17
+ # CommandRoutes routes only show-members-in-logged-requests here.
18
+ # Each member's reach, or with --places every place it was seen, or with --member the places of the members it
19
+ # names alone, or with --short the counts and one line a member rather than the JSON.
20
+ #: (String, String?, Hash[String, untyped]) -> untyped
21
+ def call(command, _id, options)
22
+ naming_the_executable do
23
+ @tool.feature(command).refuse_while_off
24
+ view = Views::MembersInLoggedRequestsResult.new
25
+ report = report_for(options)
26
+ next view.short(report) if options["short"]
27
+
28
+ view.result(report, side_call_sources: Models::RequestKind::SIDE_CALL_SOURCES)
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ # The scan's report in the form options ask for: every place each member --member names was seen, or each
35
+ # member's, or each member's reach.
36
+ #: (Hash[String, untyped]) -> Models::RequestLogging::report
37
+ def report_for(options)
38
+ named = options["member"]
39
+ return logging.members_seen(mapped.only(named)) if named
40
+
41
+ options["places"] ? logging.members_seen(mapped) : logging.members_reached(mapped)
42
+ end
43
+
44
+ #: () -> Models::RequestLogging
45
+ def logging = @project.request_logging
46
+
47
+ # Every mapped member, to measure.
48
+ #: () -> Models::MembersInLoggedRequests
49
+ def mapped = Models::MembersInLoggedRequests.mapped_in(@project)
50
+ end
51
+ end
52
+ end
@@ -5,6 +5,7 @@ require_relative "command"
5
5
  require_relative "../models/carried_member"
6
6
  require_relative "../models/check_since_last_audit"
7
7
  require_relative "../models/open_findings_elsewhere"
8
+ require_relative "../models/whole_file_member_read"
8
9
  require_relative "../views/acknowledged_since_last_audit"
9
10
  require_relative "../views/read_the_change"
10
11
 
@@ -53,7 +54,10 @@ module Principles
53
54
  map = audit.map
54
55
  carried = carried_assessments(audit)
55
56
  elsewhere = elsewhere(map, current)
56
- members = map.members_shown.map { |fields| member_listed(fields, carried, elsewhere, current) }
57
+ kinds = member_loads(map).transform_values { it.carrier_kind.name }
58
+ members = map.members_shown.map do |fields|
59
+ justified(fields, kinds).merge(member_listed(fields, carried, elsewhere, current))
60
+ end
57
61
  Listing.new(members: members, open_findings_elsewhere: elsewhere_listed(elsewhere, current))
58
62
  end
59
63
 
@@ -71,6 +75,13 @@ module Principles
71
75
  changed_since(fields, judged, current), shared_lines(member, elsewhere))
72
76
  end
73
77
 
78
+ # What a member's entry says justifies it, led by its name, which output shows first, and its reason, null
79
+ # when it has none, for the audit to ask for, beside the kind of carrier its file is, the fact it is judged on.
80
+ #: (Hash[String, untyped], Hash[String, String]) -> Hash[String, untyped]
81
+ def justified(fields, kinds)
82
+ { **fields.slice("name"), "reason" => fields["reason"], "carrier" => kinds.fetch(fields.fetch("id")) }
83
+ end
84
+
74
85
  # Each finding elsewhere names, once, with each evidence item's lines beside this audit's members, where current
75
86
  # locates them; the project locates each item now.
76
87
  #: (Models::OpenFindingsElsewhere, Models::MemberSnapshots) -> Array[Hash[String, untyped]]
@@ -113,10 +124,12 @@ module Principles
113
124
  open_here: @record&.open_ids_on(member.key) || []).shown
114
125
  end
115
126
 
116
- # Whether member's file changed since the last full audit's base commit; nil with no such commit, as outside git.
127
+ # Whether member's file changed since the last full audit's base commit; nil with no such commit, as outside git,
128
+ # and for a plugin member, whose file git holds no history of.
117
129
  #: (Models::Member) -> bool?
118
130
  def file_changed_outside(member)
119
131
  base = @completed&.base_commit or return
132
+ return if member.plugin_reference
120
133
 
121
134
  @history.commits_since(base, member.path).any?
122
135
  end
@@ -129,26 +142,40 @@ module Principles
129
142
  true
130
143
  end
131
144
 
132
- # The member as the request names and locates it: id, role, evidence and its lines now.
145
+ # The member as the request names and locates it: id, role, evidence and its lines now, and for a plugin
146
+ # member, where it comes from, read-only, at the version installed now.
133
147
  #: (Models::Member, Models::MemberSnapshots) -> Hash[String, untyped]
134
148
  def located(member, current)
149
+ source = @project.installed_plugins.source_of(member)
135
150
  { "id" => member.id, "role" => member.role, "evidence" => [member.reference] }
136
- .merge(current.of(member.id).lines)
151
+ .merge(current.of(member.id).lines, source ? { "source" => source } : {})
137
152
  end
138
153
 
139
154
  # The command that shows the edits to a member judged again since the last full audit's base commit: to its
140
155
  # own lines, where current locates them, for part of a file at the same path then and now; else to its file,
141
156
  # over its path then and now. Nothing for a member carried forward, or with no such commit, as outside git or
142
- # before any full audit.
157
+ # before any full audit, or for a plugin member, whose file git holds no history of.
143
158
  #: (Hash[String, untyped], Hash[String, untyped], Models::MemberSnapshots) -> Hash[String, untyped]
144
159
  def changed_since(fields, judged, current)
145
160
  base = @completed&.base_commit
146
- return {} unless judged["judge_because"] && base
147
-
148
161
  member = Models::Member.new(fields)
162
+ return {} unless judged["judge_because"] && base && !member.plugin_reference
163
+
149
164
  paths = principle_history(@principle_id).paths_from(base, member.key, fields)
150
165
  lines = member.traced_lines(paths, current.of(member.id).lines)
151
- { "read_the_change" => Views::ReadTheChange.new(since: base, paths:, lines:).to_s }
166
+ { "read_the_change" => Views::ReadTheChange.new(since: base, paths:, lines:).to_s,
167
+ **changed_lines(member, judged, base) }
168
+ end
169
+
170
+ # The changed lines of a whole-file member judged for its text changing since base, with no context, as
171
+ # WholeFileMemberRead says, beside the text it reads apart; nothing for another member, or one whose lines at
172
+ # base cannot be found.
173
+ #: (Models::Member, Hash[String, untyped], String) -> Hash[String, untyped]
174
+ def changed_lines(member, judged, base)
175
+ return {} unless Models::WholeFileMemberRead.new(whole_file: member.whole_file?, listed: judged).changed_lines?
176
+
177
+ lines = @project.member_lines(member.locator, since: base) or return {}
178
+ { "changed_lines" => lines.regions(context: 0) }
152
179
  end
153
180
 
154
181
  # The edits to member acknowledged since the last full audit, which this audit judges together, with
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require_relative "command"
5
- require_relative "inventory"
5
+ require_relative "principle_listing"
6
6
  require_relative "../models/entry_files"
7
7
  require_relative "../models/meta_principle"
8
8
  require_relative "../models/text_size"
@@ -49,7 +49,7 @@ module Principles
49
49
 
50
50
  # The project's other principles, as list-principles lists them, which this principle's first audit keeps held.
51
51
  #: () -> Array[Hash[String, untyped]]
52
- def existing_principles = handed(Inventory).rows(@principles.ids - [Models::MetaPrinciple::ID])
52
+ def existing_principles = handed(PrincipleListing).rows(@principles.ids - [Models::MetaPrinciple::ID])
53
53
 
54
54
  # Where the passage can go: how this run was started and whether the hook runs in this session, the project's
55
55
  # entry files, and the passage.
@@ -58,10 +58,18 @@ module Principles
58
58
  runs_from = @tool.runs_from
59
59
  Views::MetaPrincipleResult::Placement.new(
60
60
  runs_from: runs_from.to_s, session_start_hook_in_this_session: runs_from.session_start_hook_in_this_session?,
61
- entry_files: @project.entry_files.to_a, passage: passage(view)
61
+ entry_files: @project.entry_files.to_a, passage: passage(view),
62
+ enabled_in_project_settings: enabling_line
62
63
  )
63
64
  end
64
65
 
66
+ # The project settings line enabling the plugin, by its path and literal opening, or nil.
67
+ #: () -> Hash[String, String]?
68
+ def enabling_line
69
+ line = @project.harness.plugin_enabled_in_project_settings or return nil
70
+ { "path" => line.path, "starting_at" => line.starting_at }
71
+ end
72
+
65
73
  # The view of show-meta-principle-passage's result, with how its printed commands map the passage.
66
74
  #: () -> Views::MetaPrincipleResult
67
75
  def meta_principle_result
@@ -69,7 +77,7 @@ module Principles
69
77
  end
70
78
 
71
79
  # The passage member's heading and role, the role of a passage the project has that carries one of its steps,
72
- # and the role of any other place that keeps the principles held.
80
+ # and the role of any other place that has the principles checked.
73
81
  #: () -> Views::MetaPrincipleResult::PassageMapping
74
82
  def passage_mapping
75
83
  Views::MetaPrincipleResult::PassageMapping.new(heading: Models::MetaPrinciple::PASSAGE_HEADING,
@@ -34,8 +34,9 @@ module Principles
34
34
  kept = Models::OpenCorrection.kept(principle_id, @audit_records.find(principle_id),
35
35
  file: @audit_records.file(principle_id))
36
36
  head = Views::AnswerHead.new(request_id: kept.request_id, basis: kept.basis)
37
- placeholders = Models::DispositionPlaceholders::TEMPLATE_PLACEHOLDERS
38
- Views::CorrectionRequest.new(head:, principle_id:, findings: kept.findings, placeholders:).correction_to_fill
37
+ disposition = Views::DispositionTemplate.new(Models::DispositionPlaceholders::TEMPLATE_PLACEHOLDERS,
38
+ kept.prior_decided.deferrals_raised_again)
39
+ Views::CorrectionRequest.new(head:, principle_id:, findings: kept.findings, disposition:).correction_to_fill
39
40
  end
40
41
  end
41
42
  end
@@ -3,10 +3,14 @@
3
3
 
4
4
  require_relative "command"
5
5
  require_relative "../models/evidence_lines_since"
6
+ require_relative "../models/feature"
7
+ require_relative "../models/members_in_logged_requests"
8
+ require_relative "../models/turn_position"
6
9
  require_relative "../models/loading_decision"
7
10
  require_relative "../models/other_principles"
8
11
  require_relative "../models/prior_decision_fields"
9
12
  require_relative "../models/uncommitted_outside_the_map"
13
+ require_relative "../views/logged_requests_evidence"
10
14
  require_relative "../views/loads_to_check_result"
11
15
  require_relative "../views/open_findings_elsewhere_result"
12
16
  require_relative "../views/other_principles_unjudged_result"
@@ -43,19 +47,57 @@ module Principles
43
47
  # What the agent reads beside the members, in order: the files outside the map that differ from the
44
48
  # base commit, which a check and the answer's evidence read as they are now; the prior findings;
45
49
  # the findings other principles leave open on members sharing these lines; and the members to
46
- # check against the activation; each when it lists any; and, on the meta-principle's audit, the release
47
- # since its last audit and the other principles with members no audit has judged.
48
- #: (Models::PriorFindings, Hash[String, untyped]?) -> Array[Views::RequestPart]
49
- def listed(prior, loads)
50
+ # check against the activation; each when it lists any; on the meta-principle's audit, the release
51
+ # since its last audit and the other principles with members no audit has judged; and what the logged
52
+ # requests show of the members, unless scanned is false, for a read that prints none of it.
53
+ #: (Models::PriorFindings, Hash[String, untyped]?, ?scanned: bool) -> Array[Views::RequestPart]
54
+ def listed(prior, loads, scanned: true)
50
55
  map = @audit.map
51
56
  [outside_the_map, prior_findings_part(prior),
52
57
  Views::OpenFindingsElsewhereResult.new(@listing.open_findings_elsewhere).part,
53
58
  loads_part(loads), package_since_last_audit(map),
54
- other_principles_unjudged(map)].compact
59
+ other_principles_unjudged(map), logged_requests_part(scanned)].compact
55
60
  end
56
61
 
57
62
  private
58
63
 
64
+ # The part saying how far the listed members' text reached the logged requests, or why
65
+ # nothing shows it: the folder unguarded, which is asked first since every other read of it refuses then; none
66
+ # captured; or a tool the scan runs missing. Unless scanned, the scan itself does not run, and the part holds
67
+ # nothing.
68
+ #: (bool) -> Views::RequestPart
69
+ def logged_requests_part(scanned)
70
+ logging = @project.request_logging
71
+ evidence = Views::LoggedRequestsEvidence.new(invocation)
72
+ refusal = logging.unguarded_refusal
73
+ return evidence.unread(refusal.payload) if refusal
74
+ return evidence.none_captured if logging.none_captured?
75
+
76
+ scanned_part(logging, evidence, scanned)
77
+ end
78
+
79
+ # The part from the scan of the captured requests for the listed members, or why the scan cannot run; unless
80
+ # scanned, the part holding nothing.
81
+ #: (Models::RequestLogging, Views::LoggedRequestsEvidence, bool) -> Views::RequestPart
82
+ def scanned_part(logging, evidence, scanned)
83
+ off = @tool.feature(Models::Feature::LOGGED_REQUEST_SCAN).off_refusal
84
+ return evidence.unread(off.payload) if off
85
+ return evidence.not_scanned unless scanned
86
+
87
+ evidence.reached(logging.reach(measured_members, carried: carried_ids).to_h)
88
+ end
89
+
90
+ # The members whose reach the part shows: every one the request lists, carried ones too, each named as it is
91
+ # listed there.
92
+ #: () -> Models::MembersInLoggedRequests
93
+ def measured_members
94
+ Models::MembersInLoggedRequests.listed_in(@project, @audit.map, @listing.members.map { it.fetch("id") })
95
+ end
96
+
97
+ # The ids of the members the audit carries forward, which the part marks.
98
+ #: () -> Array[String]
99
+ def carried_ids = @listing.members.select { it["carried_forward"] }.map { it.fetch("id") }
100
+
59
101
  # The part listing the members to check against the activation, each decision's template printing the
60
102
  # placeholders an answer leaves as printed to give none; nil when none is listed.
61
103
  #: (Hash[String, untyped]?) -> Views::RequestPart?
@@ -92,7 +134,7 @@ module Principles
92
134
  # where a member's part asks, its text now.
93
135
  #: (Models::Principle) -> Array[String]
94
136
  def package_parts_mapped(map)
95
- hooks = @project.hook_commands(Models::HookCommands::ON_EVERY_HOST)
137
+ hooks = @project.harness.hook_commands(Models::HookCommands::ON_EVERY_HOST)
96
138
  map.members.package_parts(hooks) { |member| @project.member_text(member.locator) }
97
139
  end
98
140
 
@@ -0,0 +1,48 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "command"
5
+ require_relative "../error"
6
+ require_relative "../prose_list"
7
+ require_relative "../models/plugin_component"
8
+
9
+ module Principles
10
+ module Controllers
11
+ # add-member --plugin: a member read from a plugin Claude Code installed, which the project maps but never edits.
12
+ class PluginMemberAddition < Command
13
+ # Maps the file options name in an installed plugin whole, pinning the version installed and the hash of its
14
+ # text, in principle id's map, which it starts when there is none, playing the part played gives.
15
+ #: (String, Hash[String, untyped], Hash[String, untyped]) -> untyped
16
+ def add(id, options, played)
17
+ refuse_location(options)
18
+ found = installed(options)
19
+ started = !@principles.mapped?(id)
20
+ write_map(@principles.addable(id).adding(found.member(played))) do |printed|
21
+ added = map_result.plugin_member_added(printed, added: found.added)
22
+ started ? added.merge(map_result.map_created(printed)) : added
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ # Refuses the location flags a plugin member would ignore, before anything is read: its file is mapped whole.
29
+ #: (Hash[String, untyped]) -> void
30
+ def refuse_location(options)
31
+ given = MemberEntries::LOCATION_OPTIONS.filter_map { |name, flag| flag if options.key?(name) }
32
+ return if given.empty?
33
+
34
+ raise Error.new("plugin_member_located", "#{ProseList.new(given)} cannot locate a plugin member",
35
+ "A plugin's file is mapped whole, so run add-member --plugin again without " \
36
+ "#{ProseList.new(given)}.")
37
+ end
38
+
39
+ # The file PATH names inside the plugin --plugin names, checked to be a plain path before anything installed
40
+ # is read, then found among the plugins installed for the project.
41
+ #: (Hash[String, untyped]) -> Models::InstalledComponent
42
+ def installed(options)
43
+ component = Models::PluginComponent.new(text(options["path"], "PATH"))
44
+ @project.installed_plugins.holding(text(options["plugin"], "--plugin"), component)
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,84 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "command"
5
+ require_relative "../views/principle_read_result"
6
+
7
+ module Principles
8
+ # Each runs one command: reads models, applies their rules and prints through a view.
9
+ # controllers/CLAUDE.md owns the boundary.
10
+ module Controllers
11
+ # list-principles: each mapped principle with its members counted by freshness against its last audit, or the
12
+ # refusal that kept its map from being read. It changes nothing on disk. Inventory shows one principle.
13
+ class PrincipleListing < Command
14
+ #: (String, String?, Hash[String, untyped]) -> untyped
15
+ def call(command, _id, options)
16
+ naming_the_executable do
17
+ case command
18
+ when "list-principles" then listed(options)
19
+ else unknown(command)
20
+ end
21
+ end
22
+ end
23
+
24
+ # Each principle id names as list-principles lists it: its description and its members by freshness, or the
25
+ # refusal that kept its map from being read.
26
+ #: (Array[String]) -> Array[Hash[String, untyped]]
27
+ def rows(ids) = ids.map { entry(it) }
28
+
29
+ private
30
+
31
+ #: () -> Views::PrincipleReadResult
32
+ def read_result
33
+ Views::PrincipleReadResult.new(invocation)
34
+ end
35
+
36
+ # list-principles as options ask: each id on a line with --lines, else the rows as JSON.
37
+ #: (Hash[String, untyped]) -> untyped
38
+ def listed(options)
39
+ return read_result.ids(@principles.ids) if options["lines"]
40
+
41
+ listing(open_findings: options["open_findings"]).merge("wrote" => [])
42
+ end
43
+
44
+ # Its next_action offers an audit while one principle's audits do not wait on an upgrade; a map listed with its
45
+ # refusal counts, since repairing it leaves it to audit. With open_findings, each row lists its open findings.
46
+ #: (open_findings: bool?) -> untyped
47
+ def listing(open_findings:)
48
+ ids = @principles.ids
49
+ waiting = ids.filter_map { waiting_on_an_upgrade(it) }
50
+ listed = open_findings ? read_result.with_open_findings(rows(ids), open_by_principle(ids)) : rows(ids)
51
+ read_result.listing(listed, waiting: waiting, one_to_audit: waiting.size < ids.size)
52
+ end
53
+
54
+ # Each principle's open findings, from every record this copy can read, as list-open-findings reads them,
55
+ # aged until now, by principle id.
56
+ #: (Array[String]) -> Hash[String, Array[Hash[String, untyped]]]
57
+ def open_by_principle(ids)
58
+ now = Time.now.utc
59
+ @audit_records.readable_of(ids).flat_map(&:left_open).map { it.waited_at(now) }
60
+ .group_by { it.fetch("principle") }
61
+ end
62
+
63
+ # One map's row; a map this tool cannot read is listed with its refusal, so the others still show, and one
64
+ # whose record a later copy wrote says its audits wait on an upgrade, as show-audit does.
65
+ #: (String) -> Hash[String, untyped]
66
+ def entry(id)
67
+ map = @principles.find(id)
68
+ row = map.description_with_id.merge("members_by_freshness" => members_by_freshness(map))
69
+ row = row.merge(read_result.no_members(@principles.file(id))) if map.unstarted?
70
+ row.merge(waiting_on_an_upgrade(id)&.marker || {})
71
+ rescue Error => e
72
+ { "id" => id, "refusal" => e.payload }
73
+ end
74
+
75
+ # How many of map's members are in each freshness state, against its principle's last audit, or the hashes a
76
+ # record a later copy wrote holds, read-only, when this copy cannot read the rest of it.
77
+ #: (Models::Principle) -> Hash[String, Integer]
78
+ def members_by_freshness(map)
79
+ hashes = @audit_records.hashes_to_compare(map.id)
80
+ map.members_shown.map { |member| fresh(member, hashes).fetch("freshness") }.tally.sort.to_h
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,65 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "command"
5
+ require_relative "../views/request_logging_result"
6
+
7
+ module Principles
8
+ # Each runs one command: reads models, applies their rules and prints through a view.
9
+ # controllers/CLAUDE.md owns the boundary.
10
+ module Controllers
11
+ # The switch for request logging, each request the host sends written under .principles/request-logging/,
12
+ # and the read of what was captured there.
13
+ class RequestLogging < Command
14
+ # Each command, by the private method that runs it.
15
+ COMMANDS = { "turn-on-request-logging" => :turned_on,
16
+ "turn-off-request-logging" => :turned_off,
17
+ "show-logged-requests" => :shown,
18
+ "remove-logged-requests" => :removed }.freeze #: Hash[String, Symbol]
19
+
20
+ #: (String, String?, Hash[String, untyped]) -> untyped
21
+ def call(command, _id, options)
22
+ naming_the_executable do
23
+ operation = COMMANDS[command] or unknown(command)
24
+ send(operation, @project.request_logging, Views::RequestLoggingResult.new(invocation), options)
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ #: (Models::RequestLogging, Views::RequestLoggingResult, Hash[String, untyped]) -> Hash[String, untyped]
31
+ def turned_on(logging, result, options)
32
+ return result.turned_on(wrote: logging.turn_on, launch_file: logging.launch_file) unless options["for_user"]
33
+
34
+ entries = @project.user_settings_entries
35
+ result.turned_on_for_user(wrote: logging.make_user_folder, settings_file: entries.settings_file,
36
+ to_add: entries.to_add, settings_unreadable: entries.settings_unreadable?,
37
+ pruned: logging.prune_unregistered.to_h)
38
+ end
39
+
40
+ #: (Models::RequestLogging, Views::RequestLoggingResult, Hash[String, untyped]) -> Hash[String, untyped]
41
+ def turned_off(logging, result, options)
42
+ return result.turned_off(wrote: logging.turn_off) unless options["for_user"]
43
+
44
+ entries = @project.user_settings_entries
45
+ result.turned_off_for_user(settings_file: entries.settings_file, own: entries.own,
46
+ shared: Models::UserSettingsEntries::TELEMETRY_AND_EXPORTERS,
47
+ pruned: logging.prune_unregistered.to_h)
48
+ end
49
+
50
+ #: (Models::RequestLogging, Views::RequestLoggingResult, Hash[String, untyped]) -> Hash[String, untyped]
51
+ def shown(logging, result, _options)
52
+ captured = logging.captured
53
+ result.shown(sessions: captured.sessions.map(&:to_h), orphan_requests: captured.orphans.to_h,
54
+ newest_request_written_at: captured.newest_request_written_at,
55
+ newest_session_id: captured.newest_session_id)
56
+ end
57
+
58
+ #: (Models::RequestLogging, Views::RequestLoggingResult, Hash[String, untyped]) -> Hash[String, untyped]
59
+ def removed(logging, result, options)
60
+ removed = logging.remove(keep_sessions: options["keep_sessions"])
61
+ result.removed(removed: removed, pruned: logging.prune_unregistered.to_h)
62
+ end
63
+ end
64
+ end
65
+ end
@@ -1,11 +1,13 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
+ require_relative "../models/feature"
4
5
  require_relative "../models/meta_principle"
5
6
  require_relative "../models/principles_package"
6
7
  require_relative "../models/principles_on_path"
7
8
  require_relative "../models/runs_from"
8
9
  require_relative "../views/invocation"
10
+ require_relative "../views/shell_word"
9
11
  require_relative "../views/meta_principle_passage"
10
12
 
11
13
  module Principles
@@ -35,35 +37,69 @@ module Principles
35
37
  end
36
38
  end
37
39
 
40
+ # What PATH says of this run, as Launch reads it, each read only when a command needs it: other gives the path
41
+ # and printed version of another principles earlier on PATH than this one, and which of the commands it is
42
+ # asked about that copy does not run, or nil, since reading it starts that copy; launched says whether this run
43
+ # was launched as the first principles on PATH, as a RubyGems binstub is, so a bare principles runs this same
44
+ # copy; tool says whether PATH holds a fast standard tool, such as rg, which a feature runs. Nothing is on PATH
45
+ # unless Launch says so, so a feature that needs a tool is off by default.
46
+ class OnPath
47
+ #: (?other: ^(Array[String]) -> [String, String, Array[String]]?, ?launched: ^() -> bool,
48
+ #| ?tool: ^(String) -> bool) -> void
49
+ def initialize(other: ->(_) {}, launched: -> { false }, tool: ->(_) { false })
50
+ @other = other
51
+ @launched = launched
52
+ @tool = tool
53
+ freeze
54
+ end
55
+
56
+ # The feature command runs, on only while PATH holds every fast standard tool it needs.
57
+ #: (String) -> Models::Feature
58
+ def feature(command) = Models::Feature.new(command, on_path: @tool)
59
+
60
+ # Another principles earlier on PATH, asked about the commands of asking, or nil.
61
+ #: (Array[String]) -> [String, String, Array[String]]?
62
+ def other(asking) = @other.call(asking)
63
+
64
+ #: () -> bool
65
+ def launched? = @launched.call
66
+ end
67
+
38
68
  # version gives the version running, read only when a command needs it, since in a checkout reading it
39
- # asks git; other_on_path gives the path and printed version of another principles earlier on PATH than this
40
- # one, and which of the commands it is asked about that copy does not run, or nil, read only when a command
41
- # needs it, since reading it starts that copy; launched_on_path says
42
- # whether this run was launched as the first principles on PATH, as a RubyGems binstub is, so a bare
43
- # principles runs this same copy; folders are the folders the process was given.
44
- #: (executable: String, version: ^() -> String,
45
- #| ?other_on_path: ^(Array[String]) -> [String, String, Array[String]]?, ?launched_on_path: ^() -> bool,
46
- #| folders: Folders) -> void
47
- def initialize(executable:, version:, folders:, other_on_path: ->(_) {}, launched_on_path: -> { false })
69
+ # asks git; on_path is what PATH says of this run; folders are the folders the process was given;
70
+ # bundle_gemfile is the Gemfile bundler ran this run under, or nil when it did not.
71
+ #: (executable: String, version: ^() -> String, folders: Folders, ?on_path: OnPath, ?bundle_gemfile: String?)
72
+ #| -> void
73
+ def initialize(executable:, version:, folders:, on_path: OnPath.new, bundle_gemfile: nil)
48
74
  @executable = executable
75
+ @bundle_gemfile = bundle_gemfile
49
76
  @version = version
50
- @other_on_path = other_on_path
51
- @launched_on_path = launched_on_path
77
+ @on_path = on_path
52
78
  @folders = folders
53
79
  freeze
54
80
  end
55
81
 
56
82
  # The executable every printed command names: the bare principles when that runs this copy, else the entry
57
- # point's own.
83
+ # point's own, under the bundler it ran under, so a command pasted into a shell that lacks bundler's environment
84
+ # runs as this one did.
58
85
  #: () -> String
59
- def executable = bare_from_path? ? ON_PATH : @executable
86
+ def executable
87
+ return ON_PATH if bare_from_path?
88
+ return @executable unless @bundle_gemfile
89
+
90
+ "BUNDLE_GEMFILE=#{Views::ShellWord.new(@bundle_gemfile)} bundle exec #{@executable}"
91
+ end
60
92
 
61
93
  #: () -> String
62
94
  def version = @version.call
63
95
 
64
96
  # Whether this run was launched as the first principles on PATH, so a bare principles runs this same copy.
65
97
  #: () -> bool
66
- def launched_on_path? = @launched_on_path.call
98
+ def launched_on_path? = @on_path.launched?
99
+
100
+ # This machine's temporary folder, as the process was given it.
101
+ #: () -> String
102
+ def temp_directory = @folders.temp_directory
67
103
 
68
104
  # Where this run comes from, by the entry point it was invoked through, whatever its commands are printed as.
69
105
  #: () -> Models::RunsFrom
@@ -85,10 +121,14 @@ module Principles
85
121
  # whether it runs each command of asking, or nil.
86
122
  #: (?asking: Array[String]) -> Models::PrinciplesOnPath?
87
123
  def other_on_path(asking: [])
88
- path, version, lacking = @other_on_path.call(asking)
124
+ path, version, lacking = @on_path.other(asking)
89
125
  path && version ? Models::PrinciplesOnPath.new(path, version, lacking: lacking || []) : nil
90
126
  end
91
127
 
128
+ # The feature command runs, on only while PATH holds every fast standard tool it needs.
129
+ #: (String) -> Models::Feature
130
+ def feature(command) = @on_path.feature(command)
131
+
92
132
  # The release of principles this run comes from, as the audit of map's principle keeps it: the version running
93
133
  # and the passage as setup prints it, which only a view holds; nil for a principle whose audit keeps none.
94
134
  #: (Models::Principle) -> Models::PrinciplesPackage?
@@ -6,6 +6,7 @@ require_relative "member_problems_report"
6
6
  require_relative "audit"
7
7
  require_relative "../models/session_start_input"
8
8
  require_relative "../views/session_start_report"
9
+ require_relative "../views/set_up_offer_line"
9
10
 
10
11
  module Principles
11
12
  # Each runs one command: reads models, applies their rules and prints through a view.
@@ -20,12 +21,24 @@ module Principles
20
21
  naming_the_executable do
21
22
  unknown(command) unless command == "report-at-session-start"
22
23
 
23
- printed(Models::SessionStartInput.new(options["stdin"].to_s))
24
+ input = Models::SessionStartInput.new(options["stdin"].to_s)
25
+ printed(input).tap { register(input) }
24
26
  end
25
27
  end
26
28
 
27
29
  private
28
30
 
31
+ # Registers the session to the project while request logging is on in the user's own settings, in a project
32
+ # with maps, then prunes every session no project registered, printing nothing of either (022 F4, F8, F11).
33
+ #: (Models::SessionStartInput) -> void
34
+ def register(input)
35
+ logging = @project.request_logging
36
+ logging.register_session(session_id: input.session_id, cwd: input.cwd) unless @principles.ids.empty?
37
+ logging.prune_unregistered
38
+ rescue Error
39
+ nil
40
+ end
41
+
29
42
  # The lines the session starts with, from the hook's input: from the plugin, any other version on PATH, then
30
43
  # what list-member-problems reports of the members, then the open findings; none of those in a project with no
31
44
  # maps. A refusal is named by its code, with the command that shows its repair, since a hook exiting 1 shows the
@@ -55,7 +68,18 @@ module Principles
55
68
  # Each line the session starts with, source: startup, resume, clear or compact.
56
69
  #: (String) -> Array[String]
57
70
  def reported(source)
58
- handed(MemberProblemsReport).session_start_lines(source) + handed(Audit).session_start_open_findings(source)
71
+ handed(MemberProblemsReport).session_start_lines(source) + offer_to_set_up(source) +
72
+ handed(Audit).session_start_open_findings(source)
73
+ end
74
+
75
+ # While principles is not set up, the line asking to offer setup, once a full audit of a principle has completed
76
+ # and shown what a map and an audit give (019 F5).
77
+ #: (String) -> Array[String]
78
+ def offer_to_set_up(source)
79
+ return [] if @principles.set_up?
80
+
81
+ audited = @audit_records.readable_of(@principles.ids).count(&:last_completed)
82
+ Views::SetUpOfferLine.new(invocation.without_project).lines(audited, source)
59
83
  end
60
84
  end
61
85
  end