principles 0.0.7 → 0.0.8

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 (331) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +383 -0
  3. data/LICENSE +202 -0
  4. data/NOTICE +4 -0
  5. data/README.md +111 -0
  6. data/exe/principles +20 -0
  7. data/lib/principles/after_commit_hook_options.rb +2 -2
  8. data/lib/principles/cli.rb +50 -42
  9. data/lib/principles/command_line.rb +22 -16
  10. data/lib/principles/command_routes.rb +20 -6
  11. data/lib/principles/controllers/acknowledgement.rb +29 -74
  12. data/lib/principles/controllers/acknowledgements.rb +154 -0
  13. data/lib/principles/controllers/after_commit_report.rb +44 -0
  14. data/lib/principles/controllers/answer.rb +48 -18
  15. data/lib/principles/controllers/answer_phase.rb +20 -3
  16. data/lib/principles/controllers/assessment.rb +32 -11
  17. data/lib/principles/controllers/audit.rb +43 -19
  18. data/lib/principles/controllers/audit_completion.rb +21 -12
  19. data/lib/principles/controllers/command.rb +13 -12
  20. data/lib/principles/controllers/correction.rb +15 -7
  21. data/lib/principles/controllers/first_audit_brief.rb +40 -0
  22. data/lib/principles/controllers/full_audit_request.rb +41 -82
  23. data/lib/principles/controllers/hook_setup.rb +49 -0
  24. data/lib/principles/controllers/inventory.rb +10 -8
  25. data/lib/principles/controllers/mapping.rb +2 -2
  26. data/lib/principles/controllers/member_acknowledgement.rb +32 -21
  27. data/lib/principles/controllers/member_entries.rb +4 -4
  28. data/lib/principles/controllers/member_problems_report.rb +62 -16
  29. data/lib/principles/controllers/members_a_commit_changed.rb +3 -3
  30. data/lib/principles/controllers/members_to_assess.rb +23 -20
  31. data/lib/principles/controllers/meta_principle_setup.rb +5 -6
  32. data/lib/principles/controllers/open_correction.rb +42 -0
  33. data/lib/principles/controllers/parts_to_read.rb +117 -0
  34. data/lib/principles/controllers/repoint.rb +1 -1
  35. data/lib/principles/controllers/running_tool.rb +56 -6
  36. data/lib/principles/controllers/session_start_report.rb +62 -0
  37. data/lib/principles/controllers/survey.rb +2 -2
  38. data/lib/principles/data/audit_files.rb +7 -7
  39. data/lib/principles/data/bounded_file.rb +1 -1
  40. data/lib/principles/data/candidate_files_found.rb +6 -3
  41. data/lib/principles/data/command-steps.json +61 -6
  42. data/lib/principles/data/expected_type.rb +3 -3
  43. data/lib/principles/data/first_parent_log.rb +1 -1
  44. data/lib/principles/data/head_reflog.rb +74 -0
  45. data/lib/principles/data/hook_input.rb +59 -0
  46. data/lib/principles/data/ignored_by_git.rb +2 -2
  47. data/lib/principles/data/known_fields.rb +1 -1
  48. data/lib/principles/data/linked_path.rb +1 -1
  49. data/lib/principles/data/map_files.rb +2 -2
  50. data/lib/principles/data/principles_on_path.rb +83 -0
  51. data/lib/principles/data/principles_subfolder.rb +1 -1
  52. data/lib/principles/data/project_files.rb +10 -3
  53. data/lib/principles/data/repository.rb +14 -7
  54. data/lib/principles/data/running_version.rb +10 -8
  55. data/lib/principles/data/schema_check.rb +5 -5
  56. data/lib/principles/data/schemas/acknowledgement-answer.schema.json +86 -21
  57. data/lib/principles/data/schemas/acknowledgements-answer.schema.json +9 -2
  58. data/lib/principles/data/schemas/assessment-answer.schema.json +43 -22
  59. data/lib/principles/data/schemas/audit-record.schema.json +29 -20
  60. data/lib/principles/data/schemas/command-steps.schema.json +1 -1
  61. data/lib/principles/data/schemas/correction-answer-guide.schema.json +1 -1
  62. data/lib/principles/data/schemas/correction-answer.schema.json +9 -9
  63. data/lib/principles/data/schemas/member-map.schema.json +3 -3
  64. data/lib/principles/data/schemas/repointing-answer.schema.json +1 -1
  65. data/lib/principles/error.rb +4 -4
  66. data/lib/principles/failure_refusal.rb +57 -0
  67. data/lib/principles/invocation_options.rb +4 -4
  68. data/lib/principles/launch.rb +49 -0
  69. data/lib/principles/list_open_findings_options.rb +1 -1
  70. data/lib/principles/models/accepted_loading.rb +2 -2
  71. data/lib/principles/models/acknowledged_check.rb +23 -11
  72. data/lib/principles/models/acknowledgement.rb +34 -18
  73. data/lib/principles/models/acknowledgement_left_as_printed.rb +7 -15
  74. data/lib/principles/models/acknowledgement_refusal.rb +25 -10
  75. data/lib/principles/models/acknowledgements.rb +45 -29
  76. data/lib/principles/models/acknowledgements_across.rb +68 -0
  77. data/lib/principles/models/activation.rb +2 -2
  78. data/lib/principles/models/after_commit_input.rb +115 -0
  79. data/lib/principles/models/agent_loads.rb +1 -1
  80. data/lib/principles/models/answer_fields.rb +2 -2
  81. data/lib/principles/models/answer_place.rb +3 -3
  82. data/lib/principles/models/answer_text.rb +2 -2
  83. data/lib/principles/models/answered_time.rb +4 -4
  84. data/lib/principles/models/assessment_answer.rb +10 -10
  85. data/lib/principles/models/assessment_basis.rb +2 -2
  86. data/lib/principles/models/assessment_left_as_printed.rb +1 -1
  87. data/lib/principles/models/assessment_report.rb +6 -7
  88. data/lib/principles/models/audit.rb +33 -34
  89. data/lib/principles/models/audit_record.rb +54 -28
  90. data/lib/principles/models/audit_records.rb +13 -13
  91. data/lib/principles/models/audit_start.rb +3 -3
  92. data/lib/principles/models/audited_member_lines.rb +1 -1
  93. data/lib/principles/models/candidate_files.rb +18 -10
  94. data/lib/principles/models/candidate_inventory.rb +6 -6
  95. data/lib/principles/models/candidate_outline.rb +9 -9
  96. data/lib/principles/models/carried_assessments.rb +18 -3
  97. data/lib/principles/models/carried_member.rb +5 -5
  98. data/lib/principles/models/changed_regions.rb +92 -0
  99. data/lib/principles/models/check_result_guide.rb +50 -0
  100. data/lib/principles/models/check_since_last_audit.rb +5 -4
  101. data/lib/principles/models/cited_files.rb +4 -4
  102. data/lib/principles/models/command_steps.rb +3 -3
  103. data/lib/principles/models/commits_brought_in.rb +1 -1
  104. data/lib/principles/models/commits_since_base.rb +1 -1
  105. data/lib/principles/models/correction_answer.rb +2 -2
  106. data/lib/principles/models/correction_basis.rb +7 -7
  107. data/lib/principles/models/dated_line.rb +1 -2
  108. data/lib/principles/models/decided_prior_findings.rb +6 -6
  109. data/lib/principles/models/declared_map_changes.rb +5 -5
  110. data/lib/principles/models/disposition.rb +21 -21
  111. data/lib/principles/models/entry_file.rb +1 -1
  112. data/lib/principles/models/entry_files.rb +1 -1
  113. data/lib/principles/models/evidence_item.rb +1 -1
  114. data/lib/principles/models/evidence_lines_since.rb +2 -2
  115. data/lib/principles/models/evidence_replacements.rb +3 -3
  116. data/lib/principles/models/finding_write_ups.rb +12 -5
  117. data/lib/principles/models/findings_left_open.rb +4 -4
  118. data/lib/principles/models/first_full_audit.rb +32 -0
  119. data/lib/principles/models/first_raised_claim.rb +1 -1
  120. data/lib/principles/models/fix_only_fields.rb +1 -1
  121. data/lib/principles/models/head_moves.rb +66 -0
  122. data/lib/principles/models/hook_commands.rb +49 -4
  123. data/lib/principles/models/ignored_candidates.rb +1 -1
  124. data/lib/principles/models/instruction_named.rb +2 -3
  125. data/lib/principles/models/json_digest.rb +2 -2
  126. data/lib/principles/models/json_path_query.rb +1 -1
  127. data/lib/principles/models/kept_prior_finding.rb +9 -9
  128. data/lib/principles/models/last_completed_revision.rb +4 -5
  129. data/lib/principles/models/left_as_printed.rb +2 -2
  130. data/lib/principles/models/line_diff.rb +113 -0
  131. data/lib/principles/models/line_span.rb +1 -1
  132. data/lib/principles/models/list_member_problems_check.rb +4 -4
  133. data/lib/principles/models/listed_members.rb +7 -9
  134. data/lib/principles/models/loaded_files.rb +4 -5
  135. data/lib/principles/models/loading_decision.rb +3 -3
  136. data/lib/principles/models/loading_facts.rb +1 -1
  137. data/lib/principles/models/loads_to_check.rb +1 -1
  138. data/lib/principles/models/located_text.rb +1 -1
  139. data/lib/principles/models/mapped_principles.rb +2 -2
  140. data/lib/principles/models/member.rb +31 -4
  141. data/lib/principles/models/member_assessments.rb +8 -8
  142. data/lib/principles/models/member_elsewhere.rb +4 -4
  143. data/lib/principles/models/member_file.rb +4 -4
  144. data/lib/principles/models/member_grounds.rb +1 -1
  145. data/lib/principles/models/member_hashes_as_written.rb +1 -1
  146. data/lib/principles/models/member_lines.rb +29 -61
  147. data/lib/principles/models/member_loads.rb +2 -2
  148. data/lib/principles/models/member_moves.rb +1 -1
  149. data/lib/principles/models/member_problems.rb +14 -15
  150. data/lib/principles/models/member_repair_moves.rb +15 -9
  151. data/lib/principles/models/member_sighting.rb +10 -10
  152. data/lib/principles/models/member_snapshots.rb +1 -1
  153. data/lib/principles/models/member_state.rb +1 -1
  154. data/lib/principles/models/members_across_principles.rb +77 -0
  155. data/lib/principles/models/members_elsewhere.rb +2 -2
  156. data/lib/principles/models/members_sharing_lines.rb +7 -7
  157. data/lib/principles/models/meta_principle.rb +11 -4
  158. data/lib/principles/models/missing_files.rb +3 -3
  159. data/lib/principles/models/new_findings.rb +4 -4
  160. data/lib/principles/models/open_correction.rb +57 -0
  161. data/lib/principles/models/open_finding.rb +36 -31
  162. data/lib/principles/models/open_findings_elsewhere.rb +2 -2
  163. data/lib/principles/models/other_principles.rb +2 -2
  164. data/lib/principles/models/other_templates_placeholders.rb +17 -16
  165. data/lib/principles/models/outline_budget.rb +7 -7
  166. data/lib/principles/models/outline_group.rb +1 -1
  167. data/lib/principles/models/outline_section.rb +2 -2
  168. data/lib/principles/models/part_named.rb +41 -0
  169. data/lib/principles/models/placement.rb +2 -2
  170. data/lib/principles/models/principle.rb +13 -13
  171. data/lib/principles/models/principle_history.rb +8 -8
  172. data/lib/principles/models/principle_members.rb +14 -7
  173. data/lib/principles/models/principles_folder_move.rb +1 -1
  174. data/lib/principles/models/principles_on_path.rb +29 -0
  175. data/lib/principles/models/principles_package.rb +3 -3
  176. data/lib/principles/models/prior_decision_fields.rb +8 -8
  177. data/lib/principles/models/prior_finding_decision.rb +8 -8
  178. data/lib/principles/models/prior_finding_outcomes.rb +1 -1
  179. data/lib/principles/models/prior_findings.rb +5 -5
  180. data/lib/principles/models/problem_report.rb +26 -8
  181. data/lib/principles/models/project.rb +27 -19
  182. data/lib/principles/models/project_history.rb +18 -12
  183. data/lib/principles/models/quoted_change.rb +8 -8
  184. data/lib/principles/models/recent_decision.rb +3 -3
  185. data/lib/principles/models/record_format.rb +16 -10
  186. data/lib/principles/models/record_judged_against.rb +4 -4
  187. data/lib/principles/models/recorded_entry.rb +17 -8
  188. data/lib/principles/models/recorded_finding.rb +9 -9
  189. data/lib/principles/models/recorded_findings.rb +2 -2
  190. data/lib/principles/models/recorded_hashes.rb +2 -2
  191. data/lib/principles/models/recorded_members.rb +13 -13
  192. data/lib/principles/models/refusal_before_shape.rb +2 -2
  193. data/lib/principles/models/repoint.rb +3 -3
  194. data/lib/principles/models/report_hooks.rb +69 -0
  195. data/lib/principles/models/reported_check.rb +34 -31
  196. data/lib/principles/models/request_id.rb +18 -6
  197. data/lib/principles/models/runs_from.rb +7 -2
  198. data/lib/principles/models/sent_answer.rb +14 -12
  199. data/lib/principles/models/sent_prior_decisions.rb +1 -1
  200. data/lib/principles/models/session_start_input.rb +37 -0
  201. data/lib/principles/models/shape_problems_beside.rb +1 -1
  202. data/lib/principles/models/skill_loads.rb +1 -1
  203. data/lib/principles/models/stale_request.rb +59 -0
  204. data/lib/principles/models/still_holds_restatement.rb +6 -6
  205. data/lib/principles/models/submitted_answer.rb +1 -1
  206. data/lib/principles/models/template_placeholders.rb +6 -6
  207. data/lib/principles/models/text_within.rb +1 -1
  208. data/lib/principles/models/tracked_paths.rb +38 -0
  209. data/lib/principles/models/unchecked_members.rb +2 -2
  210. data/lib/principles/models/uncommitted_files.rb +1 -1
  211. data/lib/principles/models/uncommitted_outside_the_map.rb +2 -2
  212. data/lib/principles/models/waits_on.rb +1 -1
  213. data/lib/principles/models/write_up_opening.rb +5 -5
  214. data/lib/principles/models/write_up_pointer.rb +3 -3
  215. data/lib/principles/models/write_up_repoint.rb +2 -3
  216. data/lib/principles/positional_arguments.rb +13 -6
  217. data/lib/principles/prose_list.rb +1 -1
  218. data/lib/principles/session_start_options.rb +1 -1
  219. data/lib/principles/start_audit_options.rb +46 -12
  220. data/lib/principles/supported_ruby.rb +24 -7
  221. data/lib/principles/version.rb +2 -2
  222. data/lib/principles/views/acknowledged_since_last_audit.rb +2 -2
  223. data/lib/principles/views/acknowledgement_result.rb +97 -11
  224. data/lib/principles/views/activation_in_hand.rb +1 -1
  225. data/lib/principles/views/answered_request.rb +6 -2
  226. data/lib/principles/views/assessed_members.rb +50 -41
  227. data/lib/principles/views/assessment_request.rb +39 -36
  228. data/lib/principles/views/audit_changes.rb +4 -4
  229. data/lib/principles/views/audit_commit.rb +5 -4
  230. data/lib/principles/views/audit_result.rb +92 -53
  231. data/lib/principles/views/candidate_files_result.rb +7 -6
  232. data/lib/principles/views/check_notes.rb +29 -6
  233. data/lib/principles/views/check_result_template.rb +45 -34
  234. data/lib/principles/views/completed_audit_next_step.rb +44 -0
  235. data/lib/principles/views/context_parts.rb +112 -0
  236. data/lib/principles/views/correction_request.rb +44 -25
  237. data/lib/principles/views/diff_since_last_audit.rb +8 -6
  238. data/lib/principles/views/findings_result.rb +17 -6
  239. data/lib/principles/views/first_audit_brief.rb +51 -0
  240. data/lib/principles/views/first_audit_line.rb +45 -0
  241. data/lib/principles/views/help.rb +4 -4
  242. data/lib/principles/views/hook_setup_result.rb +91 -0
  243. data/lib/principles/views/instruction.rb +3 -3
  244. data/lib/principles/views/invocation.rb +14 -6
  245. data/lib/principles/views/json_with_entries_on_lines.rb +6 -35
  246. data/lib/principles/views/landed_since_base.rb +1 -1
  247. data/lib/principles/views/line_history_since_last_audit.rb +35 -0
  248. data/lib/principles/views/lines_shared_with_member.rb +6 -6
  249. data/lib/principles/views/loads_to_check_result.rb +8 -5
  250. data/lib/principles/views/map_added_to.rb +3 -3
  251. data/lib/principles/views/map_result.rb +9 -9
  252. data/lib/principles/views/member_change_since_baseline.rb +44 -23
  253. data/lib/principles/views/member_lines_beside_text.rb +43 -0
  254. data/lib/principles/views/member_repairs.rb +3 -2
  255. data/lib/principles/views/member_row.rb +2 -2
  256. data/lib/principles/views/members_a_commit_changed.rb +13 -10
  257. data/lib/principles/views/members_with_no_baseline.rb +3 -3
  258. data/lib/principles/views/meta_principle_passage.rb +1 -1
  259. data/lib/principles/views/meta_principle_result.rb +12 -5
  260. data/lib/principles/views/one_member_check_result_template.rb +7 -7
  261. data/lib/principles/views/open_findings_elsewhere_result.rb +5 -2
  262. data/lib/principles/views/open_findings_line.rb +25 -36
  263. data/lib/principles/views/other_principles_unjudged_result.rb +6 -3
  264. data/lib/principles/views/outside_the_map_result.rb +5 -2
  265. data/lib/principles/views/package_since_last_audit_result.rb +29 -6
  266. data/lib/principles/views/parts_index_result.rb +60 -0
  267. data/lib/principles/views/principle_read_result.rb +5 -6
  268. data/lib/principles/views/principle_with_changed_members.rb +1 -1
  269. data/lib/principles/views/principles_with_no_completed_audit.rb +1 -2
  270. data/lib/principles/views/printed_json.rb +51 -0
  271. data/lib/principles/views/printed_principle.rb +1 -1
  272. data/lib/principles/views/prior_finding_decisions_result.rb +4 -4
  273. data/lib/principles/views/prior_findings_result.rb +17 -14
  274. data/lib/principles/views/problem_lines.rb +39 -17
  275. data/lib/principles/views/problem_result.rb +40 -37
  276. data/lib/principles/views/prompts/acknowledge-a-change/judge-each-member-once-for-every-principle.md +2 -0
  277. data/lib/principles/views/prompts/acknowledge-a-change/read-the-deferred-findings-it-keeps.md +1 -0
  278. data/lib/principles/views/prompts/acknowledge-a-change/resolve-them-in-a-full-audit.md +1 -0
  279. data/lib/principles/views/prompts/acknowledge-a-change/say-whether-the-change-keeps-the-meaning.md +3 -3
  280. data/lib/principles/views/prompts/assess-every-member/confirm-each-write-up-pointer-the-answer-drops.md +2 -0
  281. data/lib/principles/views/prompts/assess-every-member/have-a-changed-check-reviewed-before-running-it.md +1 -1
  282. data/lib/principles/views/prompts/assess-every-member/have-a-new-check-reviewed-before-running-it.md +1 -1
  283. data/lib/principles/views/prompts/assess-every-member/judge-a-carried-assessment-citing-a-decided-finding.md +3 -0
  284. data/lib/principles/views/prompts/assess-every-member/judge-a-submitted-carried-assessment-citing-a-decided-finding.md +5 -0
  285. data/lib/principles/views/prompts/assess-every-member/judge-the-keeping-under-the-release-since-the-last-audit.md +1 -1
  286. data/lib/principles/views/prompts/assess-every-member/keep-the-printed-review-basis-or-replace-it.md +1 -0
  287. data/lib/principles/views/prompts/assess-every-member/name-the-commit-that-made-the-check.md +1 -0
  288. data/lib/principles/views/prompts/assess-every-member/read-a-trimmed-instruction-whole.md +1 -1
  289. data/lib/principles/views/prompts/assess-every-member/read-the-request-in-parts.md +1 -0
  290. data/lib/principles/views/prompts/assess-every-member/why-each-member-is-judged-again.md +3 -2
  291. data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +1 -1
  292. data/lib/principles/views/prompts/dispose-of-each-finding/confirm-each-deferral-written-up-nowhere.md +2 -0
  293. data/lib/principles/views/prompts/dispose-of-each-finding/retain-assessment-and-correction.md +4 -4
  294. data/lib/principles/views/prompts/find-a-principle-to-map/where-the-inventory-looks.md +2 -2
  295. data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +4 -3
  296. data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +6 -6
  297. data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +11 -11
  298. data/lib/principles/views/prompts/learn-what-a-command-does/report-after-commit.md +14 -0
  299. data/lib/principles/views/prompts/learn-what-a-command-does/report-at-session-start.md +26 -0
  300. data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +20 -18
  301. data/lib/principles/views/prompts/learn-what-a-command-does/show-first-audit-brief.md +19 -0
  302. data/lib/principles/views/prompts/learn-what-a-command-does/show-hook-setup.md +13 -0
  303. data/lib/principles/views/prompts/learn-what-a-command-does/show-meta-principle-passage.md +3 -1
  304. data/lib/principles/views/prompts/learn-what-a-command-does/show-open-correction.md +12 -0
  305. data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +21 -22
  306. data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +5 -4
  307. data/lib/principles/views/prompts/report-the-completed-audit/commit-only-what-the-audit-changed.md +2 -2
  308. data/lib/principles/views/prompts/run-a-first-audit-in-the-background/follow-the-brief.md +18 -0
  309. data/lib/principles/views/prompts/set-principles-up/offer-the-report-hooks.md +2 -0
  310. data/lib/principles/views/prompts/set-principles-up/wire-the-report-hooks-with-the-user.md +8 -0
  311. data/lib/principles/views/prompts/start-a-session/act-on-the-open-findings.md +3 -4
  312. data/lib/principles/views/prompts/start-a-session/every-loaded-line-costs-every-session.md +1 -1
  313. data/lib/principles/views/prompts/start-a-session/hand-the-first-audit-to-a-subagent.md +3 -0
  314. data/lib/principles/views/prompts/start-a-session/run-each-command-above.md +1 -0
  315. data/lib/principles/views/prompts/start-a-session/start-no-second-first-audit.md +2 -0
  316. data/lib/principles/views/prompts.rb +1 -1
  317. data/lib/principles/views/read_the_change.rb +36 -0
  318. data/lib/principles/views/record_waiting_on_an_upgrade.rb +2 -2
  319. data/lib/principles/views/repoint_result.rb +1 -1
  320. data/lib/principles/views/report_hooks_offer.rb +25 -0
  321. data/lib/principles/views/request_part.rb +5 -5
  322. data/lib/principles/views/request_parts.rb +1 -1
  323. data/lib/principles/views/session_start_report.rb +46 -0
  324. data/lib/principles/views/shell_word.rb +1 -1
  325. data/lib/principles/views/trimmed_instructions_note.rb +30 -0
  326. data/lib/principles/views/visible_text.rb +1 -1
  327. data/lib/principles/views/workflow_diagram.rb +1 -1
  328. data/principles.gemspec +44 -0
  329. metadata +83 -14
  330. data/lib/principles/views/prompts/start-a-session/it-returns-after-each-clear-or-compaction-too.md +0 -1
  331. data/lib/principles/views/prompts/start-a-session/it-returns-at-each-session-start.md +0 -1
