principles 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -1
  3. data/exe/principles +1 -1
  4. data/lib/principles/cli.rb +9 -10
  5. data/lib/principles/command_routes.rb +7 -1
  6. data/lib/principles/controllers/carrier_edit_report.rb +40 -0
  7. data/lib/principles/controllers/command.rb +7 -3
  8. data/lib/principles/controllers/context_budget.rb +61 -0
  9. data/lib/principles/controllers/inventory.rb +3 -2
  10. data/lib/principles/controllers/member_addition.rb +1 -1
  11. data/lib/principles/controllers/member_entries.rb +30 -38
  12. data/lib/principles/controllers/member_entry_changes.rb +71 -0
  13. data/lib/principles/controllers/member_problems_report.rb +1 -1
  14. data/lib/principles/controllers/members_in_logged_requests.rb +5 -5
  15. data/lib/principles/controllers/members_to_assess.rb +11 -1
  16. data/lib/principles/controllers/meta_principle_setup.rb +10 -2
  17. data/lib/principles/controllers/parts_to_read.rb +2 -1
  18. data/lib/principles/controllers/plugin_member_addition.rb +4 -4
  19. data/lib/principles/controllers/request_logging.rb +17 -4
  20. data/lib/principles/controllers/running_tool.rb +19 -5
  21. data/lib/principles/controllers/session_start_report.rb +26 -2
  22. data/lib/principles/data/captured_requests.rb +118 -0
  23. data/lib/principles/data/carrier_page_markers.rb +38 -0
  24. data/lib/principles/data/claude_code_home.rb +17 -0
  25. data/lib/principles/data/command-steps.json +59 -19
  26. data/lib/principles/data/kept_line.rb +14 -7
  27. data/lib/principles/data/logged_request_matches.rb +23 -17
  28. data/lib/principles/data/logged_request_scan.rb +79 -11
  29. data/lib/principles/data/map_files.rb +1 -1
  30. data/lib/principles/data/project_files.rb +15 -0
  31. data/lib/principles/data/request_logging_folder.rb +42 -74
  32. data/lib/principles/data/request_shape.rb +33 -0
  33. data/lib/principles/data/running_version.rb +1 -1
  34. data/lib/principles/data/schemas/command-steps.schema.json +1 -1
  35. data/lib/principles/data/schemas/member-map.schema.json +2 -0
  36. data/lib/principles/data/settings_env_keys.rb +26 -0
  37. data/lib/principles/data/user_request_logging_folder.rb +73 -0
  38. data/lib/principles/invocation_options.rb +4 -4
  39. data/lib/principles/launch.rb +15 -6
  40. data/lib/principles/models/captured_sessions.rb +53 -15
  41. data/lib/principles/models/carrier_edit_input.rb +56 -0
  42. data/lib/principles/models/carrier_pages_shown.rb +28 -0
  43. data/lib/principles/models/carved_message_bytes.rb +115 -0
  44. data/lib/principles/models/context_parts.rb +59 -0
  45. data/lib/principles/models/declared_map_changes.rb +22 -13
  46. data/lib/principles/models/dropped_thinking.rb +73 -0
  47. data/lib/principles/models/feature.rb +2 -1
  48. data/lib/principles/models/installed_component.rb +3 -3
  49. data/lib/principles/models/logged_request_reach.rb +19 -11
  50. data/lib/principles/models/map_format_raise.rb +28 -0
  51. data/lib/principles/models/mapped_principles.rb +2 -1
  52. data/lib/principles/models/member.rb +6 -1
  53. data/lib/principles/models/member_justification.rb +52 -0
  54. data/lib/principles/models/member_problems.rb +2 -1
  55. data/lib/principles/models/member_reach.rb +28 -5
  56. data/lib/principles/models/member_snapshots.rb +11 -0
  57. data/lib/principles/models/members_by_part.rb +67 -0
  58. data/lib/principles/models/members_in_logged_requests.rb +56 -17
  59. data/lib/principles/models/meta_principle.rb +4 -4
  60. data/lib/principles/models/part_token_estimates.rb +60 -0
  61. data/lib/principles/models/plugin_enabled_in_project_settings.rb +61 -0
  62. data/lib/principles/models/principle.rb +7 -4
  63. data/lib/principles/models/principle_members.rb +7 -0
  64. data/lib/principles/models/project.rb +20 -31
  65. data/lib/principles/models/project_harness.rb +48 -0
  66. data/lib/principles/models/report_hooks.rb +9 -4
  67. data/lib/principles/models/request_channel.rb +62 -0
  68. data/lib/principles/models/request_kind.rb +62 -0
  69. data/lib/principles/models/request_logging.rb +107 -72
  70. data/lib/principles/models/request_logging_guard.rb +84 -0
  71. data/lib/principles/models/request_time.rb +46 -0
  72. data/lib/principles/models/session_registry.rb +61 -0
  73. data/lib/principles/models/session_start_input.rb +11 -2
  74. data/lib/principles/models/session_trend.rb +36 -0
  75. data/lib/principles/models/turn_opening.rb +83 -0
  76. data/lib/principles/models/turn_position.rb +43 -0
  77. data/lib/principles/models/user_logged_requests.rb +90 -0
  78. data/lib/principles/models/user_settings_entries.rb +49 -0
  79. data/lib/principles/version.rb +2 -2
  80. data/lib/principles/views/assessed_members.rb +4 -4
  81. data/lib/principles/views/assessment_request.rb +6 -3
  82. data/lib/principles/views/audit_result.rb +13 -6
  83. data/lib/principles/views/candidate_files_result.rb +1 -1
  84. data/lib/principles/views/carrier_edit_denial.rb +36 -0
  85. data/lib/principles/views/context_budget_result.rb +99 -0
  86. data/lib/principles/views/correction_request.rb +11 -1
  87. data/lib/principles/views/hook_setup_result.rb +3 -1
  88. data/lib/principles/views/logged_requests_evidence.rb +18 -3
  89. data/lib/principles/views/map_format_raised.rb +28 -0
  90. data/lib/principles/views/map_result.rb +7 -6
  91. data/lib/principles/views/maps_needing_members_or_audit.rb +1 -1
  92. data/lib/principles/views/members_in_logged_requests_result.rb +75 -20
  93. data/lib/principles/views/meta_principle_result.rb +38 -13
  94. data/lib/principles/views/problem_lines.rb +22 -0
  95. data/lib/principles/views/prompts/assess-every-member/ask-whether-a-member-seen-only-as-read-is-loaded.md +3 -0
  96. data/lib/principles/views/prompts/assess-every-member/ask-whether-each-reason-holds.md +2 -0
  97. data/lib/principles/views/prompts/assess-every-member/judge-the-keeping-against-the-other-principles.md +2 -0
  98. data/lib/principles/views/prompts/assess-every-member/weigh-what-reached-the-context.md +2 -2
  99. data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +1 -1
  100. data/lib/principles/views/prompts/dispose-of-each-finding/fix-or-record-each-finding.md +1 -1
  101. data/lib/principles/views/prompts/dispose-of-each-finding/read-the-carrier-page-before-fixing.md +1 -0
  102. data/lib/principles/views/prompts/edit-a-carrier/read-the-page-before-the-first-edit.md +2 -0
  103. data/lib/principles/views/prompts/learn-what-a-command-does/add-member.md +19 -20
  104. data/lib/principles/views/prompts/learn-what-a-command-does/change-member-name.md +12 -0
  105. data/lib/principles/views/prompts/learn-what-a-command-does/change-member-reason.md +12 -0
  106. data/lib/principles/views/prompts/learn-what-a-command-does/every-command-and-how-they-chain.md +1 -1
  107. data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +4 -4
  108. data/lib/principles/views/prompts/learn-what-a-command-does/remove-logged-requests.md +7 -1
  109. data/lib/principles/views/prompts/learn-what-a-command-does/report-at-session-start.md +7 -3
  110. data/lib/principles/views/prompts/learn-what-a-command-does/report-before-carrier-edit.md +13 -0
  111. data/lib/principles/views/prompts/learn-what-a-command-does/show-context-budget.md +69 -0
  112. data/lib/principles/views/prompts/learn-what-a-command-does/show-hook-setup.md +4 -4
  113. data/lib/principles/views/prompts/learn-what-a-command-does/show-logged-requests.md +4 -2
  114. data/lib/principles/views/prompts/learn-what-a-command-does/show-members-in-logged-requests.md +21 -7
  115. data/lib/principles/views/prompts/learn-what-a-command-does/show-meta-principle-passage.md +13 -10
  116. data/lib/principles/views/prompts/learn-what-a-command-does/show-principle.md +5 -5
  117. data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +7 -7
  118. data/lib/principles/views/prompts/learn-what-a-command-does/turn-off-request-logging.md +8 -0
  119. data/lib/principles/views/prompts/learn-what-a-command-does/turn-on-request-logging.md +12 -0
  120. data/lib/principles/views/prompts/read-what-reached-the-context/explain-user-request-logging-to-the-user.md +10 -0
  121. data/lib/principles/views/prompts/read-what-reached-the-context/what-a-thread-continuation-holds.md +3 -0
  122. data/lib/principles/views/prompts/read-what-reached-the-context/what-each-context-budget-line-says.md +4 -0
  123. data/lib/principles/views/prompts/read-what-reached-the-context/what-each-member-line-says.md +2 -0
  124. data/lib/principles/views/prompts/report-after-a-commit/a-row-ending-audit-asks-to-acknowledge-or-audit-again.md +1 -0
  125. data/lib/principles/views/prompts/report-after-a-commit/a-row-ending-mapping-commit-asks-for-an-audit.md +1 -0
  126. data/lib/principles/views/prompts/report-after-a-commit/a-row-ending-pinned-asks-for-an-audit.md +1 -0
  127. data/lib/principles/views/prompts/run-a-first-audit-in-the-background/follow-the-brief.md +1 -0
  128. data/lib/principles/views/prompts/set-principles-up/ask-to-set-principles-up-after-an-audit.md +1 -0
  129. data/lib/principles/views/prompts/set-principles-up/entry-file-passage.md +1 -1
  130. data/lib/principles/views/prompts/set-principles-up/map-the-enabling-line-at-no-edit.md +3 -0
  131. data/lib/principles/views/prompts/set-principles-up/name-the-step-each-member-lacks.md +2 -2
  132. data/lib/principles/views/prompts/set-principles-up/place-the-passage-with-the-user.md +4 -2
  133. data/lib/principles/views/prompts/set-principles-up/what-the-passage-presumes.md +1 -1
  134. data/lib/principles/views/prompts/set-principles-up/why-set-principles-up.md +1 -0
  135. data/lib/principles/views/prompts/start-a-session/ask-to-set-principles-up.md +2 -0
  136. data/lib/principles/views/prompts/start-a-session/name-the-principles-nothing-checks.md +1 -0
  137. data/lib/principles/views/request_logging_result.rb +48 -2
  138. data/lib/principles/views/set_up_offer_line.rb +43 -0
  139. metadata +55 -3
  140. data/lib/principles/views/prompts/set-principles-up/keep-them-held-between-audits.md +0 -2
