principles 0.0.5 → 0.0.7
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 +9 -0
- data/lib/principles/command_line.rb +31 -30
- data/lib/principles/command_routes.rb +9 -3
- data/lib/principles/controllers/acknowledgement.rb +82 -95
- data/lib/principles/controllers/answer.rb +14 -11
- data/lib/principles/controllers/assessment.rb +27 -24
- data/lib/principles/controllers/audit.rb +24 -4
- data/lib/principles/controllers/audit_completion.rb +10 -4
- data/lib/principles/controllers/command.rb +2 -2
- data/lib/principles/controllers/correction.rb +16 -7
- data/lib/principles/controllers/full_audit_request.rb +8 -3
- data/lib/principles/controllers/guidance_search_paths.rb +31 -0
- data/lib/principles/controllers/inventory.rb +3 -22
- data/lib/principles/controllers/mapping.rb +9 -1
- data/lib/principles/controllers/member_acknowledgement.rb +137 -0
- 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 +33 -25
- data/lib/principles/controllers/members_to_assess.rb +1 -1
- data/lib/principles/controllers/meta_principle_setup.rb +1 -1
- data/lib/principles/controllers/repoint.rb +5 -2
- data/lib/principles/controllers/survey.rb +60 -0
- data/lib/principles/data/audit_files.rb +4 -0
- data/lib/principles/data/candidate_files_found.rb +48 -13
- data/lib/principles/data/command-steps.json +86 -25
- 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 +11 -3
- 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/schemas/acknowledgement-answer.schema.json +6 -6
- data/lib/principles/data/schemas/acknowledgements-answer.schema.json +88 -0
- data/lib/principles/data/schemas/answer-guide.schema.json +255 -63
- data/lib/principles/data/schemas/assessment-answer.schema.json +15 -1
- data/lib/principles/data/schemas/command-steps.schema.json +1 -1
- data/lib/principles/data/schemas/correction-answer-guide.schema.json +2 -1
- data/lib/principles/data/schemas/correction-answer.schema.json +12 -54
- 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 +5 -4
- data/lib/principles/list_open_findings_options.rb +23 -0
- data/lib/principles/models/acknowledged_check.rb +94 -0
- data/lib/principles/models/acknowledgement.rb +40 -36
- data/lib/principles/models/acknowledgement_left_as_printed.rb +72 -0
- data/lib/principles/models/acknowledgements.rb +99 -0
- data/lib/principles/models/answered_time.rb +9 -0
- data/lib/principles/models/assessment_report.rb +13 -13
- data/lib/principles/models/audit.rb +17 -4
- data/lib/principles/models/audit_entry_protecting_map.rb +28 -0
- data/lib/principles/models/audit_record.rb +9 -0
- data/lib/principles/models/audit_records.rb +34 -8
- data/lib/principles/models/candidate_files.rb +17 -6
- data/lib/principles/models/candidate_inventory.rb +51 -7
- data/lib/principles/models/captured_head.rb +72 -0
- data/lib/principles/models/check_since_last_audit.rb +4 -8
- data/lib/principles/models/correction_basis.rb +14 -5
- data/lib/principles/models/declared_map_changes.rb +25 -9
- 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/guidance_search_path.rb +26 -0
- data/lib/principles/models/guidance_search_paths.rb +57 -0
- data/lib/principles/models/line_span.rb +6 -0
- data/lib/principles/models/list_member_problems_check.rb +80 -0
- data/lib/principles/models/listed_members.rb +49 -0
- data/lib/principles/models/loaded_files.rb +1 -2
- data/lib/principles/models/loading_decision.rb +17 -8
- data/lib/principles/models/loading_scope.rb +61 -0
- data/lib/principles/models/loads_to_check.rb +0 -1
- data/lib/principles/models/locator.rb +6 -0
- data/lib/principles/models/mapped_principles.rb +39 -37
- data/lib/principles/models/member_assessments.rb +11 -2
- data/lib/principles/models/member_file.rb +20 -71
- data/lib/principles/models/member_history.rb +7 -5
- 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 +57 -29
- data/lib/principles/models/member_region.rb +129 -0
- data/lib/principles/models/member_repair_moves.rb +9 -11
- data/lib/principles/models/member_sighting.rb +5 -8
- 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/other_templates_placeholders.rb +1 -1
- data/lib/principles/models/outline_budget.rb +29 -14
- 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 +14 -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/problem_report.rb +36 -9
- data/lib/principles/models/project.rb +47 -30
- data/lib/principles/models/project_history.rb +45 -25
- data/lib/principles/models/record_format.rb +6 -0
- data/lib/principles/models/reported_check.rb +16 -12
- data/lib/principles/models/request_id.rb +1 -1
- data/lib/principles/models/sent_answer.rb +35 -5
- data/lib/principles/models/survey_search_paths.rb +26 -0
- data/lib/principles/models/uncommitted_files.rb +50 -0
- data/lib/principles/models/unknown_principle.rb +29 -0
- data/lib/principles/positional_arguments.rb +38 -0
- data/lib/principles/session_start_options.rb +3 -3
- data/lib/principles/start_audit_options.rb +10 -2
- data/lib/principles/version.rb +2 -2
- data/lib/principles/views/acknowledgement_result.rb +54 -16
- 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 +26 -5
- data/lib/principles/views/assessment_request.rb +24 -4
- data/lib/principles/views/audit_result.rb +30 -27
- data/lib/principles/views/candidate_files_result.rb +56 -12
- data/lib/principles/views/candidate_outlines_result.rb +25 -0
- data/lib/principles/views/check_result_template.rb +18 -17
- data/lib/principles/views/consecutive_sections_elsewhere.rb +27 -0
- data/lib/principles/views/correction_request.rb +38 -10
- data/lib/principles/views/findings_result.rb +21 -0
- data/lib/principles/views/guidance_search_paths_result.rb +26 -0
- data/lib/principles/views/invocation.rb +19 -4
- data/lib/principles/views/json_with_entries_on_lines.rb +12 -4
- data/lib/principles/views/loads_to_check_result.rb +3 -2
- data/lib/principles/views/map_added_to.rb +56 -2
- data/lib/principles/views/map_result.rb +22 -42
- data/lib/principles/views/maps_needing_members_or_audit.rb +47 -0
- data/lib/principles/views/member_change_since_baseline.rb +2 -1
- data/lib/principles/views/member_repairs.rb +2 -1
- data/lib/principles/views/member_row.rb +61 -0
- data/lib/principles/views/members_a_commit_changed.rb +2 -1
- data/lib/principles/views/members_with_no_baseline.rb +8 -1
- data/lib/principles/views/new_loading_scope.rb +31 -0
- data/lib/principles/views/one_member_check_result_template.rb +37 -21
- data/lib/principles/views/open_findings_line.rb +2 -1
- data/lib/principles/views/principle_read_result.rb +4 -1
- data/lib/principles/views/principles_with_no_completed_audit.rb +9 -3
- data/lib/principles/views/problem_lines.rb +50 -45
- data/lib/principles/views/problem_result.rb +59 -25
- data/lib/principles/views/prompts/acknowledge-a-change/report-the-exit-status-its-own-listing-gives.md +3 -0
- data/lib/principles/views/prompts/acknowledge-a-change/run-the-check-and-report-it-passing.md +3 -3
- data/lib/principles/views/prompts/acknowledge-a-change/say-whether-each-change-keeps-its-meaning.md +8 -0
- data/lib/principles/views/prompts/acknowledge-a-change/say-whether-the-change-keeps-the-meaning.md +6 -6
- data/lib/principles/views/prompts/assess-every-member/answer-guide.json +67 -43
- data/lib/principles/views/prompts/assess-every-member/decide-each-member-loading.md +2 -1
- data/lib/principles/views/prompts/assess-every-member/run-the-check-then-report-it.md +2 -2
- data/lib/principles/views/prompts/assess-every-member/run-the-reviewed-check-and-say-what-its-review-rested-on.md +5 -3
- 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 +12 -0
- 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/choose-an-existing-or-new-principle.md +2 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/choose-one-principle.md +4 -2
- 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/read-left-out-files.md +2 -2
- 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/every-command-and-how-they-chain.md +1 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +37 -4
- data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +20 -19
- data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +65 -61
- 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 +33 -7
- 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/start-audit.md +10 -10
- 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/start-a-session/act-on-the-open-findings.md +1 -1
- data/lib/principles/views/prompts/start-a-session/every-loaded-line-costs-every-session.md +1 -0
- data/lib/principles/views/prompts/start-a-session/start-with-the-principles-skill.md +1 -0
- metadata +67 -4
- data/lib/principles/models/candidate_listing.rb +0 -41
|
@@ -7,6 +7,8 @@ require_relative "../models/finding_write_ups"
|
|
|
7
7
|
require_relative "../models/repoint"
|
|
8
8
|
require_relative "../views/repoint_result"
|
|
9
9
|
|
|
10
|
+
require_relative "../views/answered_request"
|
|
11
|
+
|
|
10
12
|
module Principles
|
|
11
13
|
# Each runs one command: reads models, applies their rules and prints through a view.
|
|
12
14
|
# controllers/CLAUDE.md owns the boundary.
|
|
@@ -29,7 +31,7 @@ module Principles
|
|
|
29
31
|
# The result of answering, and the record it changes, not yet written, which the repoint refuses once the last
|
|
30
32
|
# completed record changed after the request was printed, unless it writes nothing.
|
|
31
33
|
# @override
|
|
32
|
-
#: (Models::SubmittedAnswer) -> [
|
|
34
|
+
#: (Models::SubmittedAnswer) -> [Views::AnsweredRequest, Array[Models::AuditRecord]]
|
|
33
35
|
def answered(submitted)
|
|
34
36
|
id = submitted.request_id.principle_id
|
|
35
37
|
response = submitted.response
|
|
@@ -37,7 +39,8 @@ module Principles
|
|
|
37
39
|
repointed, changes = repoint.writable(response, records: @audit_records, at: Time.now.utc.iso8601) do |locator|
|
|
38
40
|
snapshot(locator)
|
|
39
41
|
end
|
|
40
|
-
[view.repointed(principle_id: id, file: @audit_records.file(id),
|
|
42
|
+
[Views::AnsweredRequest.new(view.repointed(principle_id: id, file: @audit_records.file(id),
|
|
43
|
+
outcome: outcome(repoint, repointed))), changes]
|
|
41
44
|
end
|
|
42
45
|
|
|
43
46
|
private
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "command"
|
|
5
|
+
require_relative "../views/candidate_files_result"
|
|
6
|
+
require_relative "../views/candidate_outlines_result"
|
|
7
|
+
require_relative "../views/json_with_entries_on_lines"
|
|
8
|
+
|
|
9
|
+
module Principles
|
|
10
|
+
# Each runs one command: reads models, applies their rules and prints through a view.
|
|
11
|
+
# controllers/CLAUDE.md owns the boundary.
|
|
12
|
+
module Controllers
|
|
13
|
+
# list-candidate-files: the survey of the files that look like agent guidance, with their outlines within the
|
|
14
|
+
# budget, and the question of which principle they carry. It changes nothing on disk, and changes for the survey's
|
|
15
|
+
# reasons alone, apart from the reads of what is already mapped (#1015).
|
|
16
|
+
class Survey < Command
|
|
17
|
+
#: (String, String?, Hash[String, untyped]) -> untyped
|
|
18
|
+
def call(command, _id, options)
|
|
19
|
+
naming_the_executable do
|
|
20
|
+
case command
|
|
21
|
+
when "list-candidate-files" then list_candidate_files(options)
|
|
22
|
+
when "show-candidate-outlines" then show_candidate_outlines(options.fetch("path"))
|
|
23
|
+
else unknown(command)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
#: (Array[String]) -> Views::JsonWithEntriesOnLines
|
|
31
|
+
def show_candidate_outlines(paths)
|
|
32
|
+
found = @project.candidate_outlines(paths)
|
|
33
|
+
.within_budget { |inventory| Views::CandidateOutlinesResult.new(inventory.to_h).result.text.bytesize }
|
|
34
|
+
Views::CandidateOutlinesResult.new(found.to_h).result
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# The survey; with a revision, only once it names a commit in git (#1171).
|
|
38
|
+
#: (Hash[String, untyped]) -> untyped
|
|
39
|
+
def list_candidate_files(options)
|
|
40
|
+
after = options["commits_after"]
|
|
41
|
+
mapped = @principles.descriptions
|
|
42
|
+
commit = @history.commit_named(after) if after
|
|
43
|
+
found = @project.candidate_files(after: commit, also: options.fetch("also", []))
|
|
44
|
+
.within_budget { |inventory| candidate_files_result(inventory, mapped).text.bytesize }
|
|
45
|
+
candidate_files_result(found, mapped)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# list-candidate-files' result for one inventory, as it prints.
|
|
49
|
+
#: (Models::CandidateInventory, Array[Hash[String, untyped]]) -> Views::JsonWithEntriesOnLines
|
|
50
|
+
def candidate_files_result(found, mapped)
|
|
51
|
+
listed = Views::CandidateFilesResult::Found.new(inventory: found.to_h, untracked: found.untracked,
|
|
52
|
+
owner_asks: found.owner_asks)
|
|
53
|
+
question = Views::CandidateFilesResult.new(invocation).question(listed, existing_maps: @principles.ids,
|
|
54
|
+
map_file: @principles.file("ID"),
|
|
55
|
+
mapped_principles: mapped)
|
|
56
|
+
Views::JsonWithEntriesOnLines.new(question.merge("wrote" => []), under: "inventory", key: "files")
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -33,6 +33,10 @@ module Principles
|
|
|
33
33
|
@directory.exist?(id)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
+
# Any current entry, including an unreadable record or dangling link, protects a map from removal.
|
|
37
|
+
#: (String) -> bool
|
|
38
|
+
def entry?(id) = @directory.entry?(id, shown_as: relative(id))
|
|
39
|
+
|
|
36
40
|
# The record of id's last audit, or nil when it has none, checked against its schema (D29), handing the block
|
|
37
41
|
# a record the schema refuses, as parse does.
|
|
38
42
|
#: (String) ?{ (untyped) -> void } -> Hash[String, untyped]?
|
|
@@ -15,7 +15,7 @@ module Principles
|
|
|
15
15
|
# Folders the inventory never enters: version control, this tool's own records, and installed packages.
|
|
16
16
|
PRUNED_FOLDERS = %w[.git .principles .memeplex .coord node_modules vendor .bundle].freeze
|
|
17
17
|
|
|
18
|
-
# The instruction files an agent host loads by convention
|
|
18
|
+
# The instruction files an agent host loads by convention, beside any explicitly selected paths.
|
|
19
19
|
CANDIDATE_NAMES = %w[CLAUDE.md AGENTS.md].freeze
|
|
20
20
|
CANDIDATE_PATH = %r{(?:\A|/)\.claude/(?:rules/|skills/|agents/|settings[^/]*\.json\z)}
|
|
21
21
|
|
|
@@ -32,39 +32,73 @@ module Principles
|
|
|
32
32
|
leads_to == path ? entry : entry.merge("symlink_to" => leads_to)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
# also names more files to list, inside the project, beside those hosts load by convention.
|
|
36
|
+
#: (ProjectFiles, ?also: Array[String], ?matching: Array[String]) -> void
|
|
37
|
+
def initialize(files, also: [], matching: [])
|
|
37
38
|
@files = files
|
|
39
|
+
@also = also
|
|
40
|
+
@matching = matching
|
|
38
41
|
end
|
|
39
42
|
|
|
40
43
|
#: () -> Hash[String, untyped]
|
|
41
44
|
def to_h
|
|
42
|
-
|
|
45
|
+
walked = candidate_paths
|
|
46
|
+
candidates = walked | @also
|
|
43
47
|
ignored = IgnoredByGit.new(@files.root, candidates).facts
|
|
44
|
-
|
|
45
|
-
entries = entries.sort_by { |entry| entry.fetch("path") }
|
|
46
|
-
listed = { "files" => entries, "unreadable" => skipped,
|
|
47
|
-
"possibly_test_data" => entries.filter_map { |entry| test_data_hint(entry.fetch("path")) } }
|
|
48
|
+
listed = listing(candidates - (ignored&.fetch("ignored") || [])).merge(additional_search_paths(walked))
|
|
48
49
|
ignored ? listed.merge(ignored) : listed
|
|
49
50
|
end
|
|
50
51
|
|
|
51
52
|
private
|
|
52
53
|
|
|
54
|
+
# Explicit matches before ignore/readability filtering; counts of zero remain observable.
|
|
55
|
+
#: (Array[String]) -> Hash[String, untyped]
|
|
56
|
+
def additional_search_paths(paths)
|
|
57
|
+
return { "selected_files" => @also.uniq.sort } if @matching.empty?
|
|
58
|
+
|
|
59
|
+
matches = @matching.to_h { |glob| [glob, paths.select { |path| matches?(glob, path) }] }
|
|
60
|
+
{ "selected_files" => (@also | matches.values.flatten).sort,
|
|
61
|
+
"additional_search_paths" => matches.map do |glob, found|
|
|
62
|
+
{ "glob" => glob, "matched_files" => found.length }
|
|
63
|
+
end }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
#: (String, String) -> bool
|
|
67
|
+
def matches?(glob, path)
|
|
68
|
+
File.fnmatch?(glob, path, File::FNM_PATHNAME | File::FNM_DOTMATCH | File::FNM_EXTGLOB)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Readable file entries and per-path refusals, with the test-data hints for readable entries.
|
|
72
|
+
#: (Array[String]) -> Hash[String, untyped]
|
|
73
|
+
def listing(paths)
|
|
74
|
+
entries, skipped = readable(paths)
|
|
75
|
+
entries = entries.sort_by { |entry| entry.fetch("path") }
|
|
76
|
+
{ "files" => entries, "unreadable" => skipped,
|
|
77
|
+
"possibly_test_data" => entries.filter_map { |entry| test_data_hint(entry.fetch("path")) } }
|
|
78
|
+
end
|
|
79
|
+
|
|
53
80
|
# Each candidate's path relative to the root, in the order the walk finds them.
|
|
54
81
|
#: () -> Array[String]
|
|
55
82
|
def candidate_paths
|
|
56
83
|
paths = [] #: Array[String]
|
|
57
84
|
Find.find(@files.root) do |absolute|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
next
|
|
61
|
-
end
|
|
85
|
+
next unless file_in_walk?(absolute)
|
|
86
|
+
|
|
62
87
|
relative = absolute.delete_prefix("#{@files.root}/")
|
|
63
88
|
paths << relative if candidate?(relative)
|
|
64
89
|
end
|
|
65
90
|
paths
|
|
66
91
|
end
|
|
67
92
|
|
|
93
|
+
# Whether this walk visits a file, pruning internal folders and other projects before descending.
|
|
94
|
+
#: (String) -> bool
|
|
95
|
+
def file_in_walk?(absolute)
|
|
96
|
+
return File.basename(absolute) != ".git" unless File.directory?(absolute)
|
|
97
|
+
|
|
98
|
+
Find.prune if PRUNED_FOLDERS.include?(File.basename(absolute)) || nested_repository?(absolute)
|
|
99
|
+
false
|
|
100
|
+
end
|
|
101
|
+
|
|
68
102
|
# A folder below the root holding its own .git, a worktree's file or a clone's folder, is another project,
|
|
69
103
|
# as git treats it (#376). The root may hold one too: this tool runs in a worktree.
|
|
70
104
|
#: (String) -> bool
|
|
@@ -98,7 +132,8 @@ module Principles
|
|
|
98
132
|
|
|
99
133
|
#: (String) -> bool
|
|
100
134
|
def candidate?(relative)
|
|
101
|
-
CANDIDATE_NAMES.include?(File.basename(relative)) || relative.match?(CANDIDATE_PATH)
|
|
135
|
+
CANDIDATE_NAMES.include?(File.basename(relative)) || relative.match?(CANDIDATE_PATH) ||
|
|
136
|
+
@matching.any? { |glob| matches?(glob, relative) }
|
|
102
137
|
end
|
|
103
138
|
end
|
|
104
139
|
end
|
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
"writes": "Writes nothing." },
|
|
5
5
|
{ "id": "write-map", "heading": "Write the member map, `.principles/maps/ID.json`, which the project commits",
|
|
6
6
|
"writes": "Writes `.principles/maps/ID.json`; commit it as it changes. Never a member's file." },
|
|
7
|
+
{ "id": "remove-map", "heading": "Remove an obsolete map; retain its member files and audit history",
|
|
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
|
+
{ "id": "write-guidance-search-paths", "heading": "Write the recorded guidance search paths, which the project commits",
|
|
10
|
+
"writes": "Writes `.principles/guidance-search-paths.json`; commit it as it changes. Never a map, audit or guidance file." },
|
|
7
11
|
{ "id": "write-audit-record", "heading": "Audit; these write only the audit record, `.principles/audits/ID.json`, which the project commits",
|
|
8
12
|
"writes": "Writes `.principles/audits/ID.json`, listed under `wrote` when it does; commit it. Never the map or a member's file." }
|
|
9
13
|
],
|
|
@@ -18,19 +22,43 @@
|
|
|
18
22
|
},
|
|
19
23
|
"commands": [
|
|
20
24
|
{
|
|
21
|
-
"name": "list-candidate-files", "usage": "list-candidate-files", "group": "read", "options": [],
|
|
25
|
+
"name": "list-candidate-files", "usage": "list-candidate-files [--commits-after REV] [--also GLOB]...", "group": "read", "options": ["commits-after", "also"],
|
|
22
26
|
"summary": "Ask what in this project looks like a principle.",
|
|
23
27
|
"help": "learn-what-a-command-does/list-candidate-files",
|
|
24
28
|
"steps": [
|
|
25
29
|
{ "id": "list-instruction-files", "actor": "cli",
|
|
26
|
-
"does": "Lists the instruction files agent hosts load by convention, naming git-ignored ones unread rather than listing them, each folder git ignores counted once, leaving out folders that hold their own git repository, and names any under a fixtures, examples or samples folder and, in git, any git does not track.
|
|
30
|
+
"does": "Lists the instruction files agent hosts load by convention, naming git-ignored ones unread rather than listing them, each folder git ignores counted once, leaving out folders that hold their own git repository, and names any under a fixtures, examples or samples folder and, in git, any git does not track. With --commits-after, lists the files the commits after it changed first, marked, Markdown outside those places included, and refuses outside git and a revision git cannot resolve to a commit. Repeated --also root-relative globs include explicitly selected guidance, including skill references and named non-Markdown files; additional_search_paths reports each match count within traversal boundaries. No location is saved.",
|
|
31
|
+
"refuses": ["range_needs_git", "unknown_revision", "invalid_guidance_search_path"] },
|
|
27
32
|
{ "id": "choose-one-principle", "actor": "agent",
|
|
28
|
-
"does": "Show the user a table of the principles several listed files reinforce, asking nothing before it, then
|
|
33
|
+
"does": "Show the user a table of the principles several listed files reinforce, asking nothing before it, then, when maps exist, compare each rule with the descriptions in mapped_principles before choosing whether to extend an existing map or create a distinct one. Decide whether each file named in possibly_test_data is guidance or a sample. After the table, ask where else the repository keeps guidance; --also includes it in a read-only survey without recording it.",
|
|
29
34
|
"prompt": "find-a-principle-to-map/choose-one-principle",
|
|
30
|
-
"cannot_check": "whether a file is guidance or test data; ask the project's owner when you cannot tell.",
|
|
35
|
+
"cannot_check": "whether a rule is a facet of an existing principle or distinct, or whether a file is guidance or test data; ask the project's owner when you cannot tell.",
|
|
36
|
+
"next": [
|
|
37
|
+
{ "to": "extend-existing-principle", "when": "the rule is a facet of an existing principle" },
|
|
38
|
+
{ "to": "map-distinct-principle", "when": "the rule is a distinct principle" }
|
|
39
|
+
] },
|
|
40
|
+
{ "id": "extend-existing-principle", "actor": "agent",
|
|
41
|
+
"does": "Choose the existing principle and the additional place that carries it, with its role.",
|
|
42
|
+
"answer_with": "add-member" },
|
|
43
|
+
{ "id": "map-distinct-principle", "actor": "agent",
|
|
44
|
+
"does": "Choose a lower-kebab-case id and describe what the distinct principle is and why it matters.",
|
|
31
45
|
"answer_with": "create-principle" }
|
|
32
46
|
]
|
|
33
47
|
},
|
|
48
|
+
{
|
|
49
|
+
"name": "show-candidate-outlines", "usage": "show-candidate-outlines PATH...", "group": "read", "options": [],
|
|
50
|
+
"summary": "Read the outlines the survey left out, by literal file path.",
|
|
51
|
+
"help": "learn-what-a-command-does/show-candidate-outlines",
|
|
52
|
+
"steps": [
|
|
53
|
+
{ "id": "read-requested-outlines", "actor": "cli",
|
|
54
|
+
"does": "Lists only the requested literal project files, once each, in path order. Each readable Markdown file receives the survey's outline, including explicitly requested test data and skill references; non-Markdown files show path and size alone. Ignored files and links to ignored text stay unread. Each failed path retains its refusal beside successful entries. The whole rendered result uses OutlineBudget and names shortened or omitted outlines.",
|
|
55
|
+
"refuses_like": ["locate-text"] },
|
|
56
|
+
{ "id": "continue-the-survey", "actor": "agent",
|
|
57
|
+
"does": "Judge which requested outlines matter to the survey. Repair failed paths; request fewer paths to recover omitted outlines, or read only needed line ranges when one file remains too large.",
|
|
58
|
+
"prompt": "read-requested-outlines/continue-the-survey",
|
|
59
|
+
"cannot_check": "whether a file or rule matters to the task; the agent judges relevance." }
|
|
60
|
+
]
|
|
61
|
+
},
|
|
34
62
|
{
|
|
35
63
|
"name": "list-principles", "usage": "list-principles", "group": "read", "options": [],
|
|
36
64
|
"summary": "Every mapped principle and whether its members are current.",
|
|
@@ -42,12 +70,12 @@
|
|
|
42
70
|
]
|
|
43
71
|
},
|
|
44
72
|
{
|
|
45
|
-
"name": "list-member-problems", "usage": "list-member-problems [ID] [--short | --commits-after COMMIT --hook-event EVENT]", "group": "read", "options": ["short", "commits-after", "hook-event"],
|
|
73
|
+
"name": "list-member-problems", "usage": "list-member-problems [ID] [--short | --commits-after COMMIT --hook-event EVENT]", "group": "read", "options": ["short", "session-start", "commits-after", "hook-event"],
|
|
46
74
|
"summary": "Members whose reference is broken, or whose own text changed since their baseline.",
|
|
47
75
|
"help": "learn-what-a-command-does/list-member-problems",
|
|
48
76
|
"steps": [
|
|
49
77
|
{ "id": "compare-members-with-their-baselines", "actor": "cli",
|
|
50
|
-
"does": "Finds each member of map ID, or of every map, and compares its own text with the last audit's hash for it, or else with its text at the commit that mapped it where it is. Refuses while any member cannot be found or read, or a map cannot be read, so a gate can stop on the exit status; otherwise lists each changed member with what it was compared with, and counts every state. With --short, prints one tab-separated line per changed member
|
|
78
|
+
"does": "Finds each member of map ID, or of every map, and compares its own text with the last audit's hash for it, or else with its text at the commit that mapped it where it is. Refuses while any member cannot be found or read, or a map cannot be read, so a gate can stop on the exit status; otherwise lists each changed member with what it was compared with, and counts every state. With --short, prints one tab-separated line per changed member, then one per principle counting its members no audit has assessed, and exits 3 when it prints any line.",
|
|
51
79
|
"refuses": ["broken_members"], "refuses_like": ["read-map", "read-audit"] },
|
|
52
80
|
{ "id": "repair-or-audit", "actor": "agent",
|
|
53
81
|
"does": "For a refusal, say whether each listed member moved or is gone, and repair it. For a changed member, audit its principle when the change was meant to alter the principle.",
|
|
@@ -76,12 +104,12 @@
|
|
|
76
104
|
]
|
|
77
105
|
},
|
|
78
106
|
{
|
|
79
|
-
"name": "list-open-findings", "usage": "list-open-findings [ID] [--short [--session-start SOURCE]]", "group": "read", "options": ["short", "session-start"],
|
|
107
|
+
"name": "list-open-findings", "usage": "list-open-findings [ID] [--lines | --short [--session-start SOURCE]]", "group": "read", "options": ["short", "session-start", "lines"],
|
|
80
108
|
"summary": "The findings the last audit of each principle deferred or accepted, and where each is written up.",
|
|
81
109
|
"help": "learn-what-a-command-does/list-open-findings",
|
|
82
110
|
"steps": [
|
|
83
111
|
{ "id": "read-open-findings", "actor": "cli",
|
|
84
|
-
"does": "Reads the last audit record of principle ID, or of every principle, and lists each deferred or accepted finding with its action, its members, its recorded_at pointer and when the audit was made. Says that an earlier audit's open findings are only in git. With --short, prints one line saying how many are open, how long the oldest has waited and what it waits on, and nothing when none is open; --session-start clear or compact words it for a context just cleared or compacted, and resume shortens it to the facts, since a resumed conversation holds the whole line already.",
|
|
112
|
+
"does": "Reads the last audit record of principle ID, or of every principle, and lists each deferred or accepted finding with its action, its members, its recorded_at pointer and when the audit was made. Says that an earlier audit's open findings are only in git. With --lines, prints each open finding on a line with its principle, id and waits_on. With --short, prints one line saying how many are open, how long the oldest has waited and what it waits on, and nothing when none is open; --session-start clear or compact words it for a context just cleared or compacted, and resume shortens it to the facts, since a resumed conversation holds the whole line already.",
|
|
85
113
|
"refuses_like": ["read-map", "read-audit"] },
|
|
86
114
|
{ "id": "follow-up-each-finding", "actor": "agent",
|
|
87
115
|
"does": "Read each finding where its recorded_at points, and decide each one at its principle's next full audit.",
|
|
@@ -90,15 +118,15 @@
|
|
|
90
118
|
]
|
|
91
119
|
},
|
|
92
120
|
{
|
|
93
|
-
"name": "show-answer-check", "usage": "show-answer-check REQUEST_ID --file FILE|-", "group": "read", "options": ["file"], "requires": ["file"],
|
|
121
|
+
"name": "show-answer-check", "usage": "show-answer-check [REQUEST_ID] --file FILE|-", "group": "read", "options": ["file"], "requires": ["file"],
|
|
94
122
|
"summary": "Check an answer without submitting it.",
|
|
95
123
|
"help": "learn-what-a-command-does/show-answer-check",
|
|
96
124
|
"steps": [
|
|
97
125
|
{ "id": "check-without-writing", "actor": "cli",
|
|
98
126
|
"does": "Runs every check submit-answer would and prints the same refusal, or names the files submitting would write. Writes nothing.",
|
|
99
|
-
"refuses": ["unparseable_json", "unreadable_file", "request_mismatch", "unknown_request", "stale_request", "stale_map", "undeclared_move", "moves_need_git", "map_entries_need_git",
|
|
127
|
+
"refuses": ["unparseable_json", "unreadable_file", "request_mismatch", "unknown_request", "stale_request", "stale_map", "undeclared_move", "moves_need_git", "map_entries_need_git", "invalid_removed_members", "empty_correction_map",
|
|
100
128
|
"incomplete_coverage", "invalid_delivery", "observation_repeats_last_audit", "invalid_check_result", "invalid_answer", "unknown_member", "duplicate_finding",
|
|
101
|
-
"incomplete_dispositions", "invalid_disposition", "claimed_change_missing", "unassessed_changes"],
|
|
129
|
+
"incomplete_dispositions", "invalid_disposition", "claimed_change_missing", "unassessed_changes", "git_history_unavailable"],
|
|
102
130
|
"refuses_like": ["read-map", "read-audit", "locate-text", "rewrite-audit"] },
|
|
103
131
|
{ "id": "submit-the-checked-answer", "actor": "agent",
|
|
104
132
|
"does": "Fix what a refusal names and check again, or submit the answer unchanged.",
|
|
@@ -125,14 +153,27 @@
|
|
|
125
153
|
"help": "learn-what-a-command-does/create-principle",
|
|
126
154
|
"steps": [
|
|
127
155
|
{ "id": "write-new-map", "actor": "cli",
|
|
128
|
-
"does": "Checks that ID is lower-kebab-case, not yet mapped and not sticking-to-your-principles, which setup starts, then writes a map with the description and no members.",
|
|
129
|
-
"refuses": ["invalid_id", "principle_exists", "meta_principle_id", "invalid_answer"] },
|
|
156
|
+
"does": "Checks that ID is lower-kebab-case, not yet mapped and not sticking-to-your-principles, which setup starts. Verifies that its map is absent at committed HEAD, requiring any prior removal to be committed, then writes a map with the description and no members.",
|
|
157
|
+
"refuses": ["invalid_id", "principle_exists", "meta_principle_id", "invalid_answer", "map_removal_not_committed", "git_history_unavailable"] },
|
|
130
158
|
{ "id": "choose-members", "actor": "agent",
|
|
131
|
-
"does": "Choose the files, sections or passages that reinforce the principle, and the part each plays.",
|
|
159
|
+
"does": "Choose the files, sections or passages that reinforce the principle, and the part each plays, using list-candidate-files to survey the guidance first if no survey has been done.",
|
|
132
160
|
"cannot_check": "whether the members you choose are the right ones.",
|
|
133
161
|
"answer_with": "add-member" }
|
|
134
162
|
]
|
|
135
163
|
},
|
|
164
|
+
{
|
|
165
|
+
"name": "remove-principle", "usage": "remove-principle ID [--confirm]", "group": "remove-map", "options": ["confirm"],
|
|
166
|
+
"summary": "Remove an obsolete map while keeping its member files and audit history.",
|
|
167
|
+
"help": "learn-what-a-command-does/remove-principle",
|
|
168
|
+
"steps": [
|
|
169
|
+
{ "id": "remove-map-with-audit-protection", "actor": "cli",
|
|
170
|
+
"does": "Removes only the named map. Refuses any current audit entry unless --confirm explicitly deactivates its map in routine reports, preserving the entry and unresolved findings. An unknown entry check still refuses.",
|
|
171
|
+
"refuses_like": ["read-map"], "refuses": ["principle_has_audit_record", "store_entry_unreadable", "store_remove_failed", "symlinked_store_file", "not_a_file"] },
|
|
172
|
+
{ "id": "inspect-remaining-maps", "actor": "agent",
|
|
173
|
+
"does": "Commit the map removal if it was tracked, then inspect the remaining principles.",
|
|
174
|
+
"answer_with": "list-principles" }
|
|
175
|
+
]
|
|
176
|
+
},
|
|
136
177
|
{
|
|
137
178
|
"name": "change-description", "usage": "change-description ID --description TEXT", "group": "write-map", "options": ["description"],
|
|
138
179
|
"summary": "Reword a mapped principle.",
|
|
@@ -158,8 +199,8 @@
|
|
|
158
199
|
"help": "learn-what-a-command-does/add-member",
|
|
159
200
|
"steps": [
|
|
160
201
|
{ "id": "locate-new-member", "actor": "cli",
|
|
161
|
-
"does": "
|
|
162
|
-
"refuses": ["invalid_answer", "ending_without_start"], "refuses_like": ["read-map", "locate-text"] },
|
|
202
|
+
"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.",
|
|
203
|
+
"refuses": ["invalid_answer", "ending_without_start", "ambiguous_passage_end", "map_removal_not_committed", "git_history_unavailable"], "refuses_like": ["read-map", "locate-text"] },
|
|
163
204
|
{ "id": "write-member", "actor": "cli",
|
|
164
205
|
"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.",
|
|
165
206
|
"refuses": ["member_exists"] },
|
|
@@ -178,7 +219,7 @@
|
|
|
178
219
|
"refuses": ["unknown_member", "invalid_answer"], "refuses_like": ["read-map"] },
|
|
179
220
|
{ "id": "locate-new-place", "actor": "cli",
|
|
180
221
|
"does": "Finds the text at the new locator, in PATH when --path names the file the member's file was renamed to or its text moved into, or else in its own file. The locator replaces the old one whole, and the member keeps its role and the key its audit is filed under.",
|
|
181
|
-
"refuses": ["invalid_answer", "ending_without_start", "member_exists"], "refuses_like": ["locate-text"] }
|
|
222
|
+
"refuses": ["invalid_answer", "ending_without_start", "ambiguous_passage_end", "member_exists"], "refuses_like": ["locate-text"] }
|
|
182
223
|
]
|
|
183
224
|
},
|
|
184
225
|
{
|
|
@@ -218,7 +259,7 @@
|
|
|
218
259
|
]
|
|
219
260
|
},
|
|
220
261
|
{
|
|
221
|
-
"name": "start-audit", "usage": "start-audit ID [--member MEMBER | --write-ups] [--as template | --instruction FIELD]", "group": "write-audit-record", "options": ["member", "write-ups", "as", "instruction"],
|
|
262
|
+
"name": "start-audit", "usage": "start-audit ID [--member MEMBER ... | --write-ups] [--as template | --instruction FIELD]", "group": "write-audit-record", "options": ["member", "write-ups", "as", "instruction"],
|
|
222
263
|
"summary": "Ask for an assessment of every member and the set.",
|
|
223
264
|
"help": "learn-what-a-command-does/start-audit",
|
|
224
265
|
"steps": [
|
|
@@ -229,7 +270,7 @@
|
|
|
229
270
|
{ "to": "start-acknowledgement", "when": "you passed --member" },
|
|
230
271
|
{ "to": "start-repointing", "when": "you passed --write-ups" }] },
|
|
231
272
|
{ "id": "assess-every-member", "actor": "agent",
|
|
232
|
-
"does": "Assess each member not carried forward, and any carried one whose sighting is too old to stand behind, the set as a whole and one decision you made recently under it, with a finding for each problem. Decide each prior finding and member to check against the activation
|
|
273
|
+
"does": "Assess each member not carried forward, and any carried one whose sighting is too old to stand behind, the set as a whole and one decision you made recently under it, with a finding for each problem. Run each check, carried_checks_to_run's too, per check_instructions. Decide each prior finding and listed member to check against the activation.",
|
|
233
274
|
"prompt": "assess-every-member/assess-each-member-and-the-set",
|
|
234
275
|
"checks": "every member is assessed or carried forward once, a marker only where the request carries the member, and each piece of evidence resolves to project text that has not changed since the request.",
|
|
235
276
|
"cannot_check": "whether your assessment is true, a member reached your context, or your findings are the right ones.",
|
|
@@ -249,12 +290,12 @@
|
|
|
249
290
|
]
|
|
250
291
|
},
|
|
251
292
|
{
|
|
252
|
-
"name": "submit-answer", "usage": "submit-answer REQUEST_ID --file FILE|-", "group": "write-audit-record", "options": ["file"], "requires": ["file"],
|
|
293
|
+
"name": "submit-answer", "usage": "submit-answer [REQUEST_ID] --file FILE|-", "group": "write-audit-record", "options": ["file"], "requires": ["file"],
|
|
253
294
|
"summary": "Give the answer a request asked for.",
|
|
254
295
|
"help": "learn-what-a-command-does/submit-answer",
|
|
255
296
|
"steps": [
|
|
256
297
|
{ "id": "match-request", "actor": "cli",
|
|
257
|
-
"does": "Reads FILE, or stdin for -, and
|
|
298
|
+
"does": "Reads FILE, or stdin for -, and takes its request_id, an id this tool prints, as the request; REQUEST_ID, when given, must match.",
|
|
258
299
|
"refuses": ["unparseable_json", "unreadable_file", "request_mismatch", "unknown_request"], "refuses_like": ["rewrite-audit"],
|
|
259
300
|
"next": [{ "to": "acknowledge-the-change", "when": "the request was a one-member audit" },
|
|
260
301
|
{ "to": "record-the-repoints", "when": "the request was a repoint of write-ups" },
|
|
@@ -279,8 +320,8 @@
|
|
|
279
320
|
"next": [{ "to": "check-assessment", "when": "the request was an assessment" },
|
|
280
321
|
{ "to": "check-dispositions", "when": "the request was a correction" }] },
|
|
281
322
|
{ "id": "check-assessment", "actor": "cli",
|
|
282
|
-
"does": "Refuses
|
|
283
|
-
"refuses": ["stale_request", "audit_completed_since_request", "incomplete_prior_findings", "invalid_decision", "raised_in_not_found", "raised_in_unreadable", "raised_in_lacks_finding", "raised_in_time_differs", "first_raised_not_earlier", "incomplete_loading_decisions", "invalid_loading_decision", "incomplete_coverage", "invalid_delivery", "observation_repeats_last_audit", "invalid_check_result", "invalid_answer", "unknown_member", "duplicate_finding"],
|
|
323
|
+
"does": "Refuses changed request inputs or, with a Git base, a committed current-ID map gap on captured HEAD's first-parent line; unverifiable continuity refuses. Checks complete member, loading and prior-finding decisions and resolvable evidence. Prints a correction request for findings, writing an open record only outside git.",
|
|
324
|
+
"refuses": ["stale_request", "git_history_unavailable", "audit_completed_since_request", "incomplete_prior_findings", "invalid_decision", "raised_in_not_found", "raised_in_unreadable", "raised_in_lacks_finding", "raised_in_time_differs", "first_raised_not_earlier", "incomplete_loading_decisions", "invalid_loading_decision", "incomplete_coverage", "invalid_delivery", "observation_repeats_last_audit", "invalid_check_result", "invalid_answer", "unknown_member", "duplicate_finding"],
|
|
284
325
|
"refuses_like": ["locate-text"],
|
|
285
326
|
"next": [{ "to": "complete-audit", "when": "there are no findings" },
|
|
286
327
|
{ "to": "dispose-of-each-finding", "when": "there are findings" }] },
|
|
@@ -291,8 +332,8 @@
|
|
|
291
332
|
"cannot_check": "whether a fix is right or a deferral justified.",
|
|
292
333
|
"answer_with": "submit-answer" },
|
|
293
334
|
{ "id": "check-dispositions", "actor": "cli",
|
|
294
|
-
"does": "
|
|
295
|
-
"refuses": ["stale_map", "undeclared_move", "moves_need_git", "map_entries_need_git", "stale_request", "audit_completed_since_request", "incomplete_dispositions", "invalid_disposition", "invalid_answer", "claimed_change_missing", "unassessed_changes"],
|
|
335
|
+
"does": "Checks the original request, basis and hashes and, with a Git base, uninterrupted current-ID map presence on captured HEAD's first-parent line. Refuses unverifiable continuity or undeclared map changes. Checks one disposition per finding, that only fixed members changed since the base, and each recorded_at resolves.",
|
|
336
|
+
"refuses": ["stale_map", "undeclared_move", "moves_need_git", "map_entries_need_git", "invalid_removed_members", "empty_correction_map", "stale_request", "git_history_unavailable", "audit_completed_since_request", "incomplete_dispositions", "invalid_disposition", "invalid_answer", "claimed_change_missing", "unassessed_changes"],
|
|
296
337
|
"refuses_like": ["locate-text"] },
|
|
297
338
|
{ "id": "complete-audit", "actor": "cli",
|
|
298
339
|
"does": "Writes the record unless it already says the same, and prints the open and resolved findings and the files to commit, in git only those differing from HEAD, with the commits since the base touching each changed member.",
|
|
@@ -301,6 +342,26 @@
|
|
|
301
342
|
"does": "Commit the record with your fixes, and report the outcome, open findings included, to the project's owner.",
|
|
302
343
|
"cannot_check": "that the owner was told, or that you committed." }
|
|
303
344
|
]
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
"name": "add-guidance-search-path", "usage": "add-guidance-search-path GLOB", "group": "write-guidance-search-paths", "options": [],
|
|
348
|
+
"summary": "Record an additional guidance search path after the principles table has been shown.",
|
|
349
|
+
"help": "learn-what-a-command-does/add-guidance-search-path",
|
|
350
|
+
"steps": [
|
|
351
|
+
{ "id": "record-guidance-search-path", "actor": "cli",
|
|
352
|
+
"does": "Validate a root-relative glob and record it once in the project's guidance search paths.",
|
|
353
|
+
"refuses": ["invalid_guidance_search_path", "unparseable_guidance_search_paths", "invalid_guidance_search_paths", "newer_guidance_search_paths", "guidance_search_paths_io_error", "symlinked_directory", "symlinked_guidance_search_paths"] }
|
|
354
|
+
]
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
"name": "remove-guidance-search-path", "usage": "remove-guidance-search-path GLOB", "group": "write-guidance-search-paths", "options": [],
|
|
358
|
+
"summary": "Stop recording one additional guidance search path.",
|
|
359
|
+
"help": "learn-what-a-command-does/remove-guidance-search-path",
|
|
360
|
+
"steps": [
|
|
361
|
+
{ "id": "remove-recorded-location", "actor": "cli",
|
|
362
|
+
"does": "Validate the glob and remove that recorded location, retaining an empty configuration after the last removal.",
|
|
363
|
+
"refuses": ["invalid_guidance_search_path", "unknown_guidance_search_path", "unparseable_guidance_search_paths", "invalid_guidance_search_paths", "newer_guidance_search_paths", "guidance_search_paths_io_error", "symlinked_directory", "symlinked_guidance_search_paths"] }
|
|
364
|
+
]
|
|
304
365
|
}
|
|
305
366
|
]
|
|
306
367
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../error"
|
|
5
|
+
require_relative "git_command"
|
|
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 literal entries of one exact committed tree, read through its supplied Git command.
|
|
11
|
+
class CommittedTree
|
|
12
|
+
SHA = /\A\h{40}(?:\h{24})?\z/ #: Regexp
|
|
13
|
+
ENTRY_TYPES = { "100644" => "blob", "100755" => "blob", "120000" => "blob", "040000" => "tree",
|
|
14
|
+
"160000" => "commit" }.freeze #: Hash[String, String]
|
|
15
|
+
|
|
16
|
+
#: (GitCommand, String, Error) -> void
|
|
17
|
+
def initialize(git, revision, refusal)
|
|
18
|
+
@git = git
|
|
19
|
+
@revision = revision.dup.freeze #: String
|
|
20
|
+
@refusal = refusal
|
|
21
|
+
freeze
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
#: (String) -> bool
|
|
25
|
+
def entry?(path) = !tree_output(path).empty?
|
|
26
|
+
|
|
27
|
+
#: (String) -> Hash[String, String]?
|
|
28
|
+
def raw_entry(path)
|
|
29
|
+
output = tree_output(path)
|
|
30
|
+
return nil if output.empty?
|
|
31
|
+
|
|
32
|
+
fields = raw_metadata(output, path)
|
|
33
|
+
return fields.freeze unless fields.fetch("type") == "blob"
|
|
34
|
+
|
|
35
|
+
fields.merge("bytes" => blob_bytes(fields.fetch("object_id"))).freeze
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
#: (String) -> String
|
|
41
|
+
def tree_output(path)
|
|
42
|
+
raise @refusal unless SHA.match?(@revision)
|
|
43
|
+
|
|
44
|
+
output, status = @git.run_with_status(["ls-tree", "-z", @revision, "--", path])
|
|
45
|
+
raise @refusal unless status&.zero?
|
|
46
|
+
|
|
47
|
+
output
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
#: (String, String) -> Hash[String, String]
|
|
51
|
+
def raw_metadata(output, path)
|
|
52
|
+
record = output.b
|
|
53
|
+
raise @refusal unless record.end_with?("\0") && record.count("\0") == 1
|
|
54
|
+
|
|
55
|
+
metadata, returned = record.delete_suffix("\0").split("\t", 2)
|
|
56
|
+
raise @refusal unless returned == path.b
|
|
57
|
+
|
|
58
|
+
entry_fields(metadata.to_s)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
#: (String) -> Hash[String, String]
|
|
62
|
+
def entry_fields(metadata)
|
|
63
|
+
match = /\A([0-7]{6}) (blob|tree|commit) (\h{40}(?:\h{24})?)\z/.match(metadata)
|
|
64
|
+
raise @refusal unless match
|
|
65
|
+
|
|
66
|
+
parts = match.captures.map { it.to_s.freeze }
|
|
67
|
+
mode = parts.fetch(0)
|
|
68
|
+
type = parts.fetch(1)
|
|
69
|
+
object_id = parts.fetch(2)
|
|
70
|
+
raise @refusal unless ENTRY_TYPES[mode] == type && object_id.length == @revision.length
|
|
71
|
+
|
|
72
|
+
{ "mode" => mode, "type" => type, "object_id" => object_id }
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
#: (String) -> String
|
|
76
|
+
def blob_bytes(object_id)
|
|
77
|
+
bytes, status = @git.run_with_status(["cat-file", "blob", object_id])
|
|
78
|
+
raise @refusal unless status&.zero?
|
|
79
|
+
|
|
80
|
+
bytes.b.freeze
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "git_command"
|
|
5
|
+
|
|
6
|
+
module Principles
|
|
7
|
+
# Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
|
|
8
|
+
module Data
|
|
9
|
+
# The commits on a first-parent line that changed any of some paths, as git log gives them, newest first, each as
|
|
10
|
+
# its full and short sha, subject line, author date and whether it is a root commit ("true" or "false"). The list
|
|
11
|
+
# and each commit are frozen, and a list asked to be kept is read from git once, a refusal included (#1161).
|
|
12
|
+
class FirstParentLog
|
|
13
|
+
#: (GitCommand) -> void
|
|
14
|
+
def initialize(git)
|
|
15
|
+
@git = git
|
|
16
|
+
@kept = {} #: Hash[[String, Array[String]], Array[Hash[String, String]]]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# The commits in range, a revision range Repository has checked, that changed any of paths; kept, when range
|
|
20
|
+
# always names the same commits, so git is not asked again.
|
|
21
|
+
#: (String, Array[String], kept: bool) -> Array[Hash[String, String]]
|
|
22
|
+
def touching(range, paths, kept:)
|
|
23
|
+
return read(range, paths) unless kept
|
|
24
|
+
|
|
25
|
+
@kept[[range, paths.dup.freeze]] ||= read(range, paths)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
#: (String, Array[String]) -> Array[Hash[String, String]]
|
|
31
|
+
def read(range, paths)
|
|
32
|
+
output, ok = @git.run(["log", "--first-parent", "--format=%H%x00%h%x00%s%x00%aI%x00%P", "--end-of-options",
|
|
33
|
+
range, "--", *paths])
|
|
34
|
+
(ok ? commits(output).each(&:freeze) : []).freeze
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Each commit in output, the log read asks git for.
|
|
38
|
+
#: (String) -> Array[Hash[String, String]]
|
|
39
|
+
def commits(output)
|
|
40
|
+
output.force_encoding("UTF-8").lines.map do |line|
|
|
41
|
+
sha, short, subject, authored_at, parents = line.chomp.split("\0", 5)
|
|
42
|
+
{ "sha" => sha.to_s, "commit" => short.to_s, "subject" => subject.to_s, "authored_at" => authored_at.to_s,
|
|
43
|
+
"root" => parents.to_s.empty?.to_s }
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|