@@ -9,7 +9,7 @@ module Principles
9
9
  # controllers/CLAUDE.md owns the boundary.
10
10
  module Controllers
11
11
  # list-member-problems --commits-after COMMIT --hook-event EVENT, which the plugin's after-commit hook runs once a
12
- # Bash call moved HEAD (D73): the members the commits after COMMIT changed, as the hook's JSON, or nothing. It
12
+ # Bash call moved HEAD: the members the commits after COMMIT changed, as the hook's JSON, or nothing. It
13
13
  # exits 0 whatever it finds, since the host shows the user an error for any other status, and reports a refusal
14
14
  # only when those commits could have caused it, so a broken setup does not repeat at every commit (review R8).
15
15
  class MembersACommitChanged < Command
@@ -38,7 +38,7 @@ module Principles
38
38
  private
39
39
 
40
40
  # The hook's output naming changed, the members the commits changed, beside others still listed, with the wait
41
- # of each of their principles whose record a later copy wrote, which says why their audits wait (D85 V8, #1066).
41
+ # of each of their principles whose record a later copy wrote, which says why their audits wait.
42
42
  #: (String, Array[Hash[String, untyped]], others: Integer) -> Views::Lines
43
43
  def changed_lines(event, changed, others:)
44
44
  waits = changed.map { it.fetch("principle") }.uniq.filter_map { waiting_on_an_upgrade(it) }
