principles 0.0.8 → 0.0.10
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 +32 -0
- data/LICENSE +1 -1
- data/README.md +40 -4
- data/lib/principles/controllers/audit.rb +4 -2
- data/lib/principles/controllers/inventory.rb +16 -6
- data/lib/principles/controllers/member_problems_report.rb +2 -8
- data/lib/principles/data/command-steps.json +4 -4
- data/lib/principles/data/repository.rb +7 -0
- data/lib/principles/data/running_version.rb +1 -1
- data/lib/principles/data/schemas/command-steps.schema.json +1 -1
- data/lib/principles/invocation_options.rb +1 -1
- data/lib/principles/models/findings_left_open.rb +9 -5
- data/lib/principles/models/open_finding.rb +5 -0
- data/lib/principles/models/project.rb +4 -0
- data/lib/principles/version.rb +2 -2
- data/lib/principles/views/findings_result.rb +14 -3
- data/lib/principles/views/open_findings_line.rb +121 -53
- data/lib/principles/views/principle_read_result.rb +11 -0
- data/lib/principles/views/problem_lines.rb +18 -30
- data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +2 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +12 -12
- data/lib/principles/views/prompts/learn-what-a-command-does/list-principles.md +3 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/report-at-session-start.md +14 -16
- data/lib/principles/views/prompts/start-a-session/act-on-the-changed-members.md +2 -0
- data/lib/principles/views/prompts/start-a-session/act-on-the-open-findings.md +1 -4
- data/principles.gemspec +2 -2
- metadata +6 -9
- data/lib/principles/views/prompts/start-a-session/every-loaded-line-costs-every-session.md +0 -1
- data/lib/principles/views/prompts/start-a-session/raise-them-at-the-next-pause.md +0 -1
- data/lib/principles/views/prompts/start-a-session/raise-them-before-the-first-task.md +0 -1
- data/lib/principles/views/prompts/start-a-session/run-each-command-above.md +0 -1
- data/lib/principles/views/prompts/start-a-session/start-with-the-principles-skill.md +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cc95d7d905593eee8514b36fd6cbc6a80629a6f210542a232dada441890cf454
|
|
4
|
+
data.tar.gz: 964984c9b9d5a44d53c65ce0b92924d960eca08db17a93897abbe17db71b7482
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4534da22b02e7aa9a8e961268a1710f430c27bca7a8613b4d4fd1a8c337705f1a41967dbc3abb976535ae58891f66211ebea1b18e27fab015c88b6f5d35cb1df
|
|
7
|
+
data.tar.gz: 7b17bd8475e8158b80a9c4af83ff94de2022bd2525901096ea7ae16163c2f811fb1441c1591ea33415fce5f7ef8a8e763900f61a63443158b3bc21ddfb69d4d2
|
data/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,38 @@ 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.0.10] - 2026-11-21
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- **Your agent raises open audit findings that wait on you in its first reply, instead of skimming past them.** The open-findings line `principles report-at-session-start` prints now names the oldest finding waiting on someone and what it needs, states git's `user.name` for the agent to judge whether that is you, and says to raise each in the first reply, since nothing else will. On this tool's own repository the line is 30% shorter than before.
|
|
21
|
+
- **You see how long the oldest finding has waited on you, so a stale one stands out.** The open-findings line `principles report-at-session-start` prints says "open N days" beside the oldest finding it names, as it did before the line was rewritten, for 15 more bytes.
|
|
22
|
+
- **Your agent deals with changed audited rules before starting your task, instead of leaving the notice for later.** Each line `principles report-at-session-start` prints for a principle whose audited members changed now says that its audit no longer covers them, and asks the agent to run `principles list-member-problems ID` before your task, to acknowledge the edit or audit again. The closing line that pointed at those commands is gone.
|
|
23
|
+
- **The README opens with a 51-second video of what principles does.**
|
|
24
|
+
- **The tagline now reads "Tighter harness, longer running agents: trust the principles, loosen the supervision."** in the README and the gem summary, and the gem description says what the README says of harness support: built for Claude Code, Codex partly supported, Pi after that.
|
|
25
|
+
|
|
26
|
+
### Removed
|
|
27
|
+
|
|
28
|
+
- **Each session starts 110 bytes lighter.** `principles report-at-session-start` no longer restates the meta-principle line; it prints only lines naming a fact and a command.
|
|
29
|
+
|
|
30
|
+
## [0.0.9] - 2026-11-21
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
|
|
34
|
+
- **One command answers "what principles are in place, and what is each still waiting on?"** Run `principles list-principles --open-findings`: each principle's row adds its open findings, one line each, saying whom it waits on and how long it has been open, so an agent no longer joins `list-principles` with `list-open-findings` in a script. Without the flag, `list-principles` prints as before, about a fifth smaller than with it.
|
|
35
|
+
|
|
36
|
+
- **Install `principles` in Claude Code from its public repository.** Run `/plugin marketplace add realfastAI/principles`, then `/plugin install principles@realfastai`. The plugin's hooks report which mapped places changed as each session starts and after each commit, and its `setup-ruby` skill installs Ruby 3.4, asking you first, when none is found. The gem stays the install for a terminal or another harness.
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
|
|
40
|
+
- **The public repository's README now shows its images.** For publishers, every file under `images/` is published byte for byte at the same path in the public repository, and never added to the gem, so both READMEs share one copy. The leak check still reads an SVG as text, and leaves a binary raster image unread, since its compressed bytes can spell a refused word by chance.
|
|
41
|
+
|
|
42
|
+
- **A release can no longer stop half-done on an unclean public checkout.** For publishers, `bundle exec rake release`, the dry run included, now refuses before the gate and before tagging when the public repository's checkout has uncommitted or untracked files. It names each file and says to commit or remove them there.
|
|
43
|
+
|
|
44
|
+
- **The gem you install is built from the public repository's commit, so it matches the source you can read there.** Each release commits its public copy first, builds the gem from that commit, dated by it so a rebuild is byte-identical, and only then pushes; for publishers, `bundle exec rake release` checks before any step that the gem builds and installs from that copy, and a stopped release finishes by running it again, uploading nothing RubyGems already serves.
|
|
45
|
+
|
|
46
|
+
- **Licence scanners now recognise `LICENSE` as the Apache License 2.0.** It is the text exactly as Apache publishes it; the copyright line stays in `NOTICE`.
|
|
47
|
+
|
|
16
48
|
## [0.0.8] - 2026-11-20
|
|
17
49
|
|
|
18
50
|
### Added
|
data/LICENSE
CHANGED
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
same "printed page" as the copyright notice for easier
|
|
188
188
|
identification within third-party archives.
|
|
189
189
|
|
|
190
|
-
Copyright
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
191
|
|
|
192
192
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
193
|
you may not use this file except in compliance with the License.
|
data/README.md
CHANGED
|
@@ -1,12 +1,46 @@
|
|
|
1
|
-
|
|
1
|
+

