From ad70ec6dadc7dfa9ff3503d700f1cedfd4860f19 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 14 Nov 2026 23:36:30 +0100 Subject: [PATCH] =?UTF-8?q?Answer=20prose=20round=201:=200=20=F0=9F=94=B4,?= =?UTF-8?q?=209=20=F0=9F=9F=A1=20(0=20misread);=20say=20DM=20throughout,?= =?UTF-8?q?=20untangle=20the=20notifier's=20help,=20error=20and=20README?= =?UTF-8?q?=20lines,=20and=20sort=20the=20new=20README=20bullets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- README.md | 8 ++++---- bin/mattermost_dm/dm.py | 2 +- bin/notifier/notify.py | 8 ++++---- bin/notifier/test_notifier.py | 2 +- bin/project_config/main.py | 13 +++++++------ bin/project_config/settings.py | 2 +- bin/rest_client/json_request.py | 2 +- 8 files changed, 20 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dfe9172..b841315d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ - The new `project-record open ` prints the file in which an agent reads and edits one of a project's five records (`decisions`, `score-anchors`, `comprehension-history`, `reading-cost` and `changelog`), and `project-record save ` stores the edit. Every tool now reads and writes a record the same one way, so that a later release can keep a record outside files. No config needs a change. - `loop-inbox` is gone. loop-claude now asks its questions only on its own terminal. A line typed there answers a question, and `/talk` opens the worker's session. The DM still tells you a loop waits. To upgrade, quit any `loop-inbox` still open and remove your `~/.local/bin/loop-inbox` link. Once every loop started before the upgrade has reloaded or ended, remove the folder `~/.local/state/loop-claude/`, which nothing reads any more. - rule-hook refuses a Read or a Grep of `~/.claude/.env` or of the `env-file` any project's config names, and a Bash command that names either or searches a folder holding either with `ag`, `grep -r` or `rg`, unless the tool skips the file as hidden or ignored, so that a worker doesn't put a credential in its transcript in passing. A command that hides the path, such as behind a glob or a variable, still goes through. -- A project's config names the service for loop-claude's DMs: `notifier = "mattermost"` or `"slack"`, with the bot's token and the recipient in the `env-file`. Slack's keys are `SLACK_TOKEN` and `SLACK_RECIPIENT`, a bot token with the `chat:write` scope and a member ID. To upgrade, move the Mattermost keys from `~/.claude/.env` into a file outside the checkout and the config's folder, such as `~/.claude-projects/.env`, name it as `env-file` and add `notifier = "mattermost"`. A project with no `notifier` gets no DM, and `~/.claude/.env` is no longer read. A failure names each missing key and holds no token. +- A project's config names the service for loop-claude's DMs: `notifier = "mattermost"` or `"slack"`, with the bot's token and the recipient in the `env-file`. To upgrade, move the Mattermost keys from `~/.claude/.env` into a file outside the checkout and the config's folder, such as `~/.claude-projects/.env`, name it as `env-file` and add `notifier = "mattermost"`. A project with no `notifier` gets no DM, and `~/.claude/.env` is no longer read. A failure names each missing key and holds no token. - `mattermost-dm` is now `notify`, which sends through the project's `notifier`; `notify --help` names the keys. ## 0.10.0 diff --git a/README.md b/README.md index 52511de2..48a6f589 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ Then pick a model with `/model`. Link `loop-claude` onto `PATH`: `ln -s ~/.claude/bin/loop-claude ~/.local/bin/loop-claude`. Every claude it starts, the interactive ones included, skips every permission prompt. -To get loop-claude's questions and stops as DMs from a bot, write the bot's token and your recipient into `~/.claude-projects/.env`, in the keys `~/.claude/bin/notify --help` names for Mattermost or Slack, run `chmod 600` on it, and add `env-file = "~/.claude-projects/.env"` and `notifier = "mattermost"` (or `"slack"`) to the project's config, as Install → "Set up a project" describes. Without `notifier`, loop-claude sends no DM for the project, whatever the env file holds; `~/.claude/.env` is no longer read. +To get loop-claude's questions and stops as DMs from a bot, write the bot's token, your username or member ID and, for Mattermost, the server into `~/.claude-projects/.env`, in the keys `~/.claude/bin/notify --help` names, run `chmod 600` on it, and add `env-file = "~/.claude-projects/.env"` and `notifier = "mattermost"` (or `"slack"`) to the project's config, as Install → "Set up a project" describes. ### Set up a project @@ -96,7 +96,7 @@ principles = "~/.claude/principles" A project may also set `env-file`, the file of `KEY=value` credentials its tools read, such as `env-file = "~/.claude-projects/log.env"`. It is a path that starts with `/` or `~/`, outside the checkout and the config's folder, so that no git remote receives it. A tool that needs a key fails and names each one the file lacks. No failure message, prompt, log line or archived loop output holds a token from the file. rule-hook refuses a Read or a Grep of the file and a Bash command that names it or searches a folder holding it with `ag`, `grep -r` or `rg`, unless the tool skips the file as hidden or ignored, so a worker doesn't read it in passing; `rule-hook --help` says which calls it checks. A project without the setting has no credentials, and never reads another project's. `project-config env-file` prints the path. -It may set `notifier = "mattermost"` or `"slack"` too, the service that carries loop-claude's DMs; it needs `env-file`, which holds the notifier's keys, and `project-config notifier` prints it. A project that names none gets no DMs. +A project may also set `notifier` to `"mattermost"` or `"slack"`, the service that sends loop-claude's DMs. The `env-file` then holds that service's keys. A project that sets none gets no DMs, whatever its env file holds. `project-config notifier` prints the setting. A project's config may set four more things, each optional, as `project-config --help` describes. `language` names the language its owners write in, where that isn't English: the worker writes the project's prose in it, and the prose reviewer judges the prose in it. `commit-title`, `pull-request-title` and `branch` are templates for a project that titles and names these in another way than `CLAUDE.md` → "Git, commits, and PRs" says. `chunk-preflight` names the branch and the worktree by the `branch` template. On a branch that fits it, rule-hook refuses a commit, and `chunk-pr` a pull request, whose title doesn't fit its template; on any other branch, such as a release review's, a title is the summary alone. A tool that reads a commit title, such as a round's `Answer round :`, reads the template's `{summary}`: it tries `commit-title`, then `pull-request-title`, since a squash merge titles the commit as the pull request, then takes the title whole. While a project's config holds a fault, rule-hook refuses every commit there, and the tools that read its titles fail naming the fault. @@ -164,9 +164,9 @@ Install puts only `loop-claude` on `PATH`; call the others by their path, such a - `judge-replay ` replays loop-claude's judge on archived verdicts of the projects run on the model, and prints what each rung a review climbs to misses, and the lowest rung below them that, like each candidate above it, returns them; `judge-replay --help` states the replay. - `larv-review ` holds larv-review's mechanical rules: the chunk's review folder, the paired ruling's base and vote count, each pass's round count, the scoring run's trigger and setup; the comprehension history's format, its latest places and its count of how often seats agree; and each reviewer's prompt header. `larv-review --help` states them. `settings.json` → `hooks` runs `larv-review reviewer-context` as each subagent starts. A reviewer under `agents/` whose frontmatter has `omitClaudeMd: true` starts without `CLAUDE.md`, and the command hands it that file's "Shared goal", "Prose" and "Vocabulary" sections. - `loop-claude ` runs a project's next chunk cycle after cycle; `loop-claude --help` states its contract. -- `notify []` sends a message, or else stdin, from the bot of the project's `notifier`, Mattermost or Slack, to the human; the project's `env-file` holds the bot's token and the human, and `notify --help` names its keys. `loop-claude --help` says when loop-claude sends one. - `metric-bench [history]` benches cheap static metrics of a project's Python against the places its comprehension history names as hardest; `metric-bench --help` states the metrics and the scores. - `mutate-changes [--base ] [--prefix ] [--jobs ]` mutation-tests the lines a branch changes and prints each mutant its tests don't kill; `mutate-changes --help` says which tool it runs for each language. +- `notify []` sends a message, or else stdin, as a DM from the bot of the project's `notifier`, Mattermost or Slack, to the human; the project's `env-file` holds the bot's token, the recipient and, for Mattermost, the server, and `notify --help` names its keys. `loop-claude --help` says when loop-claude sends one. - `project-config []` prints the paths a project's config sets, or the one asked for, and fails naming each setting the config leaves out; Install → "Set up a project" shows a config. - `project-record open ` prints the path of a file holding one of a project's records, for an agent to read and edit, and `project-record save ` stores the edit; for a record kept as a file, that file is the record. `goals-and-audience` opens the goals file the same way. - `rank_todo.py [--check] [todo.md]` scores and ranks a project's `todo.md`, by default the one its config names; `rank_todo.py --help` states the format. @@ -195,8 +195,8 @@ Install puts only `loop-claude` on `PATH`; call the others by their path, such a - `loop_effects/` holds `Effects`: the processes, terminal, clock and git a tool reaches, injected so its tests can script them. loop-claude, both replay tools and `reviewer-merge-trials`' driver use it. - `loop_state/` holds where loop-claude keeps its files (`paths.py`), which `rung_replay` reads too. - `machine_load/` takes the machine's heavy slots, its shared lock files, for `run_heavy` and `adf_codec`, and reads the memory share that loop-claude waits for. It also gives `mutate_changes` a slot's CPU count. -- `notifier/` sends the human a DM through the notifier a project's config names, for `notify` and for loop-claude through `loop_effects`; `mattermost_dm/` and `slack_dm/` are its two backends. - `model_routing/` holds the routing ladder, which loop-claude, `rule_hook`, both replay tools and `subagent-rung` read, and the list prices, which `routing_figures` and `transcript_archive` read. +- `notifier/` sends the human a DM through the notifier a project's config names, for `notify` and for loop-claude through `loop_effects`; `mattermost_dm/` and `slack_dm/` are its two backends. - `plan_store/` reads and writes a project's plan through the store the project's config names (`stores.py`), with the markdown file's edits in `markdown_edits.py`. `contract.py` holds the tests every backend that writes must pass, which `jira_epic.py` doesn't yet, and `fakes.py` a plan in memory. - `rank_todo.py`, `settings_filter.py` and `statusline.py` are tools of one file each, tested beside them. - `record_store/` reads and writes a project's records, each through the store the project's config names (`stores.py`). `contract.py` holds the tests every backend must pass, and `fakes.py` a store in memory that the tests of other tools use. diff --git a/bin/mattermost_dm/dm.py b/bin/mattermost_dm/dm.py index 54d7fd00..e99f47dd 100644 --- a/bin/mattermost_dm/dm.py +++ b/bin/mattermost_dm/dm.py @@ -1,4 +1,4 @@ -"""Sends a direct message from a Mattermost bot to one user, through Mattermost's REST API v4. `notifier` picks it where a project's config names `mattermost`.""" +"""Sends a direct message from a Mattermost bot to one user, through Mattermost's REST API v4. The `notifier` setting `mattermost` picks it.""" import dataclasses import pathlib import urllib.parse diff --git a/bin/notifier/notify.py b/bin/notifier/notify.py index 52347ab4..625ca667 100644 --- a/bin/notifier/notify.py +++ b/bin/notifier/notify.py @@ -1,4 +1,4 @@ -"""Sends a notice through the notifier that a project's config names.""" +"""Sends a DM through the notifier that a project's config names.""" import dataclasses import pathlib import typing @@ -16,7 +16,7 @@ Sender = typing.Callable[[str], Failure | None] @dataclasses.dataclass(frozen=True) class Backend: - """A notifier's three parts. `read_config` returns whatever `send` takes as its config.""" + """What one notifier needs: `read_config` reads its credentials from an env file, and returns whatever `send` takes as its config; `send` posts a message with them through `http`; `keys` are the env file's keys.""" read_config: typing.Callable[[pathlib.Path], typing.Any] send: typing.Callable[[typing.Any, str, Http], Failure | None] http: Http @@ -33,7 +33,7 @@ assert tuple(BACKENDS) == NOTIFIERS def sender_of(project: ProjectConfig, http: Http | None = None) -> Sender | Failure: """A sender through the project's notifier, with the credentials in its env file read; http replaces the backend's own. A Failure where the project names no notifier or its env file cannot be used.""" if project.notifier is None or project.env_file is None: - return Failure(f"{project.folder / 'config.toml'} sets no `{NOTIFIER}`; set it to one of {', '.join(NOTIFIERS)}, and `env-file` to the file that holds its keys: mattermost needs {', '.join(BACKENDS['mattermost'].keys)}, slack needs {', '.join(BACKENDS['slack'].keys)}") + return Failure(f"{project.folder / 'config.toml'} sets no `{NOTIFIER}`; set `notifier` to {' or '.join(NOTIFIERS)}, and `env-file` to the file that holds that service's keys ({'; '.join(f'{name}: {', '.join(backend.keys)}' for name, backend in BACKENDS.items())})") backend = BACKENDS[project.notifier] config = backend.read_config(project.env_file) if isinstance(config, Failure): @@ -44,7 +44,7 @@ def sender_of(project: ProjectConfig, http: Http | None = None) -> Sender | Fail def notify(text: str, directory: str | None, home: pathlib.Path, http: Http | None = None) -> Failure | None: """Sends text through the notifier of the project whose checkout holds directory. - It is skipped where the config names no notifier, since the project hasn't asked for notices. It is skipped too where no config can be read: loop-claude has stopped with that reason, and without a config there is no notifier to ask.""" + The DM is skipped where the config names no notifier, since the project hasn't asked for DMs. It is skipped too where no config can be read: loop-claude has stopped with that reason, and without a config there is no notifier to ask.""" project = located(directory, home) if isinstance(project, Failure) or project.notifier is None: return None diff --git a/bin/notifier/test_notifier.py b/bin/notifier/test_notifier.py index b4f0e10b..46450389 100644 --- a/bin/notifier/test_notifier.py +++ b/bin/notifier/test_notifier.py @@ -99,7 +99,7 @@ class Notify(Project): def test_sender_in_names_the_settings_to_add_where_the_config_names_no_notifier(self): failed = notify.sender_in(str(self.checkout), self.home) assert isinstance(failed, Failure), failed - self.assertEqual(failed.reason, f"{self.folder / 'config.toml'} sets no `notifier`; set it to one of mattermost, slack, and `env-file` to the file that holds its keys: mattermost needs MATTERMOST_URL, MATTERMOST_TOKEN, MATTERMOST_RECIPIENT, slack needs SLACK_TOKEN, SLACK_RECIPIENT") + self.assertEqual(failed.reason, f"{self.folder / 'config.toml'} sets no `notifier`; set `notifier` to mattermost or slack, and `env-file` to the file that holds that service's keys (mattermost: MATTERMOST_URL, MATTERMOST_TOKEN, MATTERMOST_RECIPIENT; slack: SLACK_TOKEN, SLACK_RECIPIENT)") class Main(Project): diff --git a/bin/project_config/main.py b/bin/project_config/main.py index 6ab39031..e52040b8 100644 --- a/bin/project_config/main.py +++ b/bin/project_config/main.py @@ -36,10 +36,10 @@ a path that starts with / or ~/ and lies outside the checkout and the config's f "~/.claude-projects/acme-billing.env". Where it is left out, the project has no credentials file, and a tool that needs one fails naming the setting. It is printed with the others only where it is set. -`notifier` is an optional setting, "mattermost" or "slack": the service that carries loop-claude's notices -and `notify`'s messages to the human, with the credentials in `env-file`, which it then requires; `notify ---help` names the keys. Left out, the project gets no notices. It is printed with the others only where -it is set. +`notifier` is an optional setting, "mattermost" or "slack": the service that sends loop-claude's DMs and +`notify`'s messages to the human. Setting it requires `env-file`, which holds that service's keys; +`notify --help` names them. Left out, the project gets no DMs. It is printed with the others only where it +is set. `wait-for-approval` is an optional setting, true or false: whether `chunk-pr merge` waits for a human's approval of the pull request, as its branch protection requires on GitHub, before it merges. Left out, it is @@ -89,8 +89,9 @@ The chunk for the issue ABC-123 is then on the branch ABC-123, in the worktree < and its commits and pull request are titled "ABC-123 - …". Exit 1, naming each fault on stderr, where no config names the checkout, or its config leaves out a -setting, names an unknown one, misspells a path, a language or a template, names a notifier that is neither mattermost nor slack or sets one without `env-file`, sets `wait-for-approval` or -`tooling-on-host` to anything but true or false, or sets `readability-floor` to anything but a number +setting, names an unknown one, misspells a path, a language or a template, sets `wait-for-approval` or +`tooling-on-host` to anything but true or false, sets `notifier` to anything but mattermost or slack or +without `env-file`, or sets `readability-floor` to anything but a number from 1 to 10, and where `env-file` or `notifier` is asked for and not set. No path setting has a default. """ import pathlib diff --git a/bin/project_config/settings.py b/bin/project_config/settings.py index 15e8b01e..c53812d8 100644 --- a/bin/project_config/settings.py +++ b/bin/project_config/settings.py @@ -19,7 +19,7 @@ SETTINGS = ("plan", "working-rules", "decisions", "score-anchors", "comprehensio SPELLING = '"checkout:" for a path in the checkout, "folder:" for one in the config\'s folder, or a path that starts with / or ~/' # A path setting a project may leave out: the file of KEY=value credentials its tools read. It has no default either: a project without it asks for no credentials, and never reads another project's. ENV_FILE = "env-file" -# An optional setting: the service that carries the loop's notices to the human, one of NOTIFIERS. A project that names none gets no notices, so a client's env file for Jira credentials is never read for a chat token. It needs `env-file`, which holds the notifier's credentials. +# An optional setting: the service that sends the loop's DMs to the human, one of NOTIFIERS. A project that names none gets no DMs, so a client's env file of Jira credentials is never read for a chat token. NOTIFIER = "notifier" NOTIFIERS = ("mattermost", "slack") # An optional boolean setting: whether `chunk-pr merge` waits for a human's approval of the pull request. False where left out. diff --git a/bin/rest_client/json_request.py b/bin/rest_client/json_request.py index 16394dc1..369cda81 100644 --- a/bin/rest_client/json_request.py +++ b/bin/rest_client/json_request.py @@ -19,7 +19,7 @@ class NoRedirect(urllib.request.HTTPRedirectHandler): return None -# Sends a request: method, url, token and the body as JSON where there is one. It answers the JSON, or a Failure saying why there is none. +# Sends a request: method, url, token and the body as JSON where there is one. It returns the JSON answer, or a Failure saying why there is none. Http = typing.Callable[[str, str, str, object], object] OPENER = urllib.request.build_opener(NoRedirect)