8b1b11001a
The plugin and the binary shipped on two release cadences and nothing on an operator's machine ever checked that the one they installed described the other. The generated flag block existed precisely so a renamed flag could not ship with documentation recommending the old one — and then shipped one version behind the registry it came from, which is the same bug one hop downstream. So the prose moved into the binary. `internal/scaffold` embeds every document; `kettle init` and `kettle gen scaffold` write them into a project's own `.claude/`. The two cannot disagree because there is one artefact. The namespace survived the move. A project's skills are flat, so the prefix is spelled into the directory name (`kettle-issue`); a project's *commands* take their namespace from a subdirectory, so `commands/kettle/init.md` is still `/kettle:init`. Four of the six command files are thin pointers at a skill, and that is what kept ~1,600 lines of `/kettle:…` cross-references true without a rewrite. `init` and `auth` lost `disable-model-invocation: true` — being a command is that property — and `auth` now restricts `allowed-tools` so a model cannot reach `kettle auth add` at all. `gen scaffold` writes files whole rather than splicing a region. The old refusal protected somebody's hand-written prose around the block; that prose is embedded now, so there is none to protect, and preserving local edits would freeze a project's documentation at whatever version first initialized it. `--check` warns before an upgrade discards one. The plugin's `agents-sync.sh` — 141 lines of Python behind a filename that said `.sh` — became `internal/mirror` and `kettle mirror`. Same seven branches, same refusal to merge two real files that differ, now with a table test per branch and a check that a repair converges in one pass. `--hook` is the PreToolUse form and exits 0 on every path including a panic. It is opt-in per project, which is strictly narrower than the plugin hook that was on for everybody who installed it. `kettle init --interactive` walks a person through the login, the token (read with the echo off, so it lands in no history and no file), the repository, the `.claude/` tree and the mirror hook. It refuses a stdin that is not a terminal and names the flags instead: every question it asks has one, and it performs nothing itself, so an interactive run and a flag run are one code path. Two rules that used to be prose are now the binary's: init refuses a linked worktree and names the main checkout, and writing into an existing `.claude/settings.json` is refused with the snippet printed rather than reformatting a file the operator commits. The scaffold version stamp went to its own `.kettle/scaffold.yaml` rather than into `config.yaml`, because unknown keys there are a hard error and that file may be committed and read by whatever build each machine has. golang.org/x/term becomes a direct dependency; it was already in the tree indirectly, so no module was added. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
102 lines
6.3 KiB
Markdown
102 lines
6.3 KiB
Markdown
# AGENTS.md — internal/, and the boundaries between the packages in it
|
|
|
|
Nine packages, one direction of knowledge. The diagram is in
|
|
[`cli/AGENTS.md`](../AGENTS.md); **this file owns the rules that hold it and the
|
|
tests that fail when one is broken.** Each package's own document owns what is
|
|
inside it.
|
|
|
|
The rule in one sentence: **read the diagram bottom-up and each layer knows
|
|
strictly less about trackers than the one above it.** A tracker concept — an issue
|
|
number, a login, an HTTP call, a label colour — that shows up in
|
|
[`issue`](issue/AGENTS.md) is in the wrong place, and a domain concept — a
|
|
section, an acceptance criterion, a type taxonomy — that shows up in
|
|
[`gitea`](gitea/AGENTS.md) is in the wrong place too.
|
|
|
|
## Six rules, eleven tests
|
|
|
|
Each test fails on a real mistake rather than on a naming convention.
|
|
|
|
| rule | enforced by |
|
|
|---|---|
|
|
| [`issue`](issue/AGENTS.md) may import [`project`](project/AGENTS.md) and the standard library, and **nothing else** | `TestDomainDependsOnNothing` walks `go list -deps` and fails on any import path with a dot in its first element — which is what keeps yaml *and* the SDK out of the domain; `TestDomainDoesNotReachTheNetworkOrTheShell` names `net/http`, `net`, `os/exec` and `encoding/json`, standard library the first test cannot catch |
|
|
| [`wire`](wire/AGENTS.md) imports **only** the standard library | `TestWireDependsOnNothing` and `TestWireReachesNeitherTheNetworkNorTheDisk`, the same two checks |
|
|
| [`gitea`](gitea/AGENTS.md) must not import [`issue`](issue/AGENTS.md) **or** [`mapping`](mapping/AGENTS.md) | `TestTransportDoesNotImportTheDomain` — the transport knows numbers, logins, HTTP and JSON, and none of what they mean |
|
|
| [`mapping`](mapping/AGENTS.md) reaches for nothing but the domain, `wire` and the SDK, and does no I/O | `TestTheBridgeTranslatesAndNothingElse` on its **direct** imports, with `os`, `net/http`, `internal/gitea`, `internal/config` and `internal/project` named; `TestTheBridgeHasNoClock` greps its sources for `time.Now` |
|
|
| [`mirror`](mirror/AGENTS.md) imports **only** the standard library, and shells out to nothing | `TestMirrorDependsOnNothing` and `TestMirrorNeitherDialsNorShellsOut` |
|
|
| [`scaffold`](scaffold/AGENTS.md) imports **only** the standard library, and reads nothing off the disk | `TestScaffoldDependsOnNothing` and `TestScaffoldReadsNothingOffTheDisk` |
|
|
|
|
The domain's two tests were **untouched by the migration to the Gitea SDK, and
|
|
that is the point: the domain did not notice it happened.**
|
|
|
|
The last two rows are the newest and are there for the same reason as `wire`'s,
|
|
turned outward rather than inward. `mirror` walks any directory on the machine
|
|
and `scaffold` hands out documents that must exist wherever the binary does — so
|
|
one import of `internal/config` would make `mirror` unusable outside a project,
|
|
and one `os.ReadFile` would make `scaffold`'s documents files that can be
|
|
missing. Neither failure would show up in this repository; both would show up on
|
|
somebody else's machine.
|
|
|
|
`mirror` bans `os/exec` by name, and that one is a small monument: this package
|
|
was 141 lines of Python behind a filename that said `.sh`, so the shell-out it
|
|
must not grow is the exact thing it used to be.
|
|
|
|
## The one rule that got weaker, and why the trade was taken
|
|
|
|
The payload shapes used to live in `wire`, a package that imported the standard
|
|
library and nothing else, so "the bridge cannot reach a transport" was a fact
|
|
about the import graph: there was nothing in its dependency closure that could
|
|
open a socket. `code.gitea.io/sdk/gitea` is a client and a set of types in one
|
|
package, so importing the types imports the client, and a test that walked the
|
|
closure would now be asserting something false.
|
|
|
|
What is still true, and what the test now says, is that **mapping performs no
|
|
I/O** — no `os`, no `net/http`, no transport, no configuration, no clock. Note
|
|
the deliberate asymmetry with the domain's test: this one checks **direct**
|
|
imports, because the domain reaches `os` *through* `project` and that is the
|
|
domain's business. `time` is allowed here where it was not, because the SDK hands
|
|
over a `time.Time` and somebody has to format it back into the string an issue
|
|
file holds; the clock itself is still the caller's, and the grep for `time.Now`
|
|
is what says so.
|
|
|
|
## Why `wire` still exists
|
|
|
|
It existed because Go needs the JSON shapes to be one type — the transport and
|
|
the bridge were written in parallel and each invented its own `Issue`, `Label`,
|
|
`Milestone` and `Comment`. The SDK settles that argument for the shapes.
|
|
|
|
**What survives is addressing**, which the SDK has no answer for at all: it takes
|
|
an owner, a name and an `int64`, and never parses. `42`, `#42`, `owner/repo#42`
|
|
and an issue URL are four spellings of one address, all four are what somebody
|
|
has in hand, and `wire.Key` is what the ledger is keyed by and what the `gitea:`
|
|
metadata field holds. So `wire` keeps `Repo`, `Key`, their parsing and their
|
|
tests, and lost the payloads.
|
|
|
|
## Adding a package here
|
|
|
|
Three questions, in order:
|
|
|
|
1. **What does it know that its neighbours must not?** A package that cannot
|
|
answer this is a file in an existing one.
|
|
2. **Which direction does it import?** Draw it into the diagram in
|
|
[`cli/AGENTS.md`](../AGENTS.md) before writing code; an arrow that has to point
|
|
both ways means the split is in the wrong place.
|
|
3. **What test fails when the boundary is crossed?** Write it with the package,
|
|
not after. Every rule above has one, and each of them exists because the
|
|
equivalent convention in the Python version was a grep somebody eventually
|
|
forgot to run.
|
|
|
|
Then give it an `AGENTS.md`, add it to the table in [`cli/AGENTS.md`](../AGENTS.md),
|
|
and add its rule to the table above.
|
|
|
|
## Keeping this file true
|
|
|
|
- **Scope:** the boundaries *between* the packages under `internal/` — the six
|
|
rules, the eleven tests that hold them, and the history of the one that changed.
|
|
Files: every `layering_test.go`, plus `TestTransportDoesNotImportTheDomain` in
|
|
`gitea/client_test.go`.
|
|
- **Update it when** a layering test is added, renamed, removed or weakened; when
|
|
a package is added or removed; or when an import that was forbidden becomes
|
|
allowed — that last one always comes with a reason, and the reason is what this
|
|
file is for.
|
|
- **Do not** restate what a package does. The table links to the file that says so.
|