@@ -28,12 +28,24 @@ module Principles
28
28
  private
29
29
 
30
30
  #: (Models::RequestLogging, Views::RequestLoggingResult, Hash[String, untyped]) -> Hash[String, untyped]
31
- def turned_on(logging, result, _options)
32
- result.turned_on(wrote: logging.turn_on, launch_file: logging.launch_file)
31
+ def turned_on(logging, result, options)
32
+ return result.turned_on(wrote: logging.turn_on, launch_file: logging.launch_file) unless options["for_user"]
33
+
34
+ entries = @project.user_settings_entries
35
+ result.turned_on_for_user(wrote: logging.make_user_folder, settings_file: entries.settings_file,
36
+ to_add: entries.to_add, settings_unreadable: entries.settings_unreadable?,
37
+ pruned: logging.prune_unregistered.to_h)
33
38
  end
34
39
 
35
40
  #: (Models::RequestLogging, Views::RequestLoggingResult, Hash[String, untyped]) -> Hash[String, untyped]
36
- def turned_off(logging, result, _options) = result.turned_off(wrote: logging.turn_off)
41
+ def turned_off(logging, result, options)
42
+ return result.turned_off(wrote: logging.turn_off) unless options["for_user"]
43
+
44
+ entries = @project.user_settings_entries
45
+ result.turned_off_for_user(settings_file: entries.settings_file, own: entries.own,
46
+ shared: Models::UserSettingsEntries::TELEMETRY_AND_EXPORTERS,
47
+ pruned: logging.prune_unregistered.to_h)
48
+ end
37
49
 
