principles 0.0.9 → 0.0.11
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 +17 -0
- data/README.md +3 -3
- data/lib/principles/controllers/acknowledgement.rb +11 -4
- data/lib/principles/controllers/acknowledgements.rb +4 -4
- data/lib/principles/controllers/assessment.rb +1 -1
- data/lib/principles/controllers/audit.rb +2 -1
- data/lib/principles/controllers/broken_member_repairs.rb +60 -0
- data/lib/principles/controllers/command.rb +8 -30
- data/lib/principles/controllers/correction.rb +7 -5
- data/lib/principles/controllers/full_audit_request.rb +32 -16
- data/lib/principles/controllers/inventory.rb +3 -3
- data/lib/principles/controllers/member_acknowledgement.rb +5 -5
- data/lib/principles/controllers/member_addition.rb +1 -1
- data/lib/principles/controllers/member_entries.rb +1 -1
- data/lib/principles/controllers/member_problems_report.rb +6 -9
- data/lib/principles/controllers/members_to_assess.rb +1 -1
- data/lib/principles/controllers/meta_principle_setup.rb +4 -3
- data/lib/principles/controllers/open_correction.rb +3 -3
- data/lib/principles/data/command-steps.json +4 -4
- data/lib/principles/data/repository.rb +4 -4
- data/lib/principles/data/running_version.rb +1 -1
- data/lib/principles/data/schemas/command-steps.schema.json +1 -1
- data/lib/principles/invocation_options.rb +4 -4
- data/lib/principles/models/acknowledgement.rb +1 -27
- data/lib/principles/models/acknowledgement_left_as_printed.rb +2 -1
- data/lib/principles/models/acknowledgement_placeholders.rb +48 -0
- data/lib/principles/models/assessment_answer.rb +2 -2
- data/lib/principles/models/assessment_left_as_printed.rb +1 -1
- data/lib/principles/models/audit.rb +1 -1
- data/lib/principles/models/audit_records.rb +1 -1
- data/lib/principles/models/candidate_inventory.rb +1 -1
- data/lib/principles/models/disposition.rb +12 -76
- data/lib/principles/models/disposition_placeholders.rb +48 -0
- data/lib/principles/models/disposition_text_field.rb +41 -0
- data/lib/principles/models/evidence_item.rb +1 -1
- data/lib/principles/models/findings_left_open.rb +3 -3
- data/lib/principles/models/fix_only_fields.rb +4 -3
- data/lib/principles/models/located_text.rb +19 -11
- data/lib/principles/models/member_assessments.rb +11 -4
- data/lib/principles/models/member_file.rb +9 -12
- data/lib/principles/models/member_mapping_run.rb +1 -1
- data/lib/principles/models/member_repair_moves.rb +20 -4
- data/lib/principles/models/member_snapshots.rb +10 -10
- data/lib/principles/models/members_sharing_lines.rb +1 -1
- data/lib/principles/models/misspelt_member_id.rb +9 -3
- data/lib/principles/models/named_placeholder.rb +32 -0
- data/lib/principles/models/open_finding.rb +0 -4
- data/lib/principles/models/other_templates_placeholders.rb +25 -6
- data/lib/principles/models/principle_history.rb +4 -3
- data/lib/principles/models/project.rb +7 -13
- data/lib/principles/models/project_at_commit.rb +70 -0
- data/lib/principles/models/project_history.rb +10 -52
- data/lib/principles/models/sent_answer.rb +4 -3
- data/lib/principles/models/template_placeholders.rb +22 -7
- data/lib/principles/models/text_size.rb +11 -3
- data/lib/principles/models/unfinished_field.rb +34 -0
- data/lib/principles/start_audit_options.rb +10 -2
- data/lib/principles/version.rb +2 -2
- data/lib/principles/views/acknowledged_result.rb +59 -0
- data/lib/principles/views/acknowledgement_result.rb +32 -42
- data/lib/principles/views/answer_in_a_file.rb +53 -0
- data/lib/principles/views/assessed_members.rb +4 -2
- data/lib/principles/views/audit_result.rb +3 -1
- data/lib/principles/views/context_parts.rb +1 -1
- data/lib/principles/views/correction_request.rb +19 -13
- data/lib/principles/views/member_repairs.rb +21 -5
- data/lib/principles/views/meta_principle_result.rb +26 -5
- data/lib/principles/views/open_findings_line.rb +69 -28
- data/lib/principles/views/parts_index_result.rb +8 -6
- data/lib/principles/views/principle_read_result.rb +2 -2
- data/lib/principles/views/problem_lines.rb +22 -27
- data/lib/principles/views/problem_result.rb +11 -0
- data/lib/principles/views/prompts/answer-any-judgement-request/fill-the-answer-in-a-file.md +6 -0
- data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +1 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/change-member-check.md +4 -3
- data/lib/principles/views/prompts/learn-what-a-command-does/change-member-role.md +4 -3
- data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +7 -8
- data/lib/principles/views/prompts/learn-what-a-command-does/move-member.md +4 -3
- data/lib/principles/views/prompts/learn-what-a-command-does/remove-member-check.md +4 -3
- data/lib/principles/views/prompts/learn-what-a-command-does/remove-member.md +4 -3
- data/lib/principles/views/prompts/learn-what-a-command-does/report-at-session-start.md +15 -16
- data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +5 -5
- data/lib/principles/views/prompts/start-a-session/act-on-the-changed-members.md +2 -0
- data/lib/principles/views/prompts/start-a-session/act-on-the-changed-principles.md +2 -0
- data/lib/principles/views/prompts.rb +7 -4
- data/principles.gemspec +2 -2
- metadata +17 -6
- data/lib/principles/views/prompts/start-a-session/run-each-command-above.md +0 -1
- data/lib/principles/views/prompts/start-a-session/start-with-the-principles-skill.md +0 -1
|
@@ -13,13 +13,21 @@ module Principles
|
|
|
13
13
|
freeze
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
# Its bytes, none for a text not measured.
|
|
17
|
+
#: () -> Integer
|
|
18
|
+
def bytes = @text.to_s.bytesize
|
|
19
|
+
|
|
20
|
+
# Its tokens, estimated as characters / 4, rounded up; none for a text not measured.
|
|
21
|
+
#: () -> Integer
|
|
22
|
+
def estimated_tokens = (@text.to_s.length / 4.0).ceil
|
|
23
|
+
|
|
16
24
|
# The size under fields' two names, its bytes then its tokens; empty when there is no text.
|
|
17
25
|
#: ([String, String]) -> Hash[String, Integer]
|
|
18
26
|
def under(fields)
|
|
19
|
-
|
|
27
|
+
return {} unless @text
|
|
20
28
|
|
|
21
|
-
|
|
22
|
-
{
|
|
29
|
+
bytes_field, tokens_field = fields
|
|
30
|
+
{ bytes_field => bytes, tokens_field => estimated_tokens }
|
|
23
31
|
end
|
|
24
32
|
end
|
|
25
33
|
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "answer_place"
|
|
5
|
+
|
|
6
|
+
module Principles
|
|
7
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
8
|
+
module Models
|
|
9
|
+
# A field the agent left unfinished: empty, the template's placeholder, the answer guide's sample, or
|
|
10
|
+
# an action not one of the four. It says where it sits in the answer and what to write there, which one
|
|
11
|
+
# refusal lists beside every other.
|
|
12
|
+
class UnfinishedField
|
|
13
|
+
#: String
|
|
14
|
+
attr_reader :repair
|
|
15
|
+
|
|
16
|
+
#: (AnswerPlace, String, problem: String, repair: String) -> void
|
|
17
|
+
def initialize(place, name, problem:, repair:)
|
|
18
|
+
@place = place
|
|
19
|
+
@name = name
|
|
20
|
+
@problem = problem
|
|
21
|
+
@repair = repair
|
|
22
|
+
freeze
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Whose field it is, such as "Finding F1 reason".
|
|
26
|
+
#: () -> String
|
|
27
|
+
def to_s = "#{@place.subject} #{@name}"
|
|
28
|
+
|
|
29
|
+
# Its entry in the refusal's fields, as a malformed answer's are.
|
|
30
|
+
#: () -> Hash[String, String]
|
|
31
|
+
def field = { "pointer" => @place.pointer, "problem" => @problem }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -7,6 +7,9 @@ module Principles
|
|
|
7
7
|
# The options that choose which audit start-audit begins, --member and --write-ups, and the form --as prints
|
|
8
8
|
# it in, and what is wrong with them as given, which CommandLine refuses as a usage error.
|
|
9
9
|
class StartAuditOptions
|
|
10
|
+
# The part that prints the answer to fill bare, saved as it stands, so no other part may print beside it.
|
|
11
|
+
TEMPLATE_PART = "response_template" #: String
|
|
12
|
+
|
|
10
13
|
# several_ids is whether start-audit was given more than one principle id.
|
|
11
14
|
#: (InvocationOptions, ?several_ids: bool) -> void
|
|
12
15
|
def initialize(options, several_ids: false)
|
|
@@ -16,7 +19,8 @@ module Principles
|
|
|
16
19
|
@write_ups = !options.value("write_ups").nil? #: bool
|
|
17
20
|
@form = options.value("as") #: String?
|
|
18
21
|
@instruction = !options.value("instruction").nil? #: bool
|
|
19
|
-
@
|
|
22
|
+
@parts = options.value("part") || [] #: Array[String]
|
|
23
|
+
@part = !@parts.empty? #: bool
|
|
20
24
|
freeze
|
|
21
25
|
end
|
|
22
26
|
|
|
@@ -53,7 +57,11 @@ module Principles
|
|
|
53
57
|
return unless @part
|
|
54
58
|
|
|
55
59
|
other = other_audit || ("the whole field --instruction prints" if @instruction)
|
|
56
|
-
"--part prints one part of a full audit's request, not of #{other}" if other
|
|
60
|
+
return "--part prints one part of a full audit's request, not of #{other}" if other
|
|
61
|
+
|
|
62
|
+
return unless @parts.include?(TEMPLATE_PART) && @parts.size > 1
|
|
63
|
+
|
|
64
|
+
"--part #{TEMPLATE_PART} prints the bare answer to save as it stands; give it alone"
|
|
57
65
|
end
|
|
58
66
|
|
|
59
67
|
# --instruction prints one field of a full audit's request whole; nil when nothing beside it prints
|
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.11"
|
|
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.11" #: String?
|
|
11
11
|
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "answered_request"
|
|
5
|
+
require_relative "invocation"
|
|
6
|
+
require_relative "../prose_list"
|
|
7
|
+
|
|
8
|
+
module Principles
|
|
9
|
+
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
10
|
+
module Views
|
|
11
|
+
# An acknowledgement's answer accepted: the members that now read as judged, the files that hold them to
|
|
12
|
+
# commit, and the command that no longer lists them.
|
|
13
|
+
class AcknowledgedResult
|
|
14
|
+
#: (Invocation) -> void
|
|
15
|
+
def initialize(invocation)
|
|
16
|
+
@invocation = invocation
|
|
17
|
+
freeze
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# The acknowledgement of each of member_ids was accepted, and file holds them all.
|
|
21
|
+
#: (principle_id: String, member_ids: Array[String], file: String) -> AnsweredRequest
|
|
22
|
+
def several_acknowledged(principle_id:, member_ids:, file:)
|
|
23
|
+
AnsweredRequest.new(
|
|
24
|
+
"status" => "acknowledged", "principle_id" => principle_id, "member_ids" => member_ids,
|
|
25
|
+
"files_to_commit" => [file],
|
|
26
|
+
"next_action" => "Commit #{file}. #{ProseList.new(member_ids)} read as judged until each is edited again.\n" \
|
|
27
|
+
"This no longer lists them: " \
|
|
28
|
+
"#{@invocation.in_project("list-member-problems", principle_id, usage: "--short")}"
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# The acknowledgement of each of member_ids was accepted for every principle that maps it, each principle's in its
|
|
33
|
+
# file, under its id in files.
|
|
34
|
+
#: (member_ids: Array[String], files: Hash[String, String]) -> AnsweredRequest
|
|
35
|
+
def across_acknowledged(member_ids:, files:)
|
|
36
|
+
AnsweredRequest.new(
|
|
37
|
+
"status" => "acknowledged", "principle_ids" => files.keys, "member_ids" => member_ids,
|
|
38
|
+
"files_to_commit" => files.values,
|
|
39
|
+
"next_action" => "Commit #{ProseList.new(files.values)}. #{ProseList.new(member_ids)} read as judged until " \
|
|
40
|
+
"each is edited again.\nThis no longer lists them: " \
|
|
41
|
+
"#{@invocation.in_project("list-member-problems", usage: "--short")}"
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# The acknowledgement was accepted and file holds it.
|
|
46
|
+
#: (principle_id: String, member_id: String, file: String) -> AnsweredRequest
|
|
47
|
+
def acknowledged(principle_id:, member_id:, file:)
|
|
48
|
+
fields = {
|
|
49
|
+
"status" => "acknowledged", "principle_id" => principle_id, "member_ids" => [member_id],
|
|
50
|
+
"files_to_commit" => [file],
|
|
51
|
+
"next_action" => "Commit #{file}. #{member_id} reads as judged until it is edited again.\n" \
|
|
52
|
+
"This no longer lists it: " \
|
|
53
|
+
"#{@invocation.in_project("list-member-problems", principle_id, usage: "--short")}"
|
|
54
|
+
}
|
|
55
|
+
AnsweredRequest.new(fields)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
# typed: strict
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
+
require_relative "answer_in_a_file"
|
|
4
5
|
require_relative "invocation"
|
|
5
|
-
require_relative "answered_request"
|
|
6
6
|
require_relative "member_change_since_baseline"
|
|
7
7
|
require_relative "prompts"
|
|
8
|
-
require_relative "../prose_list"
|
|
9
8
|
|
|
10
9
|
module Principles
|
|
11
10
|
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
12
11
|
module Views
|
|
13
12
|
# A one-member audit's request and its result.
|
|
14
13
|
class AcknowledgementResult
|
|
14
|
+
# Where a placeholder names the member of the entry it prints in.
|
|
15
|
+
SLOT = "%<id>s" #: String
|
|
16
|
+
|
|
15
17
|
#: (Invocation) -> void
|
|
16
18
|
def initialize(invocation)
|
|
17
19
|
@invocation = invocation
|
|
@@ -28,7 +30,8 @@ module Principles
|
|
|
28
30
|
"context" => { "principle_id" => principle_id, **asked.fetch(:change).to_h, **asked.fetch(:context),
|
|
29
31
|
"question" => Prompts.text("acknowledge-a-change/say-whether-the-change-keeps-the-meaning") },
|
|
30
32
|
"response_template" => answer_to_fill(request_id:, asked:),
|
|
31
|
-
"answer_with" => @invocation.submit_answer(request_id)
|
|
33
|
+
"answer_with" => @invocation.submit_answer(request_id),
|
|
34
|
+
"next_action" => to_fill([principle_id], [asked.fetch(:change).member_id], request_id:) }
|
|
32
35
|
end
|
|
33
36
|
|
|
34
37
|
# The answer to the request request_id names, to fill: the request prints it as response_template, and
|
|
@@ -39,7 +42,7 @@ module Principles
|
|
|
39
42
|
def answer_to_fill(request_id:, asked:)
|
|
40
43
|
member_id = asked.fetch(:change).member_id
|
|
41
44
|
{ "request_id" => request_id, "basis" => { "member_ids" => [member_id] },
|
|
42
|
-
"members" => { member_id => asked.fetch(:placeholders) } }
|
|
45
|
+
"members" => { member_id => named(asked.fetch(:placeholders), member_id) } }
|
|
43
46
|
end
|
|
44
47
|
|
|
45
48
|
# The request for several members' acknowledgements in one answer: each of members holds a member's
|
|
@@ -52,7 +55,8 @@ module Principles
|
|
|
52
55
|
"members" => shown(members),
|
|
53
56
|
"question" => Prompts.text("acknowledge-a-change/say-whether-each-change-keeps-its-meaning") },
|
|
54
57
|
"response_template" => several_to_fill(request_id:, members:),
|
|
55
|
-
"answer_with" => @invocation.submit_answer(request_id)
|
|
58
|
+
"answer_with" => @invocation.submit_answer(request_id),
|
|
59
|
+
"next_action" => to_fill([principle_id], members.map { it.fetch(:change).member_id }, request_id:) }
|
|
56
60
|
end
|
|
57
61
|
|
|
58
62
|
# The answer to the request for several members request_id names, to fill: its basis names each member, and
|
|
@@ -60,7 +64,7 @@ module Principles
|
|
|
60
64
|
#: (request_id: String, members: Array[Hash[Symbol, untyped]]) -> Hash[String, untyped]
|
|
61
65
|
def several_to_fill(request_id:, members:)
|
|
62
66
|
{ "request_id" => request_id, "basis" => { "member_ids" => members.map { it.fetch(:change).member_id } },
|
|
63
|
-
"members" => members.to_h {
|
|
67
|
+
"members" => members.to_h { named_entry(it) } }
|
|
64
68
|
end
|
|
65
69
|
|
|
66
70
|
# The request for the members several principles map in one answer: under context.principles, each
|
|
@@ -74,7 +78,8 @@ module Principles
|
|
|
74
78
|
"context" => { "principles" => shown_once(principles),
|
|
75
79
|
**deferred_findings_kept(keeping_deferred), "question" => across_question },
|
|
76
80
|
"response_template" => across_to_fill(request_id:, principles:),
|
|
77
|
-
"answer_with" => @invocation.submit_answer(request_id)
|
|
81
|
+
"answer_with" => @invocation.submit_answer(request_id),
|
|
82
|
+
"next_action" => to_fill(principles.keys.uniq.sort, across_member_ids(principles), request_id:) }
|
|
78
83
|
end
|
|
79
84
|
|
|
80
85
|
# The answer to the request for the members several principles map, to fill: its basis names each principle and
|
|
@@ -85,51 +90,36 @@ module Principles
|
|
|
85
90
|
def across_to_fill(request_id:, principles:)
|
|
86
91
|
entries = principles.values.flatten.each_with_object({}) do |asked, by_member|
|
|
87
92
|
id = asked.fetch(:change).member_id
|
|
88
|
-
by_member[id] = asked.fetch(:placeholders).merge(by_member.fetch(id, {}))
|
|
93
|
+
by_member[id] = named(asked.fetch(:placeholders), id).merge(by_member.fetch(id, {}))
|
|
89
94
|
end
|
|
90
95
|
{ "request_id" => request_id, "basis" => { "principle_ids" => principles.keys, "member_ids" => entries.keys },
|
|
91
96
|
"members" => entries }
|
|
92
97
|
end
|
|
93
98
|
|
|
94
|
-
|
|
95
|
-
#: (principle_id: String, member_ids: Array[String], file: String) -> AnsweredRequest
|
|
96
|
-
def several_acknowledged(principle_id:, member_ids:, file:)
|
|
97
|
-
AnsweredRequest.new(
|
|
98
|
-
"status" => "acknowledged", "principle_id" => principle_id, "member_ids" => member_ids,
|
|
99
|
-
"files_to_commit" => [file],
|
|
100
|
-
"next_action" => "Commit #{file}. #{ProseList.new(member_ids)} read as judged until each is edited again.\n" \
|
|
101
|
-
"This no longer lists them: " \
|
|
102
|
-
"#{@invocation.in_project("list-member-problems", principle_id, usage: "--short")}"
|
|
103
|
-
)
|
|
104
|
-
end
|
|
99
|
+
private
|
|
105
100
|
|
|
106
|
-
#
|
|
107
|
-
#
|
|
108
|
-
#: (
|
|
109
|
-
def
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
)
|
|
101
|
+
# placeholders with each one's SLOT naming the member id, as its entry in the template prints them; any other
|
|
102
|
+
# text, a percent sign included, as it is.
|
|
103
|
+
#: (Hash[String, untyped], String) -> Hash[String, untyped]
|
|
104
|
+
def named(placeholders, id) = placeholders.transform_values { it.is_a?(String) ? it.gsub(SLOT, id) : it }
|
|
105
|
+
|
|
106
|
+
# The template's entry for the member asked asks about, by its id.
|
|
107
|
+
#: (Hash[Symbol, untyped]) -> [String, Hash[String, untyped]]
|
|
108
|
+
def named_entry(asked)
|
|
109
|
+
id = asked.fetch(:change).member_id
|
|
110
|
+
[id, named(asked.fetch(:placeholders), id)]
|
|
117
111
|
end
|
|
118
112
|
|
|
119
|
-
#
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
"files_to_commit" => [file],
|
|
125
|
-
"next_action" => "Commit #{file}. #{member_id} reads as judged until it is edited again.\n" \
|
|
126
|
-
"This no longer lists it: " \
|
|
127
|
-
"#{@invocation.in_project("list-member-problems", principle_id, usage: "--short")}"
|
|
128
|
-
}
|
|
129
|
-
AnsweredRequest.new(fields)
|
|
113
|
+
# How to fill the answer to request_id, acknowledging member_ids of principle_ids: saved bare from
|
|
114
|
+
# start-audit --as template to a file the agent edits.
|
|
115
|
+
#: (Array[String], Array[String], request_id: String) -> String
|
|
116
|
+
def to_fill(principle_ids, member_ids, request_id:)
|
|
117
|
+
AnswerInAFile.new(@invocation).acknowledgement(principle_ids, member_ids, request_id:)
|
|
130
118
|
end
|
|
131
119
|
|
|
132
|
-
|
|
120
|
+
# Each member the principles' requests ask about, once, in the order they ask.
|
|
121
|
+
#: (Hash[String, Array[Hash[Symbol, untyped]]]) -> Array[String]
|
|
122
|
+
def across_member_ids(principles) = principles.values.flatten.map { it.fetch(:change).member_id }.uniq
|
|
133
123
|
|
|
134
124
|
# Where to read the deferred findings an acknowledgement across principles keeps, and the full audit of each
|
|
135
125
|
# principle in ids that resolves them, one command to a line; nothing when ids is empty.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "context_parts"
|
|
5
|
+
require_relative "invocation"
|
|
6
|
+
require_relative "prompts"
|
|
7
|
+
|
|
8
|
+
module Principles
|
|
9
|
+
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
10
|
+
module Views
|
|
11
|
+
# How to fill an answer this tool prints bare: save it to a file outside the project, fill it there with the
|
|
12
|
+
# agent's own file-edit tool, and submit that file, with the three characters JSON escapes. Filling a template
|
|
13
|
+
# in a shell heredoc took a script, since prose full of quotes needed escaping for the shell and for JSON.
|
|
14
|
+
class AnswerInAFile
|
|
15
|
+
#: (Invocation) -> void
|
|
16
|
+
def initialize(invocation)
|
|
17
|
+
@invocation = invocation
|
|
18
|
+
freeze
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# The line for a full audit's assessment, whose answer start-audit --part response_template prints bare.
|
|
22
|
+
#: (String, request_id: String) -> String
|
|
23
|
+
def assessment(principle_id, request_id:)
|
|
24
|
+
line(@invocation.in_project("start-audit", principle_id, options: ["--part", ContextParts::TEMPLATE]),
|
|
25
|
+
request_id:)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# The line for acknowledging member_ids of principle_ids, whose answer start-audit --member --as template prints
|
|
29
|
+
# bare.
|
|
30
|
+
#: (Array[String], Array[String], request_id: String) -> String
|
|
31
|
+
def acknowledgement(principle_ids, member_ids, request_id:)
|
|
32
|
+
named = member_ids.flat_map { ["--member", it] }
|
|
33
|
+
line(@invocation.listed_in_project("start-audit", principle_ids, options: [*named, "--as", "template"]),
|
|
34
|
+
request_id:)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# The line for an open correction, whose answer show-open-correction prints bare, of which only the
|
|
38
|
+
# dispositions are the agent's to fill.
|
|
39
|
+
#: (String, request_id: String) -> String
|
|
40
|
+
def correction(principle_id, request_id:)
|
|
41
|
+
line(@invocation.in_project("show-open-correction", principle_id), request_id:, what: "only its dispositions")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# The line for the answer request_id names, which the printed command save prints bare; what is the part of it
|
|
45
|
+
# the agent fills.
|
|
46
|
+
#: (String, request_id: String, ?what: String) -> String
|
|
47
|
+
def line(save, request_id:, what: "it")
|
|
48
|
+
Prompts.text("answer-any-judgement-request/fill-the-answer-in-a-file",
|
|
49
|
+
save:, what:, answer_with: @invocation.submit_answer(request_id))
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -18,7 +18,8 @@ module Principles
|
|
|
18
18
|
# reviewed_check_placeholders is the text a checked member's template prints in each field it may leave as
|
|
19
19
|
# printed to give none, for a check reviewed before it runs; unchanged_check_placeholders, for one the
|
|
20
20
|
# last audit ran.
|
|
21
|
-
# assessment_placeholder is the text a fresh member's assessment prints, which an answer may not send back
|
|
21
|
+
# assessment_placeholder is the text a fresh member's assessment prints, which an answer may not send back, its
|
|
22
|
+
# %<id>s filled with the member's id, so each slot's is its own and one edit fills one slot.
|
|
22
23
|
#: (Array[Hash[String, untyped]], reviewed_check_placeholders: Hash[String, String],
|
|
23
24
|
#| unchanged_check_placeholders: Hash[String, String], assessment_placeholder: String) -> void
|
|
24
25
|
def initialize(members, reviewed_check_placeholders:, unchanged_check_placeholders:, assessment_placeholder:)
|
|
@@ -151,7 +152,8 @@ module Principles
|
|
|
151
152
|
|
|
152
153
|
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
153
154
|
def fresh(member)
|
|
154
|
-
|
|
155
|
+
id = member.fetch("id")
|
|
156
|
+
{ "member_id" => id, "assessment" => format(@assessment_placeholder, id:),
|
|
155
157
|
"delivery" => "not_observed", "evidence" => member.fetch("evidence") }
|
|
156
158
|
end
|
|
157
159
|
end
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require_relative "assessment_request"
|
|
5
|
+
require_relative "answer_in_a_file"
|
|
5
6
|
require_relative "answered_request"
|
|
6
7
|
require_relative "audit_changes"
|
|
7
8
|
require_relative "completed_audit_next_step"
|
|
@@ -101,7 +102,8 @@ module Principles
|
|
|
101
102
|
output = judgement("assessment", request, { "read_in_parts" => read_in_parts(request.principle_id) },
|
|
102
103
|
to_fill: { "response_template" => request.template })
|
|
103
104
|
note = TrimmedInstructionsNote.new(request.trimmed_instruction_fields).to_h
|
|
104
|
-
|
|
105
|
+
fill = AnswerInAFile.new(@invocation).assessment(request.principle_id, request_id: request.request_id)
|
|
106
|
+
output.merge("context" => output.fetch("context").merge(note), "next_action" => fill)
|
|
105
107
|
end
|
|
106
108
|
|
|
107
109
|
# start-audit --as template: the assessment's answer alone, to fill and submit.
|
|
@@ -60,7 +60,7 @@ module Principles
|
|
|
60
60
|
def shown(name)
|
|
61
61
|
return { INDEX => index } if name == INDEX
|
|
62
62
|
return EMPTY if left_out.include?(name)
|
|
63
|
-
return
|
|
63
|
+
return @template if name == TEMPLATE
|
|
64
64
|
return { name => @context.fetch(name) } unless name.start_with?(MEMBER)
|
|
65
65
|
|
|
66
66
|
id = name.delete_prefix(MEMBER)
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require_relative "answer_head"
|
|
5
|
+
require_relative "answer_in_a_file"
|
|
5
6
|
require_relative "invocation"
|
|
6
7
|
require_relative "prompts"
|
|
7
8
|
|
|
@@ -12,7 +13,8 @@ module Principles
|
|
|
12
13
|
# every disposition's shape, and what submitting the assessment stored.
|
|
13
14
|
class CorrectionRequest
|
|
14
15
|
# head is what the answer hands back unchanged, the request's id and the basis the correction depends on;
|
|
15
|
-
# placeholders is the text the template leaves in each field the agent writes
|
|
16
|
+
# placeholders is the text the template leaves in each field the agent writes, with %<id>s where each
|
|
17
|
+
# disposition names its finding.
|
|
16
18
|
#: (head: AnswerHead, principle_id: String, findings: Array[untyped], placeholders: Hash[String, String]) -> void
|
|
17
19
|
def initialize(head:, principle_id:, findings:, placeholders:)
|
|
18
20
|
@head = head
|
|
@@ -31,7 +33,15 @@ module Principles
|
|
|
31
33
|
def context
|
|
32
34
|
{ "principle_id" => @principle_id, "findings" => @findings,
|
|
33
35
|
"question" => Prompts.text("dispose-of-each-finding/fix-or-record-each-finding"),
|
|
34
|
-
"answer_guide" =>
|
|
36
|
+
"answer_guide" => self.class.answer_guide(@placeholders.fetch("reason")) }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# The guide to every disposition's shape, whose deferred sample's reason is reason_placeholder, the template's,
|
|
40
|
+
# its slot filled for no one finding, as the guide speaks of any.
|
|
41
|
+
#: (String) -> Hash[String, untyped]
|
|
42
|
+
def self.answer_guide(reason_placeholder)
|
|
43
|
+
Prompts.data("dispose-of-each-finding/answer-guide",
|
|
44
|
+
reason_placeholder: format(reason_placeholder, id: "this finding"))
|
|
35
45
|
end
|
|
36
46
|
|
|
37
47
|
# The answer to fill in, as show-open-correction and show-answer-check --as template print it alone: one
|
|
@@ -40,10 +50,11 @@ module Principles
|
|
|
40
50
|
#: () -> Hash[String, untyped]
|
|
41
51
|
def template
|
|
42
52
|
@head.leading("dispositions" => @findings.map do |finding|
|
|
43
|
-
{
|
|
44
|
-
|
|
53
|
+
named = @placeholders.transform_values { format(it, id: finding["id"]) }
|
|
54
|
+
{ "finding_id" => finding["id"], "action" => named.fetch("action"),
|
|
55
|
+
"reason" => named.fetch("reason"), "changed_members" => [], "removed_members" => [],
|
|
45
56
|
"evidence" => [],
|
|
46
|
-
"reassessment" =>
|
|
57
|
+
"reassessment" => named.fetch("reassessment"), "recorded_at" => nil, "waits_on" => nil }
|
|
47
58
|
end)
|
|
48
59
|
end
|
|
49
60
|
|
|
@@ -69,15 +80,10 @@ module Principles
|
|
|
69
80
|
"next_action" => "#{save}\n#{acceptable.fetch("next_action")}")
|
|
70
81
|
end
|
|
71
82
|
|
|
72
|
-
# How to fill the correction by hand: save its answer alone, which show-open-correction prints from the
|
|
73
|
-
# record, to a file, fill only its dispositions there, and submit that file.
|
|
83
|
+
# How to fill the correction by hand: save its answer alone, which show-open-correction prints bare from the
|
|
84
|
+
# open record, to a file, fill only its dispositions there with a file-edit tool, and submit that file.
|
|
74
85
|
#: (Invocation) -> String
|
|
75
|
-
def to_fill_by_hand(invocation)
|
|
76
|
-
"Save the correction's answer alone in a file outside the project, such as under $TMPDIR, from this " \
|
|
77
|
-
"command's output, which prints it again from the open record whenever you need it: " \
|
|
78
|
-
"#{invocation.in_project("show-open-correction", @principle_id)}\nEdit only its dispositions in that " \
|
|
79
|
-
"file, then submit it: #{invocation.submit_answer(request_id)}"
|
|
80
|
-
end
|
|
86
|
+
def to_fill_by_hand(invocation) = AnswerInAFile.new(invocation).correction(@principle_id, request_id:)
|
|
81
87
|
|
|
82
88
|
# What to keep while the correction is open, and the read-only command that prints its answer again from the
|
|
83
89
|
# open record, in git or outside it.
|
|
@@ -17,6 +17,22 @@ module Principles
|
|
|
17
17
|
"ending_at" => "NEW_ENDING_TEXT", "query" => "QUERY",
|
|
18
18
|
"path" => "NEW_PATH" }.freeze #: Hash[String, String]
|
|
19
19
|
|
|
20
|
+
# One move that may repair the member: the locator fields it keeps, by name, and those the agent fills in.
|
|
21
|
+
class Move
|
|
22
|
+
#: Hash[String, String]
|
|
23
|
+
attr_reader :keep
|
|
24
|
+
|
|
25
|
+
#: Array[String]
|
|
26
|
+
attr_reader :fill
|
|
27
|
+
|
|
28
|
+
#: (keep: Hash[String, String], fill: Array[String]) -> void
|
|
29
|
+
def initialize(keep:, fill:)
|
|
30
|
+
@keep = keep
|
|
31
|
+
@fill = fill
|
|
32
|
+
freeze
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
20
36
|
#: (Invocation) -> void
|
|
21
37
|
def initialize(invocation)
|
|
22
38
|
@invocation = invocation
|
|
@@ -25,14 +41,14 @@ module Principles
|
|
|
25
41
|
|
|
26
42
|
# The repairs for member_id of principle id: each of moves, as Models::MemberRepairMoves gives them, the locator
|
|
27
43
|
# fields it keeps and those to fill in, as a copyable move-member, then remove-member.
|
|
28
|
-
#: (String, String, Array[
|
|
44
|
+
#: (String, String, Array[Move]) -> Array[String]
|
|
29
45
|
def commands(id, member_id, moves)
|
|
30
46
|
[*moves.map { move(id, member_id, it) }, @invocation.in_project("remove-member", id, member_id)]
|
|
31
47
|
end
|
|
32
48
|
|
|
33
49
|
# member, as show-principle prints it, with its repairs as repair_with when moves, its moves, are given, as the
|
|
34
50
|
# controller gives them for a member an audit would refuse.
|
|
35
|
-
#: (String, Hash[String, untyped], Array[
|
|
51
|
+
#: (String, Hash[String, untyped], Array[Move]?) -> Hash[String, untyped]
|
|
36
52
|
def beside(id, member, moves)
|
|
37
53
|
return member unless moves
|
|
38
54
|
|
|
@@ -41,10 +57,10 @@ module Principles
|
|
|
41
57
|
|
|
42
58
|
private
|
|
43
59
|
|
|
44
|
-
#: (String, String,
|
|
60
|
+
#: (String, String, Move) -> String
|
|
45
61
|
def move(id, member_id, move)
|
|
46
|
-
kept = move.
|
|
47
|
-
fill = move.
|
|
62
|
+
kept = move.keep.flat_map { |field, value| [FLAGS.fetch(field), value] }
|
|
63
|
+
fill = move.fill
|
|
48
64
|
usage = fill.map { "#{FLAGS.fetch(it)} #{PLACEHOLDERS.fetch(it)}" }.join(" ") unless fill.empty?
|
|
49
65
|
@invocation.in_project("move-member", id, member_id, options: kept, usage: usage)
|
|
50
66
|
end
|
|
@@ -52,16 +52,37 @@ module Principles
|
|
|
52
52
|
Prompts.text("set-principles-up/what-the-passage-presumes", estimated_tokens: estimated_tokens.to_s)
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
+
# The passage as the agent pastes it: its text, its size in bytes and estimated tokens, which loads in every
|
|
56
|
+
# session that loads the entry file it goes in, and what it presumes of a teammate without principles.
|
|
57
|
+
class Passage
|
|
58
|
+
#: Integer
|
|
59
|
+
attr_reader :estimated_tokens
|
|
60
|
+
|
|
61
|
+
#: (text: String, bytes: Integer, estimated_tokens: Integer, presumes: String) -> void
|
|
62
|
+
def initialize(text:, bytes:, estimated_tokens:, presumes:)
|
|
63
|
+
@text = text
|
|
64
|
+
@bytes = bytes
|
|
65
|
+
@estimated_tokens = estimated_tokens
|
|
66
|
+
@presumes = presumes
|
|
67
|
+
freeze
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
#: () -> Hash[String, untyped]
|
|
71
|
+
def to_h
|
|
72
|
+
{ "text" => @text, "bytes" => @bytes, "estimated_tokens" => @estimated_tokens, "presumes" => @presumes }
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
55
76
|
# Where the passage can go, as the agent places it from: how this run was started and whether the plugin's
|
|
56
|
-
# session-start hook runs in this session, each root entry file's facts, and the passage
|
|
57
|
-
# and what it presumes of a teammate without principles.
|
|
77
|
+
# session-start hook runs in this session, each root entry file's facts, and the passage.
|
|
58
78
|
class Placement
|
|
59
79
|
#: (runs_from: String, session_start_hook_in_this_session: bool, entry_files: Array[Hash[String, untyped]],
|
|
60
|
-
#| passage:
|
|
80
|
+
#| passage: Passage) -> void
|
|
61
81
|
def initialize(runs_from:, session_start_hook_in_this_session:, entry_files:, passage:)
|
|
62
82
|
@fields = { "runs_from" => runs_from,
|
|
63
83
|
"session_start_hook_in_this_session" => session_start_hook_in_this_session,
|
|
64
|
-
"entry_files" => entry_files, "passage" => passage }.freeze #: Hash[String, untyped]
|
|
84
|
+
"entry_files" => entry_files, "passage" => passage.to_h }.freeze #: Hash[String, untyped]
|
|
85
|
+
@passage = passage
|
|
65
86
|
freeze
|
|
66
87
|
end
|
|
67
88
|
|
|
@@ -70,7 +91,7 @@ module Principles
|
|
|
70
91
|
|
|
71
92
|
# The passage's estimated size, which loads in every session that loads the entry file it goes in.
|
|
72
93
|
#: () -> Integer
|
|
73
|
-
def estimated_tokens = @
|
|
94
|
+
def estimated_tokens = @passage.estimated_tokens
|
|
74
95
|
|
|
75
96
|
# Whether the plugin's hooks report in this session, so its hook entries need no offer.
|
|
76
97
|
#: () -> bool
|