principles 0.0.4 → 0.0.6
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/lib/principles/after_commit_hook_options.rb +4 -1
- data/lib/principles/cli.rb +3 -1
- data/lib/principles/command_line.rb +38 -26
- data/lib/principles/command_routes.rb +11 -4
- data/lib/principles/controllers/acknowledgement.rb +93 -17
- data/lib/principles/controllers/answer.rb +45 -76
- data/lib/principles/controllers/answer_phase.rb +54 -0
- data/lib/principles/controllers/assessment.rb +46 -11
- data/lib/principles/controllers/audit.rb +17 -6
- data/lib/principles/controllers/audit_completion.rb +9 -5
- data/lib/principles/controllers/command.rb +5 -4
- data/lib/principles/controllers/correction.rb +22 -10
- data/lib/principles/controllers/full_audit_request.rb +11 -1
- data/lib/principles/controllers/guidance_search_paths.rb +31 -0
- data/lib/principles/controllers/inventory.rb +15 -29
- data/lib/principles/controllers/mapping.rb +9 -1
- data/lib/principles/controllers/member_addition.rb +65 -0
- data/lib/principles/controllers/member_entries.rb +6 -24
- data/lib/principles/controllers/member_problems_report.rb +13 -6
- data/lib/principles/controllers/members_a_commit_changed.rb +2 -1
- data/lib/principles/controllers/members_to_assess.rb +21 -13
- data/lib/principles/controllers/meta_principle_setup.rb +1 -1
- data/lib/principles/controllers/repoint.rb +22 -23
- data/lib/principles/controllers/survey.rb +60 -0
- data/lib/principles/data/audit_files.rb +4 -0
- data/lib/principles/data/bounded_file.rb +9 -4
- data/lib/principles/data/candidate_files_found.rb +48 -13
- data/lib/principles/data/command-steps.json +85 -24
- data/lib/principles/data/committed_tree.rb +84 -0
- data/lib/principles/data/first_parent_log.rb +48 -0
- data/lib/principles/data/first_parent_range.rb +122 -0
- data/lib/principles/data/git_command.rb +37 -0
- data/lib/principles/data/guidance_search_paths_file.rb +107 -0
- data/lib/principles/data/map_files.rb +35 -10
- data/lib/principles/data/principles_directory.rb +40 -0
- data/lib/principles/data/principles_subfolder.rb +39 -16
- data/lib/principles/data/project_files.rb +22 -11
- data/lib/principles/data/repository.rb +55 -29
- data/lib/principles/data/requested_candidate_files.rb +43 -0
- data/lib/principles/data/running_version.rb +3 -5
- data/lib/principles/data/schema_check.rb +16 -6
- data/lib/principles/data/schemas/acknowledgement-answer.schema.json +18 -5
- data/lib/principles/data/schemas/answer-guide.schema.json +255 -68
- data/lib/principles/data/schemas/audit-record.schema.json +10 -1
- data/lib/principles/data/schemas/command-steps.schema.json +2 -1
- data/lib/principles/data/schemas/correction-answer-guide.schema.json +2 -1
- data/lib/principles/data/schemas/correction-answer.schema.json +6 -0
- data/lib/principles/data/schemas/guidance-search-paths.schema.json +13 -0
- data/lib/principles/data/schemas/member-map-history.schema.json +20 -0
- data/lib/principles/data/verified_head.rb +162 -0
- data/lib/principles/invocation_options.rb +3 -3
- data/lib/principles/models/acknowledgement.rb +95 -84
- data/lib/principles/models/acknowledgement_left_as_printed.rb +51 -0
- data/lib/principles/models/acknowledgement_refusal.rb +90 -0
- data/lib/principles/models/answer_place.rb +4 -0
- data/lib/principles/models/assessment_answer.rb +0 -45
- data/lib/principles/models/assessment_left_as_printed.rb +81 -0
- data/lib/principles/models/audit_entry_protecting_map.rb +28 -0
- data/lib/principles/models/audit_record.rb +12 -16
- data/lib/principles/models/audit_records.rb +52 -23
- data/lib/principles/models/candidate_files.rb +44 -10
- data/lib/principles/models/candidate_inventory.rb +69 -8
- data/lib/principles/models/candidate_outline.rb +195 -0
- data/lib/principles/models/captured_head.rb +72 -0
- data/lib/principles/models/carried_member.rb +42 -0
- data/lib/principles/models/check_since_last_audit.rb +20 -11
- data/lib/principles/models/command_steps.rb +17 -1
- data/lib/principles/models/declared_map_changes.rb +29 -12
- data/lib/principles/models/declared_member_removals.rb +75 -0
- data/lib/principles/models/disposition.rb +4 -2
- data/lib/principles/models/fix_only_fields.rb +12 -0
- data/lib/principles/models/frontmatter_fields.rb +9 -8
- data/lib/principles/models/guidance_search_path.rb +26 -0
- data/lib/principles/models/guidance_search_paths.rb +57 -0
- data/lib/principles/models/instruction_named.rb +35 -0
- data/lib/principles/models/left_as_printed.rb +39 -0
- data/lib/principles/models/line_span.rb +6 -0
- data/lib/principles/models/loaded_files.rb +1 -2
- data/lib/principles/models/loading_scope.rb +61 -0
- data/lib/principles/models/locator.rb +6 -0
- data/lib/principles/models/mapped_principles.rb +39 -37
- data/lib/principles/models/member_assessments.rb +9 -31
- data/lib/principles/models/member_file.rb +20 -47
- data/lib/principles/models/member_hashes_as_written.rb +10 -6
- data/lib/principles/models/member_history.rb +7 -5
- data/lib/principles/models/member_lines.rb +63 -15
- data/lib/principles/models/member_loading_scopes.rb +49 -0
- data/lib/principles/models/member_loads.rb +4 -0
- data/lib/principles/models/member_mapping_run.rb +30 -0
- data/lib/principles/models/member_moves.rb +4 -0
- data/lib/principles/models/member_problems.rb +63 -33
- data/lib/principles/models/member_region.rb +129 -0
- data/lib/principles/models/member_repair_moves.rb +52 -0
- data/lib/principles/models/member_snapshots.rb +14 -1
- data/lib/principles/models/members_in_consecutive_sections.rb +56 -0
- data/lib/principles/models/meta_principle.rb +14 -0
- data/lib/principles/models/missing_files.rb +2 -2
- data/lib/principles/models/open_findings_elsewhere.rb +4 -0
- data/lib/principles/models/other_templates_placeholders.rb +81 -42
- data/lib/principles/models/outline_budget.rb +142 -0
- data/lib/principles/models/outline_group.rb +31 -0
- data/lib/principles/models/outline_section.rb +56 -0
- data/lib/principles/models/principle.rb +14 -7
- data/lib/principles/models/principle_file_revision.rb +48 -0
- data/lib/principles/models/principle_history.rb +46 -19
- data/lib/principles/models/principle_lineage.rb +118 -0
- data/lib/principles/models/principle_map_revision.rb +39 -0
- data/lib/principles/models/principle_mapping_history.rb +132 -0
- data/lib/principles/models/principle_members.rb +25 -0
- data/lib/principles/models/principle_predecessor.rb +45 -0
- data/lib/principles/models/principle_publication.rb +177 -0
- data/lib/principles/models/principle_revision.rb +104 -0
- data/lib/principles/models/prior_decision_fields.rb +3 -2
- data/lib/principles/models/prior_finding_decision.rb +14 -4
- data/lib/principles/models/problem_report.rb +17 -5
- data/lib/principles/models/project.rb +46 -39
- data/lib/principles/models/project_history.rb +45 -25
- data/lib/principles/models/quoted_change.rb +137 -0
- data/lib/principles/models/record_format.rb +12 -2
- data/lib/principles/models/recorded_entry.rb +6 -0
- data/lib/principles/models/recorded_hashes.rb +7 -3
- data/lib/principles/models/recorded_members.rb +27 -15
- data/lib/principles/models/refusal_before_shape.rb +21 -0
- data/lib/principles/models/repoint.rb +13 -0
- data/lib/principles/models/reported_check.rb +5 -14
- data/lib/principles/models/sent_answer.rb +61 -0
- data/lib/principles/models/shape_problems_beside.rb +40 -0
- data/lib/principles/models/submitted_answer.rb +34 -0
- data/lib/principles/models/survey_search_paths.rb +26 -0
- data/lib/principles/models/template_placeholders.rb +34 -4
- data/lib/principles/models/text_within.rb +55 -0
- data/lib/principles/models/unchecked_members.rb +76 -0
- data/lib/principles/models/uncommitted_files.rb +50 -0
- data/lib/principles/models/unknown_principle.rb +29 -0
- data/lib/principles/models/write_up_opening.rb +21 -4
- data/lib/principles/positional_arguments.rb +37 -0
- data/lib/principles/session_start_options.rb +2 -2
- data/lib/principles/start_audit_options.rb +19 -4
- data/lib/principles/version.rb +2 -2
- data/lib/principles/views/acknowledgement_result.rb +23 -11
- data/lib/principles/views/added_member.rb +41 -0
- data/lib/principles/views/answered_request.rb +21 -0
- data/lib/principles/views/assessed_members.rb +43 -10
- data/lib/principles/views/assessment_request.rb +91 -31
- data/lib/principles/views/audit_result.rb +40 -28
- data/lib/principles/views/candidate_files_result.rb +85 -19
- data/lib/principles/views/candidate_outlines_result.rb +25 -0
- data/lib/principles/views/check_notes.rb +44 -0
- data/lib/principles/views/check_result_template.rb +14 -23
- data/lib/principles/views/consecutive_sections_elsewhere.rb +27 -0
- data/lib/principles/views/correction_request.rb +32 -1
- data/lib/principles/views/guidance_search_paths_result.rb +26 -0
- data/lib/principles/views/instruction.rb +74 -0
- data/lib/principles/views/json_with_entries_on_lines.rb +59 -0
- data/lib/principles/views/loads_to_check_result.rb +2 -2
- data/lib/principles/views/map_added_to.rb +56 -2
- data/lib/principles/views/map_result.rb +23 -43
- data/lib/principles/views/maps_needing_members_or_audit.rb +47 -0
- data/lib/principles/views/member_change_since_baseline.rb +23 -5
- data/lib/principles/views/member_repairs.rb +22 -52
- data/lib/principles/views/members_a_commit_changed.rb +16 -6
- data/lib/principles/views/new_loading_scope.rb +31 -0
- data/lib/principles/views/one_member_check_result_template.rb +47 -0
- data/lib/principles/views/open_findings_elsewhere_result.rb +3 -3
- data/lib/principles/views/open_findings_line.rb +77 -23
- data/lib/principles/views/principle_read_result.rb +24 -29
- data/lib/principles/views/principles_with_no_completed_audit.rb +9 -3
- data/lib/principles/views/prior_findings_result.rb +23 -15
- data/lib/principles/views/problem_lines.rb +3 -1
- data/lib/principles/views/problem_result.rb +8 -3
- data/lib/principles/views/prompts/acknowledge-a-change/run-the-check-and-report-it-passing.md +3 -0
- data/lib/principles/views/prompts/acknowledge-a-change/say-whether-the-change-keeps-the-meaning.md +6 -12
- data/lib/principles/views/prompts/assess-every-member/answer-guide.json +67 -48
- data/lib/principles/views/prompts/assess-every-member/assess-each-member-and-the-set.md +0 -4
- data/lib/principles/views/prompts/assess-every-member/claim-an-earlier-first-raised-at.md +7 -0
- data/lib/principles/views/prompts/assess-every-member/decide-each-prior-finding.md +4 -16
- data/lib/principles/views/prompts/assess-every-member/judge-the-set-with-carried-assessments.md +5 -10
- data/lib/principles/views/prompts/assess-every-member/keep-or-change-what-a-deferral-waits-on.md +4 -0
- data/lib/principles/views/prompts/assess-every-member/read-a-compact-carried-member.md +8 -0
- data/lib/principles/views/prompts/assess-every-member/read-a-trimmed-instruction-whole.md +1 -0
- data/lib/principles/views/prompts/assess-every-member/review-a-new-or-changed-check-before-running-it.md +9 -0
- data/lib/principles/views/prompts/assess-every-member/say-what-observed-means.md +4 -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 +16 -3
- data/lib/principles/views/prompts/dispose-of-each-finding/retain-assessment-and-correction.md +4 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/ask-about-other-guidance-search-paths.md +6 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/ask-the-owner-after-the-table.md +1 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/ask-which-principle-to-map.md +2 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/choose-an-existing-or-new-principle.md +2 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/choose-one-principle.md +11 -5
- data/lib/principles/views/prompts/find-a-principle-to-map/compare-with-mapped-principles.md +11 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/leave-test-data-out-of-the-survey.md +1 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/read-a-cut-section-back.md +3 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/read-left-out-files.md +3 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/survey-a-later-range.md +3 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/what-each-command-writes.md +4 -4
- data/lib/principles/views/prompts/find-a-principle-to-map/where-the-inventory-looks.md +5 -4
- data/lib/principles/views/prompts/learn-what-a-command-does/add-guidance-search-path.md +17 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/add-member.md +35 -6
- data/lib/principles/views/prompts/learn-what-a-command-does/create-principle.md +16 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +55 -7
- data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +9 -8
- 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/list-principles.md +1 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/move-member.md +5 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/remove-guidance-search-path.md +13 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/remove-principle.md +25 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +27 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/show-candidate-outlines.md +21 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-meta-principle-passage.md +5 -5
- data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +24 -24
- data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +51 -54
- data/lib/principles/views/prompts/read-requested-outlines/continue-the-survey.md +7 -0
- data/lib/principles/views/prompts/report-after-a-commit/the-principles-skill-is-where-to-start.md +1 -0
- data/lib/principles/views/prompts/set-principles-up/keep-them-held-between-audits.md +2 -0
- data/lib/principles/views/prompts/set-principles-up/name-the-step-each-member-lacks.md +2 -0
- data/lib/principles/views/prompts/set-principles-up/place-the-passage-with-the-user.md +9 -6
- data/lib/principles/views/prompts/start-a-session/see-the-earlier-line.md +2 -0
- data/lib/principles/views/record_waiting_on_an_upgrade.rb +3 -3
- data/lib/principles/views/request_part.rb +16 -8
- data/lib/principles/views/request_parts.rb +4 -0
- metadata +92 -7
- data/lib/principles/models/candidate_listing.rb +0 -32
- data/lib/principles/views/prompts/find-a-principle-to-map/ask-the-owner-before-mapping.md +0 -1
- data/lib/principles/views/prompts/report-after-a-commit/the-map-and-audit-skill-says-how-to-audit-these-members.md +0 -1
- data/lib/principles/views/prompts/set-principles-up/set-up-first.md +0 -2
|
@@ -13,7 +13,8 @@ module Principles
|
|
|
13
13
|
# One member's check and the result an agent reports for it (D30). This tool never runs the check: it
|
|
14
14
|
# refuses a report that cannot be about the member's own check, and cannot confirm the run happened.
|
|
15
15
|
class ReportedCheck
|
|
16
|
-
SHAPES = "
|
|
16
|
+
SHAPES = "Merge one inner example from answer_guide.check_result.examples into that member's " \
|
|
17
|
+
"response_template.check_result as copy_from says."
|
|
17
18
|
# How review_basis records a review the agent made itself, which the placeholder and the repair both give.
|
|
18
19
|
SELF_REVIEWED = "\"Self-reviewed by the agent: <what you checked it against>\"" #: String
|
|
19
20
|
# The not_run_reason a template prints beside exit_status's placeholder, which an answer that leaves it as
|
|
@@ -51,7 +52,7 @@ module Principles
|
|
|
51
52
|
# none; a check it did not run is reviewed before it runs, and the result says in review_basis what that review
|
|
52
53
|
# rested on (D63). kept is the line the stored record keeps for that run's review, with its
|
|
53
54
|
# review_basis_since, which an unchanged check's result carries until the answer gives another (D52).
|
|
54
|
-
#: (AnswerPlace, String
|
|
55
|
+
#: (AnswerPlace, String, ran: String?, kept: Hash[String, untyped]) -> void
|
|
55
56
|
def initialize(assessment, check, ran:, kept:)
|
|
56
57
|
@assessment = assessment
|
|
57
58
|
@check = check
|
|
@@ -60,11 +61,9 @@ module Principles
|
|
|
60
61
|
freeze
|
|
61
62
|
end
|
|
62
63
|
|
|
63
|
-
# The reported result, once it is checked against the member's check
|
|
64
|
-
#: (untyped) -> Hash[String, untyped]
|
|
64
|
+
# The reported result, once it is checked against the member's check.
|
|
65
|
+
#: (untyped) -> Hash[String, untyped]
|
|
65
66
|
def result(reported)
|
|
66
|
-
return no_check(reported) unless @check
|
|
67
|
-
|
|
68
67
|
missing_result unless reported
|
|
69
68
|
given = filled(reported)
|
|
70
69
|
same_command(given.fetch("command"))
|
|
@@ -105,14 +104,6 @@ module Principles
|
|
|
105
104
|
"answer_guide.check_result.limits asks for one. #{SHAPES}")
|
|
106
105
|
end
|
|
107
106
|
|
|
108
|
-
#: (untyped) -> nil
|
|
109
|
-
def no_check(reported)
|
|
110
|
-
return unless reported
|
|
111
|
-
|
|
112
|
-
refuse(reported_at, "the member has no check, so its assessment takes no check_result",
|
|
113
|
-
"Remove check_result from this member's assessment.")
|
|
114
|
-
end
|
|
115
|
-
|
|
116
107
|
#: (String) -> void
|
|
117
108
|
def same_command(command)
|
|
118
109
|
return if command == @check
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../data/schema_check"
|
|
5
|
+
require_relative "../data/project_files"
|
|
6
|
+
require_relative "../error"
|
|
7
|
+
require_relative "refusal_before_shape"
|
|
8
|
+
|
|
9
|
+
module Principles
|
|
10
|
+
module Models
|
|
11
|
+
# An answer an agent sent for a phase's request, read from its source, whose head, the fields every answer hands
|
|
12
|
+
# back as its request printed them, is checked on arrival: they say whether it still answers that request
|
|
13
|
+
# (#990). The rest is checked only once that request is known, against the placeholders its template printed and
|
|
14
|
+
# the phase's schema (D29, #1052, #1084).
|
|
15
|
+
class SentAnswer
|
|
16
|
+
HEAD = %w[request_id basis].freeze #: Array[String]
|
|
17
|
+
|
|
18
|
+
# What a refusal's message calls the answer: the agent holds its file's path, which cost context in every
|
|
19
|
+
# repair (#1112, #1118).
|
|
20
|
+
NAMED = "The answer" #: String
|
|
21
|
+
# What a refusal to read its file calls that file (#1131).
|
|
22
|
+
FILE_NAMED = "The answer file" #: String
|
|
23
|
+
|
|
24
|
+
REPAIR = "Repair each field listed, starting from the request's response_template." #: String
|
|
25
|
+
|
|
26
|
+
# The answer read from the file or stdin the agent named, using its phase's schema.
|
|
27
|
+
#: (Data::ProjectFiles, String, stdin: String?, phase: String) -> SentAnswer
|
|
28
|
+
def self.read(files, file, stdin:, phase:)
|
|
29
|
+
parsed = if file == "-" then files.parse_json(stdin.to_s, "-", named: NAMED)
|
|
30
|
+
else files.read_json(file, named: FILE_NAMED)
|
|
31
|
+
end
|
|
32
|
+
new(parsed, file, Data::SchemaCheck.new("#{phase}-answer"))
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# parsed is the answer as its source, a file or - for stdin, holds it; check is its phase's answer schema.
|
|
36
|
+
#: (untyped, String, Data::SchemaCheck) -> void
|
|
37
|
+
def initialize(parsed, source, check)
|
|
38
|
+
@parsed = parsed
|
|
39
|
+
@source = source
|
|
40
|
+
@check = check
|
|
41
|
+
check.only(HEAD).checked(parsed, code: "invalid_answer", source: source, repair: REPAIR, named: NAMED)
|
|
42
|
+
freeze
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# The answer's head, checked.
|
|
46
|
+
#: () -> Hash[String, untyped]
|
|
47
|
+
def head = @parsed.slice(*HEAD)
|
|
48
|
+
|
|
49
|
+
# The whole answer, once each refusal its request's rules make before its shape, in order, then its shape, is
|
|
50
|
+
# checked: such as a stray check_result on a member with no check, a field holding a placeholder its
|
|
51
|
+
# request's template did not print, and a one-member audit's field left as its template printed it, each handed
|
|
52
|
+
# the shape's problems to name beside its own (#1106).
|
|
53
|
+
#: (Array[RefusalBeforeShape]) -> untyped
|
|
54
|
+
def checked(before_shape)
|
|
55
|
+
shape_problems = @check.problems(@parsed)
|
|
56
|
+
before_shape.each { |refusal| refusal.refuse_in(@parsed, @source, shape_problems) }
|
|
57
|
+
@check.checked(@parsed, code: "invalid_answer", source: @source, repair: REPAIR, named: NAMED)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Principles
|
|
5
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
6
|
+
module Models
|
|
7
|
+
# The problems an answer's shape has beside those a refusal before the shape names, which that refusal names too,
|
|
8
|
+
# so one refusal lists every repair (#1106, #1109), and says so in its message, which an agent reads first (#1130).
|
|
9
|
+
class ShapeProblemsBeside
|
|
10
|
+
# What the message adds when there are any.
|
|
11
|
+
MESSAGE = ", and fields not in the shape this tool reads" #: String
|
|
12
|
+
|
|
13
|
+
# problems are the shape's, as Data::SchemaCheck#problems gives them; each at or under a pointer in named, which
|
|
14
|
+
# the refusal names, is left out, since its repair repairs that one too.
|
|
15
|
+
#: (Array[Hash[String, String]], named: Array[String]) -> void
|
|
16
|
+
def initialize(problems, named:)
|
|
17
|
+
elsewhere = problems.reject { |problem| under?(problem.fetch("pointer"), named) }
|
|
18
|
+
@fields = elsewhere.freeze #: Array[Hash[String, String]]
|
|
19
|
+
freeze
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
#: Array[Hash[String, String]]
|
|
23
|
+
attr_reader :fields
|
|
24
|
+
|
|
25
|
+
# The refusal's own message, saying when it names these too.
|
|
26
|
+
#: (String) -> String
|
|
27
|
+
def message(own) = "#{own}#{MESSAGE unless @fields.empty?}"
|
|
28
|
+
|
|
29
|
+
# The refusal's own repair, with also, how to repair these, when there are any.
|
|
30
|
+
#: (String, String) -> String
|
|
31
|
+
def repair(own, also) = "#{own}#{also unless @fields.empty?}"
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
# Whether pointer is one of named, or inside one.
|
|
36
|
+
#: (String, Array[String]) -> bool
|
|
37
|
+
def under?(pointer, named) = named.any? { pointer == it || pointer.start_with?("#{it}/") }
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "prior_findings"
|
|
5
|
+
require_relative "request_id"
|
|
6
|
+
|
|
7
|
+
module Principles
|
|
8
|
+
# The domain logic, which loads and saves itself through data/. models/CLAUDE.md owns the boundary.
|
|
9
|
+
module Models
|
|
10
|
+
# An answer submitted to the request request_id names, its shape checked, with the prior findings a full
|
|
11
|
+
# audit's request listed, which checking its head found (#1052), or nil for any other phase.
|
|
12
|
+
class SubmittedAnswer
|
|
13
|
+
#: RequestId
|
|
14
|
+
attr_reader :request_id
|
|
15
|
+
|
|
16
|
+
#: untyped
|
|
17
|
+
attr_reader :response
|
|
18
|
+
|
|
19
|
+
#: (RequestId, untyped, PriorFindings?) -> void
|
|
20
|
+
def initialize(request_id, response, prior)
|
|
21
|
+
@request_id = request_id
|
|
22
|
+
@response = response
|
|
23
|
+
@prior = prior
|
|
24
|
+
freeze
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# The prior findings a full audit's assessment request listed, which only that phase's answer has.
|
|
28
|
+
#: () -> PriorFindings
|
|
29
|
+
def prior_findings
|
|
30
|
+
@prior or raise ArgumentError, "an assessment's prior findings come from checking its head"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "guidance_search_path"
|
|
5
|
+
|
|
6
|
+
module Principles
|
|
7
|
+
# The domain logic, which loads and saves itself through data/. models/CLAUDE.md owns the boundary.
|
|
8
|
+
module Models
|
|
9
|
+
# The project's recorded guidance search paths and this invocation's temporary selections, combined once.
|
|
10
|
+
class SurveySearchPaths
|
|
11
|
+
#: Array[String]
|
|
12
|
+
attr_reader :globs
|
|
13
|
+
|
|
14
|
+
#: (recorded: Array[String], also: Array[String]) -> void
|
|
15
|
+
def initialize(recorded:, also:)
|
|
16
|
+
@recorded = recorded.map { |glob| GuidanceSearchPath.new(glob).glob }.uniq.freeze #: Array[String]
|
|
17
|
+
@globs = (@recorded | also.map { |glob| GuidanceSearchPath.new(glob).glob }).freeze #: Array[String]
|
|
18
|
+
freeze
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Saved provenance is distinct from all match counts; omit it when the project records no search paths.
|
|
22
|
+
#: () -> Hash[String, untyped]
|
|
23
|
+
def recorded_listing = @recorded.empty? ? {} : { "recorded_guidance_search_paths" => @recorded }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# typed: strict
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
+
require_relative "left_as_printed"
|
|
5
|
+
require_relative "refusal_before_shape"
|
|
6
|
+
|
|
4
7
|
module Principles
|
|
5
8
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
6
9
|
module Models
|
|
@@ -8,16 +11,24 @@ module Principles
|
|
|
8
11
|
# fills the fields that apply and never reshapes the answer (#993, #994). The model that owns a part of the answer
|
|
9
12
|
# holds one, which a controller hands to the view that prints it.
|
|
10
13
|
class TemplatePlaceholders
|
|
14
|
+
include RefusalBeforeShape
|
|
15
|
+
|
|
11
16
|
# placeholders is the text printed in each field, by field name, or for a field that takes pointers, one pointer
|
|
12
17
|
# whose fields hold that text, so the template shows their shape (#1042); empty_lists names the fields a template
|
|
13
|
-
# may instead start as an empty list, which is not given either (#838)
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
# may instead start as an empty list, which is not given either (#838); also_printed, the other text a template
|
|
19
|
+
# may print in a field, refused alike (#1142).
|
|
20
|
+
#: (Hash[String, untyped], ?empty_lists: Array[String], ?also_printed: Hash[String, String]) -> void
|
|
21
|
+
def initialize(placeholders, empty_lists: [], also_printed: {})
|
|
16
22
|
@placeholders = placeholders.freeze #: Hash[String, untyped]
|
|
17
23
|
@empty_lists = empty_lists.freeze #: Array[String]
|
|
24
|
+
@also_printed = also_printed.freeze #: Hash[String, String]
|
|
18
25
|
freeze
|
|
19
26
|
end
|
|
20
27
|
|
|
28
|
+
# The text printed in each field, with field's other text in place of its own.
|
|
29
|
+
#: (String) -> Hash[String, untyped]
|
|
30
|
+
def with_other_text_in(field) = @placeholders.merge(field => @also_printed.fetch(field))
|
|
31
|
+
|
|
21
32
|
# The text printed in each field, for the view that prints it.
|
|
22
33
|
#: () -> Hash[String, untyped]
|
|
23
34
|
def to_h = @placeholders
|
|
@@ -30,12 +41,31 @@ module Principles
|
|
|
30
41
|
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
31
42
|
def given(fields) = fields.reject { |field, value| left?(field, value) }
|
|
32
43
|
|
|
44
|
+
# Refuses answer, as sent, when it leaves a field as its placeholder, for a template whose every field must be
|
|
45
|
+
# written, as a one-member audit's (#773); read before the answer's shape, which would refuse a placeholder in a
|
|
46
|
+
# field of another type without naming it, so the refusal names the shape's other problems too (#1106). source
|
|
47
|
+
# is unused, as other refusals before the shape name it.
|
|
48
|
+
# @override
|
|
49
|
+
#: (untyped, String, Array[Hash[String, String]]) -> void
|
|
50
|
+
def refuse_in(answer, _source, shape_problems)
|
|
51
|
+
return unless answer.is_a?(Hash)
|
|
52
|
+
|
|
53
|
+
left = @placeholders.keys.select { |field| printed?(field, answer[field]) }
|
|
54
|
+
LeftAsPrinted.new(left.to_h { [it, "/#{it}"] }).refuse(besides: shape_problems)
|
|
55
|
+
end
|
|
56
|
+
|
|
33
57
|
# Whether value is field's placeholder, or the empty list it may start as, as printed; a field with neither
|
|
34
58
|
# never is.
|
|
35
59
|
#: (String, untyped) -> bool
|
|
36
60
|
def left?(field, value)
|
|
37
|
-
(@placeholders.key?(field) &&
|
|
61
|
+
(@placeholders.key?(field) && printed?(field, value)) || (@empty_lists.include?(field) && value == [])
|
|
38
62
|
end
|
|
63
|
+
|
|
64
|
+
private
|
|
65
|
+
|
|
66
|
+
# Whether value is a text the template prints in field.
|
|
67
|
+
#: (String, untyped) -> bool
|
|
68
|
+
def printed?(field, value) = [@placeholders[field], @also_printed[field]].compact.include?(value)
|
|
39
69
|
end
|
|
40
70
|
end
|
|
41
71
|
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Principles
|
|
5
|
+
# The domain logic, which loads and saves itself through data/. models/CLAUDE.md owns the boundary.
|
|
6
|
+
module Models
|
|
7
|
+
# A text cut to at most some characters, as a candidate file's outline prints its items, opening line and
|
|
8
|
+
# description: whole when it fits, else back to a sentence end or a whole word (#1155).
|
|
9
|
+
class TextWithin
|
|
10
|
+
# Text up to its last sentence end that a space follows.
|
|
11
|
+
SENTENCES = /\A.*[.!?](?=\s)/
|
|
12
|
+
# Text up to its last whole word.
|
|
13
|
+
WORDS = /\A.*(?=\s)/
|
|
14
|
+
|
|
15
|
+
#: (String, at_most: Integer) -> void
|
|
16
|
+
def initialize(text, at_most:)
|
|
17
|
+
@text = text
|
|
18
|
+
@at_most = at_most
|
|
19
|
+
freeze
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Whether the text is longer than at_most characters.
|
|
23
|
+
#: () -> bool
|
|
24
|
+
def cut? = @text.length > @at_most
|
|
25
|
+
|
|
26
|
+
# The text whole, else up to its last sentence end within at_most characters, else up to its last whole word.
|
|
27
|
+
#: () -> String
|
|
28
|
+
def kept
|
|
29
|
+
return @text unless cut?
|
|
30
|
+
|
|
31
|
+
sentences_kept || words_kept
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# The text whole, else up to its last sentence end, else cut on a word ending in an ellipsis.
|
|
35
|
+
#: () -> String
|
|
36
|
+
def by_sentences = cut? && !sentences_kept ? "#{words_kept}…" : kept
|
|
37
|
+
|
|
38
|
+
# The text whole, else cut on a word ending in an ellipsis.
|
|
39
|
+
#: () -> String
|
|
40
|
+
def by_words = cut? ? "#{words_kept}…" : @text
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
#: () -> String?
|
|
45
|
+
def sentences_kept = window[SENTENCES]
|
|
46
|
+
|
|
47
|
+
#: () -> String
|
|
48
|
+
def words_kept = window[WORDS] || @text[0, @at_most].to_s
|
|
49
|
+
|
|
50
|
+
# The text's first at_most characters and the one after, so a sentence or word ending at the cap is kept.
|
|
51
|
+
#: () -> String
|
|
52
|
+
def window = @text[0, @at_most + 1].to_s
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../error"
|
|
5
|
+
require_relative "../prose_list"
|
|
6
|
+
require_relative "answer_place"
|
|
7
|
+
require_relative "principle_members"
|
|
8
|
+
require_relative "refusal_before_shape"
|
|
9
|
+
|
|
10
|
+
module Principles
|
|
11
|
+
module Models
|
|
12
|
+
# The members of a principle that name no check, whose assessments take no check_result. An answer is read for
|
|
13
|
+
# one before its shape is checked, since the shape would ask for the command such a check_result lacks, sending
|
|
14
|
+
# the agent to fill in what it should remove (#1088).
|
|
15
|
+
class UncheckedMembers
|
|
16
|
+
include RefusalBeforeShape
|
|
17
|
+
|
|
18
|
+
#: (PrincipleMembers) -> void
|
|
19
|
+
def initialize(members)
|
|
20
|
+
@members = members
|
|
21
|
+
freeze
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Refuses answer when it gives check_result on the assessment of a member with no check. It reads the answer as
|
|
25
|
+
# sent, so it leaves anything malformed to the shape's refusal or the coverage refusal; source is unused, as
|
|
26
|
+
# other refusals before the shape name it.
|
|
27
|
+
# @override
|
|
28
|
+
#: (untyped, String, Array[Hash[String, String]]) -> void
|
|
29
|
+
def refuse_in(answer, _source, _shape_problems)
|
|
30
|
+
assessments = answer["member_assessments"] if answer.is_a?(Hash)
|
|
31
|
+
return unless assessments.is_a?(Array)
|
|
32
|
+
|
|
33
|
+
assessments.each_with_index do |assessment, index|
|
|
34
|
+
next unless stray?(assessment)
|
|
35
|
+
|
|
36
|
+
refuse_at(AnswerPlace.member_assessment(index, assessment["member_id"]), assessment["check_result"])
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Refuses reported, the check_result given on the assessment at place of a member with no check, naming the
|
|
41
|
+
# members that hold the principle's checks, since an agent may have taken this one for one of them (#1090); nil
|
|
42
|
+
# when none is given, as such an assessment should.
|
|
43
|
+
#: (AnswerPlace, untyped) -> nil
|
|
44
|
+
def refuse_at(place, reported)
|
|
45
|
+
return unless reported
|
|
46
|
+
|
|
47
|
+
raise place.child("check_result").refusal(
|
|
48
|
+
Error.new("invalid_check_result", "the member has no check, so its assessment takes no check_result",
|
|
49
|
+
["Remove check_result from this member's assessment.", checked_on].compact.join(" "))
|
|
50
|
+
)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
# The sentence naming the members that hold the principle's checks, or nil when none does.
|
|
56
|
+
#: () -> String?
|
|
57
|
+
def checked_on
|
|
58
|
+
checked = @members.checked_ids
|
|
59
|
+
return if checked.empty?
|
|
60
|
+
|
|
61
|
+
"This principle's #{checked.one? ? "check is" : "checks are"} on #{ProseList.new(checked)}."
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Whether assessment gives a check_result for a mapped member that names no check.
|
|
65
|
+
#: (untyped) -> bool
|
|
66
|
+
def stray?(assessment)
|
|
67
|
+
return false unless assessment.is_a?(Hash) && assessment["check_result"]
|
|
68
|
+
|
|
69
|
+
id = assessment["member_id"]
|
|
70
|
+
return false unless id.is_a?(String)
|
|
71
|
+
|
|
72
|
+
@members.unchecked?(id)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../error"
|
|
5
|
+
|
|
6
|
+
module Principles
|
|
7
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
8
|
+
module Models
|
|
9
|
+
# The files, and the files their links lead to, that differ from HEAD or are not yet committed, as ProjectHistory
|
|
10
|
+
# found them for a write-up or an audit's members, and the refusal each gives while there are any.
|
|
11
|
+
class UncommittedFiles
|
|
12
|
+
# An existing assessment keeps its prepared answer while these whole files are brought back to a commit.
|
|
13
|
+
ASSESSMENT_REPAIR = "An audit requires the whole map and member files to be committed, even when an edit " \
|
|
14
|
+
"is outside a judged passage.\nCommit the intended changes in the named files, then retry " \
|
|
15
|
+
"the same answer unchanged. If that retry is refused as stale, follow its repair to " \
|
|
16
|
+
"start a new audit."
|
|
17
|
+
|
|
18
|
+
#: (Array[String]) -> void
|
|
19
|
+
def initialize(paths)
|
|
20
|
+
@paths = paths
|
|
21
|
+
freeze
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Refuses the write-up at path while it, or a file its links lead to, differs from HEAD: the record is committed
|
|
25
|
+
# pointing at it, so a fresh clone would find nothing there (#760).
|
|
26
|
+
#: (String) -> void
|
|
27
|
+
def refuse_write_up(path)
|
|
28
|
+
return if @paths.empty?
|
|
29
|
+
|
|
30
|
+
linked = @paths - [path]
|
|
31
|
+
raise Error.new("uncommitted_files",
|
|
32
|
+
"The write-up at #{path} differs from the last commit" +
|
|
33
|
+
(linked.empty? ? "" : ", through #{linked.join(", ")}"),
|
|
34
|
+
"The record will point at the write-up as committed.\n" \
|
|
35
|
+
"Commit the write-up, then submit the same answer again.")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Refuses an audit of id while any of its map or members differs from HEAD.
|
|
39
|
+
#: (String) -> void
|
|
40
|
+
def refuse_audit(id)
|
|
41
|
+
return if @paths.empty?
|
|
42
|
+
|
|
43
|
+
raise Error.new("uncommitted_files", "The map or members of #{id} differ from the last commit: " \
|
|
44
|
+
"#{@paths.join(", ")}",
|
|
45
|
+
"An audit assesses the map and members as committed, so its record can name the commit " \
|
|
46
|
+
"it began from.\nCommit them, then start it again: #{Error::EXECUTABLE} start-audit #{id}")
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../error"
|
|
5
|
+
require_relative "meta_principle"
|
|
6
|
+
|
|
7
|
+
module Principles
|
|
8
|
+
module Models
|
|
9
|
+
# An absent principle id, whose repair creates an ordinary map or sets up the keeping principle.
|
|
10
|
+
class UnknownPrinciple
|
|
11
|
+
#: (String) -> void
|
|
12
|
+
def initialize(id)
|
|
13
|
+
@id = id.dup.freeze #: String
|
|
14
|
+
freeze
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
#: () -> Error
|
|
18
|
+
def refusal
|
|
19
|
+
creating = if @id == MetaPrinciple::ID
|
|
20
|
+
MetaPrinciple::SET_UP
|
|
21
|
+
else
|
|
22
|
+
"To create it: #{Error::EXECUTABLE} create-principle #{@id} --description TEXT"
|
|
23
|
+
end
|
|
24
|
+
Error.new("unknown_principle", "No map named #{@id}",
|
|
25
|
+
"#{creating}\nTo see the mapped ids: #{Error::EXECUTABLE} list-principles")
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -55,11 +55,22 @@ module Principles
|
|
|
55
55
|
def to_h
|
|
56
56
|
index = (@first...@last).find { |each| !line(each).blank? } or return nil
|
|
57
57
|
text = opening_text(index)
|
|
58
|
-
{ "text" => text
|
|
58
|
+
{ "text" => cut(text), "line" => index + 1 }.merge(text.length > LIMIT ? { "truncated" => true } : {})
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
private
|
|
62
62
|
|
|
63
|
+
# text whole within the limit, or else up to the last whole word that fits, since a cut mid-word reads as a
|
|
64
|
+
# different phrase (#1078); one word longer than the limit is cut where the limit falls.
|
|
65
|
+
#: (String) -> String
|
|
66
|
+
def cut(text)
|
|
67
|
+
return text if text.length <= LIMIT
|
|
68
|
+
|
|
69
|
+
fits = text[0, LIMIT + 1].to_s
|
|
70
|
+
boundary = fits.rindex(" ") or return fits[0, LIMIT].to_s
|
|
71
|
+
fits[0, boundary].to_s
|
|
72
|
+
end
|
|
73
|
+
|
|
63
74
|
# A heading line whole, since a heading is not a sentence and "F4." may number it (#739). Otherwise the
|
|
64
75
|
# first sentence: hard-wrapped lines joined with single spaces up to the sentence's end, or else to its
|
|
65
76
|
# paragraph's end, a blank line, the next list item or heading, or the file's end. It runs past the region's
|
|
@@ -78,13 +89,19 @@ module Principles
|
|
|
78
89
|
[line(index), *rest].map(&:text)
|
|
79
90
|
end
|
|
80
91
|
|
|
81
|
-
# text up to the end of its first sentence, or all of it when none ends.
|
|
92
|
+
# text up to the end of its first sentence, or all of it when none ends. A mark inside a parenthesis, as in
|
|
93
|
+
# "(e.g. this)", ends no sentence, since cutting there leaves a fragment (#1078).
|
|
82
94
|
#: (String) -> String
|
|
83
95
|
def sentence(text)
|
|
84
|
-
|
|
85
|
-
text[0,
|
|
96
|
+
ends = text.to_enum(:scan, SENTENCE_END).map { Regexp.last_match&.end(0) }
|
|
97
|
+
found = ends.compact.find { |at| closed?(text[0, at].to_s) } or return text
|
|
98
|
+
text[0, found].to_s
|
|
86
99
|
end
|
|
87
100
|
|
|
101
|
+
# Whether every parenthesis opened in text is closed by its end.
|
|
102
|
+
#: (String) -> bool
|
|
103
|
+
def closed?(text) = text.count("(") <= text.count(")")
|
|
104
|
+
|
|
88
105
|
# The line at index, or a blank one past the file's end.
|
|
89
106
|
#: (Integer) -> Line
|
|
90
107
|
def line(index) = @lines[index] || Line.new("")
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Principles
|
|
5
|
+
# The positional words a command takes and the values the invocation gives them, after option parsing.
|
|
6
|
+
class PositionalArguments
|
|
7
|
+
#: (Array[String], Array[String]) -> void
|
|
8
|
+
def initialize(names, values)
|
|
9
|
+
@names = names.dup.freeze #: Array[String]
|
|
10
|
+
@values = values.dup.freeze #: Array[String]
|
|
11
|
+
freeze
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
#: () -> String?
|
|
15
|
+
def id = %w[id id?].include?(@names.first) ? @values.first : nil
|
|
16
|
+
|
|
17
|
+
# Every named argument other than the principle id, as the controller receives it.
|
|
18
|
+
#: () -> Hash[String, untyped]
|
|
19
|
+
def bindings
|
|
20
|
+
bound = @names.zip(@values).to_h.except("id", "id?")
|
|
21
|
+
repeated = @names.last
|
|
22
|
+
return bound unless repeated == "path..."
|
|
23
|
+
|
|
24
|
+
bound.except(repeated).merge("path" => @values.drop(@names.length - 1))
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
#: () -> Array[String]
|
|
28
|
+
def missing = @names.drop(@values.length).reject { |name| name.end_with?("?") }.map(&:upcase)
|
|
29
|
+
|
|
30
|
+
#: () -> bool
|
|
31
|
+
def too_many? = @names.last != "path..." && @values.length > @names.length
|
|
32
|
+
|
|
33
|
+
# The command's positional arguments as usage shows them, optional ones in brackets.
|
|
34
|
+
#: () -> String
|
|
35
|
+
def shown = @names.map { |name| name.end_with?("?") ? "[#{name.chomp("?").upcase}]" : name.upcase }.join(" ")
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -8,7 +8,7 @@ module Principles
|
|
|
8
8
|
# is wrong with it as given, which CommandLine refuses as a usage error.
|
|
9
9
|
class SessionStartOptions
|
|
10
10
|
# The sources Claude Code's SessionStart hook names.
|
|
11
|
-
SOURCES = %w[startup clear compact].freeze #: Array[String]
|
|
11
|
+
SOURCES = %w[startup resume clear compact].freeze #: Array[String]
|
|
12
12
|
|
|
13
13
|
#: (InvocationOptions) -> void
|
|
14
14
|
def initialize(options)
|
|
@@ -21,7 +21,7 @@ module Principles
|
|
|
21
21
|
#: () -> String?
|
|
22
22
|
def fault
|
|
23
23
|
start = @start or return
|
|
24
|
-
return "--session-start takes startup, clear or compact, not #{start}" unless SOURCES.include?(start)
|
|
24
|
+
return "--session-start takes startup, resume, clear or compact, not #{start}" unless SOURCES.include?(start)
|
|
25
25
|
|
|
26
26
|
"--session-start words only the --short line" unless @short
|
|
27
27
|
end
|
|
@@ -12,6 +12,7 @@ module Principles
|
|
|
12
12
|
@member = !options.value("member").nil? #: bool
|
|
13
13
|
@write_ups = !options.value("write_ups").nil? #: bool
|
|
14
14
|
@form = options.value("as") #: String?
|
|
15
|
+
@instruction = !options.value("instruction").nil? #: bool
|
|
15
16
|
freeze
|
|
16
17
|
end
|
|
17
18
|
|
|
@@ -20,18 +21,32 @@ module Principles
|
|
|
20
21
|
def fault
|
|
21
22
|
return "--member and --write-ups each start a different audit; give one" if @member && @write_ups
|
|
22
23
|
|
|
23
|
-
form_fault
|
|
24
|
+
instruction_fault || form_fault
|
|
24
25
|
end
|
|
25
26
|
|
|
26
27
|
private
|
|
27
28
|
|
|
28
|
-
# --
|
|
29
|
+
# --instruction prints one field of a full audit's request whole (D81 step 2); nil when nothing beside it prints
|
|
30
|
+
# another output.
|
|
31
|
+
#: () -> String?
|
|
32
|
+
def instruction_fault
|
|
33
|
+
return unless @instruction
|
|
34
|
+
|
|
35
|
+
other = if @form then "the answer --as template prints"
|
|
36
|
+
elsif @member then "the one-member audit --member starts"
|
|
37
|
+
elsif @write_ups then "the repoint --write-ups starts"
|
|
38
|
+
end
|
|
39
|
+
"--instruction prints one field of a full audit's request, not of #{other}" if other
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# --as template prints a full audit's answer alone (D81 step 1), or a one-member audit's (#773), the one form
|
|
43
|
+
# built so far; nil when it fits.
|
|
29
44
|
#: () -> String?
|
|
30
45
|
def form_fault
|
|
31
46
|
form = @form or return
|
|
32
|
-
return "--as takes template, the
|
|
47
|
+
return "--as takes template, the answer alone, not #{form}" unless form == "template"
|
|
33
48
|
|
|
34
|
-
"--as template prints a full audit's answer, not one --
|
|
49
|
+
"--as template prints a full or one-member audit's answer, not one --write-ups starts" if @write_ups
|
|
35
50
|
end
|
|
36
51
|
end
|
|
37
52
|
end
|
data/lib/principles/version.rb
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
module Principles
|
|
5
5
|
# The next production release, as major.minor.patch. A production build is versioned with this alone.
|
|
6
|
-
RELEASE = "0.0.
|
|
6
|
+
RELEASE = "0.0.6"
|
|
7
7
|
# The version a built gem prints. `rake build[production]` stamps RELEASE here, in the copy of lib/ it
|
|
8
8
|
# packages, and `rake build[development]` stamps RELEASE.g<short sha>. A checkout leaves it nil, and
|
|
9
9
|
# Data::RunningVersion reads the commit this tool runs from instead.
|
|
10
|
-
BUILT_VERSION = "0.0.
|
|
10
|
+
BUILT_VERSION = "0.0.6" #: String?
|
|
11
11
|
end
|