38
50
  #: (Models::RequestLogging, Views::RequestLoggingResult, Hash[String, untyped]) -> Hash[String, untyped]
39
51
  def shown(logging, result, _options)
@@ -45,7 +57,8 @@ module Principles
45
57
 
46
58
  #: (Models::RequestLogging, Views::RequestLoggingResult, Hash[String, untyped]) -> Hash[String, untyped]
47
59
  def removed(logging, result, options)
48
- result.removed(removed: logging.remove(keep_sessions: options["keep_sessions"]))
60
+ removed = logging.remove(keep_sessions: options["keep_sessions"])
61
+ result.removed(removed: removed, pruned: logging.prune_unregistered.to_h)
49
62
  end
50
63
  end
51
64
  end
@@ -7,6 +7,7 @@ require_relative "../models/principles_package"
7
7
  require_relative "../models/principles_on_path"
8
8
  require_relative "../models/runs_from"
9
9
  require_relative "../views/invocation"
10
+ require_relative "../views/shell_word"
10
11
  require_relative "../views/meta_principle_passage"
11
12
 
12
13
  module Principles
@@ -65,10 +66,13 @@ module Principles
65
66
  end
66
67
 
67
68
  # version gives the version running, read only when a command needs it, since in a checkout reading it
68
- # asks git; on_path is what PATH says of this run; folders are the folders the process was given.
69
- #: (executable: String, version: ^() -> String, folders: Folders, ?on_path: OnPath) -> void
70
- def initialize(executable:, version:, folders:, on_path: OnPath.new)
69
+ # asks git; on_path is what PATH says of this run; folders are the folders the process was given;
70
+ # bundle_gemfile is the Gemfile bundler ran this run under, or nil when it did not.
71
+ #: (executable: String, version: ^() -> String, folders: Folders, ?on_path: OnPath, ?bundle_gemfile: String?)
72
+ #| -> void
73
+ def initialize(executable:, version:, folders:, on_path: OnPath.new, bundle_gemfile: nil)
71
74
  @executable = executable
75
+ @bundle_gemfile = bundle_gemfile
72
76
  @version = version
73
77
  @on_path = on_path
74
78
  @folders = folders
@@ -76,9 +80,15 @@ module Principles
76
80
  end
77
81
 
78
82
  # The executable every printed command names: the bare principles when that runs this copy, else the entry
79
- # point's own.
83
+ # point's own, under the bundler it ran under, so a command pasted into a shell that lacks bundler's environment
84
+ # runs as this one did.
80
85
  #: () -> String
81
- def executable = bare_from_path? ? ON_PATH : @executable
86
+ def executable
87
+ return ON_PATH if bare_from_path?
88
+ return @executable unless @bundle_gemfile
89
+
90
+ "BUNDLE_GEMFILE=#{Views::ShellWord.new(@bundle_gemfile)} bundle exec #{@executable}"
91
+ end
82
92
 
83
93
  #: () -> String
84
94
  def version = @version.call
@@ -87,6 +97,10 @@ module Principles
87
97
  #: () -> bool
88
98
  def launched_on_path? = @on_path.launched?
89
99
 
100
+ # This machine's temporary folder, as the process was given it.
101
+ #: () -> String
102
+ def temp_directory = @folders.temp_directory
103
+
90
104
  # Where this run comes from, by the entry point it was invoked through, whatever its commands are printed as.
91
105
  #: () -> Models::RunsFrom
92
106
  def runs_from = Models::RunsFrom.new(@executable)
@@ -6,6 +6,7 @@ require_relative "member_problems_report"
6
6
  require_relative "audit"
7
7
  require_relative "../models/session_start_input"
8
8
  require_relative "../views/session_start_report"
9
+ require_relative "../views/set_up_offer_line"
9
10
 
10
11
  module Principles
11
12
  # Each runs one command: reads models, applies their rules and prints through a view.
@@ -20,12 +21,24 @@ module Principles
20
21
  naming_the_executable do
21
22
  unknown(command) unless command == "report-at-session-start"
22
23
 
23
- printed(Models::SessionStartInput.new(options["stdin"].to_s))
24
+ input = Models::SessionStartInput.new(options["stdin"].to_s)
25
+ printed(input).tap { register(input) }
24
26
  end
25
27
  end
26
28
 
27
29
  private
28
30
 
31
+ # Registers the session to the project while request logging is on in the user's own settings, in a project
32
+ # with maps, then prunes every session no project registered, printing nothing of either (022 F4, F8, F11).
33
+ #: (Models::SessionStartInput) -> void
34
+ def register(input)
35
+ logging = @project.request_logging
36
+ logging.register_session(session_id: input.session_id, cwd: input.cwd) unless @principles.ids.empty?
37
+ logging.prune_unregistered
38
+ rescue Error
39
+ nil
40
+ end
41
+
29
42
  # The lines the session starts with, from the hook's input: from the plugin, any other version on PATH, then
30
43
  # what list-member-problems reports of the members, then the open findings; none of those in a project with no
31
44
  # maps. A refusal is named by its code, with the command that shows its repair, since a hook exiting 1 shows the
@@ -55,7 +68,18 @@ module Principles
55
68
  # Each line the session starts with, source: startup, resume, clear or compact.
56
69
  #: (String) -> Array[String]
57
70
  def reported(source)
58
- handed(MemberProblemsReport).session_start_lines(source) + handed(Audit).session_start_open_findings(source)
71
+ handed(MemberProblemsReport).session_start_lines(source) + offer_to_set_up(source) +
72
+ handed(Audit).session_start_open_findings(source)
73
+ end
74
+
75
+ # While principles is not set up, the line asking to offer setup, once a full audit of a principle has completed
76
+ # and shown what a map and an audit give (019 F5).
77
+ #: (String) -> Array[String]
78
+ def offer_to_set_up(source)
79
+ return [] if @principles.set_up?
80
+
81
+ audited = @audit_records.readable_of(@principles.ids).count(&:last_completed)
82
+ Views::SetUpOfferLine.new(invocation.without_project).lines(audited, source)
59
83
  end
60
84
  end
61
85
  end