@@ -46,7 +46,7 @@ module Principles
46
46
  end
47
47
 
48
48
  #: () -> Views::MembersACommitChanged
49
- def view = Views::MembersACommitChanged.new(invocation)
49
+ def view = Views::MembersACommitChanged.new(invocation, skill: @tool.runs_from.principles_skill_in_this_session?)
50
50
  end
51
51
  end
52
52
  end
@@ -6,7 +6,7 @@ require_relative "../models/carried_member"
6
6
  require_relative "../models/check_since_last_audit"
7
7
  require_relative "../models/open_findings_elsewhere"
8
8
  require_relative "../views/acknowledged_since_last_audit"
9
- require_relative "../views/diff_since_last_audit"
9
+ require_relative "../views/read_the_change"
10
10
 
11
11
  module Principles
12
12
  # Each runs one command: reads models, applies their rules and prints through a view.
@@ -16,7 +16,7 @@ module Principles
16
16
  # it, beside what the principle's audit record says of it since the last full audit.
17
17
  class MembersToAssess < Command
18
18
  # The members a full audit's request lists, each as the agent assesses it, and the findings other principles
19
- # leave open on members sharing their lines, each once, which each member's mapped_elsewhere names by id (D62).
19
+ # leave open on members sharing their lines, each once, which each member's mapped_elsewhere names by id.
20
20
  class Listing
