principles 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +151 -1
- data/README.md +10 -6
- data/exe/principles +1 -1
- data/lib/principles/cli.rb +9 -10
- data/lib/principles/command_line.rb +15 -6
- data/lib/principles/command_routes.rb +18 -2
- data/lib/principles/controllers/acknowledgement.rb +19 -4
- data/lib/principles/controllers/acknowledgements.rb +43 -12
- data/lib/principles/controllers/after_commit_report.rb +15 -2
- data/lib/principles/controllers/assessment.rb +7 -3
- data/lib/principles/controllers/audit.rb +17 -8
- data/lib/principles/controllers/audit_completion.rb +34 -9
- data/lib/principles/controllers/carrier_edit_report.rb +40 -0
- data/lib/principles/controllers/carrier_practices.rb +26 -0
- data/lib/principles/controllers/command.rb +36 -5
- data/lib/principles/controllers/context_budget.rb +61 -0
- data/lib/principles/controllers/correction.rb +15 -5
- data/lib/principles/controllers/full_audit_request.rb +38 -42
- data/lib/principles/controllers/inventory.rb +78 -71
- data/lib/principles/controllers/last_record_notice_beside.rb +51 -0
- data/lib/principles/controllers/member_addition.rb +20 -5
- data/lib/principles/controllers/member_entries.rb +50 -39
- data/lib/principles/controllers/member_entry_changes.rb +71 -0
- data/lib/principles/controllers/member_problems_report.rb +26 -6
- data/lib/principles/controllers/members_a_commit_changed.rb +14 -5
- data/lib/principles/controllers/members_in_logged_requests.rb +52 -0
- data/lib/principles/controllers/members_to_assess.rb +35 -8
- data/lib/principles/controllers/meta_principle_setup.rb +12 -4
- data/lib/principles/controllers/open_correction.rb +3 -2
- data/lib/principles/controllers/parts_to_read.rb +48 -6
- data/lib/principles/controllers/plugin_member_addition.rb +48 -0
- data/lib/principles/controllers/principle_listing.rb +84 -0
- data/lib/principles/controllers/request_logging.rb +65 -0
- data/lib/principles/controllers/running_tool.rb +55 -15
- data/lib/principles/controllers/session_start_report.rb +26 -2
- data/lib/principles/data/branches_bringing_in.rb +52 -0
- data/lib/principles/data/captured_requests.rb +118 -0
- data/lib/principles/data/carrier_page_markers.rb +38 -0
- data/lib/principles/data/changes_since.rb +56 -0
- data/lib/principles/data/claude_code_home.rb +75 -0
- data/lib/principles/data/command-steps.json +139 -23
- data/lib/principles/data/decoded_leaf.rb +63 -0
- data/lib/principles/data/head_reflog.rb +13 -2
- data/lib/principles/data/kept_line.rb +39 -0
- data/lib/principles/data/known_marketplaces.rb +50 -0
- data/lib/principles/data/logged_request_matches.rb +144 -0
- data/lib/principles/data/logged_request_scan.rb +188 -0
- data/lib/principles/data/map_files.rb +18 -4
- data/lib/principles/data/plugin_folder.rb +85 -0
- data/lib/principles/data/plugin_registry.rb +73 -0
- data/lib/principles/data/principles_store.rb +49 -0
- data/lib/principles/data/project_files.rb +15 -0
- data/lib/principles/data/ran.rb +25 -0
- data/lib/principles/data/raw_request_filter.rb +61 -0
- data/lib/principles/data/repository.rb +29 -27
- data/lib/principles/data/request_logging_folder.rb +135 -0
- data/lib/principles/data/request_shape.rb +33 -0
- data/lib/principles/data/running_version.rb +1 -1
- data/lib/principles/data/schemas/acknowledgement-answer.schema.json +16 -1
- data/lib/principles/data/schemas/acknowledgements-answer.schema.json +16 -1
- data/lib/principles/data/schemas/assessment-answer.schema.json +8 -0
- data/lib/principles/data/schemas/command-steps.schema.json +1 -1
- data/lib/principles/data/schemas/correction-answer-guide.schema.json +2 -1
- data/lib/principles/data/schemas/correction-answer.schema.json +14 -0
- data/lib/principles/data/schemas/member-map.schema.json +12 -1
- data/lib/principles/data/settings_env_keys.rb +26 -0
- data/lib/principles/data/string_counts.rb +39 -0
- data/lib/principles/data/tools_on_path.rb +25 -0
- data/lib/principles/data/user_request_logging_folder.rb +73 -0
- data/lib/principles/invocation_options.rb +5 -3
- data/lib/principles/launch.rb +29 -10
- data/lib/principles/models/acknowledged_check.rb +11 -1
- data/lib/principles/models/acknowledgement.rb +5 -0
- data/lib/principles/models/acknowledgement_refusal.rb +20 -11
- data/lib/principles/models/acknowledgements_to_offer.rb +86 -0
- data/lib/principles/models/after_commit_input.rb +5 -0
- data/lib/principles/models/answer_fields.rb +3 -0
- data/lib/principles/models/assessment_basis.rb +10 -3
- data/lib/principles/models/audit.rb +10 -10
- data/lib/principles/models/audit_record.rb +10 -0
- data/lib/principles/models/audit_records.rb +4 -3
- data/lib/principles/models/audit_start.rb +9 -0
- data/lib/principles/models/authored_locator.rb +33 -0
- data/lib/principles/models/candidate_files.rb +23 -3
- data/lib/principles/models/candidate_outline.rb +18 -125
- data/lib/principles/models/captured_sessions.rb +166 -0
- data/lib/principles/models/carrier_edit_input.rb +56 -0
- data/lib/principles/models/carrier_kind.rb +79 -0
- data/lib/principles/models/carrier_pages_shown.rb +28 -0
- data/lib/principles/models/carved_message_bytes.rb +115 -0
- data/lib/principles/models/cited_files.rb +12 -3
- data/lib/principles/models/context_parts.rb +59 -0
- data/lib/principles/models/decided_prior_findings.rb +5 -0
- data/lib/principles/models/declared_map_changes.rb +22 -13
- data/lib/principles/models/disposition.rb +37 -6
- data/lib/principles/models/disposition_placeholders.rb +12 -0
- data/lib/principles/models/disposition_text_field.rb +4 -0
- data/lib/principles/models/dropped_thinking.rb +73 -0
- data/lib/principles/models/feature.rb +54 -0
- data/lib/principles/models/finding_outcomes.rb +55 -0
- data/lib/principles/models/findings_left_open.rb +9 -11
- data/lib/principles/models/head_moves.rb +27 -10
- data/lib/principles/models/installed_component.rb +55 -0
- data/lib/principles/models/installed_plugins.rb +174 -0
- data/lib/principles/models/kept_sessions.rb +34 -0
- data/lib/principles/models/locator.rb +8 -0
- data/lib/principles/models/logged_request_reach.rb +52 -0
- data/lib/principles/models/logged_request_scan_completeness.rb +43 -0
- data/lib/principles/models/map_format_raise.rb +28 -0
- data/lib/principles/models/mapped_baseline.rb +46 -0
- data/lib/principles/models/mapped_principles.rb +2 -1
- data/lib/principles/models/maps_holding_file_whole.rb +42 -0
- data/lib/principles/models/markdown_text.rb +143 -0
- data/lib/principles/models/member.rb +19 -1
- data/lib/principles/models/member_entry.rb +56 -0
- data/lib/principles/models/member_justification.rb +52 -0
- data/lib/principles/models/member_lines.rb +11 -0
- data/lib/principles/models/member_loads.rb +17 -2
- data/lib/principles/models/member_problems.rb +46 -42
- data/lib/principles/models/member_reach.rb +59 -0
- data/lib/principles/models/member_snapshots.rb +34 -4
- data/lib/principles/models/member_text_as_sent.rb +31 -0
- data/lib/principles/models/member_texts.rb +45 -0
- data/lib/principles/models/members_by_part.rb +67 -0
- data/lib/principles/models/members_in_logged_requests.rb +279 -0
- data/lib/principles/models/meta_principle.rb +4 -4
- data/lib/principles/models/missing_files.rb +41 -16
- data/lib/principles/models/nearly_matching_maps.rb +56 -0
- data/lib/principles/models/open_correction.rb +5 -0
- data/lib/principles/models/open_finding.rb +4 -3
- data/lib/principles/models/outline_budget.rb +10 -1
- data/lib/principles/models/outline_item.rb +25 -0
- data/lib/principles/models/outline_section.rb +15 -4
- data/lib/principles/models/part_named.rb +16 -2
- data/lib/principles/models/part_token_estimates.rb +60 -0
- data/lib/principles/models/plugin_component.rb +37 -0
- data/lib/principles/models/plugin_enabled_in_project_settings.rb +61 -0
- data/lib/principles/models/plugin_install.rb +33 -0
- data/lib/principles/models/plugin_name.rb +23 -0
- data/lib/principles/models/plugin_reference.rb +53 -0
- data/lib/principles/models/principle.rb +7 -4
- data/lib/principles/models/principle_members.rb +22 -0
- data/lib/principles/models/prior_finding_decision.rb +1 -1
- data/lib/principles/models/prior_finding_outcomes.rb +12 -1
- data/lib/principles/models/problem_report.rb +14 -25
- data/lib/principles/models/project.rb +51 -56
- data/lib/principles/models/project_harness.rb +48 -0
- data/lib/principles/models/project_history.rb +19 -5
- data/lib/principles/models/recorded_members.rb +7 -0
- data/lib/principles/models/report_hooks.rb +9 -4
- data/lib/principles/models/request_channel.rb +62 -0
- data/lib/principles/models/request_kind.rb +62 -0
- data/lib/principles/models/request_logging.rb +231 -0
- data/lib/principles/models/request_logging_guard.rb +84 -0
- data/lib/principles/models/request_time.rb +46 -0
- data/lib/principles/models/runs_from.rb +0 -5
- data/lib/principles/models/script_comments.rb +58 -0
- data/lib/principles/models/session_registry.rb +61 -0
- data/lib/principles/models/session_start_input.rb +11 -2
- data/lib/principles/models/session_trend.rb +36 -0
- data/lib/principles/models/stale_request.rb +9 -0
- data/lib/principles/models/turn_opening.rb +83 -0
- data/lib/principles/models/turn_position.rb +43 -0
- data/lib/principles/models/unfixed_part.rb +82 -0
- data/lib/principles/models/unresolved_plugin_members.rb +35 -0
- data/lib/principles/models/user_logged_requests.rb +90 -0
- data/lib/principles/models/user_settings_entries.rb +49 -0
- data/lib/principles/models/whole_file_member_read.rb +48 -0
- data/lib/principles/models/without_prose.rb +20 -0
- data/lib/principles/models/workflow_jobs.rb +92 -0
- data/lib/principles/show_members_in_logged_requests_options.rb +27 -0
- data/lib/principles/show_principle_options.rb +32 -0
- data/lib/principles/version.rb +2 -2
- data/lib/principles/views/acknowledged_result.rb +31 -12
- data/lib/principles/views/acknowledgement_result.rb +18 -13
- data/lib/principles/views/acknowledgement_template_alone.rb +55 -0
- data/lib/principles/views/acknowledgements_offered.rb +54 -0
- data/lib/principles/views/added_member.rb +22 -6
- data/lib/principles/views/answer_in_a_file.rb +15 -15
- data/lib/principles/views/assessed_members.rb +19 -8
- data/lib/principles/views/assessment_request.rb +14 -6
- data/lib/principles/views/audit_changes.rb +14 -8
- data/lib/principles/views/audit_findings.rb +34 -0
- data/lib/principles/views/audit_result.rb +26 -24
- data/lib/principles/views/candidate_files_result.rb +1 -1
- data/lib/principles/views/carrier_checks.rb +40 -0
- data/lib/principles/views/carrier_edit_denial.rb +36 -0
- data/lib/principles/views/carrier_practices_page.rb +49 -0
- data/lib/principles/views/completed_audit_findings.rb +33 -0
- data/lib/principles/views/completed_audit_next_step.rb +12 -4
- data/lib/principles/views/consecutive_sections_elsewhere.rb +4 -0
- data/lib/principles/views/context_budget_result.rb +99 -0
- data/lib/principles/views/context_parts.rb +129 -25
- data/lib/principles/views/correction_request.rb +32 -17
- data/lib/principles/views/disposition_template.rb +35 -0
- data/lib/principles/views/first_audit.rb +29 -15
- data/lib/principles/views/first_audit_line.rb +4 -5
- data/lib/principles/views/hook_setup_result.rb +3 -1
- data/lib/principles/views/invocation.rb +14 -5
- data/lib/principles/views/last_record_notice.rb +41 -0
- data/lib/principles/views/lines_shared_with_member.rb +16 -22
- data/lib/principles/views/logged_request_status_meanings.rb +29 -0
- data/lib/principles/views/logged_requests_evidence.rb +84 -0
- data/lib/principles/views/map_added_to.rb +14 -12
- data/lib/principles/views/map_format_raised.rb +28 -0
- data/lib/principles/views/map_result.rb +41 -18
- data/lib/principles/views/maps_needing_members_or_audit.rb +1 -1
- data/lib/principles/views/member_change_since_baseline.rb +4 -0
- data/lib/principles/views/member_row.rb +13 -4
- data/lib/principles/views/member_sets_overlap.rb +31 -0
- data/lib/principles/views/members_a_commit_changed.rb +42 -25
- data/lib/principles/views/members_changed_during_audit.rb +27 -0
- data/lib/principles/views/members_in_logged_requests_result.rb +123 -0
- data/lib/principles/views/members_too_short_to_scan.rb +45 -0
- data/lib/principles/views/members_with_no_baseline.rb +6 -6
- data/lib/principles/views/meta_principle_result.rb +52 -15
- data/lib/principles/views/open_findings_line.rb +31 -92
- data/lib/principles/views/parts_index_result.rb +9 -5
- data/lib/principles/views/principle_read_result.rb +52 -11
- data/lib/principles/views/prior_findings_result.rb +9 -1
- data/lib/principles/views/problem_facts.rb +5 -3
- data/lib/principles/views/problem_lines.rb +54 -6
- data/lib/principles/views/problem_result.rb +7 -15
- data/lib/principles/views/prompts/assess-every-member/ask-whether-a-member-seen-only-as-read-is-loaded.md +3 -0
- data/lib/principles/views/prompts/assess-every-member/ask-whether-each-reason-holds.md +2 -0
- data/lib/principles/views/prompts/assess-every-member/claim-an-earlier-first-raised-at.md +6 -6
- data/lib/principles/views/prompts/assess-every-member/judge-the-keeping-against-the-other-principles.md +2 -0
- data/lib/principles/views/prompts/assess-every-member/read-a-compact-carried-member.md +9 -8
- data/lib/principles/views/prompts/assess-every-member/read-a-flagged-member-s-text-whole.md +3 -0
- data/lib/principles/views/prompts/assess-every-member/read-a-judged-member-s-text-whole.md +3 -0
- data/lib/principles/views/prompts/assess-every-member/turn-on-request-logging-to-see-what-reaches-context.md +2 -0
- data/lib/principles/views/prompts/assess-every-member/weigh-what-reached-the-context.md +7 -0
- data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +1 -0
- data/lib/principles/views/prompts/dispose-of-each-finding/fix-or-record-each-finding.md +6 -1
- data/lib/principles/views/prompts/dispose-of-each-finding/read-the-carrier-page-before-fixing.md +1 -0
- data/lib/principles/views/prompts/edit-a-carrier/read-the-page-before-the-first-edit.md +2 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/read-a-cut-section-back.md +1 -1
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-hook-configuration.md +41 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-hook-scripts.md +35 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-instruction-files.md +37 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-other-text-an-agent-reads.md +38 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-rule-files.md +34 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-skills.md +35 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-subagent-definitions.md +35 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/add-member.md +49 -51
- data/lib/principles/views/prompts/learn-what-a-command-does/change-member-name.md +12 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/change-member-reason.md +12 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/change-member-role.md +2 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/every-command-and-how-they-chain.md +1 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +1 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +32 -32
- data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +10 -11
- data/lib/principles/views/prompts/learn-what-a-command-does/move-member.md +7 -6
- data/lib/principles/views/prompts/learn-what-a-command-does/remove-logged-requests.md +22 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/remove-member.md +2 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/report-at-session-start.md +8 -4
- data/lib/principles/views/prompts/learn-what-a-command-does/report-before-carrier-edit.md +13 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-audit.md +7 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-candidate-outlines.md +8 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/show-carrier-practices.md +13 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-context-budget.md +69 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-hook-setup.md +4 -4
- data/lib/principles/views/prompts/learn-what-a-command-does/show-logged-requests.md +22 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-members-in-logged-requests.md +62 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-meta-principle-passage.md +13 -10
- data/lib/principles/views/prompts/learn-what-a-command-does/show-principle.md +16 -16
- data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +27 -27
- data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +17 -17
- data/lib/principles/views/prompts/learn-what-a-command-does/turn-off-request-logging.md +18 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/turn-on-request-logging.md +44 -0
- data/lib/principles/views/prompts/read-requested-outlines/continue-the-survey.md +3 -2
- data/lib/principles/views/prompts/read-what-reached-the-context/explain-request-logging-to-the-user.md +11 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/explain-user-request-logging-to-the-user.md +10 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/see-whether-members-reach-the-agent.md +2 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-a-thread-continuation-holds.md +3 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-absent-means.md +2 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-each-context-budget-line-says.md +4 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-each-member-line-says.md +2 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-not-a-carrier-means.md +2 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-present-but-not-loaded-means.md +2 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-present-means.md +1 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-unmeasurable-means.md +2 -0
- data/lib/principles/views/prompts/report-after-a-commit/a-row-ending-audit-asks-to-acknowledge-or-audit-again.md +1 -0
- data/lib/principles/views/prompts/report-after-a-commit/a-row-ending-mapping-commit-asks-for-an-audit.md +1 -0
- data/lib/principles/views/prompts/report-after-a-commit/a-row-ending-pinned-asks-for-an-audit.md +1 -0
- data/lib/principles/views/prompts/report-after-a-commit/plugin-members-are-still-listed.md +1 -0
- data/lib/principles/views/prompts/report-after-a-commit/the-commits-changed-these-members-waiting-on-an-upgrade.md +2 -2
- data/lib/principles/views/prompts/report-after-a-commit/the-commits-changed-these-members.md +2 -2
- data/lib/principles/views/prompts/report-after-a-commit/this-command-shows-what-each-needs-before-the-next-commit.md +1 -0
- data/lib/principles/views/prompts/run-a-first-audit-in-the-background/follow-the-brief.md +1 -0
- data/lib/principles/views/prompts/set-principles-up/ask-to-set-principles-up-after-an-audit.md +1 -0
- data/lib/principles/views/prompts/set-principles-up/entry-file-passage.md +1 -1
- data/lib/principles/views/prompts/set-principles-up/map-the-enabling-line-at-no-edit.md +3 -0
- data/lib/principles/views/prompts/set-principles-up/name-the-step-each-member-lacks.md +2 -2
- data/lib/principles/views/prompts/set-principles-up/place-the-passage-with-the-user.md +4 -2
- data/lib/principles/views/prompts/set-principles-up/what-the-passage-presumes.md +1 -1
- data/lib/principles/views/prompts/set-principles-up/why-set-principles-up.md +1 -0
- data/lib/principles/views/prompts/start-a-session/act-on-the-open-findings.md +2 -1
- data/lib/principles/views/prompts/start-a-session/ask-to-set-principles-up.md +2 -0
- data/lib/principles/views/prompts/start-a-session/hand-the-first-audit-to-a-subagent.md +2 -3
- data/lib/principles/views/prompts/start-a-session/name-the-principles-nothing-checks.md +1 -0
- data/lib/principles/views/prompts/start-a-session/raise-the-open-findings-waiting-on-no-one.md +1 -0
- data/lib/principles/views/request_logging_result.rb +108 -0
- data/lib/principles/views/request_part.rb +10 -4
- data/lib/principles/views/request_parts.rb +9 -0
- data/lib/principles/views/set_up_offer_line.rb +43 -0
- data/lib/principles/views/whole_file_elsewhere.rb +30 -0
- metadata +154 -5
- data/lib/principles/views/prompts/report-after-a-commit/the-principles-skill-is-where-to-start.md +0 -1
- data/lib/principles/views/prompts/report-after-a-commit/this-command-shows-each-one.md +0 -1
- data/lib/principles/views/prompts/set-principles-up/keep-them-held-between-audits.md +0 -2
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "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
|
+
# Which local branches would bring paths into the project if they merged, as git reports it for Repository: each
|
|
10
|
+
# path that a branch's commits not on HEAD add or change, and do not then delete, with paths relative to the
|
|
11
|
+
# project. One git log reads only those commits, limited to the paths, so a project with many branches pays only
|
|
12
|
+
# for commits no merge has brought in yet. git names each commit by one branch that reaches it, so of branches
|
|
13
|
+
# sharing the commit that brings a path in, one is named.
|
|
14
|
+
class BranchesBringingIn
|
|
15
|
+
# What starts each commit's record in the log: the branch git reached it by.
|
|
16
|
+
RECORD = "\x01"
|
|
17
|
+
|
|
18
|
+
#: (GitCommand) -> void
|
|
19
|
+
def initialize(git)
|
|
20
|
+
@git = git
|
|
21
|
+
freeze
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Each of paths a branch brings in, with the branches that do, sorted; none outside git, or for no paths.
|
|
25
|
+
#: (Array[String]) -> Hash[String, Array[String]]
|
|
26
|
+
def of(paths)
|
|
27
|
+
return {} if paths.empty?
|
|
28
|
+
|
|
29
|
+
output, ok = @git.run(["log", "--branches", "--not", "HEAD", "--source", "--no-renames", "--name-status",
|
|
30
|
+
"--relative", "-z", "--format=%x01%S", "--", *paths])
|
|
31
|
+
return {} unless ok
|
|
32
|
+
|
|
33
|
+
newest(output.force_encoding("UTF-8")).reject { |_, status| status == "D" }.keys
|
|
34
|
+
.group_by(&:last).transform_values { it.map(&:first).sort }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
# Each branch and path the log names, with the status of the newest commit of that branch to change the path:
|
|
40
|
+
# the log lists commits newest first, each its branch, then each status and path.
|
|
41
|
+
#: (String) -> Hash[[String, String], String]
|
|
42
|
+
def newest(log)
|
|
43
|
+
found = {} #: Hash[[String, String], String]
|
|
44
|
+
log.split(RECORD).drop(1).each do |record|
|
|
45
|
+
branch, *fields = record.split("\0")
|
|
46
|
+
fields.each_slice(2) { |status, path| found[[branch.to_s, path.to_s]] ||= status.to_s.strip }
|
|
47
|
+
end
|
|
48
|
+
found
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "logged_request_scan"
|
|
5
|
+
require "json"
|
|
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 folder the host writes each request it sends to, at the path an OTEL_LOG_RAW_API_BODIES file: entry names:
|
|
11
|
+
# each request and response file, and its index, one line per response naming the session and both files.
|
|
12
|
+
class CapturedRequests
|
|
13
|
+
INDEX = "index.jsonl"
|
|
14
|
+
|
|
15
|
+
# A file the host wrote under requests/: its name there, its size and when it was last written.
|
|
16
|
+
class CapturedFile
|
|
17
|
+
#: String
|
|
18
|
+
attr_reader :name
|
|
19
|
+
#: Integer
|
|
20
|
+
attr_reader :bytes
|
|
21
|
+
#: Time
|
|
22
|
+
attr_reader :modified_at
|
|
23
|
+
|
|
24
|
+
#: (name: String, bytes: Integer, modified_at: Time) -> void
|
|
25
|
+
def initialize(name:, bytes:, modified_at:)
|
|
26
|
+
@name = name
|
|
27
|
+
@bytes = bytes
|
|
28
|
+
@modified_at = modified_at
|
|
29
|
+
freeze
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# One line of the host's index: the session, when, and the paths of the request and response files it names.
|
|
34
|
+
class IndexLine
|
|
35
|
+
#: String
|
|
36
|
+
attr_reader :session_id, :timestamp, :request_file, :response_file
|
|
37
|
+
|
|
38
|
+
#: (Hash[String, String]) -> void
|
|
39
|
+
def initialize(fields)
|
|
40
|
+
@session_id = fields.fetch("session_id") #: String
|
|
41
|
+
@timestamp = fields.fetch("timestamp") #: String
|
|
42
|
+
@request_file = fields.fetch("request_file") #: String
|
|
43
|
+
@response_file = fields.fetch("response_file") #: String
|
|
44
|
+
freeze
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# shown_as is the folder as a result names it: relative to the project for its own folder, absolute elsewhere.
|
|
49
|
+
#: (String, ?shown_as: String) -> void
|
|
50
|
+
def initialize(path, shown_as: path)
|
|
51
|
+
@path = path
|
|
52
|
+
@shown_as = shown_as
|
|
53
|
+
freeze
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# A file here, by its name, as a result names it.
|
|
57
|
+
#: (String) -> String
|
|
58
|
+
def shown(name) = "#{@shown_as}/#{name}"
|
|
59
|
+
|
|
60
|
+
# Every file the host wrote under requests/, but its index, sorted by name.
|
|
61
|
+
#: () -> Array[CapturedFile]
|
|
62
|
+
def captured_files
|
|
63
|
+
(Dir.exist?(@path) ? Dir.children(@path).sort : []).filter_map do |name|
|
|
64
|
+
path = File.join(@path, name)
|
|
65
|
+
next if name == INDEX || !File.file?(path)
|
|
66
|
+
|
|
67
|
+
stat = File.stat(path)
|
|
68
|
+
CapturedFile.new(name: name, bytes: stat.size, modified_at: stat.mtime.utc)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Each line of the host's index, leaving out a line that is not a JSON object naming a session and its files.
|
|
73
|
+
#: () -> Array[IndexLine]
|
|
74
|
+
def index_lines
|
|
75
|
+
path = File.join(@path, INDEX)
|
|
76
|
+
File.file?(path) ? IndexLines.new(File.read(path)).lines : []
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Removes one file the host wrote directly under requests/, refusing any other name, an index line's included,
|
|
80
|
+
# so a line naming a path elsewhere or the index itself cannot reach it.
|
|
81
|
+
#: (String) -> void
|
|
82
|
+
def remove_request(name)
|
|
83
|
+
unless name.match?(%r{\A[^/]+\z}) && !%w[. ..].include?(name) && name != INDEX
|
|
84
|
+
raise ArgumentError, "not a captured file under requests/: #{name.inspect}"
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
File.delete(File.join(@path, name))
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# The requests the host captured here, scanned by jq and rg: those only names, by name, when given.
|
|
91
|
+
#: (?only: Array[String]?) -> LoggedRequestScan
|
|
92
|
+
def scan(only: nil) = LoggedRequestScan.new(@path, only: only)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# The host's index text read as lines, shared by the folder and its stand-in.
|
|
96
|
+
class IndexLines
|
|
97
|
+
FIELDS = %w[session_id timestamp request_file response_file].freeze #: Array[String]
|
|
98
|
+
|
|
99
|
+
#: (String) -> void
|
|
100
|
+
def initialize(text)
|
|
101
|
+
@text = text
|
|
102
|
+
freeze
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
#: () -> Array[CapturedRequests::IndexLine]
|
|
106
|
+
def lines
|
|
107
|
+
@text.each_line.filter_map do |line|
|
|
108
|
+
fields = JSON.parse(line)
|
|
109
|
+
next unless fields.is_a?(Hash) && FIELDS.all? { |field| fields[field].is_a?(String) }
|
|
110
|
+
|
|
111
|
+
CapturedRequests::IndexLine.new(fields)
|
|
112
|
+
rescue JSON::ParserError
|
|
113
|
+
nil
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "fileutils"
|
|
5
|
+
|
|
6
|
+
module Principles
|
|
7
|
+
# Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
|
|
8
|
+
module Data
|
|
9
|
+
# The empty marker files, in this machine's temporary folder, that say which carrier kinds' practices pages a
|
|
10
|
+
# session was pointed at before its first edit of that kind: a folder per session, a file per kind. They live
|
|
11
|
+
# outside every project, since they are a session's state, not the project's, and go when the folder is cleared.
|
|
12
|
+
class CarrierPageMarkers
|
|
13
|
+
# The folder under the temporary folder that holds every session's markers.
|
|
14
|
+
FOLDER = "principles-carrier-pages"
|
|
15
|
+
|
|
16
|
+
#: (String) -> void
|
|
17
|
+
def initialize(temp_directory)
|
|
18
|
+
@root = File.join(temp_directory, FOLDER) #: String
|
|
19
|
+
freeze
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Whether session's marker for kind is there.
|
|
23
|
+
#: (String, String) -> bool
|
|
24
|
+
def marked?(session, kind) = File.exist?(File.join(@root, session, kind))
|
|
25
|
+
|
|
26
|
+
# Leaves session's marker for kind, saying whether it could; a folder that cannot be written leaves none.
|
|
27
|
+
#: (String, String) -> bool
|
|
28
|
+
def mark(session, kind)
|
|
29
|
+
folder = File.join(@root, session)
|
|
30
|
+
FileUtils.mkdir_p(folder)
|
|
31
|
+
File.write(File.join(folder, kind), "")
|
|
32
|
+
true
|
|
33
|
+
rescue SystemCallError
|
|
34
|
+
false
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
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 changed in the project after a commit, as git reports it for Repository, with paths relative to the
|
|
10
|
+
# project: the paths the commits up to HEAD changed, the commits that changed some paths, and the renames git
|
|
11
|
+
# detects up to the working tree. Each commit is a revision Repository has checked, so git cannot read it as an
|
|
12
|
+
# option.
|
|
13
|
+
class ChangesSince
|
|
14
|
+
#: (GitCommand) -> void
|
|
15
|
+
def initialize(git)
|
|
16
|
+
@git = git
|
|
17
|
+
freeze
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Each rename git detects between commit and the working tree, as {"from", "to", "similarity"}; none outside
|
|
21
|
+
# git or when commit is not there, as in a shallow clone.
|
|
22
|
+
#: (String) -> Array[Hash[String, untyped]]
|
|
23
|
+
def renames(commit)
|
|
24
|
+
output, ok = @git.run(["diff", "-M", "-z", "--name-status", "--relative", "--diff-filter=R", commit, "--"])
|
|
25
|
+
return [] unless ok
|
|
26
|
+
|
|
27
|
+
output.force_encoding("UTF-8").split("\0").each_slice(3).filter_map do |status, from, to|
|
|
28
|
+
next unless status.to_s.start_with?("R") && from && to
|
|
29
|
+
|
|
30
|
+
{ "from" => from, "to" => to, "similarity" => status.to_s.delete_prefix("R").to_i }
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Each path the commits after commit changed, up to HEAD, sorted: added, edited or deleted, and a rename by both
|
|
35
|
+
# its names, since git is asked to detect none.
|
|
36
|
+
#: (String) -> Array[String]
|
|
37
|
+
def paths(commit)
|
|
38
|
+
output, ok = @git.run(["diff", "--name-only", "-z", "--relative", "--no-renames", commit, "HEAD", "--"])
|
|
39
|
+
ok ? output.force_encoding("UTF-8").split("\0").sort : []
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# The commits after commit, up to HEAD, that changed any of paths, newest first, each as its short sha and
|
|
43
|
+
# subject line.
|
|
44
|
+
#: (String, Array[String]) -> Array[Hash[String, String]]
|
|
45
|
+
def commits(commit, paths)
|
|
46
|
+
output, ok = @git.run(["log", "--format=%h%x00%s", "--end-of-options", "#{commit}..HEAD", "--", *paths])
|
|
47
|
+
return [] unless ok
|
|
48
|
+
|
|
49
|
+
output.force_encoding("UTF-8").lines.map do |line|
|
|
50
|
+
sha, subject = line.chomp.split("\0", 2)
|
|
51
|
+
{ "commit" => sha.to_s, "subject" => subject.to_s }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "bounded_file"
|
|
5
|
+
require_relative "plugin_registry"
|
|
6
|
+
require_relative "known_marketplaces"
|
|
7
|
+
require_relative "plugin_folder"
|
|
8
|
+
require_relative "settings_env_keys"
|
|
9
|
+
|
|
10
|
+
module Principles
|
|
11
|
+
# Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
|
|
12
|
+
module Data
|
|
13
|
+
# Claude Code's config folder on this machine, where it records the plugins it installed. This tool only reads it,
|
|
14
|
+
# and never runs, installs or fetches a plugin.
|
|
15
|
+
class ClaudeCodeHome
|
|
16
|
+
# The folder Claude Code reads: CLAUDE_CONFIG_DIR when set, or else .claude in the home directory.
|
|
17
|
+
#: (?Hash[String, String], ?home: String) -> ClaudeCodeHome
|
|
18
|
+
def self.from_environment(environment = ENV.to_h, home: Dir.home)
|
|
19
|
+
new(environment["CLAUDE_CONFIG_DIR"] || File.join(home, ".claude"))
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
#: String
|
|
23
|
+
attr_reader :directory
|
|
24
|
+
|
|
25
|
+
#: (String) -> void
|
|
26
|
+
def initialize(directory)
|
|
27
|
+
@directory = directory
|
|
28
|
+
freeze
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# The registry of installed plugins, or nil while the host has installed none.
|
|
32
|
+
#: () -> PluginRegistry?
|
|
33
|
+
def registry
|
|
34
|
+
text = read("installed_plugins.json", "Claude Code's plugin registry")
|
|
35
|
+
PluginRegistry.new(text) if text
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# The marketplaces the host knows, or nil while it records none.
|
|
39
|
+
#: () -> KnownMarketplaces?
|
|
40
|
+
def marketplaces
|
|
41
|
+
text = read("known_marketplaces.json", "Claude Code's record of its plugin marketplaces")
|
|
42
|
+
KnownMarketplaces.new(text) if text
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# The user's own settings file, which this tool never writes.
|
|
46
|
+
#: () -> String
|
|
47
|
+
def settings_file = File.join(@directory, "settings.json")
|
|
48
|
+
|
|
49
|
+
# The names of the env entries the user's settings set, as SettingsEnvKeys reads them: none while there is no
|
|
50
|
+
# settings file, and nil when it cannot be read.
|
|
51
|
+
#: () -> Array[String]?
|
|
52
|
+
def settings_env_keys
|
|
53
|
+
path = settings_file
|
|
54
|
+
return [] unless File.exist?(path)
|
|
55
|
+
|
|
56
|
+
SettingsEnvKeys.of(BoundedFile.new(path, named: "Claude Code's user settings").read_text)
|
|
57
|
+
rescue Error, SystemCallError
|
|
58
|
+
nil
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# The folder the host installed a plugin's copy in, at the path its registry gives.
|
|
62
|
+
#: (String) -> PluginFolder
|
|
63
|
+
def plugin_folder(path) = PluginFolder.new(path)
|
|
64
|
+
|
|
65
|
+
private
|
|
66
|
+
|
|
67
|
+
# The text of a file in the host's plugins folder, or nil when it is absent.
|
|
68
|
+
#: (String, String) -> String?
|
|
69
|
+
def read(name, named)
|
|
70
|
+
path = File.join(@directory, "plugins", name)
|
|
71
|
+
BoundedFile.new(path, named: named).read_text if File.exist?(path)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|