Simplify codebase per audit of 8b89f14

This commit is contained in:
Ian Gulliver
2026-10-23 15:35:42 -07:00
parent 382d27d356
commit 461aac75e9
134 changed files with 1038 additions and 2907 deletions
+33 -69
View File
@@ -665,14 +665,9 @@ func (m *Manager) finishStageTool(l *live) mcp.Tool {
},
"required": ["output"]
}`),
Handler: func(ctx context.Context, raw json.RawMessage) (string, error) {
args := struct {
Output string `json:"output"`
}{}
err := json.Unmarshal(raw, &args)
if err != nil {
return "", fmt.Errorf("malformed finish_stage call: %w", err)
}
Handler: mcp.Typed(func(ctx context.Context, args struct {
Output string `json:"output"`
}) (string, error) {
if strings.TrimSpace(args.Output) == "" {
return "", fmt.Errorf("%w: output is required", ErrInvalid)
}
@@ -696,7 +691,7 @@ func (m *Manager) finishStageTool(l *live) mcp.Tool {
return lastStageText(frozen.Definition) + " End your turn now with your summary.", nil
}
return fmt.Sprintf("When this turn ends, byre hands the output to %s. End your turn now with your summary.", quoteList(next)), nil
},
}),
}
}
@@ -787,12 +782,17 @@ func prettyJSON(v any) (string, error) {
return string(b), err
}
func (m *Manager) workflowTools(tool func(name, description, schema string, run func(ctx context.Context, user api.User, raw json.RawMessage) (string, error)) mcp.Tool) []mcp.Tool {
type projectWorkflowArgs struct {
ProjectID string `json:"project_id"`
Workflow string `json:"workflow"`
}
func (m *Manager) workflowTools(l *live) []mcp.Tool {
return []mcp.Tool{
tool("list_workflows",
leadTool(m, l, "list_workflows",
"List the workflows on the server: each one's name and description.",
`{"type": "object", "properties": {}}`,
func(ctx context.Context, user api.User, raw json.RawMessage) (string, error) {
func(ctx context.Context, user api.User, _ struct{}) (string, error) {
workflows, err := m.store.ListWorkflows(ctx)
if err != nil {
return "", err
@@ -811,21 +811,16 @@ func (m *Manager) workflowTools(tool func(name, description, schema string, run
return b.String(), nil
}),
tool("read_workflow",
leadTool(m, l, "read_workflow",
"Read a workflow's definition: with name, the workflow on the server; with task_id, the copy that task froze when it was created. "+workflowHelp,
`{"type": "object", "properties": {
"name": {"type": "string"},
"task_id": {"type": "string"}
}}`,
func(ctx context.Context, user api.User, raw json.RawMessage) (string, error) {
args := struct {
Name string `json:"name"`
TaskID string `json:"task_id"`
}{}
err := json.Unmarshal(raw, &args)
if err != nil {
return "", err
}
func(ctx context.Context, user api.User, args struct {
Name string `json:"name"`
TaskID string `json:"task_id"`
}) (string, error) {
if (args.Name == "") == (args.TaskID == "") {
return "", fmt.Errorf("%w: give exactly one of name and task_id", ErrInvalid)
}
@@ -847,22 +842,17 @@ func (m *Manager) workflowTools(tool func(name, description, schema string, run
return prettyJSON(def)
}),
tool("save_workflow",
leadTool(m, l, "save_workflow",
"Create or replace a workflow on the server from its definition. Tasks that already froze it keep their copy. "+
"The name is one line of 1 to 100 characters, shown to the human on buttons and pickers. "+workflowHelp,
`{"type": "object", "properties": {
"name": {"type": "string"},
"definition": `+workflowDefinitionSchema+`
}, "required": ["name", "definition"], `+workflowSchemaDefs+`}`,
func(ctx context.Context, user api.User, raw json.RawMessage) (string, error) {
args := struct {
Name string `json:"name"`
Definition json.RawMessage `json:"definition"`
}{}
err := json.Unmarshal(raw, &args)
if err != nil {
return "", err
}
func(ctx context.Context, user api.User, args struct {
Name string `json:"name"`
Definition json.RawMessage `json:"definition"`
}) (string, error) {
w, err := m.SaveWorkflow(ctx, args.Name, "", args.Definition, leadActor(user.Login))
if err != nil {
return "", err
@@ -870,21 +860,13 @@ func (m *Manager) workflowTools(tool func(name, description, schema string, run
return fmt.Sprintf("Saved workflow %q.", w.Name), nil
}),
tool("set_review_workflow",
leadTool(m, l, "set_review_workflow",
"Set the review workflow (any saved workflow whose stages are single agents, not teams) whose stages review every snapshot of a project's tasks, from the next snapshot on; an empty workflow turns reviews off for the project. Only when the human asks.",
`{"type": "object", "properties": {
"project_id": {"type": "string"},
"workflow": {"type": "string"}
}, "required": ["project_id", "workflow"]}`,
func(ctx context.Context, user api.User, raw json.RawMessage) (string, error) {
args := struct {
ProjectID string `json:"project_id"`
Workflow string `json:"workflow"`
}{}
err := json.Unmarshal(raw, &args)
if err != nil {
return "", err
}
func(ctx context.Context, user api.User, args projectWorkflowArgs) (string, error) {
p, err := m.SetReviewWorkflow(ctx, args.ProjectID, args.Workflow, leadActor(user.Login))
if err != nil {
return "", err
@@ -895,22 +877,14 @@ func (m *Manager) workflowTools(tool func(name, description, schema string, run
return fmt.Sprintf("Project %s reviews with workflow %q from its next snapshot on.", p.Name, p.ReviewWorkflow), nil
}),
tool("set_audit_workflow",
leadTool(m, l, "set_audit_workflow",
"Set the audit workflow (any saved workflow) that byre runs in the background on a project's default branch: one run at a time, started whenever the branch's newest commit hasn't had one, to check the whole codebase against its standards rather than one change. "+
"An audit's tasks stay out of list_tasks and your signals until one asks a question, calls ready_for_merge, hits an error, or suggests discarding in a workflow without auto_discard. An empty workflow turns audits off. Only when the human asks.",
`{"type": "object", "properties": {
"project_id": {"type": "string"},
"workflow": {"type": "string"}
}, "required": ["project_id", "workflow"]}`,
func(ctx context.Context, user api.User, raw json.RawMessage) (string, error) {
args := struct {
ProjectID string `json:"project_id"`
Workflow string `json:"workflow"`
}{}
err := json.Unmarshal(raw, &args)
if err != nil {
return "", err
}
func(ctx context.Context, user api.User, args projectWorkflowArgs) (string, error) {
p, err := m.SetAuditWorkflow(ctx, args.ProjectID, args.Workflow, leadActor(user.Login))
if err != nil {
return "", err
@@ -921,19 +895,14 @@ func (m *Manager) workflowTools(tool func(name, description, schema string, run
return fmt.Sprintf("Project %s is audited with workflow %q.", p.Name, p.AuditWorkflow), nil
}),
tool("set_action_button",
leadTool(m, l, "set_action_button",
"Set the workflow the human's iPhone Action button starts, and the project it runs in: pressing the button opens byre for a prompt and starts that workflow with it as the brief. "+
"Empty project_id and workflow turn it off. Only when the human asks.",
`{"type": "object", "properties": {
"project_id": {"type": "string"},
"workflow": {"type": "string"}
}, "required": ["project_id", "workflow"]}`,
func(ctx context.Context, user api.User, raw json.RawMessage) (string, error) {
q := api.QuickRun{}
err := json.Unmarshal(raw, &q)
if err != nil {
return "", err
}
func(ctx context.Context, user api.User, q api.QuickRun) (string, error) {
u, err := m.SetQuickRun(ctx, user.Login, q)
if err != nil {
return "", err
@@ -944,18 +913,13 @@ func (m *Manager) workflowTools(tool func(name, description, schema string, run
return fmt.Sprintf("The Action button starts workflow %q in project %s.", u.QuickRun.Workflow, u.QuickRun.ProjectId), nil
}),
tool("delete_workflow",
leadTool(m, l, "delete_workflow",
"Delete a workflow from the server. Tasks that froze it keep their copy. Only when the human asks.",
`{"type": "object", "properties": {"name": {"type": "string"}}, "required": ["name"]}`,
func(ctx context.Context, user api.User, raw json.RawMessage) (string, error) {
args := struct {
Name string `json:"name"`
}{}
err := json.Unmarshal(raw, &args)
if err != nil {
return "", err
}
err = m.store.DeleteWorkflow(ctx, args.Name, leadActor(user.Login))
func(ctx context.Context, user api.User, args struct {
Name string `json:"name"`
}) (string, error) {
err := m.store.DeleteWorkflow(ctx, args.Name, leadActor(user.Login))
if err != nil {
return "", err
}