@@ -0,0 +1,118 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "logged_request_scan"
5
+ require "json"
6
+
7
+ module Principles
8
+ # Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
9
+ module Data
10
+ # The folder the host writes each request it sends to, at the path an OTEL_LOG_RAW_API_BODIES file: entry names:
11
+ # each request and response file, and its index, one line per response naming the session and both files.
12
+ class CapturedRequests
13
+ INDEX = "index.jsonl"
14
+
15
+ # A file the host wrote under requests/: its name there, its size and when it was last written.
16
+ class CapturedFile
17
+ #: String
18
+ attr_reader :name
19
+ #: Integer
20
+ attr_reader :bytes
21
+ #: Time
22
+ attr_reader :modified_at
23
+
24
+ #: (name: String, bytes: Integer, modified_at: Time) -> void
25
+ def initialize(name:, bytes:, modified_at:)
26
+ @name = name
27
+ @bytes = bytes
28
+ @modified_at = modified_at
29
+ freeze
30
+ end
31
+ end
32
+
33
+ # One line of the host's index: the session, when, and the paths of the request and response files it names.
34
+ class IndexLine
35
+ #: String
36
+ attr_reader :session_id, :timestamp, :request_file, :response_file
37
+
38
+ #: (Hash[String, String]) -> void
39
+ def initialize(fields)
40
+ @session_id = fields.fetch("session_id") #: String
41
+ @timestamp = fields.fetch("timestamp") #: String
42
+ @request_file = fields.fetch("request_file") #: String
43
+ @response_file = fields.fetch("response_file") #: String
44
+ freeze
45
+ end
46
+ end
47
+
48
+ # shown_as is the folder as a result names it: relative to the project for its own folder, absolute elsewhere.
49
+ #: (String, ?shown_as: String) -> void
50
+ def initialize(path, shown_as: path)
51
+ @path = path
52
+ @shown_as = shown_as
53
+ freeze
54
+ end
55
+
56
+ # A file here, by its name, as a result names it.
57
+ #: (String) -> String
58
+ def shown(name) = "#{@shown_as}/#{name}"
59
+
60
+ # Every file the host wrote under requests/, but its index, sorted by name.
61
+ #: () -> Array[CapturedFile]
62
+ def captured_files
63
+ (Dir.exist?(@path) ? Dir.children(@path).sort : []).filter_map do |name|
64
+ path = File.join(@path, name)
65
+ next if name == INDEX || !File.file?(path)
66
+
67
+ stat = File.stat(path)
68
+ CapturedFile.new(name: name, bytes: stat.size, modified_at: stat.mtime.utc)
69
+ end
70
+ end
71
+
72
+ # Each line of the host's index, leaving out a line that is not a JSON object naming a session and its files.
73
+ #: () -> Array[IndexLine]
74
+ def index_lines
75
+ path = File.join(@path, INDEX)
76
+ File.file?(path) ? IndexLines.new(File.read(path)).lines : []
77
+ end
78
+
79
+ # Removes one file the host wrote directly under requests/, refusing any other name, an index line's included,
80
+ # so a line naming a path elsewhere or the index itself cannot reach it.
81
+ #: (String) -> void
82
+ def remove_request(name)
83
+ unless name.match?(%r{\A[^/]+\z}) && !%w[. ..].include?(name) && name != INDEX
84
+ raise ArgumentError, "not a captured file under requests/: #{name.inspect}"
85
+ end
86
+
87
+ File.delete(File.join(@path, name))
88
+ end
89
+
90
+ # The requests the host captured here, scanned by jq and rg: those only names, by name, when given.
91
+ #: (?only: Array[String]?) -> LoggedRequestScan
92
+ def scan(only: nil) = LoggedRequestScan.new(@path, only: only)
93
+ end
94
+
95
+ # The host's index text read as lines, shared by the folder and its stand-in.
96
+ class IndexLines
97
+ FIELDS = %w[session_id timestamp request_file response_file].freeze #: Array[String]
98
+
99
+ #: (String) -> void
100
+ def initialize(text)
101
+ @text = text
102
+ freeze
103
+ end
104
+
105
+ #: () -> Array[CapturedRequests::IndexLine]
106
+ def lines
107
+ @text.each_line.filter_map do |line|
108
+ fields = JSON.parse(line)
109
+ next unless fields.is_a?(Hash) && FIELDS.all? { |field| fields[field].is_a?(String) }
110
+
111
+ CapturedRequests::IndexLine.new(fields)
112
+ rescue JSON::ParserError
113
+ nil
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,38 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require "fileutils"
5
+
6
+ module Principles
7
+ # Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
8
+ module Data
9
+ # The empty marker files, in this machine's temporary folder, that say which carrier kinds' practices pages a
10
+ # session was pointed at before its first edit of that kind: a folder per session, a file per kind. They live
11
+ # outside every project, since they are a session's state, not the project's, and go when the folder is cleared.
12
+ class CarrierPageMarkers
13
+ # The folder under the temporary folder that holds every session's markers.
14
+ FOLDER = "principles-carrier-pages"
15
+
16
+ #: (String) -> void
17
+ def initialize(temp_directory)
18
+ @root = File.join(temp_directory, FOLDER) #: String
19
+ freeze
20
+ end
21
+
22
+ # Whether session's marker for kind is there.
23
+ #: (String, String) -> bool
24
+ def marked?(session, kind) = File.exist?(File.join(@root, session, kind))
25
+
26
+ # Leaves session's marker for kind, saying whether it could; a folder that cannot be written leaves none.
27
+ #: (String, String) -> bool
28
+ def mark(session, kind)
29
+ folder = File.join(@root, session)
30
+ FileUtils.mkdir_p(folder)
31
+ File.write(File.join(folder, kind), "")
32
+ true
33
+ rescue SystemCallError
34
+ false
35
+ end
36
+ end
37
+ end
38
+ end
@@ -5,6 +5,7 @@ require_relative "bounded_file"
5
5
  require_relative "plugin_registry"
6
6
  require_relative "known_marketplaces"
7
7
  require_relative "plugin_folder"
8
+ require_relative "settings_env_keys"
8
9
 
9
10
  module Principles
10
11
  # Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
@@ -41,6 +42,22 @@ module Principles
41
42
  KnownMarketplaces.new(text) if text
42
43
  end
43
44
 
