feat: add the kettle CLI, replacing the plugin's Python scripts
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>
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"git.noodles.cam/claude-skills/marketplace/cli/internal/config"
|
||||
"git.noodles.cam/claude-skills/marketplace/cli/internal/gitea"
|
||||
"git.noodles.cam/claude-skills/marketplace/cli/internal/issue"
|
||||
)
|
||||
|
||||
// commentsSidecarPath is where an issue's comment thread lives — beside it,
|
||||
// under the same slug.
|
||||
//
|
||||
// A path, not a concept the domain needs: a thread is pulled from the tracker
|
||||
// and never pushed back, so `internal/issue` has no reason to learn that the
|
||||
// file exists. It does not have to — the file is named after the issue, and
|
||||
// issue.SlugFiles takes it away when the issue goes.
|
||||
//
|
||||
// It sits here rather than in either command because `pull` writes it and
|
||||
// `comment` rewrites it, and two spellings of one path is how the two come to
|
||||
// disagree about where a thread is.
|
||||
func commentsSidecarPath(root, id string) string {
|
||||
return filepath.Join(root, id+".comments.md")
|
||||
}
|
||||
|
||||
// The sync commands all start the same way and must fail the same way.
|
||||
//
|
||||
// Every one of them needs a store and a client, and the order matters: a
|
||||
// command that dialled first would report a network problem for a project that
|
||||
// was never initialized, and an operator would go looking at the wrong thing.
|
||||
// So the store is resolved before a socket is opened, and each failure names
|
||||
// the command that fixes it.
|
||||
|
||||
// syncStart resolves the store and builds a client for it.
|
||||
//
|
||||
// The client is built from the project's own configuration, which is why there
|
||||
// is no --login flag anywhere in this tree: which login a project runs under is
|
||||
// a fact about the project, stated once by `kettle init`, not a thing a caller
|
||||
// gets to differ about per invocation. That the two could disagree is what the
|
||||
// Python version needed a PreToolUse hook to police.
|
||||
func syncStart(out string) (string, *gitea.Client, error) {
|
||||
root, err := storeRoot(out)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
cfg, err := config.Require("")
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
client, err := gitea.New(cfg)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
return root, client, nil
|
||||
}
|
||||
|
||||
// syncStartExisting is syncStart for the commands that read the store rather
|
||||
// than create it: push, comment, close and the sync form of evict all operate
|
||||
// on issues that are already on disk, and a missing store is a mistake to
|
||||
// report, not a directory to conjure.
|
||||
func syncStartExisting(out string) (string, *gitea.Client, error) {
|
||||
root, client, err := syncStart(out)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
if err := issue.RequireStore(root); err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
return root, client, nil
|
||||
}
|
||||
Reference in New Issue
Block a user