|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# Harness Principles
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<p>Built with ❤️ at <a href="https://realfast.ai"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/realfastAI/principles/main/images/realfast-logo-white.svg"><img src="https://raw.githubusercontent.com/realfastAI/principles/main/images/realfast-logo-ink.svg" alt="realfast" height="15"></picture></a></p>
|
|
6
|
+
|
|
7
|
+
[](#install) [](LICENSE)  
|
|
8
|
+
|
|
9
|
+
**Tighter harness, longer running agents: trust the principles, loosen the supervision.**
|
|
10
|
+
|
|
11
|
+
Built for Claude Code. Codex is partly supported already, with full support coming soon, and Pi after that. Your principles are portable across harnesses that share the same context management vectors: Codex has no monitors, but shares almost every other vector with Claude Code, including `AGENTS.md`, skills and hooks.
|
|
12
|
+
|
|
13
|
+
https://github.com/user-attachments/assets/8bd9d6cb-893e-4422-86f0-ecad91af5aa9
|
|
14
|
+
|
|
15
|
+
## Who is this for?
|
|
16
|
+
|
|
17
|
+
Principles is based on a dead simple idea - an easy to use CLI that helps an agent create and manage a map of all the snippets of text across the harness that work together to create its _operating principles_.
|
|
18
|
+
|
|
19
|
+
You'll get the most from it when:
|
|
20
|
+
|
|
21
|
+
- a team of people and their agents use the same harness and repo to do their work and need to establish shared SoPs.
|
|
22
|
+
- your agents _need_ to run for long stretches, and need their operating principles reinforced consistently across CLAUDE.md/AGENTS.md, skills, hooks and all the rest of the context management vectors a harness provides.
|
|
23
|
+
|
|
24
|
+
If your project has a single `CLAUDE.md` at its root, `principles` is overkill. You can read that one file and keep it consistent yourself. Come back when your rules start to spread.
|
|
25
|
+
|
|
26
|
+
Here is one of *realfast*'s projects, where an agent answers which principles are in place, how many places carry each, and which findings are still open:
|
|
27
|
+
|
|
28
|
+

|
|
6
29
|
|
|
7
30
|
## Install
|
|
8
31
|
|
|
9
|
-
|
|
32
|
+
In Claude Code, add this repository as a plugin marketplace, install the plugin, reload your plugins, and start:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
/plugin marketplace add realfastAI/principles
|
|
36
|
+
/plugin install principles@realfastai
|
|
37
|
+
/reload-plugins
|
|
38
|
+
/principles:principles
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`/principles:principles` starts your agent mapping your project's principles. From there it follows what each result tells it, so you never need to learn the commands. The plugin also adds hooks that report which mapped places changed as each session starts and after each commit, and a `setup-ruby` skill your agent follows, asking you first, when no Ruby 3.4 is found.
|
|
42
|
+
|
|
43
|
+
From a terminal, or for another harness, install the gem instead. In Claude Code, the `!` prefix runs a shell command in your session:
|
|
10
44
|
|
|
11
45
|
```
|
|
12
46
|
! gem install principles
|
|
@@ -102,6 +136,8 @@ The hook entries run `principles report-at-session-start` and `principles report
|
|
|
102
136
|
|
|
103
137
|
The project grows out of two practices developed through use: **express intent**, keeping names and definitions current as understanding changes; and **collaboration through agents**, helping people align on shared work through the agents they each work with.
|
|
104
138
|
|
|
139
|
+
`principles` is built at [*realfast*](https://realfast.ai), where it has kept the harnesses of our own projects consistent for the past couple of months.
|
|
140
|
+
|
|
105
141
|
## Issues
|
|
106
142
|
|
|
107
143
|
Report a bug or ask for a feature at [github.com/realfastAI/principles/issues](https://github.com/realfastAI/principles/issues).
|
|
@@ -38,8 +38,9 @@ module Principles
|
|
|
38
38
|
def session_start_open_findings(source)
|
|
39
39
|
records = open_records(nil)
|
|
40
40
|
waiting = Models::FindingsLeftOpen.of(records).waiting_at(Time.now.utc)
|
|
41
|
+
not_found = Models::FindingWriteUps.of(@project, records).not_found
|
|
41
42
|
Views::OpenFindingsLine.new(invocation.without_project)
|
|
42
|
-
.lines(waiting,
|
|
43
|
+
.lines(waiting, not_found, source:, user_name: @project.git_user_name)
|
|
43
44
|
end
|
|
44
45
|
|
|
45
46
|
private
|
|
@@ -136,7 +137,8 @@ module Principles
|
|
|
136
137
|
records = open_records(id)
|
|
137
138
|
waiting = Models::FindingsLeftOpen.of(records).waiting_at(Time.now.utc)
|
|
138
139
|
Views::OpenFindingsLine.new(invocation).short(waiting, Models::FindingWriteUps.of(@project, records).not_found,
|
|
139
|
-
source: options["session_start"] || "startup"
|
|
140
|
+
source: options["session_start"] || "startup",
|
|
141
|
+
user_name: @project.git_user_name)
|
|
140
142
|
end
|
|
141
143
|
|
|
142
144
|
# The records whose open findings list-open-findings reads: id's, refused when a later copy wrote it in a
|
|
@@ -14,10 +14,10 @@ module Principles
|
|
|
14
14
|
# last audit. None changes anything on disk. Survey runs the survey of candidate files.
|
|
15
15
|
class Inventory < Command
|
|
16
16
|
#: (String, String?, Hash[String, untyped]) -> untyped
|
|
17
|
-
def call(command, id,
|
|
17
|
+
def call(command, id, options)
|
|
18
18
|
naming_the_executable do
|
|
19
19
|
case command
|
|
20
|
-
when "list-principles" then listing.merge("wrote" => [])
|
|
20
|
+
when "list-principles" then listing(open_findings: options["open_findings"]).merge("wrote" => [])
|
|
21
21
|
when "show-principle" then members(required_id(id)).merge("wrote" => [])
|
|
22
22
|
else unknown(command)
|
|
23
23
|
end
|
|
@@ -99,12 +99,22 @@ module Principles
|
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
# Its next_action offers an audit while one principle's audits do not wait on an upgrade; a map listed with its
|
|
102
|
-
# refusal counts, since repairing it leaves it to audit.
|
|
103
|
-
#: () -> untyped
|
|
104
|
-
def listing
|
|
102
|
+
# refusal counts, since repairing it leaves it to audit. With open_findings, each row lists its open findings.
|
|
103
|
+
#: (open_findings: bool?) -> untyped
|
|
104
|
+
def listing(open_findings:)
|
|
105
105
|
ids = @principles.ids
|
|
106
106
|
waiting = ids.filter_map { waiting_on_an_upgrade(it) }
|
|
107
|
-
read_result.
|
|
107
|
+
listed = open_findings ? read_result.with_open_findings(rows(ids), open_by_principle(ids)) : rows(ids)
|
|
108
|
+
read_result.listing(listed, waiting: waiting, one_to_audit: waiting.size < ids.size)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Each principle's open findings, from every record this copy can read, as list-open-findings reads them,
|
|
112
|
+
# aged until now, by principle id.
|
|
113
|
+
#: (Array[String]) -> Hash[String, Array[Hash[String, untyped]]]
|
|
114
|
+
def open_by_principle(ids)
|
|
115
|
+
now = Time.now.utc
|
|
116
|
+
@audit_records.readable_of(ids).flat_map(&:left_open).map { it.waited_at(now) }
|
|
117
|
+
.group_by { it.fetch("principle") }
|
|
108
118
|
end
|
|
109
119
|
|
|
110
120
|
# One map's row; a map this tool cannot read is listed with its refusal, so the others still show, and one
|
|
@@ -32,8 +32,7 @@ module Principles
|
|
|
32
32
|
def session_start_lines(source)
|
|
33
33
|
printing = invocation.without_project
|
|
34
34
|
problems, (report,) = checked(nil, printing)
|
|
35
|
-
lines = Views::ProblemLines.new(printing)
|
|
36
|
-
.session_start_lines(changed: problems.assessed_changes, source:, skill: skill?)
|
|
35
|
+
lines = Views::ProblemLines.new(printing).session_start_lines(changed: problems.assessed_changes)
|
|
37
36
|
lines + not_checked_lines(problems, report, printing, source)
|
|
38
37
|
end
|
|
39
38
|
|
|
@@ -48,11 +47,6 @@ module Principles
|
|
|
48
47
|
Views::FirstAuditLine.new(printing).lines(problems.awaiting_first_audit.length, source)
|
|
49
48
|
end
|
|
50
49
|
|
|
51
|
-
# Whether this session has the principles skill, which only the plugin installs, for the lines naming where
|
|
52
|
-
# to start.
|
|
53
|
-
#: () -> bool
|
|
54
|
-
def skill? = @tool.runs_from.principles_skill_in_this_session?
|
|
55
|
-
|
|
56
50
|
# list-member-problems' JSON result, or with --short its lines for a trigger, or with --hook-event the
|
|
57
51
|
# after-commit hook's JSON, which MembersACommitChanged prints.
|
|
58
52
|
#: (String?, Hash[String, untyped]) -> untyped
|
|
@@ -82,7 +76,7 @@ module Principles
|
|
|
82
76
|
never_assessed: problems.never_assessed, names_a_command:)
|
|
83
77
|
return lines unless session_start
|
|
84
78
|
|
|
85
|
-
view.at_session_start(lines, changed: problems.assessed_changes
|
|
79
|
+
view.at_session_start(lines, changed: problems.assessed_changes)
|
|
86
80
|
end
|
|
87
81
|
|
|
88
82
|
# list-member-problems' JSON result for map id, or every map, without the files it wrote.
|
|
@@ -60,12 +60,12 @@
|
|
|
60
60
|
]
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
|
-
"name": "list-principles", "usage": "list-principles", "group": "read", "options": [],
|
|
63
|
+
"name": "list-principles", "usage": "list-principles [--open-findings]", "group": "read", "options": ["open-findings"],
|
|
64
64
|
"summary": "Every mapped principle and whether its members are current.",
|
|
65
65
|
"help": "learn-what-a-command-does/list-principles",
|
|
66
66
|
"steps": [
|
|
67
67
|
{ "id": "count-members-by-freshness", "actor": "cli",
|
|
68
|
-
"does": "Reads every map and the audit record of each, and counts its members as current, changed, unassessed, locator_lost or unavailable.",
|
|
68
|
+
"does": "Reads every map and the audit record of each, and counts its members as current, changed, unassessed, locator_lost or unavailable. With --open-findings, adds each principle's open findings, one line each, saying whom it waits on, or that it is accepted, and how many days it has been open.",
|
|
69
69
|
"refuses_like": ["read-map", "read-audit"] }
|
|
70
70
|
]
|
|
71
71
|
},
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"help": "learn-what-a-command-does/list-open-findings",
|
|
110
110
|
"steps": [
|
|
111
111
|
{ "id": "read-open-findings", "actor": "cli",
|
|
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
|
|
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 deferred findings wait on someone named or no one, whom the oldest waits on and git's user.name, and to raise each that waits on the user in the first reply, and nothing when none is open; --session-start clear or compact asks for the next reply, and resume shortens it to the facts, since a resumed conversation holds the whole line already.",
|
|
113
113
|
"refuses_like": ["read-map", "read-audit"] },
|
|
114
114
|
{ "id": "follow-up-each-finding", "actor": "agent",
|
|
115
115
|
"does": "Read each finding where its recorded_at points, and decide each one at its principle's next full audit.",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"help": "learn-what-a-command-does/report-at-session-start",
|
|
133
133
|
"steps": [
|
|
134
134
|
{ "id": "report-at-session-start", "actor": "cli",
|
|
135
|
-
"does": "Reads the SessionStart hook's JSON on stdin and always exits 0, since the host adds a SessionStart hook's output to the context only then. Prints nothing in a project with no maps. Otherwise prints, each line marked principles:,
|
|
135
|
+
"does": "Reads the SessionStart hook's JSON on stdin and always exits 0, since the host adds a SessionStart hook's output to the context only then. Prints nothing in a project with no maps. Otherwise prints, each line marked principles:, one line for each principle whose members an audit assessed changed since, with its count, that its audit no longer covers them, and the list-member-problems ID command to run before the user's task, which offers acknowledging them or auditing again, then, in git, what gives each principle's members with no baseline one, then each principle whose audit record a later release wrote, whose audits wait on an upgrade, then, while any principle awaits its first full audit, one line counting them that asks for one background subagent to follow show-first-audit-brief, or to offer the audit at the next pause if none can be started, and at resume and compact only the count, asking for no second subagent, then, while any audit finding is left open, the one line list-open-findings --short prints, worded for the session's start. When list-member-problems refuses, prints instead its code and the command that shows its repair; input it cannot read is read as a startup." }
|
|
136
136
|
]
|
|
137
137
|
},
|
|
138
138
|
{
|
|
@@ -39,6 +39,13 @@ module Principles
|
|
|
39
39
|
ok && output.strip == "true"
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
# The user name git commits as here, or nil when none is set.
|
|
43
|
+
#: () -> String?
|
|
44
|
+
def user_name
|
|
45
|
+
name, ok = git(["config", "user.name"])
|
|
46
|
+
ok && !name.strip.empty? ? name.strip : nil
|
|
47
|
+
end
|
|
48
|
+
|
|
42
49
|
# The full sha of the last commit that changed path, or nil outside git or when no commit has.
|
|
43
50
|
#: (String) -> String?
|
|
44
51
|
def last_commit(path)
|
|
@@ -12,7 +12,7 @@ module Principles
|
|
|
12
12
|
class RunningVersion
|
|
13
13
|
# git archive writes the short sha of the commit it archives here, since .gitattributes marks this file
|
|
14
14
|
# export-subst; a checkout keeps the placeholder as written.
|
|
15
|
-
ARCHIVED_COMMIT = "
|
|
15
|
+
ARCHIVED_COMMIT = "a8698c23" #: String
|
|
16
16
|
|
|
17
17
|
#: (?String, release: String, ?built: String?, ?archived_commit: String) -> void
|
|
18
18
|
def initialize(checkout = File.expand_path("../../..", __dir__), release:, built: nil,
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"usage": { "$ref": "#/$defs/prose" },
|
|
73
73
|
"group": { "$ref": "#/$defs/slug" },
|
|
74
74
|
"options": { "type": "array", "uniqueItems": true,
|
|
75
|
-
"items": { "enum": ["description", "path", "section", "starting-at", "ending-at", "query", "role", "check", "file", "short", "session-start", "commits-after", "hook-event", "member", "when-files", "when-invoked", "always", "write-ups", "as", "instruction", "part", "also", "confirm", "lines"] } },
|
|
75
|
+
"items": { "enum": ["description", "path", "section", "starting-at", "ending-at", "query", "role", "check", "file", "short", "session-start", "commits-after", "hook-event", "member", "when-files", "when-invoked", "always", "write-ups", "as", "instruction", "part", "also", "confirm", "lines", "open-findings"] } },
|
|
76
76
|
"requires": { "type": "array", "uniqueItems": true, "items": { "enum": ["file"] } },
|
|
77
77
|
"summary": { "$ref": "#/$defs/prose" },
|
|
78
78
|
"help": { "type": "string", "pattern": "^[a-z]+(-[a-z]+)+/[a-z]+(-[a-z]+)+$" },
|
|
@@ -11,7 +11,7 @@ module Principles
|
|
|
11
11
|
VALUE_OPTIONS = %w[project file description path section starting-at ending-at query role
|
|
12
12
|
check session-start commits-after hook-event as instruction part].freeze #: Array[String]
|
|
13
13
|
# The options that take no value, as list-member-problems --short.
|
|
14
|
-
FLAG_OPTIONS = %w[short lines when-invoked always write-ups confirm].freeze #: Array[String]
|
|
14
|
+
FLAG_OPTIONS = %w[short lines when-invoked always write-ups confirm open-findings].freeze #: Array[String]
|
|
15
15
|
# The options that may be given more than once, each value kept in order, as change-activation --when-files and
|
|
16
16
|
# start-audit --member.
|
|
17
17
|
LIST_OPTIONS = %w[when-files also member].freeze #: Array[String]
|
|
@@ -19,15 +19,19 @@ module Principles
|
|
|
19
19
|
freeze
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
# How many are open, how many of them are deferred with no waits_on
|
|
23
|
-
#
|
|
24
|
-
#
|
|
22
|
+
# How many are open, how many of them are deferred with no waits_on and how many with one, so how many someone
|
|
23
|
+
# should raise, and the first raised earliest of those with one and of all, each as it has waited until now, or
|
|
24
|
+
# nil when none is open. How long it waited runs from first_raised_at, never from when its
|
|
25
|
+
# waits_on was asked, which a later audit may have given it.
|
|
25
26
|
#: (Time) -> Hash[String, untyped]?
|
|
26
27
|
def waiting_at(now)
|
|
27
28
|
oldest = @findings.min_by(&:first_raised_time) or return nil
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
named = @findings.select(&:waiting_on_someone_named?)
|
|
31
|
+
unnamed = @findings.count(&:waiting_on_no_one_named?)
|
|
32
|
+
{ "count" => @findings.length, "waiting_on_no_one_named" => unnamed,
|
|
33
|
+
"waiting_on_someone_named" => named.length, "to_raise" => named.length + unnamed,
|
|
34
|
+
"oldest_waiting_on_someone" => named.min_by(&:first_raised_time)&.waited_at(now), **oldest.waited_at(now) }
|
|
31
35
|
end
|
|
32
36
|
end
|
|
33
37
|
end
|
|
@@ -166,6 +166,11 @@ module Principles
|
|
|
166
166
|
#: () -> bool
|
|
167
167
|
def waiting_on_no_one_named? = action == "deferred" && without_waits_on?
|
|
168
168
|
|
|
169
|
+
# Whether it is deferred with a waits_on, so the session-start line counts it among those waiting on someone
|
|
170
|
+
# named, for the agent to judge whom.
|
|
171
|
+
#: () -> bool
|
|
172
|
+
def waiting_on_someone_named? = action == "deferred" && !without_waits_on?
|
|
173
|
+
|
|
169
174
|
# The one line it says it waits on, or nil when it says it waits on nothing.
|
|
170
175
|
#: () -> String?
|
|
171
176
|
def waits_on = @finding.waits_on
|
|
@@ -86,6 +86,10 @@ module Principles
|
|
|
86
86
|
GuidanceSearchPaths.read(@guidance_search_paths)
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
+
# The user name git commits as here, or nil when none is set, which the session-start line states as a fact.
|
|
90
|
+
#: () -> String?
|
|
91
|
+
def git_user_name = @repository.user_name
|
|
92
|
+
|
|
89
93
|
# The project's history, one for the whole command, so every read names the HEAD it first read.
|
|
90
94
|
#: () -> ProjectHistory
|
|
91
95
|
def history
|
data/lib/principles/version.rb
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
module Principles
|
|
5
5
|
# The next production release, as major.minor.patch. A production build is versioned with this alone.
|
|
6
|
-
RELEASE = "0.0.
|
|
6
|
+
RELEASE = "0.0.10"
|
|
7
7
|
# The version a built gem prints. `rake build[production]` stamps RELEASE here, in the copy of lib/ it
|
|
8
8
|
# packages, and `rake build[development]` stamps RELEASE.g<short sha>. A checkout leaves it nil, and
|
|
9
9
|
# Data::RunningVersion reads the commit this tool runs from instead.
|
|
10
|
-
BUILT_VERSION = "0.0.
|
|
10
|
+
BUILT_VERSION = "0.0.10" #: String?
|
|
11
11
|
end
|
|
@@ -39,14 +39,25 @@ module Principles
|
|
|
39
39
|
Lines.new(stdout: findings.empty? ? "#{NONE_OPEN}\n" : text, stderr: "", status: 0)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
# One finding as list-principles --open-findings lists it in its principle's row: its id, whom it waits on and
|
|
43
|
+
# the whole days it has been open, as --lines words them.
|
|
44
|
+
#: (Hash[String, untyped]) -> String
|
|
45
|
+
def summary(finding)
|
|
46
|
+
"#{one_line(finding.fetch("finding_id"))} #{waited_on(finding)}; #{days_open(finding)}"
|
|
47
|
+
end
|
|
48
|
+
|
|
42
49
|
private
|
|
43
50
|
|
|
44
51
|
#: (Hash[String, untyped]) -> String
|
|
45
52
|
def line(finding)
|
|
46
|
-
|
|
53
|
+
"#{finding.fetch("principle")}\t#{one_line(finding.fetch("finding_id"))}\t#{waited_on(finding)}\t" \
|
|
54
|
+
"#{days_open(finding)}"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
#: (Hash[String, untyped]) -> String
|
|
58
|
+
def days_open(finding)
|
|
47
59
|
days = finding.fetch("days_open")
|
|
48
|
-
"#{
|
|
49
|
-
"day#{"s" unless days == 1}"
|
|
60
|
+
"open #{days} day#{"s" unless days == 1}"
|
|
50
61
|
end
|
|
51
62
|
|
|
52
63
|
# Whom finding waits on, or that it is accepted, and so by design waits on no one.
|
|
@@ -10,14 +10,16 @@ module Principles
|
|
|
10
10
|
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
11
11
|
module Views
|
|
12
12
|
# list-open-findings --short: the one line a session-start hook puts into the agent's context while any
|
|
13
|
-
# finding is open, and nothing when none is. It
|
|
14
|
-
#
|
|
13
|
+
# finding is open that someone should raise, and nothing when none is. It states the facts the agent judges
|
|
14
|
+
# from, how many wait on someone named or on no one, whom the oldest of the former waits on and for how long,
|
|
15
|
+
# and git's user name, then says to raise each that waits on its user, and why, with the command that lists
|
|
16
|
+
# them all.
|
|
15
17
|
class OpenFindingsLine
|
|
16
18
|
# A waits_on longer than this is cut, so the line stays one short line.
|
|
17
19
|
WAITS_ON_LIMIT = 80
|
|
18
20
|
|
|
19
21
|
# The session's start the line is worded for, as Claude Code's SessionStart hook names it: startup, resume,
|
|
20
|
-
# clear or compact. It says what the context holds already, and so
|
|
22
|
+
# clear or compact. It says what the context holds already, and so which reply raises the findings.
|
|
21
23
|
class SessionStart
|
|
22
24
|
#: (String) -> void
|
|
23
25
|
def initialize(source)
|
|
@@ -29,19 +31,48 @@ module Principles
|
|
|
29
31
|
#: () -> bool
|
|
30
32
|
def resumed? = @source == "resume"
|
|
31
33
|
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
+
# The reply that raises the findings: the first at startup, and the next once the session is under way,
|
|
35
|
+
# after /clear or a compaction.
|
|
34
36
|
#: () -> String
|
|
35
|
-
def
|
|
36
|
-
|
|
37
|
+
def reply = @source == "startup" ? "first" : "next"
|
|
38
|
+
end
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
# The open findings as the line states them, from the plain hash a controller hands it: how many are open and
|
|
41
|
+
# the oldest of all, which a resumed line names, and how many wait on someone named or on no one, with the
|
|
42
|
+
# oldest of the former.
|
|
43
|
+
class Waiting
|
|
44
|
+
#: (Hash[String, untyped]) -> void
|
|
45
|
+
def initialize(fields)
|
|
46
|
+
@fields = fields
|
|
47
|
+
freeze
|
|
39
48
|
end
|
|
40
49
|
|
|
41
|
-
|
|
50
|
+
#: () -> Integer
|
|
51
|
+
def count = @fields.fetch("count")
|
|
52
|
+
|
|
53
|
+
#: () -> Integer
|
|
54
|
+
def days_open = @fields.fetch("days_open")
|
|
55
|
+
|
|
56
|
+
#: () -> Integer
|
|
57
|
+
def named = @fields.fetch("waiting_on_someone_named")
|
|
42
58
|
|
|
59
|
+
#: () -> Integer
|
|
60
|
+
def unnamed = @fields.fetch("waiting_on_no_one_named")
|
|
61
|
+
|
|
62
|
+
#: () -> Integer
|
|
63
|
+
def to_raise = @fields.fetch("to_raise")
|
|
64
|
+
|
|
65
|
+
# Whether the one finding to raise is one waiting on someone named, whose own line names its need.
|
|
43
66
|
#: () -> bool
|
|
44
|
-
def
|
|
67
|
+
def alone? = to_raise == 1 && named == 1
|
|
68
|
+
|
|
69
|
+
# The oldest open finding of all, by principle and finding_id.
|
|
70
|
+
#: () -> Hash[String, untyped]
|
|
71
|
+
def oldest = @fields.slice("principle", "finding_id")
|
|
72
|
+
|
|
73
|
+
# The oldest finding waiting on someone named, by principle, finding_id and waits_on, or nil.
|
|
74
|
+
#: () -> Hash[String, untyped]?
|
|
75
|
+
def oldest_named = @fields["oldest_waiting_on_someone"]
|
|
45
76
|
end
|
|
46
77
|
|
|
47
78
|
#: (Invocation) -> void
|
|
@@ -51,42 +82,83 @@ module Principles
|
|
|
51
82
|
end
|
|
52
83
|
|
|
53
84
|
# waiting is nil when no finding is open, or the count of open findings with the oldest one's principle,
|
|
54
|
-
# finding_id, days_open and
|
|
55
|
-
# finding_id, whose write-up can no longer be found where its recorded_at
|
|
56
|
-
# session's start: startup, resume, clear or compact.
|
|
57
|
-
#: (Hash[String, untyped]?, ?Array[Hash[String, untyped]], ?source: String) -> Lines
|
|
58
|
-
def short(waiting, not_found = [], source: "startup")
|
|
59
|
-
Lines.new(stdout: lines(waiting, not_found, source:).map { "#{it}\n" }.join, stderr: "", status: 0)
|
|
85
|
+
# finding_id, days_open, how many wait on someone named and the oldest of those, or nil. not_found is each
|
|
86
|
+
# open finding, by principle and finding_id, whose write-up can no longer be found where its recorded_at
|
|
87
|
+
# points. source is the session's start: startup, resume, clear or compact. user_name is git's, or nil.
|
|
88
|
+
#: (Hash[String, untyped]?, ?Array[Hash[String, untyped]], ?source: String, ?user_name: String?) -> Lines
|
|
89
|
+
def short(waiting, not_found = [], source: "startup", user_name: nil)
|
|
90
|
+
Lines.new(stdout: lines(waiting, not_found, source:, user_name:).map { "#{it}\n" }.join, stderr: "", status: 0)
|
|
60
91
|
end
|
|
61
92
|
|
|
62
93
|
# short's line, as a list of none or one, which report-at-session-start prints among its own.
|
|
63
|
-
#: (Hash[String, untyped]?, ?Array[Hash[String, untyped]], ?source: String) -> Array[String]
|
|
64
|
-
def lines(waiting, not_found = [], source: "startup")
|
|
65
|
-
|
|
94
|
+
#: (Hash[String, untyped]?, ?Array[Hash[String, untyped]], ?source: String, ?user_name: String?) -> Array[String]
|
|
95
|
+
def lines(waiting, not_found = [], source: "startup", user_name: nil)
|
|
96
|
+
start = SessionStart.new(source)
|
|
97
|
+
return [] unless waiting
|
|
98
|
+
|
|
99
|
+
waiting = Waiting.new(waiting)
|
|
100
|
+
return [resumed("#{how_long(waiting)} (#{oldest(waiting.oldest)})", not_found)] if start.resumed?
|
|
101
|
+
return [] if waiting.to_raise.zero?
|
|
102
|
+
|
|
103
|
+
[whole(waiting, not_found, start, user_name)]
|
|
66
104
|
end
|
|
67
105
|
|
|
68
106
|
private
|
|
69
107
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
108
|
+
# The line with what to do about the findings, for a context that does not hold it yet: the facts, then the
|
|
109
|
+
# reply that raises them and why, then the command listing them all, which one finding's own need replaces.
|
|
110
|
+
#: (Waiting, Array[Hash[String, untyped]], SessionStart, String?) -> String
|
|
111
|
+
def whole(waiting, not_found, start, user_name)
|
|
112
|
+
Prompts.text("start-a-session/act-on-the-open-findings",
|
|
113
|
+
facts: "#{waiting_on_someone(waiting)}#{no_one_named(waiting)}#{write_ups(not_found)}" \
|
|
114
|
+
"#{git_user(user_name) unless waiting.named.zero?}",
|
|
115
|
+
raise: raise_which(waiting), reply: start.reply, command: waiting.alone? ? "" : " All: #{all}")
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# The command listing every open finding, a line each.
|
|
119
|
+
#: () -> String
|
|
120
|
+
def all = @invocation.in_project("list-open-findings", options: ["--lines"])
|
|
121
|
+
|
|
122
|
+
# Which findings the agent raises: the one, if it waits on its user, or each that does, with those waiting on
|
|
123
|
+
# no one, or each when none names anyone.
|
|
124
|
+
#: (Waiting) -> String
|
|
125
|
+
def raise_which(waiting)
|
|
126
|
+
return "If it waits on your user, raise it" if waiting.alone?
|
|
127
|
+
return "Raise each" if waiting.named.zero?
|
|
73
128
|
|
|
74
|
-
|
|
129
|
+
"Raise each that waits on your user#{" or on no one" if waiting.unnamed.positive?}"
|
|
75
130
|
end
|
|
76
131
|
|
|
77
|
-
# The
|
|
78
|
-
#: (
|
|
79
|
-
def
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
132
|
+
# The sentence naming the oldest finding that waits on someone named, and whom, counting them when several do.
|
|
133
|
+
#: (Waiting) -> String
|
|
134
|
+
def waiting_on_someone(waiting)
|
|
135
|
+
oldest = waiting.oldest_named or return ""
|
|
136
|
+
need = need(oldest.fetch("waits_on"))
|
|
137
|
+
need = "#{need}." unless need.end_with?(".")
|
|
138
|
+
named = "#{oldest(oldest)}, #{age(oldest.fetch("days_open"))},"
|
|
139
|
+
return "Open finding #{named} waits on: #{need}" if waiting.named == 1
|
|
140
|
+
|
|
141
|
+
"#{counted(waiting.named)} on someone; the oldest, #{named} waits on: #{need}"
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# How long a finding has gone unraised, in whole days.
|
|
145
|
+
#: (Integer) -> String
|
|
146
|
+
def age(days) = "open #{days} #{days == 1 ? "day" : "days"}"
|
|
147
|
+
|
|
148
|
+
# The sentence counting the findings deferred with no waits_on, after any naming someone.
|
|
149
|
+
#: (Waiting) -> String
|
|
150
|
+
def no_one_named(waiting)
|
|
151
|
+
unnamed = waiting.unnamed
|
|
152
|
+
return "" if unnamed.zero?
|
|
153
|
+
return " #{unnamed} #{unnamed == 1 ? "waits" : "wait"} on no one named." if waiting.named.positive?
|
|
154
|
+
|
|
155
|
+
"#{counted(unnamed)} on no one named."
|
|
88
156
|
end
|
|
89
157
|
|
|
158
|
+
# How many open findings wait, as the subject of the sentence saying on whom.
|
|
159
|
+
#: (Integer) -> String
|
|
160
|
+
def counted(count) = count == 1 ? "1 open finding waits" : "#{count} open findings wait"
|
|
161
|
+
|
|
90
162
|
# A resumed session's line: its conversation already holds the line printed when that context began, so this
|
|
91
163
|
# one gives the facts and where the instructions are, not the instructions again.
|
|
92
164
|
#: (String, Array[Hash[String, untyped]]) -> String
|
|
@@ -96,14 +168,12 @@ module Principles
|
|
|
96
168
|
command: @invocation.in_project("list-open-findings", options: ["--short"]))
|
|
97
169
|
end
|
|
98
170
|
|
|
99
|
-
#
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return "" if count == 1 || unnamed.zero?
|
|
104
|
-
return " All #{count} have no waits_on." if unnamed == count
|
|
171
|
+
# git's user name as a fact, for the agent to judge whether the person a finding waits on is its user.
|
|
172
|
+
#: (String?) -> String
|
|
173
|
+
def git_user(name)
|
|
174
|
+
return " git has no user.name set." unless name
|
|
105
175
|
|
|
106
|
-
"
|
|
176
|
+
" git's user.name is #{VisibleText.new(name)}."
|
|
107
177
|
end
|
|
108
178
|
|
|
109
179
|
# The sentence naming the write-ups that can no longer be found, the first by its principle and id, or
|
|
@@ -120,30 +190,28 @@ module Principles
|
|
|
120
190
|
end
|
|
121
191
|
|
|
122
192
|
# How many findings are open and how long the oldest has waited.
|
|
123
|
-
#: (
|
|
124
|
-
def how_long(waiting) = "#{
|
|
193
|
+
#: (Waiting) -> String
|
|
194
|
+
def how_long(waiting) = "#{still_open(waiting.count)}#{waited(waiting)}"
|
|
125
195
|
|
|
126
196
|
#: (Integer) -> String
|
|
127
|
-
def
|
|
197
|
+
def still_open(count)
|
|
128
198
|
count == 1 ? "1 audit finding is still open, " : "#{count} audit findings are still open, the oldest "
|
|
129
199
|
end
|
|
130
200
|
|
|
131
|
-
#: (
|
|
201
|
+
#: (Waiting) -> String
|
|
132
202
|
def waited(waiting)
|
|
133
|
-
days = waiting.
|
|
203
|
+
days = waiting.days_open
|
|
134
204
|
return "for less than a day" if days < 1
|
|
135
205
|
|
|
136
206
|
"for #{days} #{days == 1 ? "day" : "days"}"
|
|
137
207
|
end
|
|
138
208
|
|
|
139
|
-
#
|
|
140
|
-
#
|
|
141
|
-
#: (
|
|
142
|
-
def
|
|
143
|
-
named = oldest(waiting)
|
|
144
|
-
waits_on = waiting["waits_on"] or return named
|
|
209
|
+
# A finding's waits_on, cut when long. It is free text, so it is cut by characters first and then escaped,
|
|
210
|
+
# which may run past the limit to show it.
|
|
211
|
+
#: (String) -> String
|
|
212
|
+
def need(waits_on)
|
|
145
213
|
waits_on = closed("#{whole_words(waits_on[0, WAITS_ON_LIMIT - 3].to_s)}...") if waits_on.length > WAITS_ON_LIMIT
|
|
146
|
-
|
|
214
|
+
VisibleText.new(waits_on).to_s
|
|
147
215
|
end
|
|
148
216
|
|
|
149
217
|
# A cut waits_on up to its last whole word, so it never ends in part of one, or as cut when it is one
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# typed: strict
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
+
require_relative "findings_result"
|
|
4
5
|
require_relative "invocation"
|
|
5
6
|
require_relative "printed_principle"
|
|
6
7
|
require_relative "member_repairs"
|
|
@@ -43,6 +44,16 @@ module Principles
|
|
|
43
44
|
{ "principles" => entries, "next_action" => listed_next_action(entries, waiting, one_to_audit).join("\n") }
|
|
44
45
|
end
|
|
45
46
|
|
|
47
|
+
# Each of list-principles' entries with its principle's open findings, a line each, for --open-findings. open
|
|
48
|
+
# maps each principle id to its findings' plain fields, as list-open-findings --lines takes them.
|
|
49
|
+
#: (Array[Hash[String, untyped]], Hash[String, Array[Hash[String, untyped]]]) -> Array[Hash[String, untyped]]
|
|
50
|
+
def with_open_findings(entries, open)
|
|
51
|
+
findings = FindingsResult.new(@invocation)
|
|
52
|
+
entries.map do |entry|
|
|
53
|
+
entry.merge("open_findings" => open.fetch(entry.fetch("id"), []).map { findings.summary(it) })
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
46
57
|
# list-principles' note on the meta-principle's map, kept in file, when it has no members, with the two ways on.
|
|
47
58
|
#: (String) -> Hash[String, String]
|
|
48
59
|
def no_members(file)
|
|
@@ -43,44 +43,32 @@ module Principles
|
|
|
43
43
|
status: assessed_change || !never_assessed.empty? ? CHANGED : 0)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
# short's lines for a session-start hook: on stdout,
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
def at_session_start(short, changed:, source:, skill:)
|
|
54
|
-
stdout = session_start_lines(changed:, source:, skill:)
|
|
55
|
-
Lines.new(stdout: stdout.map { "#{it}\n" }.join, stderr: short.stderr, status: short.status)
|
|
46
|
+
# short's lines for a session-start hook: on stdout, one line for each principle with a changed member an
|
|
47
|
+
# audit or acknowledgement assessed, as session_start_lines says, from changed, in place of the rows and
|
|
48
|
+
# never-assessed counts, which an always-loaded carrier cannot afford; stderr and the status kept.
|
|
49
|
+
#: (Lines, changed: Hash[String, Integer]) -> Lines
|
|
50
|
+
def at_session_start(short, changed:)
|
|
51
|
+
Lines.new(stdout: session_start_lines(changed:).map { "#{it}\n" }.join, stderr: short.stderr,
|
|
52
|
+
status: short.status)
|
|
56
53
|
end
|
|
57
54
|
|
|
58
|
-
# at_session_start's stdout, a line each
|
|
59
|
-
#
|
|
60
|
-
#
|
|
61
|
-
#: (changed: Hash[String, Integer]
|
|
62
|
-
def session_start_lines(changed
|
|
63
|
-
|
|
64
|
-
[*(Prompts.text("start-a-session/every-loaded-line-costs-every-session") unless source == "resume"),
|
|
65
|
-
*counts, *(where_to_start(skill) unless counts.empty?)]
|
|
55
|
+
# at_session_start's stdout, a line for each principle with changed audited members: how many, why that
|
|
56
|
+
# matters, to act before the user's task, and the command whose output offers acknowledging them or auditing
|
|
57
|
+
# again. Its command leaves out --project, as the hook's own commands do, since a session runs in its project.
|
|
58
|
+
#: (changed: Hash[String, Integer]) -> Array[String]
|
|
59
|
+
def session_start_lines(changed:)
|
|
60
|
+
changed.map { |id, count| changed_line(id, count) }
|
|
66
61
|
end
|
|
67
62
|
|
|
68
63
|
private
|
|
69
64
|
|
|
70
|
-
#
|
|
71
|
-
# commands those lines print.
|
|
72
|
-
#: (bool) -> String
|
|
73
|
-
def where_to_start(skill)
|
|
74
|
-
return Prompts.text("start-a-session/start-with-the-principles-skill") if skill
|
|
75
|
-
|
|
76
|
-
Prompts.text("start-a-session/run-each-command-above")
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
# The session-start line counting principle id's changed audited members, with the command that lists them.
|
|
65
|
+
# The session-start line on principle id's count of changed audited members.
|
|
80
66
|
#: (String, Integer) -> String
|
|
81
67
|
def changed_line(id, count)
|
|
82
|
-
|
|
83
|
-
|
|
68
|
+
Prompts.text("start-a-session/act-on-the-changed-members",
|
|
69
|
+
members: "#{count} audited member#{"s" unless count == 1} of #{VisibleText.new(id)}",
|
|
70
|
+
them: count == 1 ? "it" : "them",
|
|
71
|
+
command: @invocation.without_project.in_project("list-member-problems", id))
|
|
84
72
|
end
|
|
85
73
|
|
|
86
74
|
# The line counting principle id's members no audit has assessed, which a reader tells from a member's row by
|
|
@@ -56,8 +56,8 @@ it, else run in the project it names once, and says when there are no maps, or m
|
|
|
56
56
|
stdout would hide. A changed member stays listed until an audit takes it in: a notice, not a gate that blocks commits.
|
|
57
57
|
For a post-commit hook, run: %{executable} list-member-problems --short || true
|
|
58
58
|
A heartbeat can compare each line's commit with the last one it reported.
|
|
59
|
-
`--short --session-start SOURCE`, for the session-start hook, prints instead
|
|
60
|
-
|
|
59
|
+
`--short --session-start SOURCE`, for the session-start hook, prints instead a line for each principle with changed
|
|
60
|
+
audited members, its count and, to run before the user's task, this command for that principle.
|
|
61
61
|
|
|
62
62
|
`--commits-after COMMIT --hook-event EVENT` is for a Claude Code hook that runs after a Bash call, so a long session
|
|
63
63
|
learns of a member it changed at the commit that changed it, not only at its next start. The plugin's after-commit
|
|
@@ -63,15 +63,15 @@ principle, id, `waits on:` its `waits_on`, `waits on no one named`, or `accepted
|
|
|
63
63
|
design, and `open N days` since first raised, with no script over this JSON. It cannot be given with `--short`.
|
|
64
64
|
|
|
65
65
|
`--short` is for a session-start hook, where an open finding would otherwise wait unseen until its principle's next full
|
|
66
|
-
audit. It prints one line instead of JSON, and nothing at all when no finding is open, exiting 0 either way:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
passing its source.
|
|
66
|
+
audit. It prints one line instead of JSON, and nothing at all when no deferred finding is open, exiting 0 either way:
|
|
67
|
+
how many deferred findings have a `waits_on`, the oldest of them by principle and id with its `waits_on`, cut at a word
|
|
68
|
+
within 80 characters with a parenthesis left open closed, how many have none, and git's `user.name`; then to raise in
|
|
69
|
+
the first reply each that waits on the agent's user, or on no one, since nothing else will, and the command that lists
|
|
70
|
+
them, which one finding's own line needs no command for. The agent judges whether that user is the one named. While
|
|
71
|
+
any open finding's `write_up_opening_reason` is `unavailable`, the line also names that write-up, or the first of them
|
|
72
|
+
with their count, so a pointer that no longer resolves is seen at session start. With `--session-start SOURCE`, one of
|
|
73
|
+
`startup`, `resume`, `clear` and `compact` as Claude Code's SessionStart hook names them, the line for `clear` or
|
|
74
|
+
`compact` asks for the next reply; without it the line is worded for `startup`. For `resume`, whose conversation holds
|
|
75
|
+
the line already, it gives only how many are open, how many whole days the oldest has waited since its
|
|
76
|
+
`first_raised_at`, not `waits_on_since`, which dates only the ask, and the command that prints the line whole. The
|
|
77
|
+
principles plugin's session-start hook prints this line, passing its source.
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
Lists every mapped principle, with its members counted by whether they changed since the last audit.
|
|
2
2
|
Run it to decide which principle to look at or audit.
|
|
3
|
+
To say what principles are in place and what each still waits on, give `--open-findings`, rather than joining
|
|
4
|
+
this list with `list-open-findings`: each row adds `open_findings`, one line per finding its last completed audit
|
|
5
|
+
deferred or accepted, with its id, whom it waits on, or that it is accepted, and how many days it has been open.
|
|
3
6
|
With nothing mapped, `next_action` names `list-candidate-files`, which surveys the project's principles for the user.
|
|
4
7
|
When the `sticking-to-your-principles` map has no members, its row adds `no_members`: setup no longer writes
|
|
5
8
|
that map before its first member, so an earlier setup, or removing its last member, left it. It names the map's
|
|
@@ -4,22 +4,20 @@ nothing more, so a shell that leaves stdin open is not kept waiting; it reads no
|
|
|
4
4
|
0, since a host adds a SessionStart hook's output to the context only on 0, and shows the user an error on any other
|
|
5
5
|
status. In a project with no maps it prints nothing.
|
|
6
6
|
|
|
7
|
-
Otherwise each line it prints starts `principles:`.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
Last, while any finding an audit deferred or accepted is open, the one line `list-open-findings --short` prints, worded
|
|
22
|
-
for the session's start, and short on resume, whose conversation holds the whole line already.
|
|
7
|
+
Otherwise each line it prints starts `principles:`. Input that is not JSON, or names no source a host sends, is read as
|
|
8
|
+
a startup. First comes one line for each principle with a member an audit assessed that changed since, counting them,
|
|
9
|
+
saying its audit no longer covers them, and asking the agent to run, before the user's task, the `list-member-problems
|
|
10
|
+
ID` command that offers acknowledging them or auditing again. An edit to a member no audit has assessed is not counted
|
|
11
|
+
here, since it carries no verdict to act on. In git, a line follows for each principle with members no baseline holds
|
|
12
|
+
yet, as a session that ended mid-mapping leaves them, saying which files to commit, or the audit to run when every file
|
|
13
|
+
is committed already. Outside git only an audit gives a baseline, so that line would repeat at every session, and is
|
|
14
|
+
left out. Then a line for each principle whose audit record a later release of principles wrote: this copy does not
|
|
15
|
+
check its members, so none of them is counted, and the line says how to update. Then, while any principle awaits its
|
|
16
|
+
first full audit, one line counting them, naming none, asks the agent to tell the user and start one background subagent
|
|
17
|
+
to follow `show-first-audit-brief`, or to offer the audit at its next pause if it cannot. At resume and compact, when
|
|
18
|
+
one may be running already, it gives the count alone and asks for no second one. Last, while any finding an audit
|
|
19
|
+
deferred or accepted is open, the one line `list-open-findings --short` prints, worded for the session's start, and
|
|
20
|
+
short on resume, whose conversation holds the whole line already.
|
|
23
21
|
|
|
24
22
|
When the maps or members cannot be read, as `list-member-problems` would refuse, it prints instead the refusal's code
|
|
25
23
|
and that command, whose refusal says why and how to repair it, and still exits 0. Stdin that cannot be read is read as
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
%{
|
|
2
|
-
no one named, and not any this conversation shows you raised. Judge from context, such as git's user name, whether a
|
|
3
|
-
named person is your user; if unsure, raise it. Whom %{each} waits on:
|
|
4
|
-
%{command}
|
|
1
|
+
%{facts} %{raise} in your %{reply} reply; nothing else will.%{command}
|
data/principles.gemspec
CHANGED
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
|
8
8
|
# Rakefile. Loaded from the checkout, as Bundler does, it is RELEASE, so Gemfile.lock does not change with
|
|
9
9
|
# every commit.
|
|
10
10
|
spec.version = Principles::BUILT_VERSION || Principles::RELEASE
|
|
11
|
-
spec.summary = "Tighter harness, longer
|
|
11
|
+
spec.summary = "Tighter harness, longer running agents: trust the principles, loosen the supervision"
|
|
12
12
|
spec.description = <<~TEXT
|
|
13
13
|
A harness configuration framework that keeps every part of your Claude Code agent's harness in alignment.
|
|
14
14
|
Name the principles your CLAUDE.md files, rules, skills, subagents and hooks encode, and map every place
|
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
|
16
16
|
move with it, and walks your agent through bringing them back into line, recording anything still to fix.
|
|
17
17
|
It never edits your harness and calls no model: it keeps the books deterministically.
|
|
18
18
|
Ruby 3.4, with no runtime gem dependencies.
|
|
19
|
-
Codex
|
|
19
|
+
Built for Claude Code. Codex is partly supported, with full support coming soon, and Pi after that.
|
|
20
20
|
TEXT
|
|
21
21
|
spec.license = "Apache-2.0"
|
|
22
22
|
spec.authors = ["Sidu Ponnappa"]
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: principles
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sidu Ponnappa
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 2026-11-20 00:00:00.000000000 Z
|
|
11
11
|
dependencies: []
|
|
12
12
|
description: |
|
|
13
13
|
A harness configuration framework that keeps every part of your Claude Code agent's harness in alignment.
|
|
@@ -16,7 +16,7 @@ description: |
|
|
|
16
16
|
move with it, and walks your agent through bringing them back into line, recording anything still to fix.
|
|
17
17
|
It never edits your harness and calls no model: it keeps the books deterministically.
|
|
18
18
|
Ruby 3.4, with no runtime gem dependencies.
|
|
19
|
-
Codex
|
|
19
|
+
Built for Claude Code. Codex is partly supported, with full support coming soon, and Pi after that.
|
|
20
20
|
email:
|
|
21
21
|
- sidu@realfast.ai
|
|
22
22
|
executables:
|
|
@@ -466,15 +466,11 @@ files:
|
|
|
466
466
|
- lib/principles/views/prompts/set-principles-up/place-the-passage-with-the-user.md
|
|
467
467
|
- lib/principles/views/prompts/set-principles-up/what-the-passage-presumes.md
|
|
468
468
|
- lib/principles/views/prompts/set-principles-up/wire-the-report-hooks-with-the-user.md
|
|
469
|
+
- lib/principles/views/prompts/start-a-session/act-on-the-changed-members.md
|
|
469
470
|
- lib/principles/views/prompts/start-a-session/act-on-the-open-findings.md
|
|
470
|
-
- lib/principles/views/prompts/start-a-session/every-loaded-line-costs-every-session.md
|
|
471
471
|
- lib/principles/views/prompts/start-a-session/hand-the-first-audit-to-a-subagent.md
|
|
472
|
-
- lib/principles/views/prompts/start-a-session/raise-them-at-the-next-pause.md
|
|
473
|
-
- lib/principles/views/prompts/start-a-session/raise-them-before-the-first-task.md
|
|
474
|
-
- lib/principles/views/prompts/start-a-session/run-each-command-above.md
|
|
475
472
|
- lib/principles/views/prompts/start-a-session/see-the-earlier-line.md
|
|
476
473
|
- lib/principles/views/prompts/start-a-session/start-no-second-first-audit.md
|
|
477
|
-
- lib/principles/views/prompts/start-a-session/start-with-the-principles-skill.md
|
|
478
474
|
- lib/principles/views/read_the_change.rb
|
|
479
475
|
- lib/principles/views/record_waiting_on_an_upgrade.rb
|
|
480
476
|
- lib/principles/views/repoint_result.rb
|
|
@@ -514,5 +510,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
514
510
|
requirements: []
|
|
515
511
|
rubygems_version: 3.6.9
|
|
516
512
|
specification_version: 4
|
|
517
|
-
summary: 'Tighter harness, longer
|
|
513
|
+
summary: 'Tighter harness, longer running agents: trust the principles, loosen the
|
|
514
|
+
supervision'
|
|
518
515
|
test_files: []
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Meta-principle: what loads at start costs every session's context; load only what the task needs.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
At your next pause,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Before the user's first task,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Run each command above; its output says what to do next.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
The principles skill, /principles, is where to start with these members; each command's output says what to do next.
|