45
+ # The user's own settings file, which this tool never writes.
46
+ #: () -> String
47
+ def settings_file = File.join(@directory, "settings.json")
48
+
49
+ # The names of the env entries the user's settings set, as SettingsEnvKeys reads them: none while there is no
50
+ # settings file, and nil when it cannot be read.
51
+ #: () -> Array[String]?
52
+ def settings_env_keys
53
+ path = settings_file
54
+ return [] unless File.exist?(path)
55
+
56
+ SettingsEnvKeys.of(BoundedFile.new(path, named: "Claude Code's user settings").read_text)
57
+ rescue Error, SystemCallError
58
+ nil
59
+ end
60
+
44
61
  # The folder the host installed a plugin's copy in, at the path its registry gives.
45
62
  #: (String) -> PluginFolder
46
63
  def plugin_folder(path) = PluginFolder.new(path)
@@ -8,8 +8,8 @@
8
8
  "writes": "Removes only `.principles/maps/ID.json`, listed under `removed`; `wrote` is empty. Commit the removal if the map was tracked. Retains member files and audit entries." },
9
9
  { "id": "write-guidance-search-paths", "heading": "Write the recorded guidance search paths, which the project commits",
10
10
  "writes": "Writes `.principles/guidance-search-paths.json`; commit it as it changes. Never a map, audit or guidance file." },
11
- { "id": "write-request-logging", "heading": "Switch request logging; these write only inside `.principles/request-logging/`, which git ignores",
12
- "writes": "Writes only inside `.principles/request-logging/`, listed under `wrote`, and refuses unless git confirms it ignores that folder. Never commit it: a logged request holds a session's whole context." },
11
+ { "id": "write-request-logging", "heading": "Switch request logging; these write only in git-ignored `.principles/request-logging/` and the user-level folder",
12
+ "writes": "Writes only inside `.principles/request-logging/`, listed under `wrote`, and refuses unless git confirms it ignores that folder. Never commit it: a logged request holds a session's whole context. With --for-user, writes only the user-level folder outside every repository, and never the user's settings." },
13
13
  { "id": "write-audit-record", "heading": "Audit; these write only the audit record, `.principles/audits/ID.json`, which the project commits",
14
14
  "writes": "Writes `.principles/audits/ID.json`, listed under `wrote` when it does; commit it. Never the map or a member's file." }
15
15
  ],
@@ -130,9 +130,18 @@
130
130
  "does": "Reads the hook's JSON on stdin after a shell call and always exits 0. When the call committed in a mapped repository, its own directory's or one its command changed into with cd or ran git -C in, prints the hook's JSON naming the members those commits changed, for the first such repository; otherwise prints nothing, at the cost of a few git calls." }
131
131
  ]
132
132
  },
