principles 0.0.6 → 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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +383 -0
- data/LICENSE +202 -0
- data/NOTICE +4 -0
- data/README.md +111 -0
- data/exe/principles +20 -0
- data/lib/principles/after_commit_hook_options.rb +2 -2
- data/lib/principles/cli.rb +58 -41
- data/lib/principles/command_line.rb +37 -14
- data/lib/principles/command_routes.rb +21 -7
- data/lib/principles/controllers/acknowledgement.rb +50 -118
- data/lib/principles/controllers/acknowledgements.rb +154 -0
- data/lib/principles/controllers/after_commit_report.rb +44 -0
- data/lib/principles/controllers/answer.rb +52 -21
- data/lib/principles/controllers/answer_phase.rb +20 -3
- data/lib/principles/controllers/assessment.rb +41 -28
- data/lib/principles/controllers/audit.rb +59 -15
- data/lib/principles/controllers/audit_completion.rb +25 -12
- data/lib/principles/controllers/command.rb +13 -12
- data/lib/principles/controllers/correction.rb +26 -11
- data/lib/principles/controllers/first_audit_brief.rb +40 -0
- data/lib/principles/controllers/full_audit_request.rb +47 -83
- data/lib/principles/controllers/hook_setup.rb +49 -0
- data/lib/principles/controllers/inventory.rb +10 -8
- data/lib/principles/controllers/mapping.rb +2 -2
- data/lib/principles/controllers/member_acknowledgement.rb +148 -0
- data/lib/principles/controllers/member_entries.rb +4 -4
- data/lib/principles/controllers/member_problems_report.rb +84 -30
- data/lib/principles/controllers/members_a_commit_changed.rb +3 -3
- data/lib/principles/controllers/members_to_assess.rb +23 -20
- data/lib/principles/controllers/meta_principle_setup.rb +5 -6
- data/lib/principles/controllers/open_correction.rb +42 -0
- data/lib/principles/controllers/parts_to_read.rb +117 -0
- data/lib/principles/controllers/repoint.rb +1 -1
- data/lib/principles/controllers/running_tool.rb +56 -6
- data/lib/principles/controllers/session_start_report.rb +62 -0
- data/lib/principles/controllers/survey.rb +2 -2
- data/lib/principles/data/audit_files.rb +7 -7
- data/lib/principles/data/bounded_file.rb +1 -1
- data/lib/principles/data/candidate_files_found.rb +6 -3
- data/lib/principles/data/command-steps.json +67 -12
- data/lib/principles/data/expected_type.rb +3 -3
- data/lib/principles/data/first_parent_log.rb +1 -1
- data/lib/principles/data/head_reflog.rb +74 -0
- data/lib/principles/data/hook_input.rb +59 -0
- data/lib/principles/data/ignored_by_git.rb +2 -2
- data/lib/principles/data/known_fields.rb +1 -1
- data/lib/principles/data/linked_path.rb +1 -1
- data/lib/principles/data/map_files.rb +2 -2
- data/lib/principles/data/principles_on_path.rb +83 -0
- data/lib/principles/data/principles_subfolder.rb +1 -1
- data/lib/principles/data/project_files.rb +10 -3
- data/lib/principles/data/repository.rb +14 -7
- data/lib/principles/data/running_version.rb +10 -8
- data/lib/principles/data/schema_check.rb +5 -5
- data/lib/principles/data/schemas/acknowledgement-answer.schema.json +86 -20
- data/lib/principles/data/schemas/acknowledgements-answer.schema.json +95 -0
- data/lib/principles/data/schemas/assessment-answer.schema.json +55 -20
- data/lib/principles/data/schemas/audit-record.schema.json +29 -20
- data/lib/principles/data/schemas/command-steps.schema.json +1 -1
- data/lib/principles/data/schemas/correction-answer-guide.schema.json +1 -1
- data/lib/principles/data/schemas/correction-answer.schema.json +14 -62
- data/lib/principles/data/schemas/member-map.schema.json +3 -3
- data/lib/principles/data/schemas/repointing-answer.schema.json +1 -1
- data/lib/principles/error.rb +4 -4
- data/lib/principles/failure_refusal.rb +57 -0
- data/lib/principles/invocation_options.rb +7 -6
- data/lib/principles/launch.rb +49 -0
- data/lib/principles/list_open_findings_options.rb +23 -0
- data/lib/principles/models/accepted_loading.rb +2 -2
- data/lib/principles/models/acknowledged_check.rb +106 -0
- data/lib/principles/models/acknowledgement.rb +51 -53
- data/lib/principles/models/acknowledgement_left_as_printed.rb +18 -5
- data/lib/principles/models/acknowledgement_refusal.rb +25 -10
- data/lib/principles/models/acknowledgements.rb +115 -0
- data/lib/principles/models/acknowledgements_across.rb +68 -0
- data/lib/principles/models/activation.rb +2 -2
- data/lib/principles/models/after_commit_input.rb +115 -0
- data/lib/principles/models/agent_loads.rb +1 -1
- data/lib/principles/models/answer_fields.rb +2 -2
- data/lib/principles/models/answer_place.rb +3 -3
- data/lib/principles/models/answer_text.rb +2 -2
- data/lib/principles/models/answered_time.rb +12 -3
- data/lib/principles/models/assessment_answer.rb +10 -10
- data/lib/principles/models/assessment_basis.rb +2 -2
- data/lib/principles/models/assessment_left_as_printed.rb +1 -1
- data/lib/principles/models/assessment_report.rb +14 -15
- data/lib/principles/models/audit.rb +46 -34
- data/lib/principles/models/audit_record.rb +58 -27
- data/lib/principles/models/audit_records.rb +13 -13
- data/lib/principles/models/audit_start.rb +3 -3
- data/lib/principles/models/audited_member_lines.rb +1 -1
- data/lib/principles/models/candidate_files.rb +18 -10
- data/lib/principles/models/candidate_inventory.rb +6 -6
- data/lib/principles/models/candidate_outline.rb +9 -9
- data/lib/principles/models/carried_assessments.rb +18 -3
- data/lib/principles/models/carried_member.rb +5 -5
- data/lib/principles/models/changed_regions.rb +92 -0
- data/lib/principles/models/check_result_guide.rb +50 -0
- data/lib/principles/models/check_since_last_audit.rb +5 -4
- data/lib/principles/models/cited_files.rb +4 -4
- data/lib/principles/models/command_steps.rb +3 -3
- data/lib/principles/models/commits_brought_in.rb +1 -1
- data/lib/principles/models/commits_since_base.rb +1 -1
- data/lib/principles/models/correction_answer.rb +2 -2
- data/lib/principles/models/correction_basis.rb +19 -10
- data/lib/principles/models/dated_line.rb +1 -2
- data/lib/principles/models/decided_prior_findings.rb +6 -6
- data/lib/principles/models/declared_map_changes.rb +5 -5
- data/lib/principles/models/disposition.rb +21 -21
- data/lib/principles/models/entry_file.rb +1 -1
- data/lib/principles/models/entry_files.rb +1 -1
- data/lib/principles/models/evidence_item.rb +1 -1
- data/lib/principles/models/evidence_lines_since.rb +2 -2
- data/lib/principles/models/evidence_replacements.rb +3 -3
- data/lib/principles/models/finding_write_ups.rb +12 -5
- data/lib/principles/models/findings_left_open.rb +4 -4
- data/lib/principles/models/first_full_audit.rb +32 -0
- data/lib/principles/models/first_raised_claim.rb +1 -1
- data/lib/principles/models/fix_only_fields.rb +1 -1
- data/lib/principles/models/head_moves.rb +66 -0
- data/lib/principles/models/hook_commands.rb +49 -4
- data/lib/principles/models/ignored_candidates.rb +1 -1
- data/lib/principles/models/instruction_named.rb +2 -3
- data/lib/principles/models/json_digest.rb +2 -2
- data/lib/principles/models/json_path_query.rb +1 -1
- data/lib/principles/models/kept_prior_finding.rb +9 -9
- data/lib/principles/models/last_completed_revision.rb +4 -5
- data/lib/principles/models/left_as_printed.rb +2 -2
- data/lib/principles/models/line_diff.rb +113 -0
- data/lib/principles/models/line_span.rb +1 -1
- data/lib/principles/models/list_member_problems_check.rb +80 -0
- data/lib/principles/models/listed_members.rb +47 -0
- data/lib/principles/models/loaded_files.rb +4 -5
- data/lib/principles/models/loading_decision.rb +19 -10
- data/lib/principles/models/loading_facts.rb +1 -1
- data/lib/principles/models/loads_to_check.rb +1 -2
- data/lib/principles/models/located_text.rb +1 -1
- data/lib/principles/models/mapped_principles.rb +2 -2
- data/lib/principles/models/member.rb +31 -4
- data/lib/principles/models/member_assessments.rb +17 -8
- data/lib/principles/models/member_elsewhere.rb +4 -4
- data/lib/principles/models/member_file.rb +4 -4
- data/lib/principles/models/member_grounds.rb +1 -1
- data/lib/principles/models/member_hashes_as_written.rb +1 -1
- data/lib/principles/models/member_lines.rb +29 -61
- data/lib/principles/models/member_loads.rb +2 -2
- data/lib/principles/models/member_moves.rb +1 -1
- data/lib/principles/models/member_problems.rb +21 -18
- data/lib/principles/models/member_repair_moves.rb +15 -9
- data/lib/principles/models/member_sighting.rb +12 -15
- data/lib/principles/models/member_snapshots.rb +1 -1
- data/lib/principles/models/member_state.rb +1 -1
- data/lib/principles/models/members_across_principles.rb +77 -0
- data/lib/principles/models/members_elsewhere.rb +2 -2
- data/lib/principles/models/members_sharing_lines.rb +7 -7
- data/lib/principles/models/meta_principle.rb +11 -4
- data/lib/principles/models/missing_files.rb +3 -3
- data/lib/principles/models/new_findings.rb +4 -4
- data/lib/principles/models/open_correction.rb +57 -0
- data/lib/principles/models/open_finding.rb +36 -31
- data/lib/principles/models/open_findings_elsewhere.rb +2 -2
- data/lib/principles/models/other_principles.rb +2 -2
- data/lib/principles/models/other_templates_placeholders.rb +17 -16
- data/lib/principles/models/outline_budget.rb +7 -7
- data/lib/principles/models/outline_group.rb +1 -1
- data/lib/principles/models/outline_section.rb +2 -2
- data/lib/principles/models/part_named.rb +41 -0
- data/lib/principles/models/placement.rb +2 -2
- data/lib/principles/models/principle.rb +13 -13
- data/lib/principles/models/principle_history.rb +8 -8
- data/lib/principles/models/principle_members.rb +14 -7
- data/lib/principles/models/principles_folder_move.rb +1 -1
- data/lib/principles/models/principles_on_path.rb +29 -0
- data/lib/principles/models/principles_package.rb +3 -3
- data/lib/principles/models/prior_decision_fields.rb +8 -8
- data/lib/principles/models/prior_finding_decision.rb +8 -8
- data/lib/principles/models/prior_finding_outcomes.rb +1 -1
- data/lib/principles/models/prior_findings.rb +5 -5
- data/lib/principles/models/problem_report.rb +42 -9
- data/lib/principles/models/project.rb +29 -20
- data/lib/principles/models/project_history.rb +18 -12
- data/lib/principles/models/quoted_change.rb +8 -8
- data/lib/principles/models/recent_decision.rb +3 -3
- data/lib/principles/models/record_format.rb +16 -10
- data/lib/principles/models/record_judged_against.rb +4 -4
- data/lib/principles/models/recorded_entry.rb +17 -8
- data/lib/principles/models/recorded_finding.rb +9 -9
- data/lib/principles/models/recorded_findings.rb +2 -2
- data/lib/principles/models/recorded_hashes.rb +2 -2
- data/lib/principles/models/recorded_members.rb +13 -13
- data/lib/principles/models/refusal_before_shape.rb +2 -2
- data/lib/principles/models/repoint.rb +3 -3
- data/lib/principles/models/report_hooks.rb +69 -0
- data/lib/principles/models/reported_check.rb +42 -36
- data/lib/principles/models/request_id.rb +19 -7
- data/lib/principles/models/runs_from.rb +7 -2
- data/lib/principles/models/sent_answer.rb +38 -16
- data/lib/principles/models/sent_prior_decisions.rb +1 -1
- data/lib/principles/models/session_start_input.rb +37 -0
- data/lib/principles/models/shape_problems_beside.rb +1 -1
- data/lib/principles/models/skill_loads.rb +1 -1
- data/lib/principles/models/stale_request.rb +59 -0
- data/lib/principles/models/still_holds_restatement.rb +6 -6
- data/lib/principles/models/submitted_answer.rb +1 -1
- data/lib/principles/models/template_placeholders.rb +6 -6
- data/lib/principles/models/text_within.rb +1 -1
- data/lib/principles/models/tracked_paths.rb +38 -0
- data/lib/principles/models/unchecked_members.rb +2 -2
- data/lib/principles/models/uncommitted_files.rb +1 -1
- data/lib/principles/models/uncommitted_outside_the_map.rb +2 -2
- data/lib/principles/models/waits_on.rb +1 -1
- data/lib/principles/models/write_up_opening.rb +5 -5
- data/lib/principles/models/write_up_pointer.rb +3 -3
- data/lib/principles/models/write_up_repoint.rb +2 -3
- data/lib/principles/positional_arguments.rb +15 -7
- data/lib/principles/prose_list.rb +1 -1
- data/lib/principles/session_start_options.rb +3 -3
- data/lib/principles/start_audit_options.rb +54 -12
- data/lib/principles/supported_ruby.rb +24 -7
- data/lib/principles/version.rb +2 -2
- data/lib/principles/views/acknowledged_since_last_audit.rb +2 -2
- data/lib/principles/views/acknowledgement_result.rb +137 -17
- data/lib/principles/views/activation_in_hand.rb +1 -1
- data/lib/principles/views/answered_request.rb +6 -2
- data/lib/principles/views/assessed_members.rb +68 -38
- data/lib/principles/views/assessment_request.rb +43 -21
- data/lib/principles/views/audit_changes.rb +4 -4
- data/lib/principles/views/audit_commit.rb +5 -4
- data/lib/principles/views/audit_result.rb +100 -53
- data/lib/principles/views/candidate_files_result.rb +7 -6
- data/lib/principles/views/check_notes.rb +29 -6
- data/lib/principles/views/check_result_template.rb +51 -39
- data/lib/principles/views/completed_audit_next_step.rb +44 -0
- data/lib/principles/views/context_parts.rb +112 -0
- data/lib/principles/views/correction_request.rb +49 -33
- data/lib/principles/views/diff_since_last_audit.rb +8 -6
- data/lib/principles/views/findings_result.rb +33 -1
- data/lib/principles/views/first_audit_brief.rb +51 -0
- data/lib/principles/views/first_audit_line.rb +45 -0
- data/lib/principles/views/help.rb +4 -4
- data/lib/principles/views/hook_setup_result.rb +91 -0
- data/lib/principles/views/instruction.rb +3 -3
- data/lib/principles/views/invocation.rb +32 -9
- data/lib/principles/views/json_with_entries_on_lines.rb +6 -35
- data/lib/principles/views/landed_since_base.rb +1 -1
- data/lib/principles/views/line_history_since_last_audit.rb +35 -0
- data/lib/principles/views/lines_shared_with_member.rb +6 -6
- data/lib/principles/views/loads_to_check_result.rb +11 -7
- data/lib/principles/views/map_added_to.rb +3 -3
- data/lib/principles/views/map_result.rb +9 -9
- data/lib/principles/views/member_change_since_baseline.rb +44 -23
- data/lib/principles/views/member_lines_beside_text.rb +43 -0
- data/lib/principles/views/member_repairs.rb +3 -2
- data/lib/principles/views/member_row.rb +61 -0
- data/lib/principles/views/members_a_commit_changed.rb +15 -11
- data/lib/principles/views/members_with_no_baseline.rb +10 -3
- data/lib/principles/views/meta_principle_passage.rb +1 -1
- data/lib/principles/views/meta_principle_result.rb +12 -5
- data/lib/principles/views/one_member_check_result_template.rb +24 -12
- data/lib/principles/views/open_findings_elsewhere_result.rb +5 -2
- data/lib/principles/views/open_findings_line.rb +26 -36
- data/lib/principles/views/other_principles_unjudged_result.rb +6 -3
- data/lib/principles/views/outside_the_map_result.rb +5 -2
- data/lib/principles/views/package_since_last_audit_result.rb +29 -6
- data/lib/principles/views/parts_index_result.rb +60 -0
- data/lib/principles/views/principle_read_result.rb +5 -6
- data/lib/principles/views/principle_with_changed_members.rb +1 -1
- data/lib/principles/views/principles_with_no_completed_audit.rb +1 -2
- data/lib/principles/views/printed_json.rb +51 -0
- data/lib/principles/views/printed_principle.rb +1 -1
- data/lib/principles/views/prior_finding_decisions_result.rb +4 -4
- data/lib/principles/views/prior_findings_result.rb +17 -14
- data/lib/principles/views/problem_lines.rb +70 -45
- data/lib/principles/views/problem_result.rb +75 -43
- data/lib/principles/views/prompts/acknowledge-a-change/judge-each-member-once-for-every-principle.md +2 -0
- data/lib/principles/views/prompts/acknowledge-a-change/read-the-deferred-findings-it-keeps.md +1 -0
- data/lib/principles/views/prompts/acknowledge-a-change/report-the-exit-status-its-own-listing-gives.md +3 -0
- data/lib/principles/views/prompts/acknowledge-a-change/resolve-them-in-a-full-audit.md +1 -0
- data/lib/principles/views/prompts/acknowledge-a-change/say-whether-each-change-keeps-its-meaning.md +8 -0
- data/lib/principles/views/prompts/acknowledge-a-change/say-whether-the-change-keeps-the-meaning.md +3 -3
- data/lib/principles/views/prompts/assess-every-member/confirm-each-write-up-pointer-the-answer-drops.md +2 -0
- data/lib/principles/views/prompts/assess-every-member/decide-each-member-loading.md +2 -1
- data/lib/principles/views/prompts/assess-every-member/have-a-changed-check-reviewed-before-running-it.md +1 -1
- data/lib/principles/views/prompts/assess-every-member/have-a-new-check-reviewed-before-running-it.md +1 -1
- data/lib/principles/views/prompts/assess-every-member/judge-a-carried-assessment-citing-a-decided-finding.md +3 -0
- data/lib/principles/views/prompts/assess-every-member/judge-a-submitted-carried-assessment-citing-a-decided-finding.md +5 -0
- data/lib/principles/views/prompts/assess-every-member/judge-the-keeping-under-the-release-since-the-last-audit.md +1 -1
- data/lib/principles/views/prompts/assess-every-member/keep-the-printed-review-basis-or-replace-it.md +1 -0
- data/lib/principles/views/prompts/assess-every-member/name-the-commit-that-made-the-check.md +1 -0
- data/lib/principles/views/prompts/assess-every-member/read-a-trimmed-instruction-whole.md +1 -1
- data/lib/principles/views/prompts/assess-every-member/read-the-request-in-parts.md +1 -0
- data/lib/principles/views/prompts/assess-every-member/run-the-check-then-report-it.md +2 -2
- data/lib/principles/views/prompts/assess-every-member/run-the-reviewed-check-and-say-what-its-review-rested-on.md +5 -3
- data/lib/principles/views/prompts/assess-every-member/why-each-member-is-judged-again.md +3 -2
- data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +1 -1
- data/lib/principles/views/prompts/dispose-of-each-finding/confirm-each-deferral-written-up-nowhere.md +2 -0
- data/lib/principles/views/prompts/dispose-of-each-finding/retain-assessment-and-correction.md +4 -4
- data/lib/principles/views/prompts/find-a-principle-to-map/where-the-inventory-looks.md +2 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/every-command-and-how-they-chain.md +1 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +4 -3
- data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +16 -16
- data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +65 -61
- data/lib/principles/views/prompts/learn-what-a-command-does/report-after-commit.md +14 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/report-at-session-start.md +26 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +22 -20
- data/lib/principles/views/prompts/learn-what-a-command-does/show-first-audit-brief.md +19 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-hook-setup.md +13 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-meta-principle-passage.md +3 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/show-open-correction.md +12 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +27 -28
- data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +39 -38
- data/lib/principles/views/prompts/report-the-completed-audit/commit-only-what-the-audit-changed.md +2 -2
- data/lib/principles/views/prompts/run-a-first-audit-in-the-background/follow-the-brief.md +18 -0
- data/lib/principles/views/prompts/set-principles-up/offer-the-report-hooks.md +2 -0
- data/lib/principles/views/prompts/set-principles-up/wire-the-report-hooks-with-the-user.md +8 -0
- data/lib/principles/views/prompts/start-a-session/act-on-the-open-findings.md +3 -4
- data/lib/principles/views/prompts/start-a-session/every-loaded-line-costs-every-session.md +1 -0
- data/lib/principles/views/prompts/start-a-session/hand-the-first-audit-to-a-subagent.md +3 -0
- data/lib/principles/views/prompts/start-a-session/run-each-command-above.md +1 -0
- data/lib/principles/views/prompts/start-a-session/start-no-second-first-audit.md +2 -0
- data/lib/principles/views/prompts/start-a-session/start-with-the-principles-skill.md +1 -0
- data/lib/principles/views/prompts.rb +1 -1
- data/lib/principles/views/read_the_change.rb +36 -0
- data/lib/principles/views/record_waiting_on_an_upgrade.rb +2 -2
- data/lib/principles/views/repoint_result.rb +1 -1
- data/lib/principles/views/report_hooks_offer.rb +25 -0
- data/lib/principles/views/request_part.rb +5 -5
- data/lib/principles/views/request_parts.rb +1 -1
- data/lib/principles/views/session_start_report.rb +46 -0
- data/lib/principles/views/shell_word.rb +1 -1
- data/lib/principles/views/trimmed_instructions_note.rb +30 -0
- data/lib/principles/views/visible_text.rb +1 -1
- data/lib/principles/views/workflow_diagram.rb +1 -1
- data/principles.gemspec +44 -0
- metadata +95 -14
- data/lib/principles/views/prompts/start-a-session/it-returns-after-each-clear-or-compaction-too.md +0 -1
- data/lib/principles/views/prompts/start-a-session/it-returns-at-each-session-start.md +0 -1
|
@@ -9,10 +9,10 @@ module Principles
|
|
|
9
9
|
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
10
10
|
module Views
|
|
11
11
|
# The correction request that follows an assessment with findings: one disposition for each, with a guide to
|
|
12
|
-
# every disposition's shape
|
|
12
|
+
# every disposition's shape, and what submitting the assessment stored.
|
|
13
13
|
class CorrectionRequest
|
|
14
14
|
# head is what the answer hands back unchanged, the request's id and the basis the correction depends on;
|
|
15
|
-
# placeholders is the text the template leaves in each field the agent writes
|
|
15
|
+
# placeholders is the text the template leaves in each field the agent writes.
|
|
16
16
|
#: (head: AnswerHead, principle_id: String, findings: Array[untyped], placeholders: Hash[String, String]) -> void
|
|
17
17
|
def initialize(head:, principle_id:, findings:, placeholders:)
|
|
18
18
|
@head = head
|
|
@@ -34,9 +34,9 @@ module Principles
|
|
|
34
34
|
"answer_guide" => Prompts.data("dispose-of-each-finding/answer-guide") }
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
# The answer to fill in, as
|
|
38
|
-
# each finding, each action the placeholder that says what it may be and what each adds, so
|
|
39
|
-
#
|
|
37
|
+
# The answer to fill in, as show-open-correction and show-answer-check --as template print it alone: one
|
|
38
|
+
# disposition for each finding, each action the placeholder that says what it may be and what each adds, so
|
|
39
|
+
# both print one template.
|
|
40
40
|
#: () -> Hash[String, untyped]
|
|
41
41
|
def template
|
|
42
42
|
@head.leading("dispositions" => @findings.map do |finding|
|
|
@@ -47,48 +47,64 @@ module Principles
|
|
|
47
47
|
end)
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
# The correction's answer alone, as show-answer-check --as template prints it.
|
|
51
|
+
#: () -> Hash[String, untyped]
|
|
52
|
+
def correction_to_fill = template
|
|
53
|
+
|
|
54
|
+
#: (AuditResult) -> Hash[String, untyped]
|
|
55
|
+
def presented_with(view)
|
|
56
|
+
view.request(view.correction_request(self))
|
|
53
57
|
end
|
|
54
58
|
|
|
55
|
-
#
|
|
59
|
+
# How to save and fill the correction's answer after submitting the checked assessment, naming the command that
|
|
60
|
+
# prints it alone rather than printing it here; keep its submit last.
|
|
56
61
|
#: (Hash[String, untyped], Invocation, String) -> Hash[String, untyped]
|
|
57
62
|
def with_correction_to_fill(acceptable, invocation, answer_file)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
assessment_id = acceptable.fetch("request_id")
|
|
64
|
+
save = "Once this answer is submitted with the last line's command, save the correction's answer it leads " \
|
|
65
|
+
"to in a file outside the project, such as under $TMPDIR, from this command's output: " \
|
|
66
|
+
"#{alone(assessment_id, answer_file, invocation)}\nFill only its dispositions, and submit it: " \
|
|
67
|
+
"#{invocation.submit_answer(request_id)}"
|
|
68
|
+
acceptable.merge("correction_recovery" => recovery(invocation),
|
|
63
69
|
"next_action" => "#{save}\n#{acceptable.fetch("next_action")}")
|
|
64
70
|
end
|
|
65
71
|
|
|
66
|
-
#
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
# How to fill the correction by hand: save its answer alone, which show-open-correction prints from the open
|
|
73
|
+
# record, to a file, fill only its dispositions there, and submit that file.
|
|
74
|
+
#: (Invocation) -> String
|
|
75
|
+
def to_fill_by_hand(invocation)
|
|
76
|
+
"Save the correction's answer alone in a file outside the project, such as under $TMPDIR, from this " \
|
|
77
|
+
"command's output, which prints it again from the open record whenever you need it: " \
|
|
78
|
+
"#{invocation.in_project("show-open-correction", @principle_id)}\nEdit only its dispositions in that " \
|
|
79
|
+
"file, then submit it: #{invocation.submit_answer(request_id)}"
|
|
80
|
+
end
|
|
71
81
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
82
|
+
# What to keep while the correction is open, and the read-only command that prints its answer again from the
|
|
83
|
+
# open record, in git or outside it.
|
|
84
|
+
#: (Invocation) -> String
|
|
85
|
+
def recovery(invocation)
|
|
86
|
+
"#{Prompts.text("dispose-of-each-finding/retain-assessment-and-correction")}\n" \
|
|
87
|
+
"#{invocation.in_project("show-open-correction", @principle_id)}"
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# The read-only command that prints the correction's answer alone, checking the assessment request
|
|
91
|
+
# assessment_request_id from assessment_file again.
|
|
92
|
+
#: (String, String, Invocation) -> String
|
|
93
|
+
def alone(assessment_request_id, assessment_file, invocation)
|
|
94
|
+
invocation.in_project("show-answer-check", assessment_request_id,
|
|
95
|
+
options: ["--file", assessment_file, "--as", "template"])
|
|
77
96
|
end
|
|
78
97
|
|
|
79
98
|
# What submitting the assessment stored, and what submitting it again would do, so an assessment submitted
|
|
80
|
-
# twice plainly replaced nothing:
|
|
81
|
-
#
|
|
99
|
+
# twice plainly replaced nothing: the open record, which keeps the assessment and, outside git, what the audit
|
|
100
|
+
# began from, and which in git is never committed, since the correction completes it.
|
|
82
101
|
#: () -> String
|
|
83
102
|
def stored
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
"began from. #{again} and leaves that record as it is."
|
|
88
|
-
end
|
|
103
|
+
kept = "This audit's open record, listed under wrote when it was first written, keeps your assessment"
|
|
104
|
+
again = "Submitting the same assessment again prints this same request and leaves that record as it is."
|
|
105
|
+
return "#{kept} and what the audit began from. #{again}" unless @head.based_on_a_commit?
|
|
89
106
|
|
|
90
|
-
"
|
|
91
|
-
"replaces nothing; the audit record is written when the audit completes."
|
|
107
|
+
"#{kept} until this correction completes the audit; do not commit it. #{again}"
|
|
92
108
|
end
|
|
93
109
|
end
|
|
94
110
|
end
|
|
@@ -8,20 +8,22 @@ module Principles
|
|
|
8
8
|
module Views
|
|
9
9
|
# The command that shows the edits to a member's file since the last full audit's base commit, to the files as
|
|
10
10
|
# they are now, which the audit judges. Each word is quoted for the shell, and each path read by git as written,
|
|
11
|
-
# not as a pattern
|
|
12
|
-
# edit, not a new file
|
|
11
|
+
# not as a pattern. Renames are followed, so over a moved file's path then and now the diff shows the
|
|
12
|
+
# edit, not a new file.
|
|
13
13
|
class DiffSinceLastAudit
|
|
14
|
-
# last_audited_commit is the last full audit's base commit; paths are the member's file then and now, once each
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
# last_audited_commit is the last full audit's base commit; paths are the member's file then and now, once each;
|
|
15
|
+
# to is the commit the diff ends at, or nil for the files as they are now.
|
|
16
|
+
#: (last_audited_commit: String, paths: Array[String], ?to: String?) -> void
|
|
17
|
+
def initialize(last_audited_commit:, paths:, to: nil)
|
|
17
18
|
@last_audited_commit = last_audited_commit
|
|
18
19
|
@paths = paths
|
|
20
|
+
@to = to
|
|
19
21
|
freeze
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
#: () -> String
|
|
23
25
|
def to_s
|
|
24
|
-
words = [@last_audited_commit, "--", *@paths].map { |word| ShellWord.new(word).to_s }
|
|
26
|
+
words = [@last_audited_commit, *@to, "--", *@paths].map { |word| ShellWord.new(word).to_s }
|
|
25
27
|
"git --literal-pathspecs diff -M #{words.join(" ")}"
|
|
26
28
|
end
|
|
27
29
|
end
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require_relative "invocation"
|
|
5
|
+
require_relative "problem_lines"
|
|
6
|
+
require_relative "visible_text"
|
|
5
7
|
|
|
6
8
|
module Principles
|
|
7
9
|
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
8
10
|
module Views
|
|
9
11
|
# list-open-findings' result: each finding the last completed audit of a principle deferred or accepted, what that
|
|
10
|
-
# covers, and what to do next
|
|
12
|
+
# covers, and what to do next.
|
|
11
13
|
class FindingsResult
|
|
12
14
|
SCOPE = "Each principle's last completed audit only, as .principles/audits/ID.json holds it. The next full " \
|
|
13
15
|
"audit decides each: one that still holds stays in the record, and one it closes is then only in git: " \
|
|
@@ -27,8 +29,38 @@ module Principles
|
|
|
27
29
|
{ "findings" => findings, "scope" => SCOPE, "next_action" => next_action(findings) }
|
|
28
30
|
end
|
|
29
31
|
|
|
32
|
+
# list-open-findings --lines: each finding on a line, its principle, id, whom it waits on and the whole days it
|
|
33
|
+
# has been open, so the agent can see which to raise, and how long each has waited, without a script over the
|
|
34
|
+
# list. Free text is escaped, and its line breaks read as spaces, so each finding stays on its
|
|
35
|
+
# own line. findings holds each one's principle, finding_id, action, days_open and any waits_on.
|
|
36
|
+
#: (Array[Hash[String, untyped]]) -> Lines
|
|
37
|
+
def lines(findings)
|
|
38
|
+
text = findings.map { |finding| "#{line(finding)}\n" }.join
|
|
39
|
+
Lines.new(stdout: findings.empty? ? "#{NONE_OPEN}\n" : text, stderr: "", status: 0)
|
|
40
|
+
end
|
|
41
|
+
|
|
30
42
|
private
|
|
31
43
|
|
|
44
|
+
#: (Hash[String, untyped]) -> String
|
|
45
|
+
def line(finding)
|
|
46
|
+
waits = waited_on(finding)
|
|
47
|
+
days = finding.fetch("days_open")
|
|
48
|
+
"#{finding.fetch("principle")}\t#{one_line(finding.fetch("finding_id"))}\t#{waits}\topen #{days} " \
|
|
49
|
+
"day#{"s" unless days == 1}"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Whom finding waits on, or that it is accepted, and so by design waits on no one.
|
|
53
|
+
#: (Hash[String, untyped]) -> String
|
|
54
|
+
def waited_on(finding)
|
|
55
|
+
return "accepted" if finding["action"] == "accepted"
|
|
56
|
+
|
|
57
|
+
waits_on = finding["waits_on"]
|
|
58
|
+
waits_on ? "waits on: #{one_line(waits_on)}" : "waits on no one named"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
#: (String) -> String
|
|
62
|
+
def one_line(text) = VisibleText.new(text.gsub(/\s+/, " ")).to_s
|
|
63
|
+
|
|
32
64
|
#: (Array[Hash[String, untyped]]) -> String
|
|
33
65
|
def next_action(findings)
|
|
34
66
|
return NONE_OPEN if findings.empty?
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "invocation"
|
|
5
|
+
require_relative "prompts"
|
|
6
|
+
|
|
7
|
+
module Principles
|
|
8
|
+
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
9
|
+
module Views
|
|
10
|
+
# show-first-audit-brief's result: the instructions one background subagent follows to run a principle's first
|
|
11
|
+
# full audit, each command filled for that principle, so the subagent types no id.
|
|
12
|
+
class FirstAuditBrief
|
|
13
|
+
# What the list asks, which the commands, one a line, follow.
|
|
14
|
+
PICK_ONE = "Leave out any your instructions or memory say to skip, and follow the brief of one, which its " \
|
|
15
|
+
"command prints:"
|
|
16
|
+
|
|
17
|
+
#: (Invocation) -> void
|
|
18
|
+
def initialize(invocation)
|
|
19
|
+
@invocation = invocation
|
|
20
|
+
freeze
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# The brief for principle id.
|
|
24
|
+
#: (String) -> Hash[String, untyped]
|
|
25
|
+
def result(id)
|
|
26
|
+
{ "principle" => id,
|
|
27
|
+
"brief" => Prompts.text("run-a-first-audit-in-the-background/follow-the-brief",
|
|
28
|
+
id: id,
|
|
29
|
+
index: @invocation.in_project("start-audit", id, options: ["--part", "index"]),
|
|
30
|
+
template: @invocation.in_project("start-audit", id, options: ["--as", "template"])),
|
|
31
|
+
"wrote" => [] }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# The principles awaiting a first full audit, ids, as list-member-problems names them, with each one's brief
|
|
35
|
+
# command on a line of its own, for the subagent to pick one from.
|
|
36
|
+
#: (Array[String]) -> Hash[String, untyped]
|
|
37
|
+
def awaiting(ids)
|
|
38
|
+
{ "awaiting_first_audit" => ids, "next_action" => pick_one(ids), "wrote" => [] }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
#: (Array[String]) -> String
|
|
44
|
+
def pick_one(ids)
|
|
45
|
+
return "Every mapped principle has had a full audit, so there is no first audit to run." if ids.empty?
|
|
46
|
+
|
|
47
|
+
[PICK_ONE, *ids.map { @invocation.in_project("show-first-audit-brief", it) }].join("\n")
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "invocation"
|
|
5
|
+
require_relative "prompts"
|
|
6
|
+
|
|
7
|
+
module Principles
|
|
8
|
+
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
9
|
+
module Views
|
|
10
|
+
# The session-start line asking for one background subagent to run a first full audit, while any principle
|
|
11
|
+
# awaits one. It counts them and names none, so its length stays fixed however many there are.
|
|
12
|
+
class FirstAuditLine
|
|
13
|
+
#: (Invocation) -> void
|
|
14
|
+
def initialize(invocation)
|
|
15
|
+
@invocation = invocation
|
|
16
|
+
freeze
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# The line, as a list of none or one, for count principles awaiting a first full audit, at the session's start
|
|
20
|
+
# from source: startup, resume, clear or compact. A resumed or compacted session may have a subagent running
|
|
21
|
+
# already from the line its context began with, so its line gives the count alone and asks for none.
|
|
22
|
+
#: (Integer, String) -> Array[String]
|
|
23
|
+
def lines(count, source)
|
|
24
|
+
return [] if count.zero?
|
|
25
|
+
|
|
26
|
+
counted = count == 1 ? "1 principle has" : "#{count} principles have"
|
|
27
|
+
[%w[resume compact].include?(source) ? started_already(counted, count) : asked(counted, count)]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
#: (String, Integer) -> String
|
|
33
|
+
def started_already(counted, count)
|
|
34
|
+
Prompts.text("start-a-session/start-no-second-first-audit", counted:, them: count == 1 ? "it" : "one")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
#: (String, Integer) -> String
|
|
38
|
+
def asked(counted, count)
|
|
39
|
+
Prompts.text("start-a-session/hand-the-first-audit-to-a-subagent",
|
|
40
|
+
counted:, them: count == 1 ? "it" : "them",
|
|
41
|
+
command: @invocation.in_project("show-first-audit-brief"))
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -6,9 +6,9 @@ require_relative "prompts"
|
|
|
6
6
|
module Principles
|
|
7
7
|
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
8
8
|
module Views
|
|
9
|
-
# What --help prints: Markdown, because it is a prompt the agent reads before running a command
|
|
10
|
-
#
|
|
11
|
-
#
|
|
9
|
+
# What --help prints: Markdown, because it is a prompt the agent reads before running a command. It is kept short,
|
|
10
|
+
# since every line lands in the agent's context. Refusal codes stay out: a refusal arrives with its own code and
|
|
11
|
+
# repair when it happens.
|
|
12
12
|
module Help
|
|
13
13
|
# What the page says after an agent's step: what the tool then checks, what it cannot check, and the
|
|
14
14
|
# usage of the command the agent runs next.
|
|
@@ -19,7 +19,7 @@ module Principles
|
|
|
19
19
|
attr_reader :cannot_check
|
|
20
20
|
#: String?
|
|
21
21
|
attr_reader :then_run
|
|
22
|
-
# When the agent runs then_run, where it is the agent's to time; "Then" otherwise
|
|
22
|
+
# When the agent runs then_run, where it is the agent's to time; "Then" otherwise.
|
|
23
23
|
#: String?
|
|
24
24
|
attr_reader :then_run_when
|
|
25
25
|
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "json"
|
|
5
|
+
require_relative "../prose_list"
|
|
6
|
+
require_relative "prompts"
|
|
7
|
+
|
|
8
|
+
module Principles
|
|
9
|
+
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
10
|
+
module Views
|
|
11
|
+
# What show-hook-setup prints: each host's file and the hook entries that go in it, for the agent to show the user
|
|
12
|
+
# and write only once the user agrees.
|
|
13
|
+
class HookSetupResult
|
|
14
|
+
# The executable each entry runs: principles as found on PATH, since the running executable's path names the
|
|
15
|
+
# installed version, which an upgrade removes, and Codex asks the user to trust a hook again when it changes.
|
|
16
|
+
EXECUTABLE = "principles"
|
|
17
|
+
|
|
18
|
+
# What the agent reads when principles did not start, which both commands' exit status 0 never says otherwise.
|
|
19
|
+
FAILED = "principles: principles failed to start, so this session gets no report from it: run it with " \
|
|
20
|
+
"--version to see why."
|
|
21
|
+
|
|
22
|
+
# A hook's timeout, in seconds, as each host reads it.
|
|
23
|
+
TIMEOUT = 15
|
|
24
|
+
|
|
25
|
+
# What the result says first when no principles on PATH prints a version, so every entry would fail to start.
|
|
26
|
+
NONE_ON_PATH = "No principles on PATH prints its version, so each entry below would print its failure line in " \
|
|
27
|
+
"every session. Install the principles gem where the hooks' shell finds it before writing them."
|
|
28
|
+
|
|
29
|
+
# What the result says first when another version of principles is first on PATH, which each entry would run,
|
|
30
|
+
# and the commands of the entries that copy does not run.
|
|
31
|
+
#: (String, String, String, lacking: Array[String]) -> String
|
|
32
|
+
def self.other_on_path(path, version, running, lacking:)
|
|
33
|
+
runs = if lacking.empty?
|
|
34
|
+
"which runs both report commands, so each entry would report as #{version} does"
|
|
35
|
+
else
|
|
36
|
+
"which does not run #{ProseList.new(lacking, conjunction: "or")}, so each entry would print its " \
|
|
37
|
+
"failure line in every session"
|
|
38
|
+
end
|
|
39
|
+
"The principles on PATH, #{path}, is #{version}, not this #{running}, so each entry below would run " \
|
|
40
|
+
"#{version}, #{runs}. Update or remove that copy before writing them."
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# hosts gives each "host" by name, its "file", why it is "offered" and its "hooks", each with its "event",
|
|
44
|
+
# "matcher" and "command";
|
|
45
|
+
# principles_on_path says what PATH would run in place of this copy, or is nil when it runs this one.
|
|
46
|
+
#: (Array[Hash[String, untyped]], principles_on_path: String?) -> void
|
|
47
|
+
def initialize(hosts, principles_on_path:)
|
|
48
|
+
@hosts = hosts
|
|
49
|
+
@principles_on_path = principles_on_path
|
|
50
|
+
freeze
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# The entries, after what PATH would run in their place, when that is not this copy.
|
|
54
|
+
#: () -> Hash[String, untyped]
|
|
55
|
+
def result
|
|
56
|
+
{ **({ "principles_on_path" => @principles_on_path } if @principles_on_path),
|
|
57
|
+
"hosts" => @hosts.map { it.slice("host", "file", "offered").merge("entries" => entries(it)) },
|
|
58
|
+
"next_action" => Prompts.text("set-principles-up/wire-the-report-hooks-with-the-user"), "wrote" => [] }
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
private
|
|
62
|
+
|
|
63
|
+
# host's entries by event, each one matcher group.
|
|
64
|
+
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
65
|
+
def entries(host)
|
|
66
|
+
{ "hooks" => host.fetch("hooks").to_h { [it.fetch("event"), [group(it)]] } }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# One matcher group, its one handler running hook's command, guarded.
|
|
70
|
+
#: (Hash[String, String]) -> Hash[String, untyped]
|
|
71
|
+
def group(hook)
|
|
72
|
+
command = guarded(hook.fetch("event"), hook.fetch("command"))
|
|
73
|
+
{ "matcher" => hook.fetch("matcher"),
|
|
74
|
+
"hooks" => [{ "type" => "command", "command" => command, "timeout" => TIMEOUT }] }
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# command, followed by the echo that runs when it exits other than 0, which it never does once started: plain
|
|
78
|
+
# text at session start, and after a call the hook's JSON, since the agent never reads such a hook's plain
|
|
79
|
+
# stdout.
|
|
80
|
+
#: (String, String) -> String
|
|
81
|
+
def guarded(event, command)
|
|
82
|
+
said = if event == "SessionStart"
|
|
83
|
+
FAILED
|
|
84
|
+
else
|
|
85
|
+
JSON.generate({ "hookSpecificOutput" => { "hookEventName" => event, "additionalContext" => FAILED } })
|
|
86
|
+
end
|
|
87
|
+
"#{EXECUTABLE} #{command} || echo '#{said}'"
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -5,7 +5,7 @@ module Principles
|
|
|
5
5
|
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
6
6
|
module Views
|
|
7
7
|
# One instruction a judgement request prints under its own field: its paragraphs, each printed only when the
|
|
8
|
-
# request holds the case it explains, and every one when the agent reads the field whole
|
|
8
|
+
# request holds the case it explains, and every one when the agent reads the field whole.
|
|
9
9
|
class Instruction
|
|
10
10
|
#: String
|
|
11
11
|
attr_reader :field
|
|
@@ -42,13 +42,13 @@ module Principles
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
# The guide to an answer's shapes a judgement request prints under its own field: its entries, each printed only
|
|
45
|
-
# when the request holds the case it shows, and every one when the agent reads the field whole
|
|
45
|
+
# when the request holds the case it shows, and every one when the agent reads the field whole.
|
|
46
46
|
class GuideInstruction
|
|
47
47
|
#: String
|
|
48
48
|
attr_reader :field
|
|
49
49
|
|
|
50
50
|
# guide is every entry; held says, by entry name, whether the request holds its case. narrowed is, by name, an
|
|
51
|
-
# entry as the request prints it when it holds the entry's case but not every case within it
|
|
51
|
+
# entry as the request prints it when it holds the entry's case but not every case within it.
|
|
52
52
|
#: (String, Hash[String, untyped], ?narrowed: Hash[String, untyped]) { (String) -> bool } -> void
|
|
53
53
|
def initialize(field, guide, narrowed: {}, &held)
|
|
54
54
|
@field = field
|
|
@@ -15,24 +15,39 @@ module Principles
|
|
|
15
15
|
#: String
|
|
16
16
|
attr_reader :project
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
# named says whether each command names the project; without_project leaves it out.
|
|
19
|
+
#: (executable: String, project: String, ?named: bool) -> void
|
|
20
|
+
def initialize(executable:, project:, named: true)
|
|
20
21
|
@executable = executable
|
|
21
22
|
@project = project
|
|
23
|
+
@named = named
|
|
22
24
|
freeze
|
|
23
25
|
end
|
|
24
26
|
|
|
25
|
-
#
|
|
27
|
+
# The same invocation, its commands leaving out --project, for output that names the project once and whose
|
|
28
|
+
# commands run from there, as list-member-problems --short's stderr does.
|
|
29
|
+
#: () -> Invocation
|
|
30
|
+
def without_project = Invocation.new(executable: @executable, project: @project, named: false)
|
|
31
|
+
|
|
32
|
+
# Whether each command names the project.
|
|
33
|
+
#: () -> bool
|
|
34
|
+
def named? = @named
|
|
35
|
+
|
|
36
|
+
# The project as a shell word, as --project gives it.
|
|
37
|
+
#: () -> String
|
|
38
|
+
def project_word = shell_word(@project)
|
|
39
|
+
|
|
40
|
+
# A command to run in this project, which it names right after the executable, as model repairs do.
|
|
26
41
|
# Each value is shell-quoted, because ids, paths and headings come from project files that anyone may have
|
|
27
|
-
# written
|
|
42
|
+
# written. options are flags with their values, such as
|
|
28
43
|
# ["--starting-at", text], quoted the same way. usage is this tool's own placeholder text, such as
|
|
29
44
|
# "--section HEADING", left for the agent to fill and never quoted. When a value starts with "-", as a
|
|
30
|
-
# path may, every option comes first and "--" ends them, so the value is not read as an option
|
|
45
|
+
# path may, every option comes first and "--" ends them, so the value is not read as an option.
|
|
31
46
|
#: (String, *String, ?options: Array[String], ?usage: String?) -> String
|
|
32
47
|
def in_project(command, *values, options: [], usage: nil) = listed_in_project(command, values, options:, usage:)
|
|
33
48
|
|
|
34
49
|
# The command that answers request request_id in this project: from file, the --file value an answer was
|
|
35
|
-
# checked from, as given, or before there is one, from a FILE the agent names
|
|
50
|
+
# checked from, as given, or before there is one, from a FILE the agent names.
|
|
36
51
|
#: (String, ?file: String?) -> String
|
|
37
52
|
def submit_answer(request_id, file: nil)
|
|
38
53
|
return in_project("submit-answer", request_id, usage: "--file FILE") unless file
|
|
@@ -40,16 +55,16 @@ module Principles
|
|
|
40
55
|
in_project("submit-answer", request_id, options: ["--file", file])
|
|
41
56
|
end
|
|
42
57
|
|
|
43
|
-
# The same command, its values given as one list, as a refusal's repair command holds them
|
|
58
|
+
# The same command, its values given as one list, as a refusal's repair command holds them.
|
|
44
59
|
#: (String, Array[String], ?options: Array[String], ?usage: String?) -> String
|
|
45
60
|
def listed_in_project(command, values, options: [], usage: nil)
|
|
46
61
|
flags = options.map { |value| shell_word(value) }
|
|
47
62
|
words = values.map { |value| shell_word(value) }
|
|
48
63
|
if values.any? { |value| value.start_with?("-") }
|
|
49
|
-
return [@executable,
|
|
64
|
+
return [@executable, named_project, command, *flags, usage, "--", *words].compact.join(" ")
|
|
50
65
|
end
|
|
51
66
|
|
|
52
|
-
[@executable,
|
|
67
|
+
[@executable, named_project, command, *words, *flags, usage].compact.join(" ")
|
|
53
68
|
end
|
|
54
69
|
|
|
55
70
|
#: () -> String
|
|
@@ -57,8 +72,16 @@ module Principles
|
|
|
57
72
|
"--project #{shell_word(@project)}"
|
|
58
73
|
end
|
|
59
74
|
|
|
75
|
+
# What each command starts with: the executable, then --project and the project unless they are left out.
|
|
76
|
+
#: () -> String
|
|
77
|
+
def prefix = [@executable, named_project].compact.join(" ")
|
|
78
|
+
|
|
60
79
|
private
|
|
61
80
|
|
|
81
|
+
# --project and the project, or nil when the commands leave it out.
|
|
82
|
+
#: () -> String?
|
|
83
|
+
def named_project = @named ? project_option : nil
|
|
84
|
+
|
|
62
85
|
#: (String) -> String
|
|
63
86
|
def shell_word(value) = ShellWord.new(value).to_s
|
|
64
87
|
end
|
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
# typed: strict
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
require_relative "printed_json"
|
|
5
5
|
|
|
6
6
|
module Principles
|
|
7
7
|
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
8
8
|
module Views
|
|
9
|
-
# A JSON result printed
|
|
10
|
-
# list-candidate-files' file entries are that array:
|
|
11
|
-
# line of
|
|
12
|
-
# output format; every other result prints pretty.
|
|
9
|
+
# A JSON result printed a field a line, as every result prints, but for one array whose entries each print compact
|
|
10
|
+
# on a line of their own. list-candidate-files' file entries are that array: a field a line costs a third more
|
|
11
|
+
# lines than an entry a line, and one compact line of 27 KB is the worst shape to read by lines.
|
|
13
12
|
class JsonWithEntriesOnLines
|
|
14
|
-
# Stands in for the array while the rest prints pretty. Replacement targets its root object and direct key,
|
|
15
|
-
# so an identical project string elsewhere stays untouched regardless of the result's field order.
|
|
16
|
-
MARKER = "\u0000entries on lines of their own\u0000"
|
|
17
|
-
|
|
18
13
|
# The array is result[under][key].
|
|
19
14
|
#: (Hash[String, untyped], under: String, key: String) -> void
|
|
20
15
|
def initialize(result, under:, key:)
|
|
21
16
|
@result = result
|
|
22
|
-
@
|
|
23
|
-
@key = key
|
|
17
|
+
@path = [under, key] #: Array[String]
|
|
24
18
|
freeze
|
|
25
19
|
end
|
|
26
20
|
|
|
@@ -30,30 +24,7 @@ module Principles
|
|
|
30
24
|
|
|
31
25
|
# The result as printed.
|
|
32
26
|
#: () -> String
|
|
33
|
-
def text
|
|
34
|
-
marked = JSON.pretty_generate(@result.merge(@under => @result.fetch(@under).merge(@key => MARKER)))
|
|
35
|
-
marked.sub(array_place) { "#{Regexp.last_match(1)}#{lines(" ")}" }
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
private
|
|
39
|
-
|
|
40
|
-
# The designated array placeholder at its known depth in JSON.pretty_generate's two-space layout.
|
|
41
|
-
#: () -> Regexp
|
|
42
|
-
def array_place
|
|
43
|
-
parent = Regexp.escape(JSON.generate(@under))
|
|
44
|
-
child = Regexp.escape(JSON.generate(@key))
|
|
45
|
-
marker = Regexp.escape(JSON.generate(MARKER))
|
|
46
|
-
/(^ #{parent}: \{.*?^ #{child}: )#{marker}/m
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# The array's entries, each compact on its own line, one step in from indent.
|
|
50
|
-
#: (String) -> String
|
|
51
|
-
def lines(indent)
|
|
52
|
-
entries = @result.fetch(@under).fetch(@key)
|
|
53
|
-
return "[]" if entries.empty?
|
|
54
|
-
|
|
55
|
-
"[\n#{entries.map { |entry| "#{indent} #{JSON.generate(entry)}" }.join(",\n")}\n#{indent}]"
|
|
56
|
-
end
|
|
27
|
+
def text = PrintedJson.with_entries_on_lines(@result, @path)
|
|
57
28
|
end
|
|
58
29
|
end
|
|
59
30
|
end
|
|
@@ -6,7 +6,7 @@ module Principles
|
|
|
6
6
|
module Views
|
|
7
7
|
# In git, what landed after a completed audit's base commit, as its result prints it: the commits since the base
|
|
8
8
|
# that touched each member the audit changed, by member id, and the base and HEAD when HEAD differs from the base
|
|
9
|
-
# and none touched one
|
|
9
|
+
# and none touched one. Outside git a completed audit has none, so it is given only in git.
|
|
10
10
|
class LandedSinceBase
|
|
11
11
|
#: (commits_by_member: Hash[String, Array[Hash[String, String]]], ?head_past_base: [String, String]?) -> void
|
|
12
12
|
def initialize(commits_by_member:, head_past_base: nil)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "shell_word"
|
|
5
|
+
|
|
6
|
+
module Principles
|
|
7
|
+
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
8
|
+
module Views
|
|
9
|
+
# The command that shows each commit's edits to a member's own lines since the last full audit's base commit, as
|
|
10
|
+
# git traces those lines back from the commit now, so a short member of a long file is read without the rest of
|
|
11
|
+
# the file's edits. Each commit is named by its short id and subject, and each word is quoted for the shell.
|
|
12
|
+
class LineHistorySinceLastAudit
|
|
13
|
+
# last_audited_commit is the last full audit's base commit; path is the member's file, at the same path then
|
|
14
|
+
# and now; first_line and last_line are the lines it spans now, 1-based; to is the commit the history ends at,
|
|
15
|
+
# or nil for HEAD, where git reads those lines, so it must hold the file as it is now, as HEAD does once an audit
|
|
16
|
+
# has refused a member file that differs from it.
|
|
17
|
+
#: (last_audited_commit: String, path: String, first_line: Integer, last_line: Integer, ?to: String?) -> void
|
|
18
|
+
def initialize(last_audited_commit:, path:, first_line:, last_line:, to: nil)
|
|
19
|
+
@last_audited_commit = last_audited_commit
|
|
20
|
+
@path = path
|
|
21
|
+
@first_line = first_line
|
|
22
|
+
@last_line = last_line
|
|
23
|
+
@to = to
|
|
24
|
+
freeze
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
#: () -> String
|
|
28
|
+
def to_s
|
|
29
|
+
range = "#{@last_audited_commit}..#{@to || "HEAD"}"
|
|
30
|
+
words = ["--format=%h %s", "-L", "#{@first_line},#{@last_line}:#{@path}", range]
|
|
31
|
+
"git log #{words.map { |word| ShellWord.new(word).to_s }.join(" ")}"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|