21
21
  #: Array[Hash[String, untyped]]
22
22
  attr_reader :members
@@ -46,8 +46,8 @@ module Principles
46
46
  # Each member of audit's map as the assessment request shows it, located as current has it: id, role, lines,
47
47
  # the evidence that locates it and the check that enforces it, if any, with whether the last audit already had
48
48
  # it run, the edits to it acknowledged since that audit, its last assessment carried forward by audit, or why
49
- # it is judged again (D49) with the command that shows its file's edits since that audit (#771), and the other
50
- # principles' members sharing its lines (#719), beside the findings their principles leave open on them (D62).
49
+ # it is judged again with the command that shows its file's edits since that audit, and the other
50
+ # principles' members sharing its lines, beside the findings their principles leave open on them.
51
51
  #: (Models::Audit, Models::MemberSnapshots) -> Listing
52
52
  def listed(audit, current)
53
53
  map = audit.map
@@ -68,18 +68,18 @@ module Principles
68
68
  member = Models::Member.new(fields)
69
69
  judged = carried(member, carried, elsewhere)
70
70
  located(member, current).merge(checked(member), acknowledged(fields), judged,
71
- changed_since(fields, judged), shared_lines(member, elsewhere))
71
+ changed_since(fields, judged, current), shared_lines(member, elsewhere))
72
72
  end
73
73
 
74
74
  # Each finding elsewhere names, once, with each evidence item's lines beside this audit's members, where current
75
- # locates them; the project locates each item now (D64).
75
+ # locates them; the project locates each item now.
76
76
  #: (Models::OpenFindingsElsewhere, Models::MemberSnapshots) -> Array[Hash[String, untyped]]
77
77
  def elsewhere_listed(elsewhere, current)
78
78
  elsewhere.listed(current.audited_lines) { |locator| @project.located_text(locator) }
79
79
  end
80
80
 
81
81
  # The other principles' members sharing a line with each member of map where current locates it, with the
82
- # findings their records leave open on them, each record read once (#772, D62). The request id hashes this
82
+ # findings their records leave open on them, each record read once. The request id hashes this
83
83
  # principle's members, not other maps or their records: another principle changing after the request is its
84
84
  # own audit to judge, and does not make this one stale.