133
+ {
134
+ "name": "report-before-carrier-edit", "usage": "report-before-carrier-edit", "group": "read", "options": [],
135
+ "summary": "Stops a session's first edit of each carrier kind once, naming its practices page.",
136
+ "help": "learn-what-a-command-does/report-before-carrier-edit",
137
+ "steps": [
138
+ { "id": "report-before-carrier-edit", "actor": "cli",
139
+ "does": "Reads the PreToolUse hook's JSON on stdin and always exits 0. When the call would edit a file in the project of a carrier kind a host loads by itself, and this session has not been pointed at that kind's page yet, prints the hook's JSON denying the call once, its reason naming show-carrier-practices KIND and asking for the same edit again, and leaves a marker for that session and kind in the temporary folder; otherwise prints nothing, and the edit goes through." }
140
+ ]
141
+ },
133
142
  {
134
143
  "name": "report-at-session-start", "usage": "report-at-session-start", "group": "read", "options": [],
135
- "summary": "What the agent should act on as a session starts, for a SessionStart hook to add to its context.",
144
+ "summary": "What the agent should act on as a session starts, for a SessionStart hook's context.",
136
145
  "help": "learn-what-a-command-does/report-at-session-start",
137
146
  "steps": [
138
147
  { "id": "report-at-session-start", "actor": "cli",
@@ -168,7 +177,7 @@
168
177
  },
169
178
  {
170
179
  "name": "show-first-audit-brief", "usage": "show-first-audit-brief [ID]", "group": "read", "options": [],
171
- "summary": "Print the instructions for one background subagent to run a principle's first full audit.",
180
+ "summary": "Print the brief for one background subagent to run a principle's first full audit.",
172
181
  "help": "learn-what-a-command-does/show-first-audit-brief",
173
182
  "steps": [
174
183
  { "id": "print-first-audit-brief", "actor": "cli",
@@ -182,25 +191,25 @@
182
191
  },
183
192
  {
184
193
  "name": "show-meta-principle-passage", "usage": "show-meta-principle-passage", "group": "read", "options": [],
185
- "summary": "Set principles up: propose the passage that keeps the others held between audits, and the add-member that maps it.",
194
+ "summary": "Set principles up: propose the passage that has agents check the others between audits, and the add-member that maps it.",
186
195
  "help": "learn-what-a-command-does/show-meta-principle-passage",
187
196
  "steps": [
188
197
  { "id": "propose-meta-principle-passage", "actor": "cli",
189
198
  "does": "Writes nothing. Shows the sticking-to-your-principles map that the printed add-member creates, its description and an activation for all work, or, where that map is already there, shows it and names its members already in an entry file; says which of CLAUDE.md and AGENTS.md exist and whether one links the other, and proposes the passage each would take, with its size.",
190
199
  "refuses_like": ["read-map"] },
191
200
  { "id": "place-the-passage", "actor": "agent",
192
- "does": "With no member mapped, show the user the passage, agree where it goes, write it there, and map it as the principle's member, or map another file or setting that keeps the principles held, such as a timer. With a member mapped, agree with the user which step each member lacks, and add any that is missing.",
201
+ "does": "With no member mapped, show the user the passage, agree where it goes, write it there, and map it as the principle's member, or map another file or setting that has every session check the principles, such as a timer. With a member mapped, agree with the user which step each member lacks, and add any that is missing.",
193
202
  "cannot_check": "where the passage belongs, or whether a passage or member already in the project does its job; agree that with the user.",
194
203
  "answer_with": "add-member" }
195
204
  ]
196
205
  },
197
206
  {
198
207
  "name": "show-hook-setup", "usage": "show-hook-setup", "group": "read", "options": [],
199
- "summary": "Show the hook entries that run the session-start and after-commit reports without the principles plugin.",
208
+ "summary": "Show the hook entries that run the session-start and after-commit reports without the plugin.",
200
209
  "help": "learn-what-a-command-does/show-hook-setup",
201
210
  "steps": [
202
211
  { "id": "show-hook-entries", "actor": "cli",
203
- "does": "Writes nothing. Prints, for Claude Code then Codex, the file a project's own hooks go in and the entries that run report-at-session-start at each session's start and report-after-commit after each shell call, each guarded to say principles failed to start instead of failing the hook, and how to remove them." },
212
+ "does": "Writes nothing. Prints, for Claude Code then Codex, the file a project's own hooks go in and the entries that run report-at-session-start at each session's start, report-after-commit after each shell call and, on Claude Code, report-before-carrier-edit before each Edit and Write, each guarded to say principles failed to start instead of failing the hook, and how to remove them." },
204
213
  { "id": "write-the-hook-entries", "actor": "agent",
205
214
  "does": "Show the user the entries for this session's host and the file they go in, and write them there only once the user agrees; remove them when the principles plugin is enabled.",
206
215
  "cannot_check": "whether the user agrees, or whether the host runs the entries; start a new session to see the report." }
@@ -233,15 +242,15 @@
233
242
  ]
234
243
  },
235
244
  {
236
- "name": "turn-on-request-logging", "usage": "turn-on-request-logging", "group": "write-request-logging", "options": [],
245
+ "name": "turn-on-request-logging", "usage": "turn-on-request-logging [--for-user]", "group": "write-request-logging", "options": ["for-user"],
237
246
  "summary": "Set up the git-ignored folder where the host can write each request it sends.",
238
247
  "help": "learn-what-a-command-does/turn-on-request-logging",
239
248
  "steps": [
240
249
  { "id": "write-ignored-request-logging-folder", "actor": "cli",
241
- "does": "Writes `.principles/request-logging/.gitignore`, holding `*`, unless it is there, then asks git whether it ignores the folder, its files and every file already in it. Refuses outside git, or when git tracks a file there, and removes what it wrote. Once git confirms it, writes the launch file `settings.json`, whose `env` asks the host to write each request's body under `requests/` with no telemetry exporter, and prints the launch line.",
250
+ "does": "Writes `.principles/request-logging/.gitignore`, holding `*`, unless it is there, then asks git whether it ignores the folder, its files and every file already in it. Refuses outside git, or when git tracks a file there, and removes what it wrote. Once git confirms it, writes the launch file `settings.json`, whose `env` asks the host to write each request's body under `requests/` with no telemetry exporter, and prints the launch line. With --for-user, writes nothing in the project: makes the user-level folder outside every repository, and its `requests/`, readable only by the user, prints the user's settings file and the `env` entries to add to it, which it never writes, and prunes that folder's sessions no project registered, by counts alone.",
242
251
  "refuses": ["request_logging_not_ignored"] },
243
252
  { "id": "launch-with-the-line", "actor": "agent",
244
- "does": "Give the user the launch line, and say that capture starts only when they relaunch the host with it and that each logged request holds the session's whole working context.",
253
+ "does": "Give the user the launch line, and say that capture starts only when they relaunch the host with it and that each logged request holds the session's whole working context. With --for-user, give the user `explain_to_user` and get their agreement before they add the entries to their settings and relaunch.",
245
254
  "cannot_check": "whether the user relaunched the host with the line, or whether the host wrote any request." }
246
255
  ]
247
256
  },
@@ -256,15 +265,28 @@
256
265
  ]
257
266
  },
258
267
  {
259
- "name": "turn-off-request-logging", "usage": "turn-off-request-logging", "group": "write-request-logging", "options": [],
260
- "summary": "Stop the host capturing each request it sends, keeping every logged request already captured.",
268
+ "name": "show-context-budget", "usage": "show-context-budget [--short] [--session ID]", "group": "read", "options": ["short", "session"],
269
+ "summary": "Show the bytes loaded at each turn's opening, beside its tokens.",
270
+ "help": "learn-what-a-command-does/show-context-budget",
271
+ "steps": [
272
+ { "id": "measure-turn-openings", "actor": "cli",
273
+ "does": "Writes nothing. Refuses while the request-logging folder exists without its `.gitignore`, or git does not ignore it, and while jq is not on PATH. Refuses a --session no turn opening was sent in. Otherwise lists, by session, each captured request that opens a turn, with its bytes and the input tokens its response counted, and each session's trend, or with --short a line a session, and no text from a request.",
274
+ "refuses": ["request_logging_unguarded", "request_logging_not_ignored", "fast_tools_missing", "unknown_session"] },
275
+ { "id": "judge-the-budget", "actor": "agent",
276
+ "does": "Judge from the bytes and tokens how much of each turn's context the host loads before the work starts, and tell the user.",
277
+ "cannot_check": "what any request held, since it prints no text from one." }
278
+ ]
279
+ },
280
+ {
281
+ "name": "turn-off-request-logging", "usage": "turn-off-request-logging [--for-user]", "group": "write-request-logging", "options": ["for-user"],
282
+ "summary": "Stop the host capturing requests, keeping those already captured.",
261
283
  "help": "learn-what-a-command-does/turn-off-request-logging",
262
284
  "steps": [
263
285
  { "id": "empty-launch-file", "actor": "cli",
264
- "does": "Refuses while the folder exists without its `.gitignore`, or git does not ignore it. Otherwise empties the launch file's `env`, so a host started with it captures nothing, and writes nothing where request logging was never turned on. Deletes no logged request.",
286
+ "does": "Refuses while the folder exists without its `.gitignore`, or git does not ignore it. Otherwise empties the launch file's `env`, so a host started with it captures nothing, and writes nothing where request logging was never turned on. Deletes no logged request. With --for-user, writes nothing: prints the user's settings file, the entry to remove from its `env` and those to remove only if they were added for request logging, and prunes the user-level folder's sessions no project registered, by counts alone.",
265
287
  "refuses": ["request_logging_unguarded", "request_logging_not_ignored"] },
266
288
  { "id": "relaunch-the-host", "actor": "agent",
267
- "does": "Tell the user the host they started with the launch file keeps capturing until they relaunch it.",
289
+ "does": "Tell the user the host they started with the launch file keeps capturing until they relaunch it. With --for-user, ask the user whether they set any of the telemetry entries for their own use, then have them remove the entries from their settings and relaunch every host they started since.",
268
290
  "cannot_check": "whether the host was relaunched." }
269
291
  ]
270
292
  },
@@ -325,13 +347,13 @@
325
347
  ]
