9480e48312
The plugin resolved its issue store from `__file__`, which put it inside a versioned plugin cache: issues written from one project were invisible from the next, and `origin: local` files — the only copy of that work by definition — were stranded a version bump at a time. The walk that answers "which directory is the project" was written three times over, and in a linked worktree the three disagreed. Both are runtime failures rather than logic ones, so the fix is a compiled binary: one walk, imported rather than re-derived, and a layering rule the build graph enforces instead of a grep. Seven packages, knowledge flowing one way. `project` answers which directory is the project and depends on nothing. `issue` is the domain — format, taxonomy, validation, checkboxes, dependency graph, the store, eviction — offline, with no tracker in it. `wire` holds the protocol shapes. `gitea` is the transport, `mapping` the bridge, `config` the credentials, `cmd` the command tree. Four tests hold the boundaries, each failing on a real mistake rather than a naming convention. The marker moves to `.kettle/` and the login pin moves out of the harness's settings file into `.kettle/config.yaml`, which pins a login by NAME; the tokens live in one file per machine, mode 0600, outside every working tree. That retires the PreToolUse guard hook entirely — the binary holds its own credentials, so a command running under a login nobody chose is not expressible rather than caught. `kettle init` migrates an older `tmp/issues` or `.tea/issues` store in, as a move: a store left behind at an old path is one somebody edits by accident months later. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
48 lines
1.5 KiB
Go
48 lines
1.5 KiB
Go
package wire_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.noodles.cam/claude-skills/marketplace/cli/internal/wire"
|
|
)
|
|
|
|
func TestParseKey(t *testing.T) {
|
|
acme := wire.Repo{Owner: "acme", Name: "widgets"}
|
|
for _, tc := range []struct {
|
|
in string
|
|
want wire.Key
|
|
}{
|
|
{"42", wire.Key{Number: 42}},
|
|
{"#42", wire.Key{Number: 42}},
|
|
{" acme/widgets#42 ", wire.Key{Repo: acme, Number: 42}},
|
|
{"https://git.example.test/acme/widgets/issues/42", wire.Key{Repo: acme, Number: 42}},
|
|
{"https://git.example.test/acme/widgets/issues/42/", wire.Key{Repo: acme, Number: 42}},
|
|
} {
|
|
got, err := wire.ParseKey(tc.in)
|
|
if err != nil {
|
|
t.Errorf("ParseKey(%q): %v", tc.in, err)
|
|
continue
|
|
}
|
|
if got != tc.want {
|
|
t.Errorf("ParseKey(%q) = %v, want %v", tc.in, got, tc.want)
|
|
}
|
|
}
|
|
|
|
// What is not a key has to be refused as one. `o/r#-3` is the case a bare
|
|
// strconv.Atoi accepts and nobody ever wrote: a key read back out of a
|
|
// metadata line somebody hand-edited must come back as "not a key", never
|
|
// as issue -3.
|
|
for _, bad := range []string{"not an issue", "o/r#-3", "o/r#4x", "o/r#", "o/r", ""} {
|
|
if got, err := wire.ParseKey(bad); err == nil {
|
|
t.Errorf("ParseKey(%q) = %v, want a refusal", bad, got)
|
|
}
|
|
}
|
|
|
|
if got := (wire.Key{Repo: acme, Number: 42}).String(); got != "acme/widgets#42" {
|
|
t.Errorf("a qualified key formatted as %q", got)
|
|
}
|
|
if got := (wire.Key{Number: 42}).In(acme).String(); got != "acme/widgets#42" {
|
|
t.Errorf("an unqualified key filled in as %q", got)
|
|
}
|
|
}
|