85
85
  #: (Models::Principle, Models::MemberSnapshots) -> Models::OpenFindingsElsewhere
@@ -91,8 +91,8 @@ module Principles
91
91
  end
92
92
 
93
93
  # The other principles' members sharing a line with member, each with its role there, so a contradiction
94
- # between the two maps shows in this audit (#719), naming the findings that principle leaves open on it, so one
95
- # problem is not raised under both (#772, D62); nothing when there are none.
94
+ # between the two maps shows in this audit, naming the findings that principle leaves open on it, so one
95
+ # problem is not raised under both; nothing when there are none.
96
96
  #: (Models::Member, Models::OpenFindingsElsewhere) -> Hash[String, untyped]
97
97
  def shared_lines(member, elsewhere)
98
98
  Views::LinesSharedWithMember.new(mapped_elsewhere: elsewhere.beside(member.id)).to_h
@@ -100,9 +100,9 @@ module Principles
100
100
 
101
101
  # The member's last assessment carried forward, with whether any evidence it cited changed since and, in git,
102
102
  # whether its file changed since the last full audit's base commit, outside the member, whose own text did not;
103
- # or why it is judged again. These are facts: the agent may re-judge any carried member (D49). flagged says
103
+ # or why it is judged again. These are facts: the agent may re-judge any carried member. flagged says
104
104
  # whether any fires, or another principle leaves a finding open on its lines, so the request prints the member
105
- # whole rather than compactly (D93).
105
+ # whole rather than compactly.
106
106
  #: (Models::Member, Models::CarriedAssessments, Models::OpenFindingsElsewhere) -> Hash[String, untyped]
107
107
  def carried(member, carried, elsewhere)
108
108
  shown = carried.shown(member.id) { |locator, sha| evidence_changed?(locator, sha) }
@@ -136,20 +136,23 @@ module Principles
136
136
  .merge(current.of(member.id).lines)
137
137
  end
138
138
 
139
- # The command that shows the edits to a member judged again to its file since the last full audit's base
140
- # commit, over its path then and now (#557, #771); nothing for a member carried forward, or with no such
141
- # commit, as outside git or before any full audit.
142
- #: (Hash[String, untyped], Hash[String, untyped]) -> Hash[String, untyped]
143
- def changed_since(fields, judged)
139
+ # The command that shows the edits to a member judged again since the last full audit's base commit: to its
140
+ # own lines, where current locates them, for part of a file at the same path then and now; else to its file,
141
+ # 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.
143
+ #: (Hash[String, untyped], Hash[String, untyped], Models::MemberSnapshots) -> Hash[String, untyped]
144
+ def changed_since(fields, judged, current)
144
145
  base = @completed&.base_commit
145
146
  return {} unless judged["judge_because"] && base
146
147
 
147
- paths = principle_history(@principle_id).paths_from(base, Models::Member.new(fields).key, fields)
148
- { "read_the_change" => Views::DiffSinceLastAudit.new(last_audited_commit: base, paths: paths).to_s }
148
+ member = Models::Member.new(fields)
149
+ paths = principle_history(@principle_id).paths_from(base, member.key, fields)
150
+ lines = member.traced_lines(paths, current.of(member.id).lines)
151
+ { "read_the_change" => Views::ReadTheChange.new(since: base, paths:, lines:).to_s }
149
152
  end
150
153
 
151
- # The edits to member acknowledged since the last full audit, which this audit judges together (D33, #312), with
152
- # its lines then and now; its read_the_change shows the whole change (#771).
154
+ # The edits to member acknowledged since the last full audit, which this audit judges together, with
155
+ # its lines then and now; its read_the_change shows the whole change.
153
156
  #: (Hash[String, untyped]) -> Hash[String, untyped]
154
157
  def acknowledged(fields)
155
158
  last = @completed or return {}
@@ -4,7 +4,6 @@
4
4
  require_relative "command"
5
5
  require_relative "inventory"
6
6
  require_relative "../models/entry_files"
7
- require_relative "../models/runs_from"
8
7
  require_relative "../models/meta_principle"
9
8
  require_relative "../models/text_size"
10
9
  require_relative "../views/meta_principle_result"
@@ -14,7 +13,7 @@ module Principles
14
13
  # controllers/CLAUDE.md owns the boundary.
15
14
  module Controllers
16
15
  # Setting principles up: shows the map of the principle that keeps every other one held, and proposes its passage
17
- # for the agent to place with the user, since this tool writes none of the project's guidance (D67, D68); the
16
+ # for the agent to place with the user, since this tool writes none of the project's guidance; the
18
17
  # add-member it prints writes the map (T74). It takes no id, since the principle is the product's own.
19
18
  class MetaPrincipleSetup < Command
20
19
  #: (String, String?, Hash[String, untyped]) -> untyped
@@ -39,7 +38,7 @@ module Principles
39
38
  end
40
39
 
41
40
  # map as the project holds it: whether it was there before this run, its members already in an entry file, and
42
- # whether principles is set up, its map having a member (D75).
41
+ # whether principles is set up, its map having a member.
43
42
  #: (Models::Principle) -> Views::MetaPrincipleResult::MapInProject
44
43
  def map_in_project(map)
