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.
- 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 +50 -42
- data/lib/principles/command_line.rb +22 -16
- data/lib/principles/command_routes.rb +20 -6
- data/lib/principles/controllers/acknowledgement.rb +29 -74
- data/lib/principles/controllers/acknowledgements.rb +154 -0
- data/lib/principles/controllers/after_commit_report.rb +44 -0
- data/lib/principles/controllers/answer.rb +48 -18
- data/lib/principles/controllers/answer_phase.rb +20 -3
- data/lib/principles/controllers/assessment.rb +32 -11
- data/lib/principles/controllers/audit.rb +43 -19
- data/lib/principles/controllers/audit_completion.rb +21 -12
- data/lib/principles/controllers/command.rb +13 -12
- data/lib/principles/controllers/correction.rb +15 -7
- data/lib/principles/controllers/first_audit_brief.rb +40 -0
- data/lib/principles/controllers/full_audit_request.rb +41 -82
- 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 +32 -21
- data/lib/principles/controllers/member_entries.rb +4 -4
- data/lib/principles/controllers/member_problems_report.rb +62 -16
- 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 +61 -6
- 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 -21
- data/lib/principles/data/schemas/acknowledgements-answer.schema.json +9 -2
- data/lib/principles/data/schemas/assessment-answer.schema.json +43 -22
- 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 +9 -9
- 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 +4 -4
- data/lib/principles/launch.rb +49 -0
- data/lib/principles/list_open_findings_options.rb +1 -1
- data/lib/principles/models/accepted_loading.rb +2 -2
- data/lib/principles/models/acknowledged_check.rb +23 -11
- data/lib/principles/models/acknowledgement.rb +34 -18
- data/lib/principles/models/acknowledgement_left_as_printed.rb +7 -15
- data/lib/principles/models/acknowledgement_refusal.rb +25 -10
- data/lib/principles/models/acknowledgements.rb +45 -29
- 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 +4 -4
- 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 +6 -7
- data/lib/principles/models/audit.rb +33 -34
- data/lib/principles/models/audit_record.rb +54 -28
- 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 +7 -7
- 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 +4 -4
- data/lib/principles/models/listed_members.rb +7 -9
- data/lib/principles/models/loaded_files.rb +4 -5
- data/lib/principles/models/loading_decision.rb +3 -3
- data/lib/principles/models/loading_facts.rb +1 -1
- data/lib/principles/models/loads_to_check.rb +1 -1
- 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 +8 -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 +14 -15
- data/lib/principles/models/member_repair_moves.rb +15 -9
- data/lib/principles/models/member_sighting.rb +10 -10
- 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 +26 -8
- data/lib/principles/models/project.rb +27 -19
- 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 +34 -31
- data/lib/principles/models/request_id.rb +18 -6
- data/lib/principles/models/runs_from.rb +7 -2
- data/lib/principles/models/sent_answer.rb +14 -12
- 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 +13 -6
- data/lib/principles/prose_list.rb +1 -1
- data/lib/principles/session_start_options.rb +1 -1
- data/lib/principles/start_audit_options.rb +46 -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 +97 -11
- 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 +50 -41
- data/lib/principles/views/assessment_request.rb +39 -36
- 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 +92 -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 +45 -34
- 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 +44 -25
- data/lib/principles/views/diff_since_last_audit.rb +8 -6
- data/lib/principles/views/findings_result.rb +17 -6
- 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 +14 -6
- 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 +8 -5
- 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 +2 -2
- data/lib/principles/views/members_a_commit_changed.rb +13 -10
- data/lib/principles/views/members_with_no_baseline.rb +3 -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 +7 -7
- data/lib/principles/views/open_findings_elsewhere_result.rb +5 -2
- data/lib/principles/views/open_findings_line.rb +25 -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 +39 -17
- data/lib/principles/views/problem_result.rb +40 -37
- 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/resolve-them-in-a-full-audit.md +1 -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/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/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/list-candidate-files.md +4 -3
- data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +6 -6
- data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +11 -11
- 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 +20 -18
- 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 +21 -22
- data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +5 -4
- 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 -1
- 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.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 +83 -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
|
@@ -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
|
|
@@ -25,25 +25,29 @@ module Principles
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
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
|
|
28
|
+
# commands run from there, as list-member-problems --short's stderr does.
|
|
29
29
|
#: () -> Invocation
|
|
30
30
|
def without_project = Invocation.new(executable: @executable, project: @project, named: false)
|
|
31
31
|
|
|
32
|
+
# Whether each command names the project.
|
|
33
|
+
#: () -> bool
|
|
34
|
+
def named? = @named
|
|
35
|
+
|
|
32
36
|
# The project as a shell word, as --project gives it.
|
|
33
37
|
#: () -> String
|
|
34
38
|
def project_word = shell_word(@project)
|
|
35
39
|
|
|
36
|
-
# A command to run in this project, which it names right after the executable, as model repairs do
|
|
40
|
+
# A command to run in this project, which it names right after the executable, as model repairs do.
|
|
37
41
|
# Each value is shell-quoted, because ids, paths and headings come from project files that anyone may have
|
|
38
|
-
# written
|
|
42
|
+
# written. options are flags with their values, such as
|
|
39
43
|
# ["--starting-at", text], quoted the same way. usage is this tool's own placeholder text, such as
|
|
40
44
|
# "--section HEADING", left for the agent to fill and never quoted. When a value starts with "-", as a
|
|
41
|
-
# 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.
|
|
42
46
|
#: (String, *String, ?options: Array[String], ?usage: String?) -> String
|
|
43
47
|
def in_project(command, *values, options: [], usage: nil) = listed_in_project(command, values, options:, usage:)
|
|
44
48
|
|
|
45
49
|
# The command that answers request request_id in this project: from file, the --file value an answer was
|
|
46
|
-
# 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.
|
|
47
51
|
#: (String, ?file: String?) -> String
|
|
48
52
|
def submit_answer(request_id, file: nil)
|
|
49
53
|
return in_project("submit-answer", request_id, usage: "--file FILE") unless file
|
|
@@ -51,7 +55,7 @@ module Principles
|
|
|
51
55
|
in_project("submit-answer", request_id, options: ["--file", file])
|
|
52
56
|
end
|
|
53
57
|
|
|
54
|
-
# 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.
|
|
55
59
|
#: (String, Array[String], ?options: Array[String], ?usage: String?) -> String
|
|
56
60
|
def listed_in_project(command, values, options: [], usage: nil)
|
|
57
61
|
flags = options.map { |value| shell_word(value) }
|
|
@@ -68,6 +72,10 @@ module Principles
|
|
|
68
72
|
"--project #{shell_word(@project)}"
|
|
69
73
|
end
|
|
70
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
|
+
|
|
71
79
|
private
|
|
72
80
|
|
|
73
81
|
# --project and the project, or nil when the commands leave it out.
|
|
@@ -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
|
|
@@ -7,15 +7,15 @@ 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
9
|
# What add-member's result says of the members sharing a line with the member it added, show-principle
|
|
10
|
-
# beside each member it shows
|
|
10
|
+
# beside each member it shows, and a full audit's request beside each member, of other maps only:
|
|
11
11
|
# those in its map (overlaps), those of them spanning exactly its lines
|
|
12
|
-
# (same_lines_as
|
|
12
|
+
# (same_lines_as), and those in other maps, with their roles there and same_lines when they span exactly
|
|
13
13
|
# its lines, spans_these_lines when their lines include all of its and within_these_lines when its lines
|
|
14
|
-
# include theirs (mapped_elsewhere
|
|
14
|
+
# include theirs (mapped_elsewhere). Each field is printed only when there are some; add-member
|
|
15
15
|
# also prints the sentences that say what it means for the agent.
|
|
16
16
|
class LinesSharedWithMember
|
|
17
17
|
# Why the agent checks the text where the lines meet, unless each member holding another's lines is a whole
|
|
18
|
-
# file, which holds every line's text
|
|
18
|
+
# file, which holds every line's text.
|
|
19
19
|
TEXT_CHECK = "Lines are not text: where two share a first or last line, a passage can start or end partway " \
|
|
20
20
|
"through it, so check the text there before deciding which edit reaches which member. " #: String
|
|
21
21
|
|
|
@@ -61,7 +61,7 @@ module Principles
|
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
# Which of them span all of this member's lines and which lie within them, so the agent can work out which
|
|
64
|
-
# member an edit reaches
|
|
64
|
+
# member an edit reaches. Lines are not text, so the agent checks where they share a first or last line.
|
|
65
65
|
#: () -> String
|
|
66
66
|
def spans_note
|
|
67
67
|
spans = @mapped_elsewhere.filter_map do |each|
|
|
@@ -99,7 +99,7 @@ module Principles
|
|
|
99
99
|
"meant, say why in this member's role. "
|
|
100
100
|
end
|
|
101
101
|
|
|
102
|
-
# Each member spanning exactly these lines, by id, with its principle when it is in another
|
|
102
|
+
# Each member spanning exactly these lines, by id, with its principle when it is in another.
|
|
103
103
|
#: () -> Array[String]
|
|
104
104
|
def same_lines_named
|
|
105
105
|
elsewhere = @mapped_elsewhere.select { |each| each["same_lines"] }
|
|
@@ -8,15 +8,18 @@ require_relative "request_part"
|
|
|
8
8
|
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
|
-
# How a full audit's request shows the members to check against the principle's activation
|
|
11
|
+
# How a full audit's request shows the members to check against the principle's activation.
|
|
12
12
|
class LoadsToCheckResult
|
|
13
|
-
#
|
|
13
|
+
# The part this lists, by the name the request prints it under and start-audit --part takes.
|
|
14
|
+
PART = "loads_to_check_against_activation" #: String
|
|
15
|
+
|
|
16
|
+
# What a decision may be, as the answer printed alone says where it is written.
|
|
14
17
|
DECISION = "accepted, with reason saying why the member loads as it does; kept, with no reason, where " \
|
|
15
18
|
"last_accepted.since_accepted is unchanged; if the activation is wrong instead, change it and " \
|
|
16
19
|
"start the audit again" #: String
|
|
17
20
|
|
|
18
21
|
# listed is the members to check, nil when there are none, and id the principle they belong to; placeholders
|
|
19
|
-
# is the text the template alone prints in each field of a decision beside it, which left is not given
|
|
22
|
+
# is the text the template alone prints in each field of a decision beside it, which left is not given.
|
|
20
23
|
#: (Invocation, Hash[String, untyped]?, String, placeholders: Hash[String, String]) -> void
|
|
21
24
|
def initialize(invocation, listed, id, placeholders:)
|
|
22
25
|
@placeholders = placeholders
|
|
@@ -33,7 +36,7 @@ module Principles
|
|
|
33
36
|
listed = @listed or return
|
|
34
37
|
|
|
35
38
|
decisions = listed.fetch("rows").map { |row| { "member_id" => row.fetch("member_id"), "decision" => nil } }
|
|
36
|
-
RequestPart.new(shown: {
|
|
39
|
+
RequestPart.new(shown: { PART => listed },
|
|
37
40
|
instructions: [Instruction.of_paragraphs("loads_to_check_instruction", instruction) { true }],
|
|
38
41
|
slots: { "loading_decisions" => decisions },
|
|
39
42
|
help: { "loading_decisions" => { "decision" => DECISION, **@placeholders } })
|
|
@@ -42,7 +45,7 @@ module Principles
|
|
|
42
45
|
private
|
|
43
46
|
|
|
44
47
|
# How to decide each listed member, naming the activation change for a principle whose work is in hand in
|
|
45
|
-
# every session
|
|
48
|
+
# every session.
|
|
46
49
|
#: () -> String
|
|
47
50
|
def instruction
|
|
48
51
|
always = @invocation.in_project("change-activation", @id, options: ["--always"])
|
|
@@ -8,10 +8,10 @@ module Principles
|
|
|
8
8
|
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
9
9
|
module Views
|
|
10
10
|
# What add-member's result needs to know of the map a member joined, beyond the map itself: whether its
|
|
11
|
-
# principle keeps the others held, which changes the step after mapping
|
|
12
|
-
# correction may be open on it, so that the member may fix one of its findings
|
|
11
|
+
# principle keeps the others held, which changes the step after mapping, and whether a full audit's
|
|
12
|
+
# correction may be open on it, so that the member may fix one of its findings, and whether to repeat
|
|
13
13
|
# what to do after mapping: with a principle's first member, or in git the first since the map's last commit, so
|
|
14
|
-
# members mapped in one sitting do not each repeat it
|
|
14
|
+
# members mapped in one sitting do not each repeat it.
|
|
15
15
|
class MapAddedTo
|
|
16
16
|
COMPLETENESS_QUESTION = "Is every carrier of the same rule mapped, and should any member belong to another " \
|
|
17
17
|
"principle? "
|
|
@@ -29,7 +29,7 @@ module Principles
|
|
|
29
29
|
"material the members govern."
|
|
30
30
|
|
|
31
31
|
# in_git says whether the project is in git, where a committed map is each member's baseline until its first
|
|
32
|
-
# full audit
|
|
32
|
+
# full audit.
|
|
33
33
|
#: (Invocation, in_git: bool) -> void
|
|
34
34
|
def initialize(invocation, in_git:)
|
|
35
35
|
@invocation = invocation
|
|
@@ -59,14 +59,14 @@ module Principles
|
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
# What this tool recorded of when the work is in hand, and what a full audit lists against it, as
|
|
62
|
-
# Models::Activation#full_audit_lists names it
|
|
62
|
+
# Models::Activation#full_audit_lists names it.
|
|
63
63
|
#: (PrintedPrinciple, lists: String) -> Hash[String, untyped]
|
|
64
64
|
def activation_changed(principle, lists:)
|
|
65
65
|
question(principle, ActivationInHand.new(principle.activation || {}).recorded(principle.id, lists),
|
|
66
66
|
start_audit(principle.id), shown: { "activation" => principle.activation })
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
# change-activation when the map already held that activation, so it wrote nothing
|
|
69
|
+
# change-activation when the map already held that activation, so it wrote nothing.
|
|
70
70
|
#: (PrintedPrinciple) -> Hash[String, untyped]
|
|
71
71
|
def activation_unchanged(principle)
|
|
72
72
|
question(principle, ActivationInHand.new(principle.activation || {}).unchanged(principle.id),
|
|
@@ -89,7 +89,7 @@ module Principles
|
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
# add-member's report of the map it started, with the description and activation it wrote, which the agent
|
|
92
|
-
# never typed
|
|
92
|
+
# never typed.
|
|
93
93
|
#: (PrintedPrinciple) -> Hash[String, untyped]
|
|
94
94
|
def map_created(principle)
|
|
95
95
|
{ "map_created" => { "description" => principle.description, "activation" => principle.activation } }
|
|
@@ -106,8 +106,8 @@ module Principles
|
|
|
106
106
|
end
|
|
107
107
|
|
|
108
108
|
# change-member-check: the stored command is the member's check in the map printed beside this, so the
|
|
109
|
-
# agent can see it byte for byte; the question names that field rather than quoting project text
|
|
110
|
-
# hidden names each character in the check that prints escaped or not at all
|
|
109
|
+
# agent can see it byte for byte; the question names that field rather than quoting project text.
|
|
110
|
+
# hidden names each character in the check that prints escaped or not at all.
|
|
111
111
|
#: (PrintedPrinciple, member: String, hidden: Array[String]) -> Hash[String, untyped]
|
|
112
112
|
def check_changed(principle, member:, hidden:)
|
|
113
113
|
done = "#{member} is now enforced by the check named in its map entry. The next audit marks it new or " \
|
|
@@ -122,8 +122,8 @@ module Principles
|
|
|
122
122
|
end
|
|
123
123
|
|
|
124
124
|
# change-member-role, change-member-check and remove-member-check: done says what changed. This tool cannot
|
|
125
|
-
# tell in git whether a full audit's correction is open, so the next step names both cases
|
|
126
|
-
# the other case by what the agent holds: a correction request (
|
|
125
|
+
# tell in git whether a full audit's correction is open, so the next step names both cases, and
|
|
126
|
+
# the other case by what the agent holds: a correction request (one user on 8e5b3f9).
|
|
127
127
|
#: (PrintedPrinciple, member: String, done: String) -> Hash[String, untyped]
|
|
128
128
|
def member_replaced(principle, member:, done:)
|
|
129
129
|
question(principle, "#{done} Check the other members, then start the audit.\nIf you hold a correction " \
|
|
@@ -143,7 +143,7 @@ module Principles
|
|
|
143
143
|
private
|
|
144
144
|
|
|
145
145
|
# shown is what the result prints of the map: the whole map unless the caller names less, as add-member
|
|
146
|
-
# does
|
|
146
|
+
# does.
|
|
147
147
|
#: (PrintedPrinciple, String, String, ?shown: Hash[String, untyped]) -> Hash[String, untyped]
|
|
148
148
|
def question(principle, text, answer_with, shown: { "map" => principle.map })
|
|
149
149
|
{ "status" => "question", "principle_id" => principle.id, "map_file" => principle.file, **shown,
|
|
@@ -1,32 +1,31 @@
|
|
|
1
1
|
# typed: strict
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
-
require_relative "
|
|
4
|
+
require_relative "read_the_change"
|
|
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
9
|
# One member's change since its baseline, as a one-member audit's request shows it: the member's id, role and
|
|
10
10
|
# evidence, the commit its baseline text is at, the commit the audit is based on, the member's own lines at
|
|
11
|
-
# each
|
|
11
|
+
# each, and the command that shows its change between them.
|
|
12
12
|
class MemberChangeSinceBaseline
|
|
13
13
|
# member holds the member's id, role and evidence; commits holds "base", HEAD, and "baseline", the commit
|
|
14
14
|
# the member's baseline text is at, and "audit_base" when the baseline is later than the audit's base;
|
|
15
|
-
# member_lines holds its own lines at each, or their counts when too long;
|
|
16
|
-
#
|
|
15
|
+
# member_lines holds its own lines at each, or their counts when too long; first_changed_lines the first line
|
|
16
|
+
# on each side the other lacks; read_the_change the command that shows the change from baseline to base.
|
|
17
17
|
#: (member: Hash[String, untyped], commits: Hash[String, String], member_lines: Hash[String, untyped],
|
|
18
|
-
#| first_changed_lines: Hash[String, String],
|
|
19
|
-
def initialize(member:, commits:, member_lines:, first_changed_lines:,
|
|
18
|
+
#| first_changed_lines: Hash[String, String], read_the_change: ReadTheChange) -> void
|
|
19
|
+
def initialize(member:, commits:, member_lines:, first_changed_lines:, read_the_change:)
|
|
20
20
|
@member = member
|
|
21
21
|
@commits = commits
|
|
22
22
|
@member_lines = member_lines
|
|
23
23
|
@first_changed_lines = first_changed_lines
|
|
24
|
-
@
|
|
24
|
+
@read_the_change = read_the_change
|
|
25
25
|
freeze
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
# The first line on each side the other lacks, which an answer leaving its quotes out reads them as
|
|
29
|
-
# #1166).
|
|
28
|
+
# The first line on each side the other lacks, which an answer leaving its quotes out reads them as.
|
|
30
29
|
#: Hash[String, String]
|
|
31
30
|
attr_reader :first_changed_lines
|
|
32
31
|
|
|
@@ -40,36 +39,58 @@ module Principles
|
|
|
40
39
|
@commits.fetch("base")
|
|
41
40
|
end
|
|
42
41
|
|
|
42
|
+
# Whether other prints the same change as this one: the same lines and first changed lines, as one
|
|
43
|
+
# member mapped by two principles does from baselines holding the same text, whatever commit each is at.
|
|
44
|
+
#: (MemberChangeSinceBaseline) -> bool
|
|
45
|
+
def same_change_as?(other) = other.change == change
|
|
46
|
+
|
|
47
|
+
# The fields as the request prints them, but the change, which another principle's entry prints under
|
|
48
|
+
# principle_id.
|
|
49
|
+
#: (String) -> Hash[String, untyped]
|
|
50
|
+
def shown_under(principle_id)
|
|
51
|
+
shown = change
|
|
52
|
+
to_h.reject { |field, _| shown.key?(field) }.merge("change_shown_under" => principle_id)
|
|
53
|
+
end
|
|
54
|
+
|
|
43
55
|
# The fields as the request prints them. Lines left out for their length point at read_the_change instead,
|
|
44
|
-
# so the request is never silently partial
|
|
56
|
+
# so the request is never silently partial.
|
|
45
57
|
#: () -> Hash[String, untyped]
|
|
46
58
|
def to_h
|
|
47
|
-
read = read_the_change
|
|
59
|
+
read = @read_the_change.to_s
|
|
48
60
|
lines = @member_lines.key?("omitted") ? @member_lines.merge("read_instead" => read) : with_read_instead(read)
|
|
49
61
|
{ "member" => @member, "baseline_commit" => @commits.fetch("baseline"), "base_commit" => base_commit,
|
|
50
62
|
**@commits.slice("audit_base").transform_keys { "audit_base_commit" },
|
|
51
63
|
"member_lines" => lines, "first_changed_lines" => @first_changed_lines, "read_the_change" => read }
|
|
52
64
|
end
|
|
53
65
|
|
|
66
|
+
protected
|
|
67
|
+
|
|
68
|
+
# The fields that print the change itself, as the request prints them, which a request across principles
|
|
69
|
+
# prints once for a shared member.
|
|
70
|
+
#: () -> Hash[String, untyped]
|
|
71
|
+
def change = to_h.slice("member_lines", "first_changed_lines")
|
|
72
|
+
|
|
54
73
|
private
|
|
55
74
|
|
|
56
|
-
# The member's lines, each side of their changed region
|
|
75
|
+
# The member's lines, each side of their changed region, or of each of their changed regions, left out pointing
|
|
76
|
+
# at read, as the whole lines do.
|
|
57
77
|
#: (String) -> Hash[String, untyped]
|
|
58
78
|
def with_read_instead(read)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
79
|
+
@member_lines.to_h do |key, value|
|
|
80
|
+
case key
|
|
81
|
+
when "changed_region" then [key, region_reading(value, read)]
|
|
82
|
+
when "changed_regions" then [key, value.map { region_reading(it, read) }]
|
|
83
|
+
else [key, value]
|
|
84
|
+
end
|
|
64
85
|
end
|
|
65
|
-
@member_lines.merge("changed_region" => sides)
|
|
66
86
|
end
|
|
67
87
|
|
|
68
|
-
#
|
|
69
|
-
#: () -> String
|
|
70
|
-
def
|
|
71
|
-
|
|
72
|
-
|
|
88
|
+
# region with each side left out pointing at read.
|
|
89
|
+
#: (Hash[String, untyped], String) -> Hash[String, untyped]
|
|
90
|
+
def region_reading(region, read)
|
|
91
|
+
region.transform_values do |side|
|
|
92
|
+
side.is_a?(Hash) && side.key?("omitted") ? side.merge("read_instead" => read) : side
|
|
93
|
+
end
|
|
73
94
|
end
|
|
74
95
|
end
|
|
75
96
|
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Principles
|
|
5
|
+
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
6
|
+
module Views
|
|
7
|
+
# A member's lines at its last full audit and now, as AcknowledgedSinceLastAudit prints them, beside the member's
|
|
8
|
+
# text printed whole, as its start-audit --part prints it: each side now names where it starts in the text and
|
|
9
|
+
# how many of its lines it spans, so the part carries each line now once.
|
|
10
|
+
class MemberLinesBesideText
|
|
11
|
+
#: (Hash[String, untyped]) -> void
|
|
12
|
+
def initialize(member_lines)
|
|
13
|
+
@member_lines = member_lines
|
|
14
|
+
freeze
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# The lines as printed, each side now that lists its lines pointing at the text instead.
|
|
18
|
+
#: () -> Hash[String, untyped]
|
|
19
|
+
def shown
|
|
20
|
+
lines = @member_lines
|
|
21
|
+
return lines.merge("now" => in_text(1, lines.fetch("now"))) if lines["now"].is_a?(Array)
|
|
22
|
+
return lines.merge("changed_region" => region(lines.fetch("changed_region"))) if lines["changed_region"]
|
|
23
|
+
return lines.merge("changed_regions" => lines.fetch("changed_regions").map { region(it) }) if
|
|
24
|
+
lines["changed_regions"]
|
|
25
|
+
|
|
26
|
+
lines
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
# A changed region, its side now pointing at the text when it lists its lines.
|
|
32
|
+
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
33
|
+
def region(changed)
|
|
34
|
+
now = changed.fetch("now")
|
|
35
|
+
now["lines"] ? changed.merge("now" => in_text(now.fetch("from_line"), now.fetch("lines"))) : changed
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Where lines start in the text, and how many they are.
|
|
39
|
+
#: (Integer, Array[String]) -> Hash[String, Integer]
|
|
40
|
+
def in_text(from_line, lines) = { "from_line" => from_line, "lines_in_text" => lines.length }
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -31,7 +31,7 @@ module Principles
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
# member, as show-principle prints it, with its repairs as repair_with when moves, its moves, are given, as the
|
|
34
|
-
# controller gives them for a member an audit would refuse
|
|
34
|
+
# controller gives them for a member an audit would refuse.
|
|
35
35
|
#: (String, Hash[String, untyped], Array[Hash[String, untyped]]?) -> Hash[String, untyped]
|
|
36
36
|
def beside(id, member, moves)
|
|
37
37
|
return member unless moves
|
|
@@ -44,7 +44,8 @@ module Principles
|
|
|
44
44
|
#: (String, String, Hash[String, untyped]) -> String
|
|
45
45
|
def move(id, member_id, move)
|
|
46
46
|
kept = move.fetch("keep").flat_map { |field, value| [FLAGS.fetch(field), value] }
|
|
47
|
-
|
|
47
|
+
fill = move.fetch("fill")
|
|
48
|
+
usage = fill.map { "#{FLAGS.fetch(it)} #{PLACEHOLDERS.fetch(it)}" }.join(" ") unless fill.empty?
|
|
48
49
|
@invocation.in_project("move-member", id, member_id, options: kept, usage: usage)
|
|
49
50
|
end
|
|
50
51
|
end
|