principles 0.0.11 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -0
- data/lib/principles/controllers/answer.rb +2 -2
- data/lib/principles/controllers/assessment.rb +19 -3
- data/lib/principles/controllers/audit.rb +14 -4
- data/lib/principles/controllers/full_audit_request.rb +16 -10
- data/lib/principles/controllers/guidance_search_paths.rb +1 -1
- data/lib/principles/controllers/member_addition.rb +4 -1
- data/lib/principles/controllers/member_problems_report.rb +7 -6
- data/lib/principles/controllers/open_finding_decisions.rb +66 -0
- data/lib/principles/controllers/running_tool.rb +22 -5
- data/lib/principles/controllers/survey.rb +3 -2
- data/lib/principles/data/candidate_files_found.rb +6 -4
- data/lib/principles/data/command-steps.json +17 -17
- data/lib/principles/data/json_text.rb +5 -1
- data/lib/principles/data/parser_message.rb +61 -0
- data/lib/principles/data/project_files.rb +4 -2
- data/lib/principles/data/running_version.rb +1 -1
- data/lib/principles/data/schemas/audit-record.schema.json +15 -0
- data/lib/principles/data/schemas/command-steps.schema.json +1 -1
- data/lib/principles/data/schemas/{repointing-answer.schema.json → deciding-answer.schema.json} +12 -6
- data/lib/principles/invocation_options.rb +1 -1
- data/lib/principles/launch.rb +5 -3
- data/lib/principles/models/after_commit_input.rb +1 -0
- data/lib/principles/models/assessment_basis.rb +1 -1
- data/lib/principles/models/audit.rb +23 -3
- data/lib/principles/models/audit_entry_protecting_map.rb +1 -0
- data/lib/principles/models/audit_record.rb +5 -14
- data/lib/principles/models/audit_records.rb +1 -1
- data/lib/principles/models/audited_member_lines.rb +1 -1
- data/lib/principles/models/candidate_files.rb +1 -1
- data/lib/principles/models/candidate_inventory.rb +19 -9
- data/lib/principles/models/candidate_outline.rb +1 -1
- data/lib/principles/models/changed_regions.rb +1 -1
- data/lib/principles/models/command_steps.rb +1 -2
- data/lib/principles/models/correction_basis.rb +1 -1
- data/lib/principles/models/declared_map_changes.rb +1 -2
- data/lib/principles/models/finding_decision.rb +84 -0
- data/lib/principles/models/finding_write_ups.rb +2 -1
- data/lib/principles/models/first_full_audit.rb +1 -0
- data/lib/principles/models/frontmatter_fields.rb +1 -1
- data/lib/principles/models/guidance_search_path.rb +1 -1
- data/lib/principles/models/guidance_search_paths.rb +5 -1
- data/lib/principles/models/head_moves.rb +1 -0
- data/lib/principles/models/ignored_candidates.rb +1 -1
- data/lib/principles/models/instruction_named.rb +1 -1
- data/lib/principles/models/json_path_query.rb +1 -1
- data/lib/principles/models/json_path_selectors.rb +1 -1
- data/lib/principles/models/json_path_string.rb +1 -1
- data/lib/principles/models/last_completed_revision.rb +1 -1
- data/lib/principles/models/line_diff.rb +1 -1
- data/lib/principles/models/line_span.rb +1 -1
- data/lib/principles/models/loading_scope.rb +1 -0
- data/lib/principles/models/located_text.rb +1 -1
- data/lib/principles/models/map_change.rb +66 -0
- data/lib/principles/models/mapped_principles.rb +4 -0
- data/lib/principles/models/markdown_file.rb +22 -1
- data/lib/principles/models/member.rb +1 -1
- data/lib/principles/models/member_elsewhere.rb +1 -1
- data/lib/principles/models/member_file.rb +6 -1
- data/lib/principles/models/member_hashes_as_written.rb +2 -2
- data/lib/principles/models/member_history.rb +1 -1
- data/lib/principles/models/member_lines.rb +1 -1
- data/lib/principles/models/member_loading_scopes.rb +1 -0
- data/lib/principles/models/member_mapping_run.rb +4 -4
- data/lib/principles/models/member_moves.rb +1 -2
- data/lib/principles/models/member_problems.rb +5 -1
- data/lib/principles/models/member_region.rb +1 -1
- data/lib/principles/models/members_elsewhere.rb +1 -1
- data/lib/principles/models/members_in_consecutive_sections.rb +1 -0
- data/lib/principles/models/members_sharing_lines.rb +1 -1
- data/lib/principles/models/misspelt_member_id.rb +1 -1
- data/lib/principles/models/open_finding.rb +4 -3
- data/lib/principles/models/open_findings_decision.rb +124 -0
- data/lib/principles/models/open_findings_elsewhere.rb +1 -1
- data/lib/principles/models/other_templates_placeholders.rb +1 -0
- data/lib/principles/models/outline_budget.rb +1 -1
- data/lib/principles/models/outline_group.rb +1 -1
- data/lib/principles/models/outline_section.rb +1 -1
- data/lib/principles/models/part_named.rb +1 -1
- data/lib/principles/models/plain_text_file.rb +1 -1
- data/lib/principles/models/principle_history.rb +3 -3
- data/lib/principles/models/principle_members.rb +1 -1
- data/lib/principles/models/problem_report.rb +13 -1
- data/lib/principles/models/project.rb +8 -3
- data/lib/principles/models/project_at_commit.rb +9 -19
- data/lib/principles/models/prose_line.rb +36 -0
- data/lib/principles/models/record_format.rb +17 -4
- data/lib/principles/models/recorded_finding.rb +47 -7
- data/lib/principles/models/recorded_findings.rb +7 -7
- data/lib/principles/models/recorded_hashes.rb +1 -1
- data/lib/principles/models/recorded_members.rb +6 -8
- data/lib/principles/models/report_hooks.rb +1 -0
- data/lib/principles/models/request_id.rb +2 -2
- data/lib/principles/models/sent_answer.rb +1 -0
- data/lib/principles/models/session_start_input.rb +1 -0
- data/lib/principles/models/stale_request.rb +22 -8
- data/lib/principles/models/submitted_answer.rb +1 -1
- data/lib/principles/models/survey_search_paths.rb +13 -5
- data/lib/principles/models/text_within.rb +1 -1
- data/lib/principles/models/unchecked_members.rb +1 -0
- data/lib/principles/models/uncommitted_outside_the_map.rb +1 -1
- data/lib/principles/models/unknown_principle.rb +1 -0
- data/lib/principles/models/write_up_opening.rb +5 -31
- data/lib/principles/models/write_up_pointer.rb +2 -1
- data/lib/principles/start_audit_options.rb +25 -18
- data/lib/principles/version.rb +2 -2
- data/lib/principles/views/acknowledgement_result.rb +12 -9
- data/lib/principles/views/added_member.rb +10 -1
- data/lib/principles/views/answer_in_a_file.rb +16 -4
- data/lib/principles/views/assessment_answer_guide.rb +59 -0
- data/lib/principles/views/assessment_request.rb +2 -26
- data/lib/principles/views/audit_result.rb +15 -6
- data/lib/principles/views/candidate_files_result.rb +9 -4
- data/lib/principles/views/context_parts.rb +40 -9
- data/lib/principles/views/correction_request.rb +8 -5
- data/lib/principles/views/first_audit_brief.rb +2 -1
- data/lib/principles/views/guidance_search_paths_result.rb +13 -6
- data/lib/principles/views/invocation.rb +14 -4
- data/lib/principles/views/json_on_one_line.rb +18 -0
- data/lib/principles/views/open_findings_decision_result.rb +60 -0
- data/lib/principles/views/problem_facts.rb +46 -0
- data/lib/principles/views/problem_result.rb +42 -31
- data/lib/principles/views/prompts/answer-any-judgement-request/fill-the-answer-in-a-file.md +1 -1
- data/lib/principles/views/prompts/assess-every-member/read-the-request-in-parts.md +2 -1
- data/lib/principles/views/prompts/decide-open-findings/give-only-what-changed-of-each.md +6 -0
- data/lib/principles/views/prompts/dispose-of-each-finding/confirm-each-deferral-written-up-nowhere.md +2 -1
- data/lib/principles/views/prompts/dispose-of-each-finding/fix-or-record-each-finding.md +2 -2
- data/lib/principles/views/prompts/find-a-principle-to-map/where-a-survey-with-only-looks.md +4 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/add-guidance-search-path.md +2 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/add-member.md +1 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +12 -12
- data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +11 -12
- data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +2 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/show-open-correction.md +2 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +8 -8
- data/lib/principles/views/prompts/run-a-first-audit-in-the-background/follow-the-brief.md +1 -1
- metadata +14 -7
- data/lib/principles/controllers/repoint.rb +0 -67
- data/lib/principles/models/repoint.rb +0 -125
- data/lib/principles/models/write_up_repoint.rb +0 -38
- data/lib/principles/views/prompts/repoint-write-ups/point-each-moved-write-up-at-its-new-place.md +0 -10
- data/lib/principles/views/repoint_result.rb +0 -80
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8cf6524aebb33da2c9c9efedba5e43ff14d0514edac930543d9667d696c91819
|
|
4
|
+
data.tar.gz: 9692a2e6b1b4aa14d6c6e1eba9929b31e1a9a17678d4e1799152e5a5112c5e28
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '0399642f807523558f0835997880cc62dacaf348ad14af9538d4ef4ebb24def915c49d56022577daa26523dd0fc9cbc5453be7e2f45ce39ad245582e84773079'
|
|
7
|
+
data.tar.gz: ae8d5ba7d7d74c13ccb5f7eb0c604ac4aa48b978121922aa31f28176eaa82be2dd63c450cae37b0a745ee309e6bdda96662a4926d0d86a44af6732ee630f4120
|
data/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,37 @@ The agent's mechanics are the means, never the lead: do not open with "An agent
|
|
|
13
13
|
|
|
14
14
|
## Unreleased
|
|
15
15
|
|
|
16
|
+
## [0.1.0] - 2026-11-23
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- **Changing whom an open finding waits on, its action or where it is written up costs one short request and answer, not a full audit.** `principles start-audit ID --open-findings` lists the principle's open findings, and with `--as template` prints an answer naming each by id alone, headed by each field a decision may give and what it means, including that a deferred finding may be left waiting on no one named and that the note itself may be kept or deleted, so filling it needs no search through the request and no guess; give only what changed of each, with a one-line reason, and `principles submit-answer` keeps each change beside its finding. On a principle with two open findings the request is about 5 KB, where its full audit's is about 28 KB.
|
|
21
|
+
- **A survey can read just the guidance a new search path adds.** `principles list-candidate-files --only GLOB`, repeated for more globs, lists only the files those globs match, leaving out the files hosts load by convention and the recorded search paths, so a second survey costs what the new files cost rather than the whole project again. `principles add-guidance-search-path` now prints that narrower survey for the glob it added. On a project of 25 guidance files with three new paths holding 17 more, one `--only` survey of the three costs about 11.6 KB, where surveying the whole project again cost about 27.6 KB. The survey's help now says each outline is a flat list of lines, headings and their list items, so reading one needs no guess at nested keys.
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- **An acknowledgement request says what it asks before the members' text, so the agent finds its question without reading it all or scripting it.** `principles start-audit ID --member A`, for one member or several, of one principle or several, now prints its question at the head of its context, before each member's change. On a three-member request of about 8.3 KB, the question starts at byte 169, where it started at byte 5,690.
|
|
26
|
+
- **A full audit answer refused because its map changed says what changed, so the agent no longer guesses which of five causes to undo.** When the map was changed and committed after `principles start-audit ID` printed the request, `principles submit-answer` names each change, such as a member's role as it was and is now, where it listed every input a request depends on. Its repair keeps the answer: copy the new request's id and basis into it and judge again only the members whose entry changed, or change the map back and submit it unchanged, where it said to start over.
|
|
27
|
+
- **A full audit's request says how large each of its parts is, so the agent chooses what to read without a script.** `principles start-audit ID` now opens with each part's name, as `--part` takes it, and its bytes, the sizes `--part index` lists. On a principle of 15 members that adds about 1.6 KB to a 37 KB request.
|
|
28
|
+
- **A full audit's guide to the answer's shapes reads without a script.** `principles start-audit ID`, and its `--part answer_guide` and `--instruction answer_guide`, now print each example the agent copies into its answer compact on a line of its own, where it ran several levels deep with no indentation to show where each one ended. The guide prints in about half the lines, with the same fields.
|
|
29
|
+
- **Breaking:** **The refusal of a decision on open findings now says what it refuses.** `principles start-audit ID --open-findings`, and `submit-answer` for its answer, refuse a principle with no completed audit, or with one left open, as `cannot_decide_open_findings` where `--write-ups` refused it as `cannot_repoint`; an agent or script matching on `cannot_repoint` should match the new code.
|
|
30
|
+
- **Breaking:** **An audit record that holds a decision on open findings is read only by this release or later.** Such a record is written in format 3, which 0.0.11 and earlier refuse to rewrite rather than drop the change, so everyone sharing a project's `.principles/` should upgrade together.
|
|
31
|
+
|
|
32
|
+
### Removed
|
|
33
|
+
|
|
34
|
+
- **Breaking:** **The old way to repoint a moved write-up is gone, and its refusal names the new one.** `principles start-audit ID --write-ups` is refused, printing the `start-audit ID --open-findings` command to run instead, which points a moved write-up again as it did and changes a finding's wait and action too.
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
|
|
38
|
+
- **An agent that edits a mapped rule is told to commit it before auditing, not sent into a refusal.** When a member's file, or its map, differs from the last commit, `principles list-member-problems`, with or without `--short`, now opens its next step with the files to commit, since `start-audit` audits only committed text and refused them until then.
|
|
39
|
+
- **An answer saved from one shell is no longer missing when another submits it.** Every step that says to save an answer to fill, from `principles start-audit ID`, `show-answer-check` and `show-first-audit-brief ID`, now names one file by its full path in the temporary folder that run of `principles` was given, in both the save and the `submit-answer` command, where it said "under $TMPDIR", which a sandboxed and an unsandboxed shell in Claude Code read as different folders. A path printed by a sandboxed run works from both shells; one printed by an unsandboxed run is outside the sandbox, so a sandboxed shell is refused writing there, rather than finding the file missing later.
|
|
40
|
+
- **A first map no longer takes one line of a wrapped list item for the whole without saying so.** When `principles add-member` is given `--starting-at` with no `--ending-at` in a Markdown file, and the paragraph or list item that line is in runs on, its result names the item's last line and asks whether the member is all of it, where it mapped the first line silently and the shortfall showed only later in `show-principle`'s line numbers.
|
|
41
|
+
- **A full audit sees each change made to an open finding since the last one before it decides the finding.** `principles start-audit ID` now lists, beside each prior finding, every change made since its record, to its wait, action or write-up, with its old value and why, where the auditor saw only the new write-up pointer and the record then dropped the move unread.
|
|
42
|
+
- **An audit asking for several parts that turn out empty learns which ones they were.** `principles start-audit ID --part A --part B` now names each empty part in its `part_empty` line, in the order given, where two empty parts printed one unnamed `part_empty` line and the agent had to rerun each part alone to find out which.
|
|
43
|
+
- **An audit reading several members at once gets every one it names, not just the last.** `principles start-audit ID --part members/A --part members/B` now prints each member named in one `members` list, in the order given, where it printed only the last one and dropped the others without a word.
|
|
44
|
+
- **A broken answer file costs a short refusal, not the rest of the file echoed back.** When `principles submit-answer` or `show-answer-check` cannot parse an answer, such as one holding a raw line break in a string, its `unparseable_json` message now quotes the first 60 characters from where the parser stopped, with any line break written as `\n`, and counts the bytes left out, instead of the whole rest of the file: about 1.4 KB for one answer. It names the line and column where the json Ruby runs gives them; Ruby 3.4's own json does not.
|
|
45
|
+
- **A write-up kept outside the project, such as a tracker comment, now stays findable from the audit record.** When an audit asks for each finding to be fixed or recorded, it now says the record keeps each disposition's reason, which `principles list-open-findings` prints, and to give an outside write-up's link there, where it said the reason was not kept, so an agent left the pointer empty and the link was lost.
|
|
46
|
+
|
|
16
47
|
## [0.0.11] - 2026-11-22
|
|
17
48
|
|
|
18
49
|
### Changed
|
|
@@ -8,7 +8,7 @@ require_relative "../models/submitted_answer"
|
|
|
8
8
|
require_relative "acknowledgement"
|
|
9
9
|
require_relative "acknowledgements"
|
|
10
10
|
require_relative "correction"
|
|
11
|
-
require_relative "
|
|
11
|
+
require_relative "open_finding_decisions"
|
|
12
12
|
require_relative "assessment"
|
|
13
13
|
|
|
14
14
|
module Principles
|
|
@@ -22,7 +22,7 @@ module Principles
|
|
|
22
22
|
# The controller that answers for each phase a request id may name.
|
|
23
23
|
PHASE_CONTROLLERS = {
|
|
24
24
|
"assessment" => Assessment, "correction" => Correction, "acknowledgement" => Acknowledgement,
|
|
25
|
-
"acknowledgements" => Acknowledgements, "
|
|
25
|
+
"acknowledgements" => Acknowledgements, "deciding" => OpenFindingDecisions
|
|
26
26
|
}.freeze #: Hash[String, Class[AnswerPhase]]
|
|
27
27
|
|
|
28
28
|
#: (String, String?, Hash[String, untyped]) -> untyped
|
|
@@ -41,9 +41,7 @@ module Principles
|
|
|
41
41
|
def checked_request(request_id, head)
|
|
42
42
|
audit = audit_now(request_id.principle_id)
|
|
43
43
|
basis = Models::AssessmentBasis.new(head.fetch("basis"))
|
|
44
|
-
prior =
|
|
45
|
-
record: @audit_records.find(audit.id),
|
|
46
|
-
loads: loads_to_check(audit))
|
|
44
|
+
prior = prior_unless_stale(request_id, audit, basis)
|
|
47
45
|
principle_history(audit.id).confirm_current_id_since(basis.base)
|
|
48
46
|
prior
|
|
49
47
|
end
|
|
@@ -80,6 +78,24 @@ module Principles
|
|
|
80
78
|
|
|
81
79
|
private
|
|
82
80
|
|
|
81
|
+
# The prior findings the request request_id names listed, printed with basis, refused unless audit, the map and
|
|
82
|
+
# members as they are now, still gives that request; a refusal names how the map changed since basis's commit,
|
|
83
|
+
# when that explains it.
|
|
84
|
+
#: (Models::RequestId, Models::Audit, Models::AssessmentBasis) -> Models::PriorFindings
|
|
85
|
+
def prior_unless_stale(request_id, audit, basis)
|
|
86
|
+
audit.check_assessment_request(request_id, basis: basis, committed: committed(basis.base, audit.map),
|
|
87
|
+
record: @audit_records.find(audit.id),
|
|
88
|
+
loads: loads_to_check(audit)) { map_at(audit.id, basis.base) }
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# The map of principle_id as commit holds it, nil outside git or where it cannot be read there.
|
|
92
|
+
#: (String, String?) -> Models::Principle?
|
|
93
|
+
def map_at(principle_id, commit)
|
|
94
|
+
commit && principle_history(principle_id).map_at(commit)
|
|
95
|
+
rescue Error
|
|
96
|
+
nil
|
|
97
|
+
end
|
|
98
|
+
|
|
83
99
|
# The placeholders a full audit's template printed, as start-audit --as template prints it now.
|
|
84
100
|
#: (Models::RequestId) -> Hash[String, untyped]?
|
|
85
101
|
def printed_placeholders(request_id)
|
|
@@ -9,7 +9,7 @@ require_relative "../views/open_findings_line"
|
|
|
9
9
|
require_relative "acknowledgement"
|
|
10
10
|
require_relative "acknowledgements"
|
|
11
11
|
require_relative "full_audit_request"
|
|
12
|
-
require_relative "
|
|
12
|
+
require_relative "open_finding_decisions"
|
|
13
13
|
|
|
14
14
|
module Principles
|
|
15
15
|
# Each runs one command: reads models, applies their rules and prints through a view.
|
|
@@ -45,19 +45,29 @@ module Principles
|
|
|
45
45
|
|
|
46
46
|
private
|
|
47
47
|
|
|
48
|
-
# The audit start-audit's options ask for: a one-member audit with --member, a
|
|
49
|
-
# findings
|
|
48
|
+
# The audit start-audit's options ask for: a one-member audit with --member, a decision on the open
|
|
49
|
+
# findings with --open-findings, else a full audit, refusing --write-ups; an audit's answer alone with
|
|
50
50
|
# --as template.
|
|
51
51
|
#: (String, Hash[String, untyped]) -> Hash[String, untyped]
|
|
52
52
|
def started_audit(id, options)
|
|
53
|
+
refuse_write_ups(id) if options["write_ups"]
|
|
53
54
|
naming_the_executable { @audit_records.refuse_newer(id, version: @tool.version) }
|
|
54
55
|
ids = [id, *options.fetch("other_ids", [])]
|
|
55
56
|
return acknowledge(ids, options.fetch("member"), to_fill: options["as"] == "template") if options["member"]
|
|
56
|
-
return handed(
|
|
57
|
+
return handed(OpenFindingDecisions).decide(id, to_fill: options["as"] == "template") if options["open_findings"]
|
|
57
58
|
|
|
58
59
|
full_audit(id, options)
|
|
59
60
|
end
|
|
60
61
|
|
|
62
|
+
# Refuses --write-ups, which --open-findings replaced for one release, printing the request for principle id
|
|
63
|
+
# that replaces it (013 R12).
|
|
64
|
+
#: (String) -> bot
|
|
65
|
+
def refuse_write_ups(id)
|
|
66
|
+
raise Error.new("replaced_option",
|
|
67
|
+
"--write-ups is replaced by --open-findings, which also changes a finding's wait and action",
|
|
68
|
+
"Run instead: #{invocation.in_project("start-audit", id, usage: "--open-findings")}")
|
|
69
|
+
end
|
|
70
|
+
|
|
61
71
|
# A full audit's request, or with --as template its answer alone, or with --instruction one instruction field
|
|
62
72
|
# of it, or with --part one other part of it, or one member's slot of the answer beside --as template.
|
|
63
73
|
#: (String, Hash[String, untyped]) -> Hash[String, untyped]
|
|
@@ -34,10 +34,14 @@ module Principles
|
|
|
34
34
|
@listing = listing #: MembersToAssess::Listing
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
# The request as start-audit prints it, with a notice when the last
|
|
37
|
+
# The request as start-audit prints it, with each part's bytes as --part prints it, and a notice when the last
|
|
38
|
+
# audit's record was left uncommitted.
|
|
38
39
|
#: () -> Hash[String, untyped]
|
|
39
40
|
def printed
|
|
40
|
-
|
|
41
|
+
request = asked
|
|
42
|
+
part_bytes = request_parts(request).part_bytes
|
|
43
|
+
audit_result.request(with_record_notice(audit_result.assessment_request(request, part_bytes:)))
|
|
44
|
+
.merge("wrote" => [])
|
|
41
45
|
end
|
|
42
46
|
|
|
43
47
|
# The answer alone, as start-audit --as template prints it, to fill and submit under the request's id.
|
|
@@ -56,17 +60,17 @@ module Principles
|
|
|
56
60
|
end
|
|
57
61
|
|
|
58
62
|
# The parts of this request each --part names, in the order given, printed together under the request's one
|
|
59
|
-
# id, so the agent need not read the whole request for them, the index with
|
|
60
|
-
# out for listing nothing as empty; the answer to fill bare, given alone, to
|
|
61
|
-
# request has no part by one of the names.
|
|
63
|
+
# id, each member's in one members list, so the agent need not read the whole request for them, the index with
|
|
64
|
+
# how to answer it, and one it leaves out for listing nothing as empty; the answer to fill bare, given alone, to
|
|
65
|
+
# save as it stands; refused when the request has no part by one of the names.
|
|
62
66
|
#: (Array[String]) -> Hash[String, untyped]
|
|
63
67
|
def part(names)
|
|
64
68
|
request = asked
|
|
65
|
-
parts = request
|
|
69
|
+
parts = request_parts(request)
|
|
66
70
|
named = names.map { named_in(parts, it) }
|
|
67
71
|
return parts.shown(Views::ContextParts::TEMPLATE) if named == [Views::ContextParts::TEMPLATE]
|
|
68
72
|
|
|
69
|
-
shown =
|
|
73
|
+
shown = { "request_id" => request.request_id }.merge(parts.shown_together(named))
|
|
70
74
|
answering(request, shown, named).merge("wrote" => [])
|
|
71
75
|
end
|
|
72
76
|
|
|
@@ -82,6 +86,10 @@ module Principles
|
|
|
82
86
|
|
|
83
87
|
private
|
|
84
88
|
|
|
89
|
+
# The parts of request that --part prints, each member's with its text now.
|
|
90
|
+
#: (Views::AssessmentRequest) -> Views::ContextParts
|
|
91
|
+
def request_parts(request) = request.context_parts(texts: member_texts, optional: PartsToRead::OPTIONAL)
|
|
92
|
+
|
|
85
93
|
# The part name names in parts, refused when the request neither prints it nor leaves it out as empty.
|
|
86
94
|
#: (Views::ContextParts, String) -> String
|
|
87
95
|
def named_in(parts, name)
|
|
@@ -143,9 +151,7 @@ module Principles
|
|
|
143
151
|
|
|
144
152
|
# The map's file and every member's file, which the base commit is judged over.
|
|
145
153
|
#: (Models::Principle) -> Array[String]
|
|
146
|
-
def audited_files(map)
|
|
147
|
-
[@principles.file(@id), *map.members.map(&:path)]
|
|
148
|
-
end
|
|
154
|
+
def audited_files(map) = @principles.audited_files(@id, map.members)
|
|
149
155
|
|
|
150
156
|
# The request, with a notice when the last audit's record was left uncommitted: a completed one to commit, or an
|
|
151
157
|
# open one, which its correction completes, never to commit.
|
|
@@ -23,7 +23,7 @@ module Principles
|
|
|
23
23
|
wrote = unchanged ? [] : [updated.save]
|
|
24
24
|
Views::GuidanceSearchPathsResult.new(invocation)
|
|
25
25
|
.result(status: unchanged ? "unchanged" : "guidance_search_paths_updated",
|
|
26
|
-
globs: updated.globs, wrote:)
|
|
26
|
+
globs: updated.globs, wrote:, added: updated.added_since(current))
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
end
|
|
@@ -45,10 +45,13 @@ module Principles
|
|
|
45
45
|
joined.with_loading_scope(Views::NewLoadingScope.new(scopes.introduced_by(@member.id)))
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
# The new member's id, current lines
|
|
48
|
+
# The new member's id, current lines, the line its paragraph or list item runs on to when it maps only the
|
|
49
|
+
# first, and its stored check, located only after its map was saved.
|
|
49
50
|
#: () -> Hash[String, untyped]
|
|
50
51
|
def located_member
|
|
52
|
+
continues = @project.continues_to(@member.locator)
|
|
51
53
|
{ "id" => @member.id }.merge(snapshot(@member.locator).lines)
|
|
54
|
+
.merge(continues ? { "continues_to_line" => continues } : {})
|
|
52
55
|
.merge(@member.to_h.slice("check"))
|
|
53
56
|
end
|
|
54
57
|
|
|
@@ -118,12 +118,13 @@ module Principles
|
|
|
118
118
|
report = problems.checked do |map_id, member, baseline, now, mapping|
|
|
119
119
|
@project.principle_history(map_id, mapping: mapping).member_history(member, baseline: baseline, now: now)
|
|
120
120
|
end
|
|
121
|
-
Views::
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
121
|
+
facts = Views::ProblemFacts.new(not_read: @project.unread_older_files,
|
|
122
|
+
no_baseline_files: problems.files_to_commit(@principles),
|
|
123
|
+
audit_files: problems.audit_files_to_commit(@principles),
|
|
124
|
+
acknowledgeable: problems.acknowledgeable_together(
|
|
125
|
+
except: waiting.map(&:principle)
|
|
126
|
+
), waiting:)
|
|
127
|
+
Views::ProblemResult.new(printing).checked_naming_commands(report, facts)
|
|
127
128
|
end
|
|
128
129
|
end
|
|
129
130
|
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "time"
|
|
5
|
+
require_relative "answer_phase"
|
|
6
|
+
require_relative "../models/finding_write_ups"
|
|
7
|
+
require_relative "../models/open_findings_decision"
|
|
8
|
+
require_relative "../views/answered_request"
|
|
9
|
+
require_relative "../views/open_findings_decision_result"
|
|
10
|
+
|
|
11
|
+
module Principles
|
|
12
|
+
# Each runs one command: reads models, applies their rules and prints through a view.
|
|
13
|
+
# controllers/CLAUDE.md owns the boundary.
|
|
14
|
+
module Controllers
|
|
15
|
+
# A decision on a principle's open findings between full audits: start-audit ID --open-findings lists each open
|
|
16
|
+
# finding with where its write-up is now, and submit-answer makes each change the answer gives in the last
|
|
17
|
+
# completed record, keeping it beside its finding.
|
|
18
|
+
class OpenFindingDecisions < AnswerPhase
|
|
19
|
+
# The request start-audit id --open-findings prints, for a decision on any of the principle's open findings, or
|
|
20
|
+
# with to_fill its answer alone.
|
|
21
|
+
#: (String, to_fill: bool) -> Hash[String, untyped]
|
|
22
|
+
def decide(id, to_fill:)
|
|
23
|
+
naming_the_executable do
|
|
24
|
+
record = @audit_records.find(id)
|
|
25
|
+
decisions = decisions_of(id, record)
|
|
26
|
+
request = view.decision_request(request_id: decisions.request_id.to_s, principle_id: id,
|
|
27
|
+
revision: decisions.revision, fields: Models::FindingDecision::FIELDS,
|
|
28
|
+
findings: Models::FindingWriteUps.of(@project, [record].compact).listed)
|
|
29
|
+
to_fill ? request.fetch("response_template") : request.merge("wrote" => [])
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# The result of answering, and the record it changes, not yet written, which is refused once the last completed
|
|
34
|
+
# record changed after the request was printed, unless it writes nothing.
|
|
35
|
+
# @override
|
|
36
|
+
#: (Models::SubmittedAnswer) -> [Views::AnsweredRequest, Array[Models::AuditRecord]]
|
|
37
|
+
def answered(submitted)
|
|
38
|
+
id = submitted.request_id.principle_id
|
|
39
|
+
decisions = decisions_of(id, @audit_records.find(id))
|
|
40
|
+
decided = decisions.decided(submitted.response, at: Time.now.utc.iso8601) { |locator| snapshot(locator) }
|
|
41
|
+
changes = decisions.confirmed_writable(decided, submitted.response, records: @audit_records)
|
|
42
|
+
[Views::AnsweredRequest.new(result(id, decisions.changed_ids(decided))), changes]
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
# The decision on principle id's open findings, as its record holds them.
|
|
48
|
+
#: (String, Models::AuditRecord?) -> Models::OpenFindingsDecision
|
|
49
|
+
def decisions_of(id, record)
|
|
50
|
+
Models::OpenFindingsDecision.new(principle_id: id, record: record, history: @history)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# The result naming the findings of principle id that the decisions changed, the record to commit, and each
|
|
54
|
+
# other principle's open finding whose write-up cannot be found (T16).
|
|
55
|
+
#: (String, Array[String]) -> Hash[String, untyped]
|
|
56
|
+
def result(id, changed)
|
|
57
|
+
others = @audit_records.of(@principles.ids - [id])
|
|
58
|
+
view.decided(principle_id: id, file: @audit_records.file(id), changed:,
|
|
59
|
+
not_found_elsewhere: Models::FindingWriteUps.of(@project, others).not_found)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
#: () -> Views::OpenFindingsDecisionResult
|
|
63
|
+
def view = Views::OpenFindingsDecisionResult.new(invocation)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -19,21 +19,37 @@ module Principles
|
|
|
19
19
|
# entry point gives itself for the same reason.
|
|
20
20
|
ON_PATH = Models::RunsFrom::PLUGIN_EXECUTABLE
|
|
21
21
|
|
|
22
|
+
# The folders the process was given, as Launch reads them: cwd, the one this run was started in, by its real
|
|
23
|
+
# path, or nil when it is gone; temp_directory, its temporary folder, where a printed next step saves an answer.
|
|
24
|
+
class Folders
|
|
25
|
+
#: String?
|
|
26
|
+
attr_reader :cwd
|
|
27
|
+
#: String
|
|
28
|
+
attr_reader :temp_directory
|
|
29
|
+
|
|
30
|
+
#: (temp_directory: String, ?cwd: String?) -> void
|
|
31
|
+
def initialize(temp_directory:, cwd: nil)
|
|
32
|
+
@cwd = cwd
|
|
33
|
+
@temp_directory = temp_directory
|
|
34
|
+
freeze
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
22
38
|
# version gives the version running, read only when a command needs it, since in a checkout reading it
|
|
23
39
|
# asks git; other_on_path gives the path and printed version of another principles earlier on PATH than this
|
|
24
40
|
# one, and which of the commands it is asked about that copy does not run, or nil, read only when a command
|
|
25
41
|
# needs it, since reading it starts that copy; launched_on_path says
|
|
26
42
|
# whether this run was launched as the first principles on PATH, as a RubyGems binstub is, so a bare
|
|
27
|
-
# principles runs this same copy;
|
|
43
|
+
# principles runs this same copy; folders are the folders the process was given.
|
|
28
44
|
#: (executable: String, version: ^() -> String,
|
|
29
45
|
#| ?other_on_path: ^(Array[String]) -> [String, String, Array[String]]?, ?launched_on_path: ^() -> bool,
|
|
30
|
-
#|
|
|
31
|
-
def initialize(executable:, version:, other_on_path: ->(_) {}, launched_on_path: -> { false }
|
|
46
|
+
#| folders: Folders) -> void
|
|
47
|
+
def initialize(executable:, version:, folders:, other_on_path: ->(_) {}, launched_on_path: -> { false })
|
|
32
48
|
@executable = executable
|
|
33
49
|
@version = version
|
|
34
50
|
@other_on_path = other_on_path
|
|
35
51
|
@launched_on_path = launched_on_path
|
|
36
|
-
@
|
|
52
|
+
@folders = folders
|
|
37
53
|
freeze
|
|
38
54
|
end
|
|
39
55
|
|
|
@@ -59,7 +75,8 @@ module Principles
|
|
|
59
75
|
# be run from elsewhere.
|
|
60
76
|
#: (String) -> Views::Invocation
|
|
61
77
|
def invocation(root)
|
|
62
|
-
Views::Invocation.new(executable: executable, project: root,
|
|
78
|
+
Views::Invocation.new(executable: executable, project: root, temp_directory: @folders.temp_directory,
|
|
79
|
+
named: !bare_from_path? || root != @folders.cwd)
|
|
63
80
|
end
|
|
64
81
|
|
|
65
82
|
# Another principles earlier on PATH than this one, which a bare principles command runs in its place, asked
|
|
@@ -40,7 +40,8 @@ module Principles
|
|
|
40
40
|
after = options["commits_after"]
|
|
41
41
|
mapped = @principles.descriptions
|
|
42
42
|
commit = @history.commit_named(after) if after
|
|
43
|
-
|
|
43
|
+
selected = { also: options.fetch("also", []), only: options.fetch("only", []) }
|
|
44
|
+
found = @project.candidate_files(after: commit, **selected)
|
|
44
45
|
.within_budget { |inventory| candidate_files_result(inventory, mapped).text.bytesize }
|
|
45
46
|
candidate_files_result(found, mapped)
|
|
46
47
|
end
|
|
@@ -49,7 +50,7 @@ module Principles
|
|
|
49
50
|
#: (Models::CandidateInventory, Array[Hash[String, untyped]]) -> Views::JsonWithEntriesOnLines
|
|
50
51
|
def candidate_files_result(found, mapped)
|
|
51
52
|
listed = Views::CandidateFilesResult::Found.new(inventory: found.to_h, untracked: found.untracked,
|
|
52
|
-
owner_asks: found.owner_asks)
|
|
53
|
+
owner_asks: found.owner_asks, conventional: found.conventional?)
|
|
53
54
|
question = Views::CandidateFilesResult.new(invocation).question(listed, existing_maps: @principles.ids,
|
|
54
55
|
map_file: @principles.file("ID"),
|
|
55
56
|
mapped_principles: mapped)
|
|
@@ -35,12 +35,14 @@ module Principles
|
|
|
35
35
|
leads_to == path ? entry : entry.merge("symlink_to" => leads_to)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
# also names more files to list, inside the project, beside those hosts load by convention
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
# also names more files to list, inside the project, beside those hosts load by convention; without
|
|
39
|
+
# conventional, only also and the matches of matching are listed.
|
|
40
|
+
#: (ProjectFiles, ?also: Array[String], ?matching: Array[String], ?conventional: bool) -> void
|
|
41
|
+
def initialize(files, also: [], matching: [], conventional: true)
|
|
41
42
|
@files = files
|
|
42
43
|
@also = also
|
|
43
44
|
@matching = matching
|
|
45
|
+
@conventional = conventional
|
|
44
46
|
end
|
|
45
47
|
|
|
46
48
|
#: () -> Hash[String, untyped]
|
|
@@ -135,7 +137,7 @@ module Principles
|
|
|
135
137
|
|
|
136
138
|
#: (String) -> bool
|
|
137
139
|
def candidate?(relative)
|
|
138
|
-
CANDIDATE_NAMES.include?(File.basename(relative)) || relative.match?(CANDIDATE_PATH) ||
|
|
140
|
+
(@conventional && (CANDIDATE_NAMES.include?(File.basename(relative)) || relative.match?(CANDIDATE_PATH))) ||
|
|
139
141
|
@matching.any? { |glob| matches?(glob, relative) }
|
|
140
142
|
end
|
|
141
143
|
end
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
},
|
|
23
23
|
"commands": [
|
|
24
24
|
{
|
|
25
|
-
"name": "list-candidate-files", "usage": "list-candidate-files [--commits-after REV] [--also GLOB]...", "group": "read", "options": ["commits-after", "also"],
|
|
25
|
+
"name": "list-candidate-files", "usage": "list-candidate-files [--commits-after REV] [--also GLOB]... [--only GLOB]...", "group": "read", "options": ["commits-after", "also", "only"],
|
|
26
26
|
"summary": "Ask what in this project looks like a principle.",
|
|
27
27
|
"help": "learn-what-a-command-does/list-candidate-files",
|
|
28
28
|
"steps": [
|
|
29
29
|
{ "id": "list-instruction-files", "actor": "cli",
|
|
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.",
|
|
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. Repeated --only globs list just their matches. No location is saved.",
|
|
31
31
|
"refuses": ["range_needs_git", "unknown_revision", "invalid_guidance_search_path"] },
|
|
32
32
|
{ "id": "choose-one-principle", "actor": "agent",
|
|
33
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.",
|
|
@@ -314,16 +314,16 @@
|
|
|
314
314
|
]
|
|
315
315
|
},
|
|
316
316
|
{
|
|
317
|
-
"name": "start-audit", "usage": "start-audit ID [ID ...] [--member MEMBER ... | --
|
|
317
|
+
"name": "start-audit", "usage": "start-audit ID [ID ...] [--member MEMBER ... | --open-findings] [--as template [--part members/ID ...] | --instruction FIELD | --part PART ...]", "group": "write-audit-record", "options": ["member", "write-ups", "open-findings", "as", "instruction", "part"],
|
|
318
318
|
"summary": "Ask for an assessment of every member and the set.",
|
|
319
319
|
"help": "learn-what-a-command-does/start-audit",
|
|
320
320
|
"steps": [
|
|
321
321
|
{ "id": "snapshot-members", "actor": "cli",
|
|
322
|
-
"does": "Refuses an empty map or, in git, an uncommitted map or member file; bases the audit on HEAD. Fill --as template's output with your own judgement
|
|
323
|
-
"refuses": ["map_has_no_members", "uncommitted_files", "unknown_instruction", "unknown_part"], "refuses_like": ["read-map", "locate-text", "rewrite-audit"],
|
|
324
|
-
"next": [{ "to": "assess-every-member", "when": "you passed
|
|
322
|
+
"does": "Refuses an empty map or, in git, an uncommitted map or member file; bases the audit on HEAD. Fill --as template's output with your own judgement; its left_as_printed_rule says how a field left as printed is read.",
|
|
323
|
+
"refuses": ["map_has_no_members", "uncommitted_files", "unknown_instruction", "unknown_part", "replaced_option"], "refuses_like": ["read-map", "locate-text", "rewrite-audit"],
|
|
324
|
+
"next": [{ "to": "assess-every-member", "when": "you passed no --member or --open-findings" },
|
|
325
325
|
{ "to": "start-acknowledgement", "when": "you passed --member" },
|
|
326
|
-
{ "to": "start-
|
|
326
|
+
{ "to": "start-deciding-open-findings", "when": "you passed --open-findings" }] },
|
|
327
327
|
{ "id": "assess-every-member", "actor": "agent",
|
|
328
328
|
"does": "Assess each member not carried, and any carried one whose sighting is too old to rely on, the set as a whole and one recent decision under it, a finding per problem. Run each check, carried_checks_to_run's too, per shared_check_instructions and check_instructions. Decide each prior finding and listed member to check against the activation.",
|
|
329
329
|
"prompt": "assess-every-member/assess-each-member-and-the-set",
|
|
@@ -339,9 +339,9 @@
|
|
|
339
339
|
"checks": "the meaning is said to be kept, the reason is one line, and both quotes are the member's.",
|
|
340
340
|
"cannot_check": "whether the change keeps the meaning, or whether you read it.",
|
|
341
341
|
"answer_with": "submit-answer" },
|
|
342
|
-
{ "id": "start-
|
|
343
|
-
"does": "With --
|
|
344
|
-
"refuses": ["
|
|
342
|
+
{ "id": "start-deciding-open-findings", "actor": "cli",
|
|
343
|
+
"does": "With --open-findings, lists each finding the last completed audit left open, as list-open-findings does, and asks what changed of any: its wait, action or write-up; --as template prints the answer alone.",
|
|
344
|
+
"refuses": ["cannot_decide_open_findings"] }
|
|
345
345
|
]
|
|
346
346
|
},
|
|
347
347
|
{
|
|
@@ -353,7 +353,7 @@
|
|
|
353
353
|
"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.",
|
|
354
354
|
"refuses": ["unparseable_json", "unreadable_file", "request_mismatch", "unknown_request"], "refuses_like": ["rewrite-audit"],
|
|
355
355
|
"next": [{ "to": "acknowledge-the-change", "when": "the request was a one-member audit" },
|
|
356
|
-
{ "to": "record-the-
|
|
356
|
+
{ "to": "record-the-decisions", "when": "the request was a decision on open findings" },
|
|
357
357
|
{ "to": "recheck-members", "when": "the request was an assessment or a correction" }] },
|
|
358
358
|
{ "id": "acknowledge-the-change", "actor": "cli",
|
|
359
359
|
"does": "For a one-member audit, checks the answer's kept meaning, one-line reason, quotes then and now and any check result, then moves the member's hash and check result in the audit record beside the acknowledgement.",
|
|
@@ -362,12 +362,12 @@
|
|
|
362
362
|
"does": "Commit the audit record, then check that list-member-problems --short no longer reports the member.",
|
|
363
363
|
"cannot_check": "that you committed, or that the change keeps the meaning.",
|
|
364
364
|
"answer_with": "list-member-problems" },
|
|
365
|
-
{ "id": "record-the-
|
|
366
|
-
"does": "
|
|
367
|
-
"refuses": ["
|
|
368
|
-
{ "id": "commit-the-
|
|
369
|
-
"does": "Commit the audit record, then check
|
|
370
|
-
"cannot_check": "that you committed, or that
|
|
365
|
+
{ "id": "record-the-decisions", "actor": "cli",
|
|
366
|
+
"does": "Makes each change a decision gives in the last completed record, a write-up once found, keeping the old value, when and why; names lost write-ups elsewhere; refused once that record changed, unless it writes nothing.",
|
|
367
|
+
"refuses": ["cannot_decide_open_findings", "audit_completed_since_request", "unknown_finding", "duplicate_finding", "invalid_answer", "uncommitted_files"], "refuses_like": ["locate-text"] },
|
|
368
|
+
{ "id": "commit-the-decisions", "actor": "agent",
|
|
369
|
+
"does": "Commit the audit record, then check each change as list-open-findings --lines states it.",
|
|
370
|
+
"cannot_check": "that you committed, or that each change is right.",
|
|
371
371
|
"answer_with": "list-open-findings" },
|
|
372
372
|
{ "id": "recheck-members", "actor": "cli",
|
|
373
373
|
"does": "Re-reads the map and every member's text, and the record outside git.",
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require "json"
|
|
5
|
+
require_relative "parser_message"
|
|
5
6
|
|
|
6
7
|
module Principles
|
|
7
8
|
# Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
|
|
@@ -36,10 +37,13 @@ module Principles
|
|
|
36
37
|
freeze
|
|
37
38
|
end
|
|
38
39
|
|
|
39
|
-
# The parsed value, made only of plain hashes and arrays; raises JSON::ParserError on a duplicate key
|
|
40
|
+
# The parsed value, made only of plain hashes and arrays; raises JSON::ParserError on a duplicate key, and on
|
|
41
|
+
# text it cannot parse with the parser's message, the rest of the input it quotes cut to an excerpt.
|
|
40
42
|
#: () -> untyped
|
|
41
43
|
def parsed
|
|
42
44
|
plain(JSON.parse(@text, object_class: UniqueKeys))
|
|
45
|
+
rescue JSON::ParserError => e
|
|
46
|
+
raise JSON::ParserError, ParserMessage.new(@text, e.message).to_s
|
|
43
47
|
end
|
|
44
48
|
|
|
45
49
|
private
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Principles
|
|
5
|
+
# Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
|
|
6
|
+
module Data
|
|
7
|
+
# The json parser's message about text it could not parse, with the rest of the input it quotes from where it
|
|
8
|
+
# stopped cut to an excerpt, since a raw line break early in a long answer echoed the whole rest of the file.
|
|
9
|
+
# json 2.9.1, Ruby 3.4's own, quotes that rest with no line or column; later versions give both after it. A
|
|
10
|
+
# message quoting none of the input is kept as it is.
|
|
11
|
+
class ParserMessage
|
|
12
|
+
# The characters of the rest of the input the message keeps.
|
|
13
|
+
EXCERPT = 60 #: Integer
|
|
14
|
+
|
|
15
|
+
# How each json version's message ends just before the rest of the input it quotes: json 2.9.1's
|
|
16
|
+
# "unexpected token at '", and a later version's reason and colon. A message ending as the input does but
|
|
17
|
+
# after neither quotes none of it.
|
|
18
|
+
LEADS = ["at '", ": "].freeze #: Array[String]
|
|
19
|
+
|
|
20
|
+
# Where a later json says it stopped, after the rest of the input.
|
|
21
|
+
POSITION = / at line \d+ column \d+\z/ #: Regexp
|
|
22
|
+
|
|
23
|
+
#: (String, String) -> void
|
|
24
|
+
def initialize(text, message)
|
|
25
|
+
@text = text
|
|
26
|
+
@message = message
|
|
27
|
+
freeze
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
#: () -> String
|
|
31
|
+
def to_s
|
|
32
|
+
position = @message[POSITION].to_s
|
|
33
|
+
quoted = @message.delete_suffix(position)
|
|
34
|
+
quoted = quoted.delete_suffix("'") if quoted.end_with?("'") && !@text.end_with?("'")
|
|
35
|
+
rest = common_suffix(quoted)
|
|
36
|
+
lead = quoted.delete_suffix(rest)
|
|
37
|
+
return @message if rest.empty? || LEADS.none? { lead.end_with?(it) }
|
|
38
|
+
|
|
39
|
+
"#{lead.delete_suffix("'")}#{excerpt(rest)}#{position}"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
# The longest end that quoted shares with the text: the rest of the input it quotes.
|
|
45
|
+
#: (String) -> String
|
|
46
|
+
def common_suffix(quoted)
|
|
47
|
+
length = 0
|
|
48
|
+
length += 1 while length < quoted.length && length < @text.length && quoted[-1 - length] == @text[-1 - length]
|
|
49
|
+
quoted[quoted.length - length, length].to_s
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# rest's first characters, written so a line break or control character shows, and how many bytes follow.
|
|
53
|
+
#: (String) -> String
|
|
54
|
+
def excerpt(rest)
|
|
55
|
+
kept = rest[0, EXCERPT].to_s
|
|
56
|
+
left = rest.bytesize - kept.bytesize
|
|
57
|
+
left.positive? ? "#{kept.inspect} and #{left} more bytes" : kept.inspect
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -87,8 +87,10 @@ module Principles
|
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
# The instruction files hosts load by convention, as CandidateFilesFound lists them, and the files also names.
|
|
90
|
-
#: (?also: Array[String], ?matching: Array[String]) -> Hash[String, untyped]
|
|
91
|
-
def inventory(also: [], matching: []
|
|
90
|
+
#: (?also: Array[String], ?matching: Array[String], ?conventional: bool) -> Hash[String, untyped]
|
|
91
|
+
def inventory(also: [], matching: [], conventional: true)
|
|
92
|
+
CandidateFilesFound.new(self, also:, matching:, conventional:).to_h
|
|
93
|
+
end
|
|
92
94
|
|
|
93
95
|
# Literal outline requests never walk the project or load saved search paths.
|
|
94
96
|
#: (Array[String]) -> Hash[String, untyped]
|