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
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"read-map": ["principles_folder_not_moved", "both_principles_folders", "symlinked_directory", "unknown_principle", "unparseable_map", "invalid_map", "newer_format", "duplicate_member"],
|
|
17
17
|
"read-audit": ["principles_folder_not_moved", "both_principles_folders", "symlinked_directory", "unparseable_audit", "invalid_audit_record"],
|
|
18
18
|
"rewrite-audit": ["newer_audit_record"],
|
|
19
|
-
"locate-text": ["outside_project", "not_a_file", "unreadable_file", "invalid_encoding", "section_needs_markdown", "query_needs_frontmatter", "query_with_other_locators", "unsupported_query", "unsupported_frontmatter", "duplicate_frontmatter_key", "field_not_found", "section_not_found",
|
|
19
|
+
"locate-text": ["outside_project", "not_a_file", "unreadable_file", "renamed_in_case", "invalid_encoding", "section_needs_markdown", "query_needs_frontmatter", "query_with_other_locators", "unsupported_query", "unsupported_frontmatter", "duplicate_frontmatter_key", "field_not_found", "section_not_found",
|
|
20
20
|
"ambiguous_heading", "passage_not_found", "ambiguous_passage", "passage_end_not_found",
|
|
21
21
|
"broken_members"]
|
|
22
22
|
},
|
|
@@ -118,7 +118,25 @@
|
|
|
118
118
|
]
|
|
119
119
|
},
|
|
120
120
|
{
|
|
121
|
-
"name": "
|
|
121
|
+
"name": "report-after-commit", "usage": "report-after-commit", "group": "read", "options": [],
|
|
122
|
+
"summary": "The mapped members a commit just changed, for a hook after each shell call to put beside the call's result.",
|
|
123
|
+
"help": "learn-what-a-command-does/report-after-commit",
|
|
124
|
+
"steps": [
|
|
125
|
+
{ "id": "report-after-commit", "actor": "cli",
|
|
126
|
+
"does": "Reads the hook's JSON on stdin after a shell call and always exits 0. When the call committed in a mapped repository, its own directory's or one its command changed into with cd or ran git -C in, prints the hook's JSON naming the members those commits changed, for the first such repository; otherwise prints nothing, at the cost of a few git calls." }
|
|
127
|
+
]
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"name": "report-at-session-start", "usage": "report-at-session-start", "group": "read", "options": [],
|
|
131
|
+
"summary": "What the agent should act on as a session starts, for a SessionStart hook to add to its context.",
|
|
132
|
+
"help": "learn-what-a-command-does/report-at-session-start",
|
|
133
|
+
"steps": [
|
|
134
|
+
{ "id": "report-at-session-start", "actor": "cli",
|
|
135
|
+
"does": "Reads the SessionStart hook's JSON on stdin and always exits 0, since the host adds a SessionStart hook's output to the context only then. Prints nothing in a project with no maps. Otherwise prints, each line marked principles:, the line saying every line loaded at session start costs every session, but on resume, then one line for each principle whose members an audit assessed changed since, with its count and the list-member-problems --short command that lists them, then the principles skill as where to start, then, in git, what gives each principle's members with no baseline one, then each principle whose audit record a later release wrote, whose audits wait on an upgrade, then, while any principle awaits its first full audit, one line counting them that asks for one background subagent to follow show-first-audit-brief, or to offer the audit at the next pause if none can be started, and at resume and compact only the count, asking for no second subagent, then, while any audit finding is left open, the one line list-open-findings --short prints, worded for the session's start. When list-member-problems refuses, prints instead its code and the command that shows its repair; input it cannot read is read as a startup." }
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"name": "show-answer-check", "usage": "show-answer-check [REQUEST_ID] --file FILE|- [--as template]", "group": "read", "options": ["file", "as"], "requires": ["file"],
|
|
122
140
|
"summary": "Check an answer without submitting it.",
|
|
123
141
|
"help": "learn-what-a-command-does/show-answer-check",
|
|
124
142
|
"steps": [
|
|
@@ -126,13 +144,38 @@
|
|
|
126
144
|
"does": "Runs every check submit-answer would and prints the same refusal, or names the files submitting would write. Writes nothing.",
|
|
127
145
|
"refuses": ["unparseable_json", "unreadable_file", "request_mismatch", "unknown_request", "stale_request", "stale_map", "undeclared_move", "moves_need_git", "map_entries_need_git", "invalid_removed_members", "empty_correction_map",
|
|
128
146
|
"incomplete_coverage", "invalid_delivery", "observation_repeats_last_audit", "invalid_check_result", "invalid_answer", "unknown_member", "duplicate_finding",
|
|
129
|
-
"incomplete_dispositions", "invalid_disposition", "claimed_change_missing", "unassessed_changes", "git_history_unavailable"
|
|
147
|
+
"incomplete_dispositions", "invalid_disposition", "claimed_change_missing", "unassessed_changes", "git_history_unavailable",
|
|
148
|
+
"no_correction_to_fill"],
|
|
130
149
|
"refuses_like": ["read-map", "read-audit", "locate-text", "rewrite-audit"] },
|
|
131
150
|
{ "id": "submit-the-checked-answer", "actor": "agent",
|
|
132
151
|
"does": "Fix what a refusal names and check again, or submit the answer unchanged.",
|
|
133
152
|
"answer_with": "submit-answer" }
|
|
134
153
|
]
|
|
135
154
|
},
|
|
155
|
+
{
|
|
156
|
+
"name": "show-open-correction", "usage": "show-open-correction ID", "group": "read", "options": [],
|
|
157
|
+
"summary": "Print the answer to fill for the correction a full audit's assessment opened, whenever you need it.",
|
|
158
|
+
"help": "learn-what-a-command-does/show-open-correction",
|
|
159
|
+
"steps": [
|
|
160
|
+
{ "id": "print-open-correction", "actor": "cli",
|
|
161
|
+
"does": "Writes nothing. Prints the correction's answer alone, which submit-answer names rather than prints, from the open audit record that keeps it, in git and outside it. Refuses while principle ID has no open correction to print: with no audit open, it names the full audit to start; with one open that an earlier release wrote, it says to submit the assessment again, which prints its correction and keeps it.",
|
|
162
|
+
"refuses": ["unknown_principle", "no_open_correction"], "refuses_like": ["read-audit"] }
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"name": "show-first-audit-brief", "usage": "show-first-audit-brief [ID]", "group": "read", "options": [],
|
|
167
|
+
"summary": "Print the instructions for one background subagent to run a principle's first full audit.",
|
|
168
|
+
"help": "learn-what-a-command-does/show-first-audit-brief",
|
|
169
|
+
"steps": [
|
|
170
|
+
{ "id": "print-first-audit-brief", "actor": "cli",
|
|
171
|
+
"does": "Writes nothing. With no ID, lists under awaiting_first_audit the principles list-member-problems names as awaiting a first full audit, and each one's brief command on its own line. With ID, prints the brief a background subagent follows to run its first full audit: stop if a principles command would ask the user's permission, read the request in parts, fill, check and submit its answer, commit nothing and edit no member file, and return at most about 600 bytes. Refuses principle ID once a full audit of it has completed, naming the command that lists those still awaiting one.",
|
|
172
|
+
"refuses": ["unknown_principle", "first_audit_completed"], "refuses_like": ["read-audit"] },
|
|
173
|
+
{ "id": "run-the-brief-in-a-subagent", "actor": "agent",
|
|
174
|
+
"does": "Start one background subagent to follow the brief, and carry on with the user's task; relay what it returns at your next pause, and commit the audit record it wrote by its path, or tell the user it is ready to commit.",
|
|
175
|
+
"cannot_check": "whether the subagent ran without asking the user's permission, or whether its return is accurate; check the record with git status --short on its path.",
|
|
176
|
+
"answer_with": "start-audit" }
|
|
177
|
+
]
|
|
178
|
+
},
|
|
136
179
|
{
|
|
137
180
|
"name": "show-meta-principle-passage", "usage": "show-meta-principle-passage", "group": "read", "options": [],
|
|
138
181
|
"summary": "Set principles up: propose the passage that keeps the others held between audits, and the add-member that maps it.",
|
|
@@ -147,6 +190,18 @@
|
|
|
147
190
|
"answer_with": "add-member" }
|
|
148
191
|
]
|
|
149
192
|
},
|
|
193
|
+
{
|
|
194
|
+
"name": "show-hook-setup", "usage": "show-hook-setup", "group": "read", "options": [],
|
|
195
|
+
"summary": "Show the hook entries that run the session-start and after-commit reports without the principles plugin.",
|
|
196
|
+
"help": "learn-what-a-command-does/show-hook-setup",
|
|
197
|
+
"steps": [
|
|
198
|
+
{ "id": "show-hook-entries", "actor": "cli",
|
|
199
|
+
"does": "Writes nothing. Prints, for Claude Code then Codex, the file a project's own hooks go in and the entries that run report-at-session-start at each session's start and report-after-commit after each shell call, each guarded to say principles failed to start instead of failing the hook, and how to remove them." },
|
|
200
|
+
{ "id": "write-the-hook-entries", "actor": "agent",
|
|
201
|
+
"does": "Show the user the entries for this session's host and the file they go in, and write them there only once the user agrees; remove them when the principles plugin is enabled.",
|
|
202
|
+
"cannot_check": "whether the user agrees, or whether the host runs the entries; start a new session to see the report." }
|
|
203
|
+
]
|
|
204
|
+
},
|
|
150
205
|
{
|
|
151
206
|
"name": "create-principle", "usage": "create-principle ID --description TEXT", "group": "write-map", "options": ["description"],
|
|
152
207
|
"summary": "Map a new principle and say what it is.",
|
|
@@ -259,18 +314,18 @@
|
|
|
259
314
|
]
|
|
260
315
|
},
|
|
261
316
|
{
|
|
262
|
-
"name": "start-audit", "usage": "start-audit ID [--member MEMBER ... | --write-ups] [--as template | --instruction FIELD]", "group": "write-audit-record", "options": ["member", "write-ups", "as", "instruction"],
|
|
317
|
+
"name": "start-audit", "usage": "start-audit ID [ID ...] [--member MEMBER ... | --write-ups] [--as template [--part members/ID] | --instruction FIELD | --part PART]", "group": "write-audit-record", "options": ["member", "write-ups", "as", "instruction", "part"],
|
|
263
318
|
"summary": "Ask for an assessment of every member and the set.",
|
|
264
319
|
"help": "learn-what-a-command-does/start-audit",
|
|
265
320
|
"steps": [
|
|
266
321
|
{ "id": "snapshot-members", "actor": "cli",
|
|
267
322
|
"does": "Refuses an empty map or, in git, an uncommitted map or member file; bases the audit on HEAD. Fill --as template's output with your own judgement, under $TMPDIR; its left_as_printed_rule says how a field left as printed is read.",
|
|
268
|
-
"refuses": ["map_has_no_members", "uncommitted_files", "unknown_instruction"], "refuses_like": ["read-map", "locate-text", "rewrite-audit"],
|
|
323
|
+
"refuses": ["map_has_no_members", "uncommitted_files", "unknown_instruction", "unknown_part"], "refuses_like": ["read-map", "locate-text", "rewrite-audit"],
|
|
269
324
|
"next": [{ "to": "assess-every-member", "when": "you passed neither --member nor --write-ups" },
|
|
270
325
|
{ "to": "start-acknowledgement", "when": "you passed --member" },
|
|
271
326
|
{ "to": "start-repointing", "when": "you passed --write-ups" }] },
|
|
272
327
|
{ "id": "assess-every-member", "actor": "agent",
|
|
273
|
-
"does": "Assess each member not carried
|
|
328
|
+
"does": "Assess each member not carried, and any carried one whose sighting is too old to rely on, the set as a whole and one recent decision under it, a finding per problem. Run each check, carried_checks_to_run's too, per shared_check_instructions and check_instructions. Decide each prior finding and listed member to check against the activation.",
|
|
274
329
|
"prompt": "assess-every-member/assess-each-member-and-the-set",
|
|
275
330
|
"checks": "every member is assessed or carried forward once, a marker only where the request carries the member, and each piece of evidence resolves to project text that has not changed since the request.",
|
|
276
331
|
"cannot_check": "whether your assessment is true, a member reached your context, or your findings are the right ones.",
|
|
@@ -7,15 +7,15 @@ module Principles
|
|
|
7
7
|
# Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
|
|
8
8
|
module Data
|
|
9
9
|
# The type one schema asks for, from its type keyword: whether a value has it, and how a refusal names it,
|
|
10
|
-
# with the keys an object takes, so an agent that sent another type learns the shape from the refusal
|
|
10
|
+
# with the keys an object takes, so an agent that sent another type learns the shape from the refusal.
|
|
11
11
|
class ExpectedType
|
|
12
12
|
TYPES = {
|
|
13
13
|
"object" => Hash, "array" => Array, "string" => String, "integer" => Integer, "boolean" => [true, false],
|
|
14
14
|
"null" => NilClass
|
|
15
15
|
}.freeze #: Hash[String, untyped]
|
|
16
16
|
# This tool's own schema keyword: what a refusal of the value's type adds, such as when to point inside a
|
|
17
|
-
# file, which the keys alone do not say
|
|
18
|
-
# keys, in place of the optional keys it names, so it names each key once
|
|
17
|
+
# file, which the keys alone do not say, as {"keys", "says"}. The refusal says it after the required
|
|
18
|
+
# keys, in place of the optional keys it names, so it names each key once.
|
|
19
19
|
ADVICE = "x-type-refusal-advice"
|
|
20
20
|
|
|
21
21
|
#: (Hash[String, untyped]) -> void
|
|
@@ -8,7 +8,7 @@ module Principles
|
|
|
8
8
|
module Data
|
|
9
9
|
# The commits on a first-parent line that changed any of some paths, as git log gives them, newest first, each as
|
|
10
10
|
# its full and short sha, subject line, author date and whether it is a root commit ("true" or "false"). The list
|
|
11
|
-
# and each commit are frozen, and a list asked to be kept is read from git once, a refusal included
|
|
11
|
+
# and each commit are frozen, and a list asked to be kept is read from git once, a refusal included.
|
|
12
12
|
class FirstParentLog
|
|
13
13
|
#: (GitCommand) -> void
|
|
14
14
|
def initialize(git)
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "git_command"
|
|
5
|
+
|
|
6
|
+
module Principles
|
|
7
|
+
# Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
|
|
8
|
+
module Data
|
|
9
|
+
# What git says of HEAD in the repository holding one directory, as report-after-commit asks it after each shell
|
|
10
|
+
# call: the repository's root, whether this tool mapped it, when its HEAD reflog was last written and the subject
|
|
11
|
+
# of that move, HEAD's committer time, and the full sha of a revision. Each is nil where git cannot say.
|
|
12
|
+
class HeadReflog
|
|
13
|
+
# The folders a mapped project holds its maps in: the folder's name now, and its earlier one.
|
|
14
|
+
MAPS_FOLDERS = %w[.principles .memeplex].freeze #: Array[String]
|
|
15
|
+
# How much of a reflog's end holds its last entry: a subject runs to one line, of a commit's first line.
|
|
16
|
+
TAIL_BYTES = 8192
|
|
17
|
+
|
|
18
|
+
#: (String) -> void
|
|
19
|
+
def initialize(directory)
|
|
20
|
+
@git = GitCommand.new(directory) #: GitCommand
|
|
21
|
+
freeze
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# The root of the work tree holding the directory, or nil outside git.
|
|
25
|
+
#: () -> String?
|
|
26
|
+
def toplevel = read(["rev-parse", "--show-toplevel"])
|
|
27
|
+
|
|
28
|
+
# Whether this tool's folder is at the root.
|
|
29
|
+
#: () -> bool
|
|
30
|
+
def mapped?
|
|
31
|
+
root = toplevel or return false
|
|
32
|
+
MAPS_FOLDERS.any? { File.directory?(File.join(root, it)) }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# When this work tree's HEAD reflog was last written, to the second, and the subject of its last entry, or nil
|
|
36
|
+
# when it keeps none.
|
|
37
|
+
#: () -> [Integer, String]?
|
|
38
|
+
def last_move
|
|
39
|
+
path = read(["rev-parse", "--path-format=absolute", "--git-path", "logs/HEAD"])
|
|
40
|
+
return unless path && File.file?(path)
|
|
41
|
+
|
|
42
|
+
[File.mtime(path).to_i, last_line(path).chomp.split("\t", 2)[1].to_s]
|
|
43
|
+
rescue SystemCallError
|
|
44
|
+
nil
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# HEAD's committer time, in seconds, or nil when there is no HEAD.
|
|
48
|
+
#: () -> Integer?
|
|
49
|
+
def committed_at = read(["log", "-1", "--format=%ct", "HEAD"])&.to_i
|
|
50
|
+
|
|
51
|
+
# The full sha revision names, or nil when it names no commit.
|
|
52
|
+
#: (String) -> String?
|
|
53
|
+
def commit(revision) = read(["rev-parse", "--verify", "--quiet", "--end-of-options", "#{revision}^{commit}"])
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
# The last line of the file at path, read from its end, since a reflog grows with every move.
|
|
58
|
+
#: (String) -> String
|
|
59
|
+
def last_line(path)
|
|
60
|
+
File.open(path) do |file|
|
|
61
|
+
file.seek([file.size - TAIL_BYTES, 0].max)
|
|
62
|
+
file.read.to_s.lines.last.to_s
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
#: (Array[String]) -> String?
|
|
67
|
+
def read(arguments)
|
|
68
|
+
output, ok = @git.run(arguments)
|
|
69
|
+
text = output.strip
|
|
70
|
+
text if ok && !text.empty?
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "io/wait"
|
|
5
|
+
require_relative "bounded_file"
|
|
6
|
+
|
|
7
|
+
module Principles
|
|
8
|
+
# Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
|
|
9
|
+
module Data
|
|
10
|
+
# The JSON a host passes on stdin to the hook that runs a command, as report-at-session-start and
|
|
11
|
+
# report-after-commit read it. A host writes it and closes stdin, but an agent's shell can run the command with
|
|
12
|
+
# stdin left open and sending nothing, which a plain read waits on for as long as the shell lets it.
|
|
13
|
+
class HookInput
|
|
14
|
+
# How long, in seconds, to wait for each part of the input before reading it as ended.
|
|
15
|
+
WAIT = 1.0 #: Float
|
|
16
|
+
|
|
17
|
+
#: (IO | StringIO, ?wait: Float) -> void
|
|
18
|
+
def initialize(io, wait: WAIT)
|
|
19
|
+
@io = io
|
|
20
|
+
@wait = wait
|
|
21
|
+
freeze
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# The text on stdin, or nothing when stdin is a terminal, so a person trying the command by hand is not left
|
|
25
|
+
# waiting on it, or cannot be read, since a hook's command exits 0. A pipe is read until it ends, or until
|
|
26
|
+
# nothing more arrives within the wait.
|
|
27
|
+
#: () -> String
|
|
28
|
+
def text
|
|
29
|
+
return "" if @io.tty?
|
|
30
|
+
return @io.read(BoundedFile::LIMIT).to_s unless @io.is_a?(IO)
|
|
31
|
+
|
|
32
|
+
arrived(@io)
|
|
33
|
+
rescue IOError, SystemCallError
|
|
34
|
+
""
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
# What arrives on io, within LIMIT, until it ends or a wait passes with nothing more.
|
|
40
|
+
#: (IO) -> String
|
|
41
|
+
def arrived(io)
|
|
42
|
+
read = +""
|
|
43
|
+
while read.bytesize < BoundedFile::LIMIT && io.wait_readable(@wait)
|
|
44
|
+
part = next_part(io, BoundedFile::LIMIT - read.bytesize) or break
|
|
45
|
+
read << part
|
|
46
|
+
end
|
|
47
|
+
read
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Up to length bytes that have arrived on io, or nil once it has ended.
|
|
51
|
+
#: (IO, Integer) -> String?
|
|
52
|
+
def next_part(io, length)
|
|
53
|
+
io.readpartial(length)
|
|
54
|
+
rescue EOFError
|
|
55
|
+
nil
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -7,8 +7,8 @@ module Principles
|
|
|
7
7
|
# Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
|
|
8
8
|
module Data
|
|
9
9
|
# What git ignores among a project's candidate files: the files, by every ignore file git reads, a global one
|
|
10
|
-
# included, so build output and personal settings are named rather than read
|
|
11
|
-
# them that git ignores, so a build folder's many copies can be counted once
|
|
10
|
+
# included, so build output and personal settings are named rather than read, and each folder above
|
|
11
|
+
# them that git ignores, so a build folder's many copies can be counted once.
|
|
12
12
|
class IgnoredByGit
|
|
13
13
|
#: (String, Array[String]) -> void
|
|
14
14
|
def initialize(root, candidates)
|
|
@@ -5,7 +5,7 @@ module Principles
|
|
|
5
5
|
# Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
|
|
6
6
|
module Data
|
|
7
7
|
# The fields a schema names, kept from data at every depth. This tool's schemas allow fields they do not
|
|
8
|
-
# name, so an older version can read a newer file
|
|
8
|
+
# name, so an older version can read a newer file, but a field a person or agent added must never
|
|
9
9
|
# be printed back as if this tool had said it.
|
|
10
10
|
class KnownFields
|
|
11
11
|
#: (Hash[String, untyped]) -> void
|
|
@@ -6,7 +6,7 @@ module Principles
|
|
|
6
6
|
module Data
|
|
7
7
|
# A path in the project, as its symbolic links lead it. A host may load an instruction file through a link, and
|
|
8
8
|
# git holds a link as the name of its target, so the text at path depends on every link on the way, a linked
|
|
9
|
-
# folder's included, and on the file they lead to
|
|
9
|
+
# folder's included, and on the file they lead to.
|
|
10
10
|
class LinkedPath
|
|
11
11
|
# The most links followed, as an operating system caps them, so a cycle ends.
|
|
12
12
|
MOST_LINKS = 40
|
|
@@ -28,7 +28,7 @@ module Principles
|
|
|
28
28
|
@directory.ids
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
# Which of the folder and its earlier name hold this subfolder
|
|
31
|
+
# Which of the folder and its earlier name hold this subfolder.
|
|
32
32
|
#: () -> Array[String]
|
|
33
33
|
def held_in
|
|
34
34
|
@directory.held_in
|
|
@@ -75,7 +75,7 @@ module Principles
|
|
|
75
75
|
File.join(PrinciplesSubfolder::FOLDER, "maps", "#{id}.json")
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
# Where map id was kept before the folder took its name now, so history reads it at earlier commits
|
|
78
|
+
# Where map id was kept before the folder took its name now, so history reads it at earlier commits.
|
|
79
79
|
#: (String) -> String
|
|
80
80
|
def earlier_relative(id)
|
|
81
81
|
File.join(PrinciplesSubfolder::EARLIER_FOLDER, "maps", "#{id}.json")
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "English"
|
|
5
|
+
require "timeout"
|
|
6
|
+
|
|
7
|
+
module Principles
|
|
8
|
+
# Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
|
|
9
|
+
module Data
|
|
10
|
+
# The principles a bare principles command runs, the first on PATH, when it is another file than this run's own:
|
|
11
|
+
# its path, what it prints for --version and which of the commands asked about it does not run, or nil when PATH
|
|
12
|
+
# finds none, finds this one, or that one prints no version.
|
|
13
|
+
class PrinciplesOnPath
|
|
14
|
+
# How long that copy may take to print its version before it is stopped and read as printing none.
|
|
15
|
+
TIMEOUT_S = 3
|
|
16
|
+
|
|
17
|
+
#: (String, own: String) -> void
|
|
18
|
+
def initialize(path, own:)
|
|
19
|
+
@folders = path.split(File::PATH_SEPARATOR) #: Array[String]
|
|
20
|
+
@own = own
|
|
21
|
+
freeze
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# asking names the commands to ask that copy about, each started for its --help, so none for a caller that
|
|
25
|
+
# needs only its version.
|
|
26
|
+
#: (?Array[String]) -> [String, String, Array[String]]?
|
|
27
|
+
def other(asking = [])
|
|
28
|
+
found = first or return nil
|
|
29
|
+
return nil if same_file?(found, @own)
|
|
30
|
+
|
|
31
|
+
version = version_of(found).to_s.strip
|
|
32
|
+
version.empty? ? nil : [found, version, asking.reject { runs?(found, it) }]
|
|
33
|
+
rescue SystemCallError
|
|
34
|
+
nil
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Whether the first principles on PATH is this run's own file, so a bare principles runs this same copy.
|
|
38
|
+
#: () -> bool
|
|
39
|
+
def own_first?
|
|
40
|
+
found = first
|
|
41
|
+
found ? same_file?(found, @own) : false
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
# What found prints for --version when it exits 0 within TIMEOUT_S, or nil.
|
|
47
|
+
#: (String) -> String?
|
|
48
|
+
def version_of(found)
|
|
49
|
+
printed = within_timeout(found, "--version")
|
|
50
|
+
printed if $CHILD_STATUS&.success?
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Whether found runs command, as its --help exits 0 within TIMEOUT_S; a command it does not know exits 2.
|
|
54
|
+
#: (String, String) -> bool
|
|
55
|
+
def runs?(found, command)
|
|
56
|
+
!within_timeout(found, command, "--help").nil? && $CHILD_STATUS&.success? == true
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# What found prints on stdout for arguments, read until it exits, or nil once TIMEOUT_S passes and it is stopped.
|
|
60
|
+
#: (String, *String) -> String?
|
|
61
|
+
def within_timeout(found, *arguments)
|
|
62
|
+
IO.popen([found, *arguments], err: File::NULL) do |io|
|
|
63
|
+
Timeout.timeout(TIMEOUT_S) { io.read }
|
|
64
|
+
rescue Timeout::Error
|
|
65
|
+
Process.kill("KILL", io.pid)
|
|
66
|
+
nil
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
#: () -> String?
|
|
71
|
+
def first
|
|
72
|
+
@folders.map { File.join(it, "principles") }.find { File.file?(it) && File.executable?(it) }
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
#: (String, String) -> bool
|
|
76
|
+
def same_file?(one, other)
|
|
77
|
+
File.realpath(one) == File.realpath(other)
|
|
78
|
+
rescue SystemCallError
|
|
79
|
+
false
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -18,7 +18,7 @@ module Principles
|
|
|
18
18
|
class PrinciplesSubfolder
|
|
19
19
|
# The folder a project keeps its maps and audit records in.
|
|
20
20
|
FOLDER = PrinciplesDirectory::FOLDER
|
|
21
|
-
# Its name before the rename to principles; a project an older version mapped still holds it
|
|
21
|
+
# Its name before the rename to principles; a project an older version mapped still holds it.
|
|
22
22
|
EARLIER_FOLDER = ".memeplex"
|
|
23
23
|
|
|
24
24
|
#: (String, String) -> void
|
|
@@ -32,11 +32,11 @@ module Principles
|
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
# The paths the text at path depends on, each symbolic link on the way and then the file they lead to, as
|
|
35
|
-
# LinkedPath gives them; path alone when it passes through no link
|
|
35
|
+
# LinkedPath gives them; path alone when it passes through no link.
|
|
36
36
|
#: (String) -> Array[String]
|
|
37
37
|
def text_paths(path) = linked(path).text_paths
|
|
38
38
|
|
|
39
|
-
# The file path's links lead to, read in place of path; path itself when it passes through no link
|
|
39
|
+
# The file path's links lead to, read in place of path; path itself when it passes through no link.
|
|
40
40
|
#: (String) -> String
|
|
41
41
|
def leads_to(path) = linked(path).leads_to
|
|
42
42
|
|
|
@@ -56,6 +56,13 @@ module Principles
|
|
|
56
56
|
absolute.start_with?("#{@root}/") && File.file?(absolute)
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
+
# Whether path names a folder inside the project.
|
|
60
|
+
#: (String) -> bool
|
|
61
|
+
def folder?(path)
|
|
62
|
+
absolute = File.expand_path(path, @root)
|
|
63
|
+
absolute.start_with?("#{@root}/") && File.directory?(absolute)
|
|
64
|
+
end
|
|
65
|
+
|
|
59
66
|
#: (String) -> String
|
|
60
67
|
def resolve(path)
|
|
61
68
|
absolute = File.expand_path(path, @root)
|
|
@@ -90,7 +97,7 @@ module Principles
|
|
|
90
97
|
#: (Array[String]) -> Array[String]?
|
|
91
98
|
def ignored_paths(paths) = IgnoredByGit.new(@root, paths).facts&.fetch("ignored")
|
|
92
99
|
|
|
93
|
-
# JSON from the file at path, which a refusal's message calls named
|
|
100
|
+
# JSON from the file at path, which a refusal's message calls named.
|
|
94
101
|
#: (String, ?named: String) -> untyped
|
|
95
102
|
def read_json(path, named: path)
|
|
96
103
|
parse_json(BoundedFile.new(path, named:).read, path, named:)
|
|
@@ -74,7 +74,7 @@ module Principles
|
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
# The full sha of the commit revision names, as git resolves it, or nil when it names none. The revision is the
|
|
77
|
-
# agent's own, so git reads it after --end-of-options, never as an option
|
|
77
|
+
# agent's own, so git reads it after --end-of-options, never as an option.
|
|
78
78
|
#: (String) -> String?
|
|
79
79
|
def commit_of(revision)
|
|
80
80
|
sha, ok = git(["rev-parse", "--verify", "--quiet", "--end-of-options", "#{revision}^{commit}"])
|
|
@@ -83,7 +83,7 @@ module Principles
|
|
|
83
83
|
|
|
84
84
|
# Each path the commits after commit changed, up to HEAD, sorted and relative to the project: added, edited or
|
|
85
85
|
# deleted, and a rename by both its names, since git is asked to detect none. commit is a full sha, as commit_of
|
|
86
|
-
# gives it, so git cannot read it as an option
|
|
86
|
+
# gives it, so git cannot read it as an option.
|
|
87
87
|
#: (String) -> Array[String]
|
|
88
88
|
def changed_since(commit)
|
|
89
89
|
output, ok = git(["diff", "--name-only", "-z", "--relative", "--no-renames", revision(commit), "HEAD", "--"])
|
|
@@ -113,7 +113,7 @@ module Principles
|
|
|
113
113
|
end
|
|
114
114
|
|
|
115
115
|
# Which of paths, relative to the project, git does not track, ignored or not. Unlike untracked, it names an
|
|
116
|
-
# ignored file too, since git holds it no more than an untracked one
|
|
116
|
+
# ignored file too, since git holds it no more than an untracked one.
|
|
117
117
|
#: (Array[String]) -> Array[String]
|
|
118
118
|
def not_tracked(paths)
|
|
119
119
|
return [] if paths.empty?
|
|
@@ -122,10 +122,18 @@ module Principles
|
|
|
122
122
|
output.split("\0").sort
|
|
123
123
|
end
|
|
124
124
|
|
|
125
|
+
# Every path in the project git tracks, as git spells it, sorted, so a path a disk that folds case opens under
|
|
126
|
+
# another spelling can be told apart; none outside git.
|
|
127
|
+
#: () -> Array[String]
|
|
128
|
+
def tracked_files
|
|
129
|
+
output, ok = git(["ls-files", "-z"])
|
|
130
|
+
ok ? output.force_encoding("UTF-8").split("\0").sort : []
|
|
131
|
+
end
|
|
132
|
+
|
|
125
133
|
# Every file in the project that differs from HEAD, is gone since it, or is untracked, sorted. Unlike
|
|
126
134
|
# uncommitted, it leaves ignored files out: it is asked about the whole project, where an ignored file is
|
|
127
135
|
# one the owner chose to keep out of git, while uncommitted is asked about named members, which an audit
|
|
128
|
-
# needs committed
|
|
136
|
+
# needs committed. Before the first commit, every file not ignored is one.
|
|
129
137
|
#: () -> Array[String]
|
|
130
138
|
def changed_files
|
|
131
139
|
changed, = head ? git(["diff", "--name-only", "--relative", "-z", "HEAD"]) : [""]
|
|
@@ -134,7 +142,7 @@ module Principles
|
|
|
134
142
|
end
|
|
135
143
|
|
|
136
144
|
# path's text at commit, frozen, or nil when the commit does not hold it. Text at a full sha never changes, so
|
|
137
|
-
# git is asked for it once; HEAD moves with each commit, so it is asked every time
|
|
145
|
+
# git is asked for it once; HEAD moves with each commit, so it is asked every time.
|
|
138
146
|
#: (String, String) -> String?
|
|
139
147
|
def text_at(commit, path)
|
|
140
148
|
return read_text_at(commit, path) unless FULL_SHA.match?(commit)
|
|
@@ -159,8 +167,7 @@ module Principles
|
|
|
159
167
|
# as its full and short sha, subject line, author date and whether it is a root commit ("true" or "false"); none
|
|
160
168
|
# outside git. since leaves out since and every commit before it. The list and each commit are frozen. Between
|
|
161
169
|
# full shas the list never changes, so git is asked for it once, and a refusal, as for a sha the clone lacks, is
|
|
162
|
-
# kept too, since asking again would be refused again; HEAD moves with each commit, so it is asked every time
|
|
163
|
-
# (#1161).
|
|
170
|
+
# kept too, since asking again would be refused again; HEAD moves with each commit, so it is asked every time.
|
|
164
171
|
#: (Array[String], ?since: String?, ?up_to: String) -> Array[Hash[String, String]]
|
|
165
172
|
def commits_touching(paths, since: nil, up_to: "HEAD")
|
|
166
173
|
range = since ? "#{revision(since)}..#{revision(up_to)}" : revision(up_to)
|
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
# typed: strict
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
-
require_relative "../version"
|
|
5
4
|
require_relative "git_command"
|
|
6
5
|
|
|
7
6
|
module Principles
|
|
8
7
|
# Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
|
|
9
8
|
module Data
|
|
10
|
-
# The version that is running: what a build stamped, or, in a checkout, the release
|
|
11
|
-
#
|
|
12
|
-
# prerelease even when every character of the sha is a digit.
|
|
9
|
+
# The version that is running: what a build stamped, or, in a checkout, the release with the commit it runs
|
|
10
|
+
# from, as RELEASE.g<short sha>. Its caller hands in both from version.rb. The g keeps a development version a
|
|
11
|
+
# RubyGems prerelease even when every character of the sha is a digit.
|
|
13
12
|
class RunningVersion
|
|
14
13
|
# git archive writes the short sha of the commit it archives here, since .gitattributes marks this file
|
|
15
|
-
# export-subst; a checkout keeps the placeholder as written
|
|
14
|
+
# export-subst; a checkout keeps the placeholder as written.
|
|
16
15
|
ARCHIVED_COMMIT = "$Format:%h$" #: String
|
|
17
16
|
|
|
18
|
-
#: (?String, ?archived_commit: String) -> void
|
|
19
|
-
def initialize(checkout = File.expand_path("../../..", __dir__),
|
|
17
|
+
#: (?String, release: String, ?built: String?, ?archived_commit: String) -> void
|
|
18
|
+
def initialize(checkout = File.expand_path("../../..", __dir__), release:, built: nil,
|
|
19
|
+
archived_commit: ARCHIVED_COMMIT)
|
|
20
20
|
@checkout = checkout
|
|
21
|
+
@release = release
|
|
22
|
+
@built = built
|
|
21
23
|
@archived_commit = archived_commit
|
|
22
24
|
end
|
|
23
25
|
|
|
24
26
|
#: () -> String
|
|
25
27
|
def to_s
|
|
26
|
-
|
|
28
|
+
@built || "#{@release}.g#{commit}"
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
private
|
|
@@ -11,17 +11,17 @@ module Principles
|
|
|
11
11
|
# Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
|
|
12
12
|
module Data
|
|
13
13
|
# Checks parsed JSON against one of the schemas in schemas/, with the standard library alone, so a run
|
|
14
|
-
# needs no gem
|
|
14
|
+
# needs no gem. It supports only KEYWORDS, which is what this tool's own schemas use; a spec fails on
|
|
15
15
|
# a schema that uses another, and a conformance spec compares its verdicts with json_schemer's.
|
|
16
16
|
class SchemaCheck
|
|
17
17
|
# The keywords a schema may use, besides annotations such as title and description.
|
|
18
18
|
KEYWORDS = %w[type properties required additionalProperties items minLength pattern enum const].freeze
|
|
19
19
|
# This tool's own schema keyword, on an object that refuses fields it does not name: for a field an agent
|
|
20
|
-
# may put there by mistake, where it belongs instead, which its refusal adds
|
|
20
|
+
# may put there by mistake, where it belongs instead, which its refusal adds, as {field => text}.
|
|
21
21
|
UNREAD_FIELD_ADVICE = "x-unread-field-advice"
|
|
22
22
|
# This tool's own schema keyword, on a string with a pattern: what to say when the value does not match, in place
|
|
23
23
|
# of the pattern, for a field whose pattern holds a template's placeholder, which another template's wording
|
|
24
|
-
# fails
|
|
24
|
+
# fails.
|
|
25
25
|
UNMATCHED_ADVICE = "x-unmatched-advice"
|
|
26
26
|
# Keywords that only describe, and check nothing; the refusal advice is worded into a refusal.
|
|
27
27
|
ANNOTATIONS = %W[$schema $id title description #{ExpectedType::ADVICE} #{UNREAD_FIELD_ADVICE}
|
|
@@ -35,7 +35,7 @@ module Principles
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
# The check of only the top-level fields named, any other field let through, so the part a later step depends
|
|
38
|
-
# on is checked before the rest, as an answer's head is
|
|
38
|
+
# on is checked before the rest, as an answer's head is.
|
|
39
39
|
#: (Array[String]) -> SchemaCheck
|
|
40
40
|
def only(fields)
|
|
41
41
|
SchemaCheck.new(@name, @schema.merge("properties" => @schema.fetch("properties", {}).slice(*fields),
|
|
@@ -138,7 +138,7 @@ module Principles
|
|
|
138
138
|
end
|
|
139
139
|
|
|
140
140
|
# Why key is refused in an object schema checks: not a field read there, the fields that are, so the agent need
|
|
141
|
-
# not guess them
|
|
141
|
+
# not guess them, and what the schema says of key, if anything.
|
|
142
142
|
#: (Hash[String, untyped], String) -> String
|
|
143
143
|
def unread(schema, key)
|
|
144
144
|
read = schema.fetch("properties", {}).keys
|