e628ad6fd9
BREAKING: the plugin is `kettle`, not `tea`, and its commands are `/kettle:*`. It also now needs a binary on PATH that it did not need before; the README and every skill say how to get one and what a missing one looks like. The plugin was 3800 lines of Python doing what a compiled binary does better, and the name pointed at a tool that no longer takes part: `tea` is Gitea's CLI, and since the transport moved into the binary nothing here shells out to it for issues at all. A plugin named after it was going to keep suggesting otherwise. Deleted: 19 scripts, the 14-file unittest suite, and the tea-guard hook. The guard blocked any `tea` invocation that would run under a login the model picked instead of the operator; the binary holds its own credentials and reads the pinned login out of the project's own config, so that failure is no longer expressible and there is nothing left to police. agents-sync stays — it is about AGENTS.md symlinks and has nothing to do with any of this. What the plugin keeps is what only a plugin can carry: the rules an operator states and a binary cannot enforce. `init` still refuses to run inside a linked worktree and still may not be model-invoked, because which directory is the project is a statement a person makes. The issue format reference stays here and stays the source of truth. The runner subagent is still for batches and still may not decide what an issue says. The command reference in the issue, sync and project skills is GENERATED from the binary's own command registry, between markers, so a flag that changed cannot ship with a skill that recommends the old one. `kettle gen skills --check` exits non-zero when they drift. The generator owns the region and nothing outside it: the frontmatter description, which is what decides whether a skill loads at all, stays hand-written. `use` survives and is the one place `tea` is still named — for releases, webhooks and actions, which kettle does not cover. Its instruction to write `--login "$GITEA_LOGIN"` and let the hook substitute the pin was true until this commit and is now rewritten: `tea` keeps its own configuration, kettle keeps its own, and configuring one configures nothing in the other. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
165 lines
4.1 KiB
Go
165 lines
4.1 KiB
Go
package cmd
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
"sort"
|
|
"strings"
|
|
|
|
"git.noodles.cam/claude-skills/marketplace/cli/internal/issue"
|
|
)
|
|
|
|
func init() {
|
|
register(&Command{
|
|
Name: "tree",
|
|
Group: GroupIssue,
|
|
Args: "[<id>…]",
|
|
Short: "draw the dependency graph of the local store",
|
|
Long: `Edges come from the ` + "`depends:`" + ` metadata, which is the authoritative edge list;
|
|
prose in the body is never walked. Because the graph is slugs all the way down,
|
|
this works identically for issues that were never pushed anywhere.
|
|
|
|
Downwards is what this draws — what an issue depends on. The other direction is
|
|
a grep, not a flag:
|
|
|
|
grep -ln 'depends:.*migrate-schema' .kettle/issues/*.md`,
|
|
Examples: []Example{
|
|
{"kettle tree", "every root (nothing depends on it)"},
|
|
{"kettle tree wire-sqlc-appclick", "one subtree"},
|
|
{"kettle tree --depth 2 --write", "shallow, and saved beside the issues"},
|
|
},
|
|
Setup: func(fs *flag.FlagSet) func([]string) error {
|
|
depth := fs.Int("depth", 6, "maximum depth")
|
|
write := fs.Bool("write", false, "also write <store>/tree-<slug>.md")
|
|
out := storeFlag(fs)
|
|
|
|
return func(args []string) error {
|
|
root, err := storeRoot(*out)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if err := issue.StoreError(root); err != nil {
|
|
return err
|
|
}
|
|
issues, err := issue.LoadAll(root)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
edges := issue.Graph(issues)
|
|
|
|
roots := args
|
|
for _, r := range roots {
|
|
if _, ok := issues[r]; !ok {
|
|
return Fail("no issue %q in %s", r, root)
|
|
}
|
|
}
|
|
if len(roots) == 0 {
|
|
dependedOn := map[string]bool{}
|
|
for _, deps := range edges {
|
|
for _, d := range deps {
|
|
dependedOn[d] = true
|
|
}
|
|
}
|
|
for id := range issues {
|
|
if !dependedOn[id] {
|
|
roots = append(roots, id)
|
|
}
|
|
}
|
|
if len(roots) == 0 { // every issue is somebody's dependency
|
|
for id := range issues {
|
|
roots = append(roots, id)
|
|
}
|
|
}
|
|
sort.Strings(roots)
|
|
}
|
|
|
|
text := renderTree(roots, issues, edges, *depth)
|
|
fmt.Print(text)
|
|
if *write {
|
|
slug := "all"
|
|
if len(roots) == 1 {
|
|
slug = roots[0]
|
|
}
|
|
path := filepath.Join(root, "tree-"+slug+".md")
|
|
if err := os.WriteFile(path, []byte(text), 0o644); err != nil {
|
|
return err
|
|
}
|
|
fmt.Printf("written: %s\n", path)
|
|
}
|
|
return nil
|
|
}
|
|
},
|
|
})
|
|
}
|
|
|
|
func renderTree(roots []string, issues map[string]*issue.Issue, edges map[string][]string, depth int) string {
|
|
var lines []string
|
|
seen := map[string]bool{}
|
|
|
|
var walk func(id, prefix string, isLast, isRoot bool, level int)
|
|
walk = func(id, prefix string, isLast, isRoot bool, level int) {
|
|
connector := ""
|
|
if !isRoot {
|
|
connector = "├── "
|
|
if isLast {
|
|
connector = "└── "
|
|
}
|
|
}
|
|
lines = append(lines, prefix+connector+treeLabel(id, issues, seen, edges))
|
|
if seen[id] || level >= depth {
|
|
return
|
|
}
|
|
seen[id] = true
|
|
kids := edges[id]
|
|
childPrefix := prefix
|
|
if !isRoot {
|
|
childPrefix = prefix + "│ "
|
|
if isLast {
|
|
childPrefix = prefix + " "
|
|
}
|
|
}
|
|
for i, k := range kids {
|
|
walk(k, childPrefix, i == len(kids)-1, false, level+1)
|
|
}
|
|
}
|
|
|
|
for _, r := range roots {
|
|
if seen[r] {
|
|
continue // already drawn as somebody's child — one tree, not two
|
|
}
|
|
walk(r, "", true, true, 0)
|
|
lines = append(lines, "")
|
|
}
|
|
|
|
head := fmt.Sprintf("%d root(s)", len(roots))
|
|
if len(roots) == 1 {
|
|
head = roots[0]
|
|
}
|
|
out := fmt.Sprintf("# Dependency tree — %s\n\n```\n%s```\n", head, strings.Join(lines, "\n"))
|
|
if cycles := issue.FindCycles(edges); len(cycles) > 0 {
|
|
out += "\n## Cycles\n\n"
|
|
for _, c := range cycles {
|
|
out += "- " + strings.Join(c, " -> ") + "\n"
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
func treeLabel(id string, issues map[string]*issue.Issue, seen map[string]bool, edges map[string][]string) string {
|
|
i, ok := issues[id]
|
|
if !ok {
|
|
return id + " (not in the store)"
|
|
}
|
|
tail := ""
|
|
if seen[id] && len(edges[id]) > 0 {
|
|
tail = " (see above)"
|
|
}
|
|
typ := i.Type()
|
|
if typ == "" {
|
|
typ = "-"
|
|
}
|
|
return fmt.Sprintf("%s [%s] %s — %s %s.md%s", id, typ, i.Title, i.State, id, tail)
|
|
}
|