326
348
  },
327
349
  {
328
- "name": "add-member", "usage": "add-member ID PATH [--section HEADING] [--starting-at TEXT [--ending-at TEXT]] [--query QUERY] [--plugin NAME@MARKETPLACE] --role ROLE [--check COMMAND]", "group": "write-map", "options": ["plugin", "section", "starting-at", "ending-at", "query", "role", "check"],
350
+ "name": "add-member", "usage": "add-member ID PATH [--section HEADING] [--starting-at TEXT [--ending-at TEXT]] [--query QUERY] [--plugin NAME@MARKETPLACE] --role ROLE --name NAME --reason REASON [--check COMMAND]", "group": "write-map", "options": ["plugin", "section", "starting-at", "ending-at", "query", "role", "name", "reason", "check"],
329
351
  "summary": "Add a file, a Markdown section or a passage.",
330
352
  "help": "learn-what-a-command-does/add-member",
331
353
  "steps": [
332
354
  { "id": "locate-new-member", "actor": "cli",
333
355
  "does": "Loads the map, or starts sticking-to-your-principles only after verifying its map path is absent at committed HEAD, requiring any prior removal to be committed. Then finds the member's text, so a locator that matches nothing is refused now rather than at the audit. With --plugin, finds the plugin's install in Claude Code's record instead.",
334
- "refuses": ["invalid_answer", "ending_without_start", "ambiguous_passage_end", "map_removal_not_committed", "git_history_unavailable", "plugin_component_not_plain", "plugin_member_located", "plugin_not_installed", "plugin_from_directory_marketplace", "plugin_marketplace_unknown", "plugin_component_linked", "plugin_component_not_found"], "refuses_like": ["read-map", "locate-text", "read-plugin-registry"] },
356
+ "refuses": ["invalid_answer", "unjustified_member", "ending_without_start", "ambiguous_passage_end", "map_removal_not_committed", "git_history_unavailable", "plugin_component_not_plain", "plugin_member_located", "plugin_not_installed", "plugin_from_directory_marketplace", "plugin_marketplace_unknown", "plugin_component_linked", "plugin_component_not_found"], "refuses_like": ["read-map", "locate-text", "read-plugin-registry"] },
335
357
  { "id": "write-member", "actor": "cli",
336
358
  "does": "Refuses a member already in the map, then adds it with its role; the first member of sticking-to-your-principles creates its map. Reports, without deciding, other maps holding a whole-file member's file whole, and those whose member set nearly matches this one's.",
337
359
  "refuses": ["member_exists"] },
@@ -343,7 +365,7 @@
343
365
  },
344
366
  {
345
367
  "name": "move-member", "usage": "move-member ID MEMBER [--path PATH] [--section HEADING] [--starting-at TEXT [--ending-at TEXT]] [--query QUERY]", "group": "write-map", "options": ["path", "section", "starting-at", "ending-at", "query"],
346
- "summary": "Point a member at a new place in its file, or in another file: the one its file was renamed to, or one its text moved into.",
368
+ "summary": "Point a member at a new place: in its file, its renamed file, or a file its text moved into.",
347
369
  "help": "learn-what-a-command-does/move-member",
348
370
  "steps": [
349
371
  { "id": "find-member", "actor": "cli", "does": "Finds MEMBER in the map.",
@@ -353,6 +375,24 @@
353
375
  "refuses": ["invalid_answer", "ending_without_start", "ambiguous_passage_end", "member_exists"], "refuses_like": ["locate-text"] }
354
376
  ]
355
377
  },
378
+ {
379
+ "name": "change-member-name", "usage": "change-member-name ID MEMBER --name NAME", "group": "write-map", "options": ["name"],
380
+ "summary": "Rename a member for display; commands still take its id.",
381
+ "help": "learn-what-a-command-does/change-member-name",
382
+ "steps": [
383
+ { "id": "write-name", "actor": "cli", "does": "Finds MEMBER in the map by its id and replaces its name, keeping its id, key and audit.",
384
+ "refuses": ["unknown_member", "invalid_answer"], "refuses_like": ["read-map"] }
385
+ ]
386
+ },
387
+ {
388
+ "name": "change-member-reason", "usage": "change-member-reason ID MEMBER --reason REASON", "group": "write-map", "options": ["reason"],
389
+ "summary": "Rewrite why a member's carrier puts its principle in context.",
390
+ "help": "learn-what-a-command-does/change-member-reason",
391
+ "steps": [
392
+ { "id": "write-reason", "actor": "cli", "does": "Finds MEMBER in the map and replaces its reason.",
393
+ "refuses": ["unknown_member", "invalid_answer"], "refuses_like": ["read-map"] }
394
+ ]
395
+ },
356
396
  {
357
397
  "name": "change-member-role", "usage": "change-member-role ID MEMBER --role ROLE", "group": "write-map", "options": ["role"],
358
398
  "summary": "Reword a member's role.",
@@ -364,7 +404,7 @@
364
404
  },
