feat: drop the kettle plugin; the binary writes its own skills

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>
This commit is contained in:
naudachu
2026-08-12 16:17:24 +05:00
parent f18a633185
commit 8b1b11001a
445 changed files with 231172 additions and 1339 deletions
+136
View File
@@ -0,0 +1,136 @@
package cmd
// The seam between the registry and the documents written from it. Both halves
// are in this package's reach, so it is asserted here rather than inferred from
// a generated file downstream.
import (
"sort"
"strings"
"testing"
"git.noodles.cam/claude-skills/marketplace/cli/internal/scaffold"
)
// A group with no document is a group whose flag table is written nowhere, and
// nothing would say so: gen walks the documents, not the registry, so the
// commands would simply be absent. This is the test that makes adding a group a
// two-step change rather than a silent one-step mistake.
func TestEveryGroupHasSomewhereToBeWritten(t *testing.T) {
inRegistry := map[string]bool{}
for _, c := range Commands() {
if c.Group == "" {
t.Errorf("command %q has no group, so it is in no document at all", c.Name)
continue
}
inRegistry[c.Group] = true
}
for _, g := range scaffold.Groups() {
if !inRegistry[g] {
t.Errorf("scaffold ships a document for group %q, which no command is in", g)
}
}
for g := range inRegistry {
if scaffold.PathFor(g) == "" {
t.Errorf("group %q has commands and no document — add one to internal/scaffold/assets", g)
}
}
}
// Every document renders, and the flag table inside it is this binary's. A
// command whose Long text spelled a region marker out in full would end the
// generated block inside itself, and renderAll is where that is caught.
func TestEveryDocumentRendersWithItsOwnFlags(t *testing.T) {
files, err := renderAll()
if err != nil {
t.Fatalf("rendering the tree failed: %v", err)
}
if len(files) != len(scaffold.Files()) {
t.Fatalf("rendered %d of %d documents", len(files), len(scaffold.Files()))
}
for _, f := range files {
if f.Group == "" {
continue
}
for _, c := range commandsIn(f.Group) {
if !strings.Contains(f.Body, "## `"+c.Usage()+"`") {
t.Errorf("%s does not document `%s`", f.Path, c.Usage())
}
for _, flag := range c.Flags() {
if !strings.Contains(f.Body, "| `--"+flag.Name+"` |") {
t.Errorf("%s documents `%s` without --%s", f.Path, c.Name, flag.Name)
}
}
}
if strings.Contains(f.Body, genOpen+"\n"+genOpen) {
t.Errorf("%s has a doubled marker", f.Path)
}
}
}
// Rendering twice produces the same bytes. Everything downstream — --check, the
// idempotence of init, a diff in somebody's repository — is built on it.
func TestRenderingIsDeterministic(t *testing.T) {
a, err := renderAll()
if err != nil {
t.Fatal(err)
}
b, err := renderAll()
if err != nil {
t.Fatal(err)
}
if len(a) != len(b) {
t.Fatalf("two renders produced %d and %d documents", len(a), len(b))
}
for i := range a {
if a[i].Path != b[i].Path {
t.Fatalf("document %d is %s then %s", i, a[i].Path, b[i].Path)
}
if a[i].Body != b[i].Body {
t.Errorf("%s differs between two renders", a[i].Path)
}
}
}
// The guess the wizard offers for --repo. It is worth exactly what it costs —
// a file read — so anything it cannot make sense of must answer "" and let the
// operator type it, rather than proposing half an address.
func TestOwnerNameReadsTheSpellingsGitActuallyWrites(t *testing.T) {
cases := []struct{ url, want string }{
{"git@git.example.com:claude-skills/marketplace.git", "claude-skills/marketplace"},
{"git@git.example.com:claude-skills/marketplace", "claude-skills/marketplace"},
{"https://git.example.com/claude-skills/marketplace.git", "claude-skills/marketplace"},
{"https://git.example.com/claude-skills/marketplace", "claude-skills/marketplace"},
{"ssh://git@git.example.com:2222/claude-skills/marketplace.git", "claude-skills/marketplace"},
{" https://git.example.com/owner/name.git ", "owner/name"},
// Deeper paths: a Gitea instance served under a prefix still ends in
// owner/name, and the last two elements are the address.
{"https://example.com/git/owner/name.git", "owner/name"},
// Nothing that can be read as an address.
{"", ""},
{"https://git.example.com/", ""},
{"https://git.example.com/lonely", ""},
{"/a/local/path", "local/path"},
}
for _, tc := range cases {
if got := ownerName(tc.url); got != tc.want {
t.Errorf("ownerName(%q) = %q, want %q", tc.url, got, tc.want)
}
}
}
// The document list is stable and sorted, which is what makes a receipt from one
// machine comparable with a receipt from another.
func TestScaffoldFilesAreSorted(t *testing.T) {
files := scaffold.Files()
paths := make([]string, len(files))
for i, f := range files {
paths[i] = f.Path
}
if !sort.StringsAreSorted(paths) {
t.Errorf("the document list is not sorted: %v", paths)
}
}