45
44
  Views::MetaPrincipleResult::MapInProject.new(
@@ -56,7 +55,7 @@ module Principles
56
55
  # entry files, and the passage.
57
56
  #: (Views::MetaPrincipleResult) -> Views::MetaPrincipleResult::Placement
58
57
  def placement(view)
59
- runs_from = Models::RunsFrom.new(@tool.executable)
58
+ runs_from = @tool.runs_from
60
59
  Views::MetaPrincipleResult::Placement.new(
61
60
  runs_from: runs_from.to_s, session_start_hook_in_this_session: runs_from.session_start_hook_in_this_session?,
62
61
  entry_files: @project.entry_files.to_a, passage: passage(view)
@@ -70,7 +69,7 @@ module Principles
70
69
  end
71
70
 
72
71
  # The passage member's heading and role, the role of a passage the project has that carries one of its steps,
73
- # and the role of any other place that keeps the principles held (D75).
72
+ # and the role of any other place that keeps the principles held.
74
73
  #: () -> Views::MetaPrincipleResult::PassageMapping
75
74
  def passage_mapping
76
75
  Views::MetaPrincipleResult::PassageMapping.new(heading: Models::MetaPrinciple::PASSAGE_HEADING,
@@ -80,7 +79,7 @@ module Principles
80
79
  end
81
80
 
82
81
  # The passage's text, as the agent pastes it, with its size, which loads in every session (F9), and what it
83
- # presumes of a teammate without principles (D71).
82
+ # presumes of a teammate without principles.
84
83
  #: (Views::MetaPrincipleResult) -> Hash[String, untyped]
85
84
  def passage(view)
86
85
  text = view.passage
@@ -0,0 +1,42 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "command"
5
+ require_relative "../models/disposition"
6
+ require_relative "../models/open_correction"
7
+ require_relative "../views/answer_head"
8
+ require_relative "../views/correction_request"
9
+
10
+ module Principles
11
+ # Each runs one command: reads models, applies their rules and prints through a view.
12
+ # controllers/CLAUDE.md owns the boundary.
13
+ module Controllers
14
+ # show-open-correction: the answer to fill for the correction a full audit's assessment with findings opened,
15
+ # printed from the open record that keeps it, which submit-answer names rather than prints, and whenever the
16
+ # agent loses it, without submitting the assessment again.
17
+ class OpenCorrection < Command
18
+ #: (String, String?, Hash[String, untyped]) -> untyped
19
+ def call(command, id, _options)
20
+ naming_the_executable do
21
+ unknown(command) unless command == "show-open-correction"
22
+
23
+ principle_id = required_id(id)
24
+ @principles.find(principle_id)
25
+ correction_to_fill(principle_id)
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ # The open correction's answer alone, as show-answer-check --as template prints it before the submit.
32
+ #: (String) -> Hash[String, untyped]
33
+ def correction_to_fill(principle_id)
34
+ kept = Models::OpenCorrection.kept(principle_id, @audit_records.find(principle_id),
35
+ file: @audit_records.file(principle_id))
36
+ head = Views::AnswerHead.new(request_id: kept.request_id, basis: kept.basis)
37
+ Views::CorrectionRequest.new(head:, principle_id:, findings: kept.findings,
38
+ placeholders: Models::Disposition::TEMPLATE_PLACEHOLDERS).correction_to_fill
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,117 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "command"
5
+ require_relative "../models/evidence_lines_since"
6
+ require_relative "../models/loading_decision"
7
+ require_relative "../models/other_principles"
8
+ require_relative "../models/prior_decision_fields"
9
+ require_relative "../models/uncommitted_outside_the_map"
10
+ require_relative "../views/loads_to_check_result"
11
+ require_relative "../views/open_findings_elsewhere_result"
12
+ require_relative "../views/other_principles_unjudged_result"
13
+ require_relative "../views/outside_the_map_result"
14
+ require_relative "../views/package_since_last_audit_result"
15
+ require_relative "../views/prior_findings_result"
16
+ require_relative "members_to_assess"
17
+
18
+ module Principles
19
+ # Each runs one command: reads models, applies their rules and prints through a view.
20
+ # controllers/CLAUDE.md owns the boundary.
21
+ module Controllers
22
+ # The parts a full audit's request lists beside its members, which FullAuditRequest hands over: each a list the
23
+ # agent reads, with its instruction and its slots in the answer.
24
+ class PartsToRead < Command
25
+ # Each part listed only when it holds something, which start-audit --part answers as empty when it is left out.
26
+ OPTIONAL = [Views::OutsideTheMapResult::PART, Views::PriorFindingsResult::PART,
27
+ Views::OpenFindingsElsewhereResult::PART, Views::LoadsToCheckResult::PART,
28
+ Views::PackageSinceLastAuditResult::PART,
29
+ Views::OtherPrinciplesUnjudgedResult::PART].freeze #: Array[String]
30
+
31
+ # audit is the audit asked of the principle's map, listing the members its request lists and audited_files the
32
+ # files its base commit is judged over.
33
+ #: (Models::Project, tool: RunningTool, audit: Models::Audit, listing: MembersToAssess::Listing,
34
+ #| audited_files: Array[String]) -> void
35
+ def initialize(project, tool:, audit:, listing:, audited_files:)
36
+ super(project, tool: tool)
37
+ @id = audit.map.id #: String
38
+ @audit = audit
39
+ @listing = listing
40
+ @audited_files = audited_files
41
+ end
42
+
43
+ # What the agent reads beside the members, in order: the files outside the map that differ from the
44
+ # base commit, which a check and the answer's evidence read as they are now; the prior findings;
45
+ # 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
+ map = @audit.map
51
+ [outside_the_map, prior_findings_part(prior),
52
+ Views::OpenFindingsElsewhereResult.new(@listing.open_findings_elsewhere).part,
53
+ loads_part(loads), package_since_last_audit(map),
54
+ other_principles_unjudged(map)].compact
55
+ end
56
+
57
+ private
58
+
59
+ # The part listing the members to check against the activation, each decision's template printing the
60
+ # placeholders an answer leaves as printed to give none; nil when none is listed.
61
+ #: (Hash[String, untyped]?) -> Views::RequestPart?
62
+ def loads_part(loads)
63
+ Views::LoadsToCheckResult.new(invocation, loads, @id, placeholders: Models::LoadingDecision::PLACEHOLDERS.to_h)
64
+ .part
65
+ end
66
+
67
+ # The part listing each other principle with members no audit has judged as they are now, as
68
+ # list-member-problems reports them, for the principle whose audit states them; nil for any other.
69
+ #: (Models::Principle) -> Views::RequestPart?
70
+ def other_principles_unjudged(map)
71
+ return unless map.keeps_others_held?
72
+
73
+ listed = Models::OtherPrinciples.of(@project, but: map.id).unjudged.map do |other, members|
74
+ Views::PrincipleWithChangedMembers.new(principle_id: other, members: members)
75
+ end
76
+ Views::OtherPrinciplesUnjudgedResult.new(listed).part
77
+ end
78
+
79
+ # The part stating the release of principles the last completed audit ran under beside the one now, and
80
+ # whether the passage changed since, for a principle whose audit keeps one; nil for any other.
81
+ #: (Models::Principle) -> Views::RequestPart?
82
+ def package_since_last_audit(map)
83
+ now = @tool.release_kept_by(map) or return
84
+ last = @audit_records.find(map.id)&.last_completed&.package
85
+ Views::PackageSinceLastAuditResult.new(invocation, at_last_audit: last&.version, now: now.version,
86
+ passage_changed: last && now.passage_changed_since?(last),
87
+ mapped: package_parts_mapped(map))
88
+ .part
89
+ end
90
+
91
+ # Each part of principles an upgrade can change that map's members are, from the hooks every host reads and,
92
+ # where a member's part asks, its text now.
93
+ #: (Models::Principle) -> Array[String]
94
+ def package_parts_mapped(map)
95
+ hooks = @project.hook_commands(Models::HookCommands::ON_EVERY_HOST)
96
+ map.members.package_parts(hooks) { |member| @project.member_text(member.locator) }
97
+ end
98
+
99
+ # The part listing the prior findings, in git with each evidence item saying whether its text changed since the
100
+ # commit the audit that left them open was based on, and whether it is found now; nil when there are
101
+ # none.
102
+ #: (Models::PriorFindings) -> Views::RequestPart?
103
+ def prior_findings_part(prior)
104
+ shown = prior.shown { |item, base| Models::EvidenceLinesSince.of(item, since: base, project: @project).facts }
105
+ Views::PriorFindingsResult.new(shown, placeholders: Models::PriorDecisionFields::TEMPLATE_PLACEHOLDERS,
106
+ last_audited_commit: prior.last_audited_commit).part
107
+ end
108
+
109
+ # The part naming the files outside the map that differ from the base commit, or nil when none do.
110
+ #: () -> Views::RequestPart?
111
+ def outside_the_map
112
+ outside = @history.uncommitted_outside(@audited_files)
113
+ Views::OutsideTheMapResult.new(outside && Models::UncommittedOutsideTheMap.new(outside).shown).part
114
+ end
115
+ end
116
+ end
117
+ end
@@ -13,7 +13,7 @@ module Principles
13
13
  # Each runs one command: reads models, applies their rules and prints through a view.
14
14
  # controllers/CLAUDE.md owns the boundary.
15
15
  module Controllers
16
- # A repoint of a principle's open findings' write-ups (D59): start-audit ID --write-ups lists each open finding
16
+ # A repoint of a principle's open findings' write-ups: start-audit ID --write-ups lists each open finding
17
17
  # with where its write-up is now, and submit-answer points the recorded_at the agent gives in the audit record.
18
18
  class Repoint < AnswerPhase
19
19
  # The request for principle id's open findings.
@@ -3,6 +3,9 @@
3
3
 
4
4
  require_relative "../models/meta_principle"
5
5
  require_relative "../models/principles_package"
6
+ require_relative "../models/principles_on_path"
7
+ require_relative "../models/runs_from"
8
+ require_relative "../views/invocation"
6
9
  require_relative "../views/meta_principle_passage"
7
10
 
8
11
  module Principles
@@ -12,23 +15,63 @@ module Principles
12
15
  # This run of the tool, as its entry point was invoked: the executable every printed command names, and the
13
16
  # version running, which only the command line can read; and so the release of principles it comes from.
14
17
  class RunningTool
15
- #: String
16
- attr_reader :executable
18
+ # The command a printed command names when a bare principles runs this same copy, the name the plugin's
19
+ # entry point gives itself for the same reason.
20
+ ON_PATH = Models::RunsFrom::PLUGIN_EXECUTABLE
17
21
 
18
22
  # version gives the version running, read only when a command needs it, since in a checkout reading it
19
- # asks git.
20
- #: (executable: String, version: ^() -> String) -> void
21
- def initialize(executable:, version:)
23
+ # asks git; other_on_path gives the path and printed version of another principles earlier on PATH than this
24
+ # one, and which of the commands it is asked about that copy does not run, or nil, read only when a command
25
+ # needs it, since reading it starts that copy; launched_on_path says
26
+ # whether this run was launched as the first principles on PATH, as a RubyGems binstub is, so a bare
27
+ # principles runs this same copy; cwd is the folder this run was started in, by its real path, or nil.
28
+ #: (executable: String, version: ^() -> String,
29
+ #| ?other_on_path: ^(Array[String]) -> [String, String, Array[String]]?, ?launched_on_path: ^() -> bool,
30
+ #| ?cwd: String?) -> void
31
+ def initialize(executable:, version:, other_on_path: ->(_) {}, launched_on_path: -> { false }, cwd: nil)
22
32
  @executable = executable
23
33
  @version = version
34
+ @other_on_path = other_on_path
35
+ @launched_on_path = launched_on_path
36
+ @cwd = cwd
24
37
  freeze
25
38
  end
26
39
 
40
+ # The executable every printed command names: the bare principles when that runs this copy, else the entry
41
+ # point's own.
42
+ #: () -> String
43
+ def executable = bare_from_path? ? ON_PATH : @executable
44
+
27
45
  #: () -> String
28
46
  def version = @version.call
29
47
 
48
+ # Whether this run was launched as the first principles on PATH, so a bare principles runs this same copy.
49
+ #: () -> bool
50
+ def launched_on_path? = @launched_on_path.call
51
+
52
+ # Where this run comes from, by the entry point it was invoked through, whatever its commands are printed as.
53
+ #: () -> Models::RunsFrom
54
+ def runs_from = Models::RunsFrom.new(@executable)
55
+
56
+ # The executable and project that this run's printed commands name, for the project at root. A command line run
57
+ # printed as the bare principles, from root itself, leaves out --project, since a command copied from its
58
+ # output runs there too; any other run names the project, as the plugin's hooks and a checkout's commands may
59
+ # be run from elsewhere.
60
+ #: (String) -> Views::Invocation
61
+ def invocation(root)
62
+ Views::Invocation.new(executable: executable, project: root, named: !bare_from_path? || root != @cwd)
63
+ end
64
+
65
+ # Another principles earlier on PATH than this one, which a bare principles command runs in its place, asked
66
+ # whether it runs each command of asking, or nil.
67
+ #: (?asking: Array[String]) -> Models::PrinciplesOnPath?
68
+ def other_on_path(asking: [])
69
+ path, version, lacking = @other_on_path.call(asking)
70
+ path && version ? Models::PrinciplesOnPath.new(path, version, lacking: lacking || []) : nil
71
+ end
72
+
30
73
  # The release of principles this run comes from, as the audit of map's principle keeps it: the version running
31
- # and the passage as setup prints it, which only a view holds; nil for a principle whose audit keeps none (D68).
74
+ # and the passage as setup prints it, which only a view holds; nil for a principle whose audit keeps none.
32
75
  #: (Models::Principle) -> Models::PrinciplesPackage?
33
76
  def release_kept_by(map)
34
77
  return unless map.keeps_package?
@@ -36,6 +79,13 @@ module Principles
36
79
  passage = Views::MetaPrinciplePassage.new(heading: Models::MetaPrinciple::PASSAGE_HEADING).text
37
80
  Models::PrinciplesPackage.of(version: version, passage: passage)
38
81
  end
82
+
83
+ private
84
+
85
+ # Whether a command line run, not the plugin's, was launched as the first principles on PATH, so its commands
86
+ # are printed as the bare principles.
87
+ #: () -> bool
88
+ def bare_from_path? = @executable != ON_PATH && launched_on_path?
39
89
  end
40
90
  end
41
91
  end
@@ -0,0 +1,62 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "command"
5
+ require_relative "member_problems_report"
6
+ require_relative "audit"
7
+ require_relative "../models/session_start_input"
8
+ require_relative "../views/session_start_report"
9
+
10
+ module Principles
11
+ # Each runs one command: reads models, applies their rules and prints through a view.
12
+ # controllers/CLAUDE.md owns the boundary.
13
+ module Controllers
14
+ # report-at-session-start, which a SessionStart hook runs: what the agent should act on as its session starts,
15
+ # read from the hook's JSON on stdin. It exits 0 whatever it finds, since the host adds the hook's stdout to the
16
+ # context only then, and prints nothing when there is nothing to act on.
17
+ class SessionStartReport < Command
18
+ #: (String, String?, Hash[String, untyped]) -> untyped
19
+ def call(command, _id, options)
20
+ naming_the_executable do
21
+ unknown(command) unless command == "report-at-session-start"
22
+
23
+ printed(Models::SessionStartInput.new(options["stdin"].to_s))
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ # The lines the session starts with, from the hook's input: from the plugin, any other version on PATH, then
30
+ # what list-member-problems reports of the members, then the open findings; none of those in a project with no
31
+ # maps. A refusal is named by its code, with the command that shows its repair, since a hook exiting 1 shows the
32
+ # user an error and gives the agent nothing.
33
+ #: (Models::SessionStartInput) -> Views::Lines
34
+ def printed(input)
35
+ first = Views::SessionStartReport.new(other_version)
36
+ begin
37
+ first.followed_by(@principles.ids.empty? ? [] : reported(input.source))
38
+ rescue Error => e
39
+ first.refused(e.payload.fetch("code"), invocation.without_project)
40
+ end.printed
41
+ end
42
+
43
+ # From the plugin's bin, the line naming another version of principles earlier on PATH, which a bare principles
44
+ # command runs in place of the plugin's; none from the command line, where the copy on PATH is this one. The
45
+ # running version is read only once another copy is found, since in a checkout reading it asks git.
46
+ #: () -> Array[String]
47
+ def other_version
48
+ return [] unless @tool.runs_from.session_start_hook_in_this_session?
49
+
50
+ other = @tool.other_on_path or return []
51
+ running = @tool.version
52
+ other.shadows?(running) ? [Views::SessionStartReport.other_version(other.path, other.version, running)] : []
53
+ end
54
+
55
+ # Each line the session starts with, source: startup, resume, clear or compact.
56
+ #: (String) -> Array[String]
57
+ def reported(source)
58
+ handed(MemberProblemsReport).session_start_lines(source) + handed(Audit).session_start_open_findings(source)
59
+ end
60
+ end
61
+ end
62
+ end
@@ -12,7 +12,7 @@ module Principles
12
12
  module Controllers
13
13
  # list-candidate-files: the survey of the files that look like agent guidance, with their outlines within the
14
14
  # budget, and the question of which principle they carry. It changes nothing on disk, and changes for the survey's
15
- # reasons alone, apart from the reads of what is already mapped (#1015).
15
+ # reasons alone, apart from the reads of what is already mapped.
16
16
  class Survey < Command
17
17
  #: (String, String?, Hash[String, untyped]) -> untyped
18
18
  def call(command, _id, options)
@@ -34,7 +34,7 @@ module Principles
34
34
  Views::CandidateOutlinesResult.new(found.to_h).result
35
35
  end
36
36
 
37
- # The survey; with a revision, only once it names a commit in git (#1171).
37
+ # The survey; with a revision, only once it names a commit in git.
38
38
  #: (Hash[String, untyped]) -> untyped
39
39
  def list_candidate_files(options)
40
40
  after = options["commits_after"]
@@ -12,9 +12,9 @@ module Principles
12
12
  module Data
13
13
  # The audit records: one JSON file per principle under .principles/audits/, committed in the audited
14
14
  # repository beside its map. A record holds the last audit's base commit, each member's hash and each
15
- # finding's id, members and action, never the agent's prose (D24, D25).
15
+ # finding's id, members and action, never the agent's prose.
16
16
  class AuditFiles
17
- # The key a record named its principle under before the rename to principles (#536).
17
+ # The key a record named its principle under before the rename to principles.
18
18
  EARLIER_ID_KEY = "memeplex_id"
19
19
 
20
20
  #: (PrinciplesSubfolder) -> void
@@ -22,7 +22,7 @@ module Principles
22
22
  @directory = directory
23
23
  end
24
24
 
25
- # Which of the folder and its earlier name hold this subfolder (#536).
25
+ # Which of the folder and its earlier name hold this subfolder.
26
26
  #: () -> Array[String]
27
27
  def held_in
28
28
  @directory.held_in
@@ -37,7 +37,7 @@ module Principles
37
37
  #: (String) -> bool
38
38
  def entry?(id) = @directory.entry?(id, shown_as: relative(id))
39
39
 
40
- # The record of id's last audit, or nil when it has none, checked against its schema (D29), handing the block
40
+ # The record of id's last audit, or nil when it has none, checked against its schema, handing the block
41
41
  # a record the schema refuses, as parse does.
42
42
  #: (String) ?{ (untyped) -> void } -> Hash[String, untyped]?
43
43
  def read(id, &)
@@ -46,9 +46,9 @@ module Principles
46
46
  parse(id, @directory.read(id, shown_as: relative(id)), &)
47
47
  end
48
48
 
49
- # The record of id from its text, with an older version's key upgraded, checked against its schema (D29). A
49
+ # The record of id from its text, with an older version's key upgraded, checked against its schema. A
50
50
  # record the schema refuses is handed to the block first, which may refuse it otherwise, as a model does one a
51
- # later copy wrote (D85).
51
+ # later copy wrote.
52
52
  #: (String, String) ?{ (untyped) -> void } -> Hash[String, untyped]
53
53
  def parse(id, text, &)
54
54
  record = upgraded(JsonText.new(text).parsed)
@@ -74,7 +74,7 @@ module Principles
74
74
  File.join(PrinciplesSubfolder::FOLDER, "audits", "#{id}.json")
75
75
  end
76
76
 
77
- # Where record id was kept before the folder took its name now, so it can be read at earlier commits (#536).
77
+ # Where record id was kept before the folder took its name now, so it can be read at earlier commits.
78
78
  #: (String) -> String
79
79
  def earlier_relative(id)
80
80
  File.join(PrinciplesSubfolder::EARLIER_FOLDER, "audits", "#{id}.json")
@@ -13,7 +13,7 @@ module Principles
13
13
  LIMIT = 4 * 1024 * 1024 #: Integer
14
14
 
15
15
  # shown_as is the path a refusal gives; named is what its message calls the file, such as "The answer" for a
16
- # file the agent named and holds the path of (#1118).
16
+ # file the agent named and holds the path of.
17
17
  #: (String, ?shown_as: String, ?named: String) -> void
18
18
  def initialize(path, shown_as: path, named: shown_as)
19
19
  @path = path
@@ -17,14 +17,17 @@ module Principles
17
17
 
18
18
  # The instruction files an agent host loads by convention, beside any explicitly selected paths.
19
19
  CANDIDATE_NAMES = %w[CLAUDE.md AGENTS.md].freeze
20
- CANDIDATE_PATH = %r{(?:\A|/)\.claude/(?:rules/|skills/|agents/|settings[^/]*\.json\z)}
20
+ # Claude Code's rules, skills, agents and settings, and Codex's skills in .agents/skills, hooks in
21
+ # .codex/hooks.json and custom agents in .codex/agents.
22
+ CANDIDATE_PATH = %r{(?:\A|/)(?:\.claude/(?:rules/|skills/|agents/|settings[^/]*\.json\z)|\.agents/skills/|
23
+ \.codex/(?:hooks\.json\z|agents/))}x
21
24
 
22
25
  # Folder names that often hold test data shaped like guidance, such as a sample CLAUDE.md under
23
26
  # spec/fixtures/. A name is a hint, not a fact: the agent decides, so these files stay listed and are
24
27
  # named here with the folder that matched (alpha 009 friction 1).
25
28
  TEST_DATA_FOLDER = %r{(?:\A|/)(fixtures?|examples?|samples?)/}
26
29
 
27
- # One readable candidate: its path, its length in characters, and for a link the file it leads to (#695).
30
+ # One readable candidate: its path, its length in characters, and for a link the file it leads to.
28
31
  # The stand-in project lists by it too, so the two cannot disagree on the shape.
29
32
  #: (String, text: String, leads_to: String) -> Hash[String, untyped]
30
33
  def self.listed(path, text:, leads_to:)
@@ -100,7 +103,7 @@ module Principles
100
103
  end
101
104
 
102
105
  # A folder below the root holding its own .git, a worktree's file or a clone's folder, is another project,
103
- # as git treats it (#376). The root may hold one too: this tool runs in a worktree.
106
+ # as git treats it. The root may hold one too: this tool runs in a worktree.
104
107
  #: (String) -> bool
105
108
  def nested_repository?(absolute)
106
109
  absolute != @files.root && File.exist?(File.join(absolute, ".git"))