365
405
  {
366
406
  "name": "change-member-check", "usage": "change-member-check ID MEMBER --check COMMAND", "group": "write-map", "options": ["check"],
367
- "summary": "Name the command that enforces a member, which each audit asks you to run.",
407
+ "summary": "Name the command enforcing a member, which each audit asks you to run.",
368
408
  "help": "learn-what-a-command-does/change-member-check",
369
409
  "steps": [
370
410
  { "id": "write-check", "actor": "cli", "does": "Finds MEMBER in the map and stores COMMAND as its check. This tool never runs it.",
@@ -5,16 +5,18 @@ module Principles
5
5
  # Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
6
6
  module Data
7
7
  # One line of a captured request's string that holds a pattern, as the scan keeps it: the request, the JSON path
8
- # of the string, its segment, the line's text, and the byte in the string the line starts at. A plain class, not
9
- # ::Data.define, since Sorbet's strict level needs a signature for each reader, which ::Data.define's lack.
8
+ # of the string, the role of the message it sits in, if any, and the line as DecodedLeaf#holding gives it, its
9
+ # segment, its text and the byte in the string it starts at. A plain class, not ::Data.define, since Sorbet's
10
+ # strict level needs a signature for each reader, which ::Data.define's lack.
10
11
  class KeptLine
11
- #: (String, String, String, String, Integer) -> void
12
- def initialize(request, path, segment, text, offset)
12
+ #: (String, String, String?, [String, String, Integer]) -> void
13
+ def initialize(request, path, role, line)
13
14
  @request = request
14
15
  @path = path
15
- @segment = segment
16
- @text = text
17
- @offset = offset
16
+ @role = role
17
+ @segment = line[0] #: String
18
+ @text = line[1] #: String
19
+ @offset = line[2] #: Integer
18
20
  freeze
19
21
  end
20
22
 
@@ -24,6 +26,11 @@ module Principles
24
26
  #: Integer
25
27
  attr_reader :offset
26
28
 
29
+ # The role of the message it sits in, such as system or user, or nil outside a message or for a role that is not
30
+ # a string.
31
+ #: String?
32
+ attr_reader :role
33
+
27
34
  # The place it was kept in, a request, path and segment, which a member's lines are counted by.
28
35
  #: () -> [String, String, String]
29
36
  def place = [@request, @path, @segment]
@@ -14,19 +14,22 @@ module Principles
14
14
  module Data
15
15
  # What a scan found in the captured requests. RawRequestFilter picks the request files that may hold a pattern,
16
16
  # StringCounts counts the strings of the others, and only the picked ones are decoded: one jq run writes each
17
- # string in them as one line, request<TAB>path<TAB>string, the path and string as JSON, and one rg run keeps those
18
- # holding a pattern, escaped by the same jq, as fixed strings. Each distinct kept string is then split into its
19
- # lines once. It holds each line holding a pattern as a KeptLine, how many strings each request it read through
20
- # held, by request, and whether the scan was whole.
17
+ # string in them as one line, request<TAB>path<TAB>role<TAB>string, the path, its message's role and the string as
18
+ # JSON, and one rg run keeps those holding a pattern, escaped by the same jq, as fixed strings. Each distinct kept
19
+ # string is then split into its lines once. It holds each line holding a pattern as a KeptLine, how many strings
20
+ # each request it read through held, by request, and whether the scan was whole.
21
21
  class LoggedRequestMatches
22
- # Each string in a request, prefixed by the request file and its JSON path, both written as JSON, so no string
23
- # can stop the run or split a line. After a request's strings comes its end line, request<TAB><TAB>strings,
24
- # giving how many it held; only an end line has an empty path, so a request with none was not decoded to its
25
- # end.
22
+ # Each string in a request, prefixed by the request file, its JSON path and the role of the message it sits in,
23
+ # null outside a message or for a role not a string, the path and role written as JSON, so no string can stop the
24
+ # run or split a line, and no absent role leaves an empty column. After a request's strings comes its end line,
25
+ # request<TAB><TAB>strings, giving how many it held; only an end line has an empty path, so a request with none
26
+ # was not decoded to its end.
26
27
  DECODE = <<~JQ
27
28
  (input_filename | split("/") | last) as $request
28
29
  | [paths(type == "string")] as $paths
29
- | ($paths[] as $path | [$request, ($path | tojson), (getpath($path) | tojson)] | join("\\t")),
30
+ | ($paths[] as $path
31
+ | ((if $path[0] == "messages" then getpath($path[0:2]).role? | strings else empty end) // null) as $role
32
+ | [$request, ($path | tojson), ($role | tojson), (getpath($path) | tojson)] | join("\\t")),
30
33
  ([$request, "", ($paths | length | tostring)] | join("\\t"))
31
34
  JQ
32
35
  # The fixed string rg keeps each end line by: no other line holds two tabs together.
@@ -95,24 +98,27 @@ module Principles
95
98
  # The lines rg kept: the end lines count each request's strings, and each other names a string holding a pattern.
96
99
  #: (Array[String], Array[String], bool) -> LoggedRequestMatches
97
100
  def self.kept_lines(kept, patterns, whole)
98
- endings, strings = kept.map { it.split("\t", 3).map(&:to_s) }.partition { |_, path, _| path.to_s.empty? }
101
+ endings, strings = kept.map { it.split("\t", 4).map(&:to_s) }.partition { |_, path, _| path.to_s.empty? }
99
102
  leaves = endings.to_h { |request, _, count| [request.to_s, Integer(count)] }
100
103
  new(found: lines_holding(strings, patterns), leaves:, whole:)
101
104
  end
102
105
 
103
- # Each line of strings, each as [request, path, string] in JSON, holding one of patterns, as [request, path,
104
- # segment, line, offset], offset the byte in the string it starts at, each distinct string read once.
106
+ # Each line of strings, each as [request, path, role, string], the last three in JSON, holding one of patterns,
107
+ # as a KeptLine, each distinct string read once.
105
108
  #: (Array[Array[String]], Array[String]) -> Array[KeptLine]
106
109
  def self.lines_holding(strings, patterns)
107
110
  held = strings.map(&:last).uniq.to_h { [it, DecodedLeaf.new(JSON.parse(it.to_s)).holding(patterns)] }
108
- strings.flat_map { |request, path, leaf| kept_in(request.to_s, path.to_s, held.fetch(leaf)) }
111
+ strings.flat_map do |request, path, role, leaf|
112
+ kept_in(request.to_s, path.to_s, JSON.parse(role.to_s), held.fetch(leaf))
113
+ end
109
114
  end
110
115
 
111
- # Each of lines, as DecodedLeaf#holding gives them, kept in request at path, the path in JSON.
112
- #: (String, String, Array[[String, String, Integer]]) -> Array[KeptLine]
113
- def self.kept_in(request, path, lines)
116
+ # Each of lines, as DecodedLeaf#holding gives them, kept in request at path, the path in JSON, in a message of
117
+ # role, or none.
118
+ #: (String, String, String?, Array[[String, String, Integer]]) -> Array[KeptLine]
119
+ def self.kept_in(request, path, role, lines)
114
120
  place = JSON.parse(path).join(".")
115
- lines.map { |segment, line, at| KeptLine.new(request, place, segment, line, at) }
121
+ lines.map { KeptLine.new(request, place, role, it) }
116
122
  end
117
123
  private_class_method :decoded, :escaped, :decode_and_match, :whole?, :kept_lines, :lines_holding, :kept_in
118
124