principles 0.1.3 → 0.1.4
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 +120 -0
- data/README.md +10 -6
- data/lib/principles/command_line.rb +15 -6
- data/lib/principles/command_routes.rb +11 -1
- 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_practices.rb +26 -0
- data/lib/principles/controllers/command.rb +29 -2
- data/lib/principles/controllers/correction.rb +15 -5
- data/lib/principles/controllers/full_audit_request.rb +38 -42
- data/lib/principles/controllers/inventory.rb +77 -71
- data/lib/principles/controllers/last_record_notice_beside.rb +51 -0
- data/lib/principles/controllers/member_addition.rb +19 -4
- data/lib/principles/controllers/member_entries.rb +25 -6
- 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 +24 -7
- data/lib/principles/controllers/meta_principle_setup.rb +2 -2
- data/lib/principles/controllers/open_correction.rb +3 -2
- data/lib/principles/controllers/parts_to_read.rb +46 -5
- 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 +52 -0
- data/lib/principles/controllers/running_tool.rb +39 -13
- data/lib/principles/data/branches_bringing_in.rb +52 -0
- data/lib/principles/data/changes_since.rb +56 -0
- data/lib/principles/data/claude_code_home.rb +58 -0
- data/lib/principles/data/command-steps.json +91 -15
- 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 +32 -0
- data/lib/principles/data/known_marketplaces.rb +50 -0
- data/lib/principles/data/logged_request_matches.rb +138 -0
- data/lib/principles/data/logged_request_scan.rb +120 -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/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 +167 -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 +10 -1
- data/lib/principles/data/string_counts.rb +39 -0
- data/lib/principles/data/tools_on_path.rb +25 -0
- data/lib/principles/invocation_options.rb +4 -2
- data/lib/principles/launch.rb +14 -4
- 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 +128 -0
- data/lib/principles/models/carrier_kind.rb +79 -0
- data/lib/principles/models/cited_files.rb +12 -3
- data/lib/principles/models/decided_prior_findings.rb +5 -0
- 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/feature.rb +53 -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 +44 -0
- data/lib/principles/models/logged_request_scan_completeness.rb +43 -0
- data/lib/principles/models/mapped_baseline.rb +46 -0
- 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 +14 -1
- data/lib/principles/models/member_entry.rb +56 -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 +45 -42
- data/lib/principles/models/member_reach.rb +36 -0
- data/lib/principles/models/member_snapshots.rb +23 -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_in_logged_requests.rb +240 -0
- 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/plugin_component.rb +37 -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_members.rb +15 -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 +35 -29
- data/lib/principles/models/project_history.rb +19 -5
- data/lib/principles/models/recorded_members.rb +7 -0
- data/lib/principles/models/request_logging.rb +196 -0
- data/lib/principles/models/runs_from.rb +0 -5
- data/lib/principles/models/script_comments.rb +58 -0
- data/lib/principles/models/stale_request.rb +9 -0
- data/lib/principles/models/unfixed_part.rb +82 -0
- data/lib/principles/models/unresolved_plugin_members.rb +35 -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 +18 -7
- data/lib/principles/views/assessment_request.rb +8 -3
- 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 +14 -19
- data/lib/principles/views/carrier_checks.rb +40 -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_parts.rb +129 -25
- data/lib/principles/views/correction_request.rb +21 -16
- 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/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 +69 -0
- data/lib/principles/views/map_added_to.rb +14 -12
- data/lib/principles/views/map_result.rb +39 -17
- 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 +68 -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 +14 -2
- 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 +32 -6
- data/lib/principles/views/problem_result.rb +7 -15
- 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/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 +5 -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 +50 -51
- 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/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 +16 -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 +2 -2
- 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-logged-requests.md +20 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-members-in-logged-requests.md +48 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-principle.md +14 -14
- 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 +10 -10
- data/lib/principles/views/prompts/learn-what-a-command-does/turn-off-request-logging.md +10 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/turn-on-request-logging.md +32 -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/see-whether-members-reach-the-agent.md +2 -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-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/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/set-principles-up/entry-file-passage.md +1 -1
- data/lib/principles/views/prompts/start-a-session/act-on-the-open-findings.md +2 -1
- 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/raise-the-open-findings-waiting-on-no-one.md +1 -0
- data/lib/principles/views/request_logging_result.rb +62 -0
- data/lib/principles/views/request_part.rb +10 -4
- data/lib/principles/views/request_parts.rb +9 -0
- data/lib/principles/views/whole_file_elsewhere.rb +30 -0
- metadata +101 -4
- 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
|
@@ -7,8 +7,9 @@ module Principles
|
|
|
7
7
|
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
8
8
|
module Views
|
|
9
9
|
# One changed member as a line of tab-separated fields, each written through VisibleText: its principle, id,
|
|
10
|
-
# newest commit that changed it (or "uncommitted"), that commit's subject, and
|
|
11
|
-
# "audit" or "
|
|
10
|
+
# newest commit that changed it (or "uncommitted", or a plugin's "version:" installed), that commit's subject, and
|
|
11
|
+
# what it was compared with: "audit", "mapping_commit" or "pinned", then "waiting_on_an_upgrade" for one compared
|
|
12
|
+
# with hashes a later copy wrote.
|
|
12
13
|
# The after-commit hook prints it, and list-member-problems --short its short form, without the subject.
|
|
13
14
|
class MemberRow
|
|
14
15
|
# member is one entry of list-member-problems' "members", with its "history".
|
|
@@ -32,11 +33,19 @@ module Principles
|
|
|
32
33
|
|
|
33
34
|
private
|
|
34
35
|
|
|
35
|
-
# The principle, id and newest commit that changed the member, or "uncommitted"
|
|
36
|
+
# The principle, id and newest commit that changed the member, or "uncommitted", or for a plugin's member, which
|
|
37
|
+
# no commit changes, the version installed now.
|
|
36
38
|
#: () -> Array[String]
|
|
37
39
|
def head
|
|
38
40
|
newest = @member.fetch("history", {}).fetch("commits", []).first
|
|
39
|
-
[@member.fetch("principle"), @member.fetch("id"), newest ? newest.fetch("commit") :
|
|
41
|
+
[@member.fetch("principle"), @member.fetch("id"), newest ? newest.fetch("commit") : changed_in]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Where a member no commit changed is changed now: a plugin's version installed, or else uncommitted text.
|
|
45
|
+
#: () -> String
|
|
46
|
+
def changed_in
|
|
47
|
+
version = @member.dig("source", "version")
|
|
48
|
+
version ? "version:#{version}" : "uncommitted"
|
|
40
49
|
end
|
|
41
50
|
|
|
42
51
|
# What the member was compared with, and whether its audit waits on an upgrade.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Principles
|
|
5
|
+
module Views
|
|
6
|
+
# The other maps whose member set nearly matches the one a member just joined, which ask the agent AddedMember's
|
|
7
|
+
# scope-or-join question.
|
|
8
|
+
class MemberSetsOverlap
|
|
9
|
+
#: (?Array[Hash[String, untyped]]) -> void
|
|
10
|
+
def initialize(facts = [])
|
|
11
|
+
@facts = facts
|
|
12
|
+
freeze
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
#: () -> Hash[String, untyped]
|
|
16
|
+
def to_h = @facts.empty? ? {} : { "member_sets_overlap" => @facts }
|
|
17
|
+
|
|
18
|
+
#: () -> String
|
|
19
|
+
def note
|
|
20
|
+
return "" if @facts.empty?
|
|
21
|
+
|
|
22
|
+
"This map's member set nearly matches another's (member_sets_overlap): by member id, they share at least " \
|
|
23
|
+
"two members and at least two thirds of the members either holds. "
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Whether it asks AddedMember's scope-or-join question: when a member set nearly matches.
|
|
27
|
+
#: () -> bool
|
|
28
|
+
def asks_scope_or_join? = @facts.any?
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -14,18 +14,38 @@ module Principles
|
|
|
14
14
|
module Views
|
|
15
15
|
# list-member-problems --commits-after COMMIT --hook-event EVENT: the whole JSON the plugin's after-commit hook
|
|
16
16
|
# prints for Claude Code, which puts its additionalContext beside the Bash call's result, or nothing at all.
|
|
17
|
-
# Claude Code asks
|
|
18
|
-
#
|
|
19
|
-
#
|
|
17
|
+
# Claude Code's hooks page asks that additionalContext be "factual statements rather than imperative system
|
|
18
|
+
# instructions", since imperative text can be surfaced to the user as a suspected injection (the
|
|
19
|
+
# after-commit hook review, R7). So it states what the commits changed, then the one command that shows what
|
|
20
|
+
# each needs before the next commit: a second pointer, the plugin's skill, left the agent choosing.
|
|
20
21
|
class MembersACommitChanged
|
|
21
22
|
NOTHING = Lines.new(stdout: "", stderr: "", status: 0).freeze #: Lines
|
|
22
23
|
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
# How many other changed members list-member-problems still lists: those earlier commits changed, and those in
|
|
25
|
+
# an installed plugin, which no commit changes.
|
|
26
|
+
StillListed = Struct.new(:from_commits, :in_plugins) do
|
|
27
|
+
#: () -> bool
|
|
28
|
+
def none? = from_commits.zero? && in_plugins.zero?
|
|
29
|
+
|
|
30
|
+
# A line for each kind still listed, or none.
|
|
31
|
+
#: () -> Array[String]
|
|
32
|
+
def lines
|
|
33
|
+
commits = Prompts.text("report-after-a-commit/others-are-still-listed",
|
|
34
|
+
count: from_commits.to_s, members: members(from_commits))
|
|
35
|
+
plugins = Prompts.text("report-after-a-commit/plugin-members-are-still-listed",
|
|
36
|
+
count: in_plugins.to_s, members: members(in_plugins))
|
|
37
|
+
[*(commits unless from_commits.zero?), *(plugins unless in_plugins.zero?)]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
#: (Integer) -> String
|
|
43
|
+
def members(count) = count == 1 ? "member is" : "members are"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
#: (Invocation) -> void
|
|
47
|
+
def initialize(invocation)
|
|
27
48
|
@invocation = invocation
|
|
28
|
-
@skill = skill
|
|
29
49
|
freeze
|
|
30
50
|
end
|
|
31
51
|
|
|
@@ -33,7 +53,7 @@ module Principles
|
|
|
33
53
|
# members it still lists. Those it marks waiting_on_an_upgrade are named apart, with the waits that say why, and
|
|
34
54
|
# no audit to run; the others still listed are counted beside them too, since this copy may
|
|
35
55
|
# audit those.
|
|
36
|
-
#: (String, Array[Hash[String, untyped]], others:
|
|
56
|
+
#: (String, Array[Hash[String, untyped]], others: StillListed, ?waits: Array[RecordWaitingOnAnUpgrade]) -> Lines
|
|
37
57
|
def changed(event, changed, others:, waits: [])
|
|
38
58
|
waiting, auditable = changed.partition { |member| member["waiting_on_an_upgrade"] }
|
|
39
59
|
reported(event, [*(to_audit(auditable, others) unless auditable.empty?),
|
|
@@ -50,20 +70,26 @@ module Principles
|
|
|
50
70
|
|
|
51
71
|
private
|
|
52
72
|
|
|
53
|
-
# The members to audit, as rows, then
|
|
54
|
-
#: (Array[Hash[String, untyped]],
|
|
73
|
+
# The members to audit, as rows, then the command that shows what each needs before the next commit.
|
|
74
|
+
#: (Array[Hash[String, untyped]], StillListed) -> Array[String]
|
|
55
75
|
def to_audit(changed, others)
|
|
56
76
|
[Prompts.text("report-after-a-commit/the-commits-changed-these-members"), *rows(changed),
|
|
57
|
-
*
|
|
58
|
-
*(Prompts.text("report-after-a-commit/the-principles-skill-is-where-to-start") if @skill)]
|
|
77
|
+
*others.lines, before_the_next_commit]
|
|
59
78
|
end
|
|
60
79
|
|
|
61
80
|
# The other changed members still listed, and the command that shows each, or nothing when none is.
|
|
62
|
-
#: (
|
|
81
|
+
#: (StillListed) -> Array[String]
|
|
63
82
|
def listed_beside_the_waiting(others)
|
|
64
|
-
return [] if others.
|
|
83
|
+
return [] if others.none?
|
|
65
84
|
|
|
66
|
-
[*
|
|
85
|
+
[*others.lines, before_the_next_commit]
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# The one command that shows what each member needs before the next commit, list-member-problems --short.
|
|
89
|
+
#: () -> String
|
|
90
|
+
def before_the_next_commit
|
|
91
|
+
Prompts.text("report-after-a-commit/this-command-shows-what-each-needs-before-the-next-commit",
|
|
92
|
+
command: @invocation.in_project("list-member-problems", options: ["--short"]))
|
|
67
93
|
end
|
|
68
94
|
|
|
69
95
|
# The members whose audits wait on an upgrade, as rows, then each wait's line, which says how to update.
|
|
@@ -76,15 +102,6 @@ module Principles
|
|
|
76
102
|
#: (Array[Hash[String, untyped]]) -> Array[String]
|
|
77
103
|
def rows(members) = members.map { MemberRow.new(it).to_s }
|
|
78
104
|
|
|
79
|
-
# The line saying how many other changed members list-member-problems still lists, or none when it lists none.
|
|
80
|
-
#: (Integer) -> Array[String]
|
|
81
|
-
def still_listed(others)
|
|
82
|
-
return [] if others.zero?
|
|
83
|
-
|
|
84
|
-
[Prompts.text("report-after-a-commit/others-are-still-listed",
|
|
85
|
-
count: others.to_s, members: others == 1 ? "member is" : "members are")]
|
|
86
|
-
end
|
|
87
|
-
|
|
88
105
|
#: () -> String
|
|
89
106
|
def command = @invocation.in_project("list-member-problems")
|
|
90
107
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Principles
|
|
5
|
+
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
6
|
+
module Views
|
|
7
|
+
# The audited principle's members that changed during a completed audit, as its result names them: each member
|
|
8
|
+
# added to the map during the audit, which no assessment read, so the next full audit assesses it (T69), and
|
|
9
|
+
# each member whose text changed, after which the next step asks for the principle's audit again.
|
|
10
|
+
class MembersChangedDuringAudit
|
|
11
|
+
#: (?added: Array[String], ?changed: Array[String]) -> void
|
|
12
|
+
def initialize(added: [], changed: [])
|
|
13
|
+
@added = added
|
|
14
|
+
@changed = changed
|
|
15
|
+
freeze
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Whether any member's text changed during the audit; when none did, nothing asks for a second audit.
|
|
19
|
+
#: () -> bool
|
|
20
|
+
def any? = @changed.any?
|
|
21
|
+
|
|
22
|
+
# The fields as printed: the members added, only when there are some.
|
|
23
|
+
#: () -> Hash[String, untyped]
|
|
24
|
+
def to_h = @added.empty? ? {} : { "members_added_awaiting_assessment" => @added }
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "logged_request_status_meanings"
|
|
5
|
+
require_relative "problem_lines"
|
|
6
|
+
|
|
7
|
+
module Principles
|
|
8
|
+
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
9
|
+
module Views
|
|
10
|
+
# How many mapped members have each status, so the agent sizes what it reads before reading any member, what each
|
|
11
|
+
# status means, then which mapped members' text the captured requests held, by member, how many requests have no
|
|
12
|
+
# query_source, which requests quote a logged request's path, which the scan could not read through, how complete
|
|
13
|
+
# the scan was, and the files the scan wrote: none.
|
|
14
|
+
class MembersInLoggedRequestsResult
|
|
15
|
+
# The result from seen, the scan's report, as the request logging gives it.
|
|
16
|
+
#: ({ members_by_status: Hash[String, Integer], members: Array[Hash[String, untyped]], orphans: Integer,
|
|
17
|
+
#| quoting_requests: Array[String], unreadable: Array[Hash[String, String]],
|
|
18
|
+
#| completeness: Hash[String, untyped] }) -> Hash[String, untyped]
|
|
19
|
+
def result(seen)
|
|
20
|
+
{ "members_by_status" => seen[:members_by_status], "status_meanings" => LoggedRequestStatusMeanings.new.to_h,
|
|
21
|
+
"members" => seen[:members], "orphans" => seen[:orphans],
|
|
22
|
+
"quoting_requests" => seen[:quoting_requests], "unreadable" => seen[:unreadable],
|
|
23
|
+
"completeness" => seen[:completeness], "wrote" => [] }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# --short: the count of members with each status, with how many requests the scan read, whether it read every
|
|
27
|
+
# one through, since an absence holds only then, how many it could not read, and how many quote a logged
|
|
28
|
+
# request, where a presence may be a quote; then one tab-separated line a member: its status, principle, member
|
|
29
|
+
# key, with its id where it is now once moved, and the segments it was seen in, or - for none.
|
|
30
|
+
#: ({ members_by_status: Hash[String, Integer], members: Array[Hash[String, untyped]], orphans: Integer,
|
|
31
|
+
#| quoting_requests: Array[String], unreadable: Array[Hash[String, String]],
|
|
32
|
+
#| completeness: Hash[String, untyped] }) -> Lines
|
|
33
|
+
def short(seen)
|
|
34
|
+
lines = [counts(seen), *seen[:members].map { member_line(it) }]
|
|
35
|
+
Lines.new(stdout: lines.map { "#{it}\n" }.join, stderr: "", status: 0)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
# The counts by status, then what the scan read, as short prints it.
|
|
41
|
+
#: ({ members_by_status: Hash[String, Integer], members: Array[Hash[String, untyped]], orphans: Integer,
|
|
42
|
+
#| quoting_requests: Array[String], unreadable: Array[Hash[String, String]],
|
|
43
|
+
#| completeness: Hash[String, untyped] }) -> String
|
|
44
|
+
def counts(seen)
|
|
45
|
+
completeness = seen[:completeness]
|
|
46
|
+
whole = completeness.fetch("complete") ? "complete" : "not complete"
|
|
47
|
+
read = "#{completeness.fetch("captured")} captured, #{whole}, #{seen[:unreadable].size} unreadable, " \
|
|
48
|
+
"#{seen[:quoting_requests].size} quoting a logged request"
|
|
49
|
+
"#{seen[:members_by_status].map { |status, count| "#{status} #{count}" }.join(", ")}; #{read}"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# One member's line: status, principle, member key, with its id where it is now once moved, and the distinct
|
|
53
|
+
# segments it was seen in.
|
|
54
|
+
#: (Hash[String, untyped]) -> String
|
|
55
|
+
def member_line(member)
|
|
56
|
+
segments = member.fetch("segments")
|
|
57
|
+
[*member.values_at("status", "principle"), named(member), segments.empty? ? "-" : segments.join(",")].join("\t")
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# member's key, followed by its id once a move has left the key naming where it was.
|
|
61
|
+
#: (Hash[String, untyped]) -> String
|
|
62
|
+
def named(member)
|
|
63
|
+
key = member.fetch("member")
|
|
64
|
+
member.key?("id") ? "#{key} (now #{member.fetch("id")})" : key
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Principles
|
|
5
|
+
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
6
|
+
module Views
|
|
7
|
+
# What list-member-problems adds, while requests are logged, for each member too short to find in a logged
|
|
8
|
+
# request: it lists each under too_short_to_scan, and its next_action asks for the move that widens each, after
|
|
9
|
+
# every other action, since the member's own text is as fresh as before.
|
|
10
|
+
class MembersTooShortToScan
|
|
11
|
+
# members is each such member by its principle, id and the move-member options that widen it, placeholders
|
|
12
|
+
# left to fill; invocation names the commands.
|
|
13
|
+
#: (Invocation, Array[Hash[String, String]]) -> void
|
|
14
|
+
def initialize(invocation, members)
|
|
15
|
+
@invocation = invocation
|
|
16
|
+
@members = members
|
|
17
|
+
freeze
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# report, list-member-problems' result whose next_action names a command as names_a_command says, with these
|
|
21
|
+
# members added, and whether its next_action names a command now.
|
|
22
|
+
#: (Hash[String, untyped], bool, nothing_changed: String) -> [Hash[String, untyped], bool]
|
|
23
|
+
def added_to(report, names_a_command, nothing_changed:)
|
|
24
|
+
return [report, names_a_command] if @members.empty?
|
|
25
|
+
|
|
26
|
+
action = report.fetch("next_action")
|
|
27
|
+
earlier = action == nothing_changed ? [] : [action]
|
|
28
|
+
[report.merge("too_short_to_scan" => @members.map { it.slice("principle", "id") },
|
|
29
|
+
"next_action" => [*earlier, *@members.map { widen(it) }].join("\n")), true]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
# The line asking to widen member, with the move that does it.
|
|
35
|
+
#: (Hash[String, String]) -> String
|
|
36
|
+
def widen(member)
|
|
37
|
+
principle = member.fetch("principle")
|
|
38
|
+
id = member.fetch("id")
|
|
39
|
+
"#{id} of #{principle} has no line long enough to find in a logged request, so the scan cannot show " \
|
|
40
|
+
"whether it reached the agent; widen it to take in a longer line: " \
|
|
41
|
+
"#{@invocation.in_project("move-member", principle, id, usage: member.fetch("move"))}"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -39,18 +39,18 @@ module Principles
|
|
|
39
39
|
#: () -> bool
|
|
40
40
|
def committing? = @because == "not_committed" && !@files.empty?
|
|
41
41
|
|
|
42
|
-
# What
|
|
43
|
-
# differ from HEAD, or
|
|
44
|
-
# audit command starts a line of its own, after its purpose.
|
|
42
|
+
# What the agent does to give the members a baseline, as one imperative: complete an audit outside git, or
|
|
43
|
+
# in git commit the files that differ from HEAD, or audit again when none does, since every file is
|
|
44
|
+
# committed already. The audit command starts a line of its own, after its purpose.
|
|
45
45
|
#: () -> String
|
|
46
46
|
def remedy
|
|
47
|
-
return "
|
|
47
|
+
return " Commit #{ProseList.new(@files)} #{to_give}." if committing?
|
|
48
48
|
|
|
49
|
-
"#{all_committed if @because == "not_committed"}\
|
|
49
|
+
"#{all_committed if @because == "not_committed"}\nRun this audit #{to_give}: #{@audit}"
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
#: () -> String
|
|
53
|
-
def
|
|
53
|
+
def to_give = "to give #{one? ? "it" : "each"} one"
|
|
54
54
|
|
|
55
55
|
#: () -> String
|
|
56
56
|
def all_committed
|
|
@@ -104,11 +104,14 @@ module Principles
|
|
|
104
104
|
class MapInProject
|
|
105
105
|
#: bool
|
|
106
106
|
attr_reader :set_up
|
|
107
|
+
#: bool
|
|
108
|
+
attr_reader :already_mapped
|
|
107
109
|
|
|
108
110
|
#: (already_mapped: bool, members_in_entry_files: Array[Hash[String, String]], set_up: bool) -> void
|
|
109
111
|
def initialize(already_mapped:, members_in_entry_files:, set_up:)
|
|
110
112
|
@fields = { "already_mapped" => already_mapped,
|
|
111
113
|
"members_in_entry_files" => members_in_entry_files }.freeze #: Hash[String, untyped]
|
|
114
|
+
@already_mapped = already_mapped
|
|
112
115
|
@set_up = set_up
|
|
113
116
|
freeze
|
|
114
117
|
end
|
|
@@ -122,9 +125,9 @@ module Principles
|
|
|
122
125
|
#: (PrintedPrinciple, Placement, MapInProject, existing_principles: Array[Hash[String, untyped]])
|
|
123
126
|
#| -> Hash[String, untyped]
|
|
124
127
|
def proposal(principle, placement, map_in_project, existing_principles:)
|
|
125
|
-
hook_setup = placement.hooks_run? ? {} : { "hook_setup" => ReportHooksOffer.new(@invocation).to_s }
|
|
126
128
|
{ "status" => "question", "principle_id" => principle.id, "map_file" => principle.file,
|
|
127
|
-
"map" => principle.map, **map_in_project.to_h, **placement.to_h,
|
|
129
|
+
"map" => principle.map, **map_in_project.to_h, **placement.to_h,
|
|
130
|
+
**hook_setup(placement, mapped: map_in_project.already_mapped || existing_principles.any?),
|
|
128
131
|
"existing_principles" => existing_principles,
|
|
129
132
|
"question" => map_in_project.set_up ? steps_lacking(principle, placement) : question(principle.id),
|
|
130
133
|
"answer_with" => add_member(principle.id), "next_action" => next_action(principle.id, existing_principles) }
|
|
@@ -132,6 +135,15 @@ module Principles
|
|
|
132
135
|
|
|
133
136
|
private
|
|
134
137
|
|
|
138
|
+
# The hook entries that report changed members, offered only while the plugin's hooks do not run and once a map
|
|
139
|
+
# exists, since before any map they report nothing.
|
|
140
|
+
#: (Placement, mapped: bool) -> Hash[String, String]
|
|
141
|
+
def hook_setup(placement, mapped:)
|
|
142
|
+
return {} if placement.hooks_run? || !mapped
|
|
143
|
+
|
|
144
|
+
{ "hook_setup" => ReportHooksOffer.new(@invocation).to_s }
|
|
145
|
+
end
|
|
146
|
+
|
|
135
147
|
# What to agree with the user and place, with the command that maps a passage the project has in a step's
|
|
136
148
|
# place, and the one that maps the passage once it is placed.
|
|
137
149
|
#: (String) -> String
|
|
@@ -10,14 +10,11 @@ module Principles
|
|
|
10
10
|
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
11
11
|
module Views
|
|
12
12
|
# list-open-findings --short: the one line a session-start hook puts into the agent's context while any
|
|
13
|
-
# finding is open that someone should raise, and nothing when none is. It
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
13
|
+
# finding is open that someone should raise, and nothing when none is. It says first to act on each that waits
|
|
14
|
+
# on the agent and to raise each that waits on a person, and why, then states the facts the agent judges from,
|
|
15
|
+
# how many wait on someone named or on no one and how long the oldest has, with the command that lists whom
|
|
16
|
+
# each waits on.
|
|
17
17
|
class OpenFindingsLine
|
|
18
|
-
# A waits_on longer than this is cut, so the line stays one short line.
|
|
19
|
-
WAITS_ON_LIMIT = 80
|
|
20
|
-
|
|
21
18
|
# The session's start the line is worded for, as Claude Code's SessionStart hook names it: startup, resume,
|
|
22
19
|
# clear or compact. It says what the context holds already, and so which reply raises the findings.
|
|
23
20
|
class SessionStart
|
|
@@ -59,20 +56,9 @@ module Principles
|
|
|
59
56
|
#: () -> Integer
|
|
60
57
|
def unnamed = @fields.fetch("waiting_on_no_one_named")
|
|
61
58
|
|
|
62
|
-
#: () -> Integer
|
|
63
|
-
def to_raise = @fields.fetch("to_raise")
|
|
64
|
-
|
|
65
|
-
# Whether the one finding to raise is one waiting on someone named, whose own line names its need.
|
|
66
|
-
#: () -> bool
|
|
67
|
-
def alone? = to_raise == 1 && named == 1
|
|
68
|
-
|
|
69
59
|
# The oldest open finding of all, by principle and finding_id.
|
|
70
60
|
#: () -> Hash[String, untyped]
|
|
71
61
|
def oldest = @fields.slice("principle", "finding_id")
|
|
72
|
-
|
|
73
|
-
# The oldest finding waiting on someone named, by principle, finding_id and waits_on, or nil.
|
|
74
|
-
#: () -> Hash[String, untyped]?
|
|
75
|
-
def oldest_named = @fields["oldest_waiting_on_someone"]
|
|
76
62
|
end
|
|
77
63
|
|
|
78
64
|
#: (Invocation) -> void
|
|
@@ -84,77 +70,61 @@ module Principles
|
|
|
84
70
|
# waiting is nil when no finding is open, or the count of open findings with the oldest one's principle,
|
|
85
71
|
# finding_id, days_open, how many wait on someone named and the oldest of those, or nil. not_found is each
|
|
86
72
|
# open finding, by principle and finding_id, whose write-up can no longer be found where its recorded_at
|
|
87
|
-
# points. source is the session's start: startup, resume, clear or compact.
|
|
88
|
-
#: (Hash[String, untyped]?, ?Array[Hash[String, untyped]], ?source: String
|
|
89
|
-
def short(waiting, not_found = [], source: "startup"
|
|
90
|
-
Lines.new(stdout: lines(waiting, not_found, source
|
|
73
|
+
# points. source is the session's start: startup, resume, clear or compact.
|
|
74
|
+
#: (Hash[String, untyped]?, ?Array[Hash[String, untyped]], ?source: String) -> Lines
|
|
75
|
+
def short(waiting, not_found = [], source: "startup")
|
|
76
|
+
Lines.new(stdout: lines(waiting, not_found, source:).map { "#{it}\n" }.join, stderr: "", status: 0)
|
|
91
77
|
end
|
|
92
78
|
|
|
93
79
|
# short's line, as a list of none or one, which report-at-session-start prints among its own.
|
|
94
|
-
#: (Hash[String, untyped]?, ?Array[Hash[String, untyped]], ?source: String
|
|
95
|
-
def lines(waiting, not_found = [], source: "startup"
|
|
80
|
+
#: (Hash[String, untyped]?, ?Array[Hash[String, untyped]], ?source: String) -> Array[String]
|
|
81
|
+
def lines(waiting, not_found = [], source: "startup")
|
|
96
82
|
start = SessionStart.new(source)
|
|
97
83
|
return [] unless waiting
|
|
98
84
|
|
|
99
85
|
waiting = Waiting.new(waiting)
|
|
100
86
|
return [resumed("#{how_long(waiting)} (#{oldest(waiting.oldest)})", not_found)] if start.resumed?
|
|
101
|
-
return [] if waiting.to_raise.zero?
|
|
102
87
|
|
|
103
|
-
[whole(waiting, not_found, start
|
|
88
|
+
[whole(waiting, not_found, start)]
|
|
104
89
|
end
|
|
105
90
|
|
|
106
91
|
private
|
|
107
92
|
|
|
108
|
-
# The line with what to do about the findings, for a context that does not hold it yet: the
|
|
109
|
-
#
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
93
|
+
# The line with what to do about the findings, for a context that does not hold it yet: the reply that raises
|
|
94
|
+
# them and why, then the facts, then the command listing them all with whom each waits on. With none naming
|
|
95
|
+
# anyone, none can wait on the agent, so it says only to raise them.
|
|
96
|
+
#: (Waiting, Array[Hash[String, untyped]], SessionStart) -> String
|
|
97
|
+
def whole(waiting, not_found, start)
|
|
98
|
+
values = { reply: start.reply, command: all,
|
|
99
|
+
facts: "#{counts(waiting)}, the oldest #{age(waiting.days_open)}.#{write_ups(not_found)}" }
|
|
100
|
+
return Prompts.text("start-a-session/raise-the-open-findings-waiting-on-no-one", **values) \
|
|
101
|
+
if waiting.named.zero?
|
|
102
|
+
|
|
103
|
+
Prompts.text("start-a-session/act-on-the-open-findings", whom: whom(waiting), **values)
|
|
116
104
|
end
|
|
117
105
|
|
|
118
106
|
# The command listing every open finding, a line each.
|
|
119
107
|
#: () -> String
|
|
120
108
|
def all = @invocation.in_project("list-open-findings", options: ["--lines"])
|
|
121
109
|
|
|
122
|
-
#
|
|
123
|
-
# no one,
|
|
110
|
+
# Whom the findings the agent raises wait on, while some name someone, once it acts on those that wait on
|
|
111
|
+
# itself: a person, and no one, if any names none, since nothing else will raise those either.
|
|
124
112
|
#: (Waiting) -> String
|
|
125
|
-
def
|
|
126
|
-
return "If it waits on your user, raise it" if waiting.alone?
|
|
127
|
-
return "Raise each" if waiting.named.zero?
|
|
113
|
+
def whom(waiting) = "a person#{" or on no one" if waiting.unnamed.positive?}"
|
|
128
114
|
|
|
129
|
-
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
# The sentence naming the oldest finding that waits on someone named, and whom, counting them when several do.
|
|
115
|
+
# How many wait on someone named and on no one, the first counted as the sentence's subject.
|
|
133
116
|
#: (Waiting) -> String
|
|
134
|
-
def
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return "Open finding #{named} waits on: #{need}" if waiting.named == 1
|
|
140
|
-
|
|
141
|
-
"#{counted(waiting.named)} on someone; the oldest, #{named} waits on: #{need}"
|
|
117
|
+
def counts(waiting)
|
|
118
|
+
unnamed = waiting.unnamed
|
|
119
|
+
return "#{counted(unnamed)} on no one named" if waiting.named.zero?
|
|
120
|
+
|
|
121
|
+
"#{counted(waiting.named)} on someone named#{", #{unnamed} on no one" if unnamed.positive?}"
|
|
142
122
|
end
|
|
143
123
|
|
|
144
124
|
# How long a finding has gone unraised, in whole days.
|
|
145
125
|
#: (Integer) -> String
|
|
146
126
|
def age(days) = "open #{days} #{days == 1 ? "day" : "days"}"
|
|
147
127
|
|
|
148
|
-
# The sentence counting the findings deferred with no waits_on, after any naming someone.
|
|
149
|
-
#: (Waiting) -> String
|
|
150
|
-
def no_one_named(waiting)
|
|
151
|
-
unnamed = waiting.unnamed
|
|
152
|
-
return "" if unnamed.zero?
|
|
153
|
-
return " #{unnamed} #{unnamed == 1 ? "waits" : "wait"} on no one named." if waiting.named.positive?
|
|
154
|
-
|
|
155
|
-
"#{counted(unnamed)} on no one named."
|
|
156
|
-
end
|
|
157
|
-
|
|
158
128
|
# How many open findings wait, as the subject of the sentence saying on whom.
|
|
159
129
|
#: (Integer) -> String
|
|
160
130
|
def counted(count) = count == 1 ? "1 open finding waits" : "#{count} open findings wait"
|
|
@@ -168,14 +138,6 @@ module Principles
|
|
|
168
138
|
command: @invocation.in_project("list-open-findings", options: ["--short"]))
|
|
169
139
|
end
|
|
170
140
|
|
|
171
|
-
# git's user name as a fact, for the agent to judge whether the person a finding waits on is its user.
|
|
172
|
-
#: (String?) -> String
|
|
173
|
-
def git_user(name)
|
|
174
|
-
return " git has no user.name set." unless name
|
|
175
|
-
|
|
176
|
-
" git's user.name is #{VisibleText.new(name)}."
|
|
177
|
-
end
|
|
178
|
-
|
|
179
141
|
# The sentence naming the write-ups that can no longer be found, the first by its principle and id, or
|
|
180
142
|
# nothing when every pointer resolves, so the usual line is unchanged.
|
|
181
143
|
#: (Array[Hash[String, untyped]]) -> String
|
|
@@ -206,32 +168,9 @@ module Principles
|
|
|
206
168
|
"for #{days} #{days == 1 ? "day" : "days"}"
|
|
207
169
|
end
|
|
208
170
|
|
|
209
|
-
# A finding's waits_on, cut when long. It is free text, so it is cut by characters first and then escaped,
|
|
210
|
-
# which may run past the limit to show it.
|
|
211
|
-
#: (String) -> String
|
|
212
|
-
def need(waits_on)
|
|
213
|
-
waits_on = closed("#{whole_words(waits_on[0, WAITS_ON_LIMIT - 3].to_s)}...") if waits_on.length > WAITS_ON_LIMIT
|
|
214
|
-
VisibleText.new(waits_on).to_s
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
# A cut waits_on up to its last whole word, so it never ends in part of one, or as cut when it is one
|
|
218
|
-
# word, which has no boundary to cut at.
|
|
219
|
-
#: (String) -> String
|
|
220
|
-
def whole_words(cut)
|
|
221
|
-
boundary = cut.rindex(" ") or return cut
|
|
222
|
-
cut[0, boundary].to_s
|
|
223
|
-
end
|
|
224
|
-
|
|
225
171
|
# The oldest finding's principle and id, which is free text and so escaped.
|
|
226
172
|
#: (Hash[String, untyped]) -> String
|
|
227
173
|
def oldest(waiting) = "#{waiting.fetch("principle")} #{VisibleText.new(waiting.fetch("finding_id"))}"
|
|
228
|
-
|
|
229
|
-
# A cut waits_on with a ")" for each "(" the cut left open, so the line's own parenthesis still reads as
|
|
230
|
-
# closing the finding's name.
|
|
231
|
-
#: (String) -> String
|
|
232
|
-
def closed(cut)
|
|
233
|
-
cut + (")" * [cut.count("(") - cut.count(")"), 0].max)
|
|
234
|
-
end
|
|
235
174
|
end
|
|
236
175
|
end
|
|
237
176
|
end
|
|
@@ -31,7 +31,7 @@ module Principles
|
|
|
31
31
|
"unless you judge it again. --as template prints the same answer long, with each slot's help. " \
|
|
32
32
|
"Then fill in the answer the response_template part prints"
|
|
33
33
|
fill = AnswerInAFile.new(@invocation).assessment(request.principle_id, request_id:)
|
|
34
|
-
listed(index, request.principle_id)
|
|
34
|
+
listed(index, request.principle_id, request.bytes_unknown)
|
|
35
35
|
.merge(TrimmedInstructionsNote.new(request.trimmed_instruction_fields).to_h)
|
|
36
36
|
.merge("answer_with" => @invocation.submit_answer(request_id),
|
|
37
37
|
"next_action" => "#{read}, #{carried(request)}. #{fill}")
|
|
@@ -49,10 +49,14 @@ module Principles
|
|
|
49
49
|
# The index under its request id, after the command that prints a part named after it, each entry's part as a
|
|
50
50
|
# shell reads it, quoted where a shell would split or expand it, so it runs as printed; the answer's template
|
|
51
51
|
# names each member by its id unquoted. One command rather than one an entry, since an entry's would repeat it
|
|
52
|
-
# and cost more than reading the whole request.
|
|
53
|
-
#: (Hash[String, untyped], String) -> Hash[String, untyped]
|
|
54
|
-
def listed(index, principle_id)
|
|
55
|
-
entries = index.fetch("index").map
|
|
52
|
+
# and cost more than reading the whole request. Each part bytes_unknown names gives why it has no bytes instead.
|
|
53
|
+
#: (Hash[String, untyped], String, Hash[String, String]) -> Hash[String, untyped]
|
|
54
|
+
def listed(index, principle_id, bytes_unknown)
|
|
55
|
+
entries = index.fetch("index").map do |entry|
|
|
56
|
+
part = entry.fetch("part")
|
|
57
|
+
sized = bytes_unknown.key?(part) ? entry.except("bytes").merge("bytes_unknown" => bytes_unknown[part]) : entry
|
|
58
|
+
sized.merge("part" => ShellWord.new(part).to_s)
|
|
59
|
+
end
|
|
56
60
|
{ "request_id" => index.fetch("request_id"),
|
|
57
61
|
"part_command" => @invocation.in_project("start-audit", principle_id, options: ["--part"]),
|
|
58
62
|
"index" => entries }
|