From 44bbfd6ebb6bf868e81cf0eb2f73acdcb802e060 Mon Sep 17 00:00:00 2001 From: Dylan Trotter Date: Wed, 7 Oct 2026 17:06:49 +0000 Subject: [PATCH] linear: replace linear_set_state with linear_update_issue Automations that pick up tickets need to claim them (assign and move in one step), and a thread handing a ticket back needs to clear itself and relabel. Until now the only write to an existing issue was its state, and linear_query refuses mutations by design. One tool instead of one per field: linear_update_issue takes the issue key and any of state, assignee ("me", a person by name or email, or "nobody"), labels to add or remove, and priority, resolves each name the way linear_create_issue already does, and applies them in a single issueUpdate. The timeline still says what changed: the result names each field that was set. linear_set_state goes; the automation is its only customer and moves to the new tool with it. Co-Authored-By: Claude Fable 5.1 --- plugins/linear/README.md | 2 +- plugins/linear/linear.test.ts | 5 +- plugins/linear/linear.ts | 68 +++++++++++--- plugins/linear/server.test.ts | 58 +++++++++--- plugins/linear/server.ts | 123 ++++++++++++++++++-------- plugins/linear/skills/linear/SKILL.md | 8 +- 6 files changed, 200 insertions(+), 64 deletions(-) diff --git a/plugins/linear/README.md b/plugins/linear/README.md index f6aaa052..a484b5d8 100644 --- a/plugins/linear/README.md +++ b/plugins/linear/README.md @@ -21,7 +21,7 @@ same connect. | `linear_search` | Issues by free text, team, state, assignee. | | `linear_create_issue` | A new issue in a team: title, description, state, assignee, labels, priority, parent. | | `linear_comment` | A Markdown comment, signed with the thread id. | -| `linear_set_state` | Move an issue to a workflow state by name. | +| `linear_update_issue` | Change an issue's state, assignee, labels and priority together. | | `linear_query` | Any read-only GraphQL query. Mutations are refused. | Writes are deliberately named tools rather than a raw mutation tool, so the diff --git a/plugins/linear/linear.test.ts b/plugins/linear/linear.test.ts index a83f8f3c..4ab75244 100644 --- a/plugins/linear/linear.test.ts +++ b/plugins/linear/linear.test.ts @@ -107,7 +107,10 @@ describe("parsing", () => { it("reads mutation results and refuses failures", () => { expect(parseCommentCreate({ data: { commentCreate: { success: true, comment: { url: "https://x" } } } })).toEqual({ url: "https://x" }); expect(() => parseCommentCreate({ data: { commentCreate: { success: false } } })).toThrow(/did not create/u); - expect(parseIssueUpdate({ data: { issueUpdate: { success: true, issue: { identifier: "ENG-1", state: { name: "Done" } } } } })).toEqual({ identifier: "ENG-1", state: "Done" }); + expect(parseIssueUpdate({ data: { issueUpdate: { success: true, issue: { identifier: "ENG-1", state: { name: "Done" } } } } })).toEqual({ identifier: "ENG-1", state: "Done", assignee: null, labels: [], priority: null }); + expect( + parseIssueUpdate({ data: { issueUpdate: { success: true, issue: { identifier: "ENG-1", state: { name: "Todo" }, assignee: { name: "Jane Doe", displayName: "jane" }, labels: { nodes: [{ name: "Bug" }] }, priority: 2 } } } }), + ).toEqual({ identifier: "ENG-1", state: "Todo", assignee: "jane", labels: ["Bug"], priority: 2 }); expect(() => parseIssueUpdate({ data: { issueUpdate: { success: false, issue: null } } })).toThrow(/did not update/u); }); }); diff --git a/plugins/linear/linear.ts b/plugins/linear/linear.ts index 097dcdec..039d8e28 100644 --- a/plugins/linear/linear.ts +++ b/plugins/linear/linear.ts @@ -111,9 +111,11 @@ const COMMENT_FIELDS = "comments(first: 50) { nodes { body createdAt url user { export const ISSUE_QUERY = `query($id: String!) { issue(id: $id) { ${ISSUE_FIELDS} ${COMMENT_FIELDS} } }`; export const ISSUES_QUERY = `query($filter: IssueFilter, $first: Int!) { issues(filter: $filter, first: $first, orderBy: updatedAt) { nodes { ${ISSUE_FIELDS} } } }`; export const SEARCH_QUERY = `query($term: String!, $filter: IssueFilter, $first: Int!) { searchIssues(term: $term, filter: $filter, first: $first) { nodes { ${ISSUE_FIELDS} } } }`; -export const ISSUE_REF_QUERY = "query($id: String!) { issue(id: $id) { id identifier team { key states { nodes { id name type position } } } } }"; +export const ISSUE_REF_QUERY = + "query($id: String!) { issue(id: $id) { id identifier labels { nodes { id name } } team { key states { nodes { id name type position } } labels(first: 250) { nodes { id name } } } } " + + "issueLabels(filter: { team: { null: true } }, first: 250) { nodes { id name } } }"; export const COMMENT_CREATE = "mutation($input: CommentCreateInput!) { commentCreate(input: $input) { success comment { url } } }"; -export const ISSUE_UPDATE = "mutation($id: String!, $input: IssueUpdateInput!) { issueUpdate(id: $id, input: $input) { success issue { identifier state { name } } } }"; +export const ISSUE_UPDATE = "mutation($id: String!, $input: IssueUpdateInput!) { issueUpdate(id: $id, input: $input) { success issue { identifier state { name } assignee { name displayName email } labels { nodes { name } } priority } } }"; export const ISSUE_CREATE = "mutation($input: IssueCreateInput!) { issueCreate(input: $input) { success issue { identifier url } } }"; /** A team by key, with the states and labels an issue in it can take. Workspace labels apply to every team. */ export const TEAM_QUERY = @@ -170,19 +172,46 @@ export function parseIssueList(payload: unknown, field: "issues" | "searchIssues return list.nodes; } -export type IssueRef = { id: string; identifier: string; team: { key: string; states: Array<{ id: string; name: string; type: string; position: number }> } }; +const labelNodes = z.object({ nodes: z.array(z.object({ id: z.string(), name: z.string() })) }); + +export type IssueRef = { + id: string; + identifier: string; + /** The labels on the issue now. */ + labels: Array<{ id: string; name: string }>; + team: { + key: string; + states: Array<{ id: string; name: string; type: string; position: number }>; + /** The labels the issue may carry: the team's own and the workspace's. */ + labels: Array<{ id: string; name: string }>; + }; +}; export function parseIssueRef(payload: unknown): IssueRef | null { const data = dataOf(payload); if (data.issue === null || data.issue === undefined) return null; const parsed = z .object({ - id: z.string(), - identifier: z.string(), - team: z.object({ key: z.string(), states: z.object({ nodes: z.array(z.object({ id: z.string(), name: z.string(), type: z.string(), position: z.number() })) }) }), + issue: z.object({ + id: z.string(), + identifier: z.string(), + labels: labelNodes.nullish(), + team: z.object({ + key: z.string(), + states: z.object({ nodes: z.array(z.object({ id: z.string(), name: z.string(), type: z.string(), position: z.number() })) }), + labels: labelNodes.nullish(), + }), + }), + issueLabels: labelNodes.nullish(), }) - .parse(data.issue); - return { id: parsed.id, identifier: parsed.identifier, team: { key: parsed.team.key, states: parsed.team.states.nodes } }; + .parse(data); + const issue = parsed.issue; + return { + id: issue.id, + identifier: issue.identifier, + labels: issue.labels?.nodes ?? [], + team: { key: issue.team.key, states: issue.team.states.nodes, labels: [...(issue.team.labels?.nodes ?? []), ...(parsed.issueLabels?.nodes ?? [])] }, + }; } /** The state whose name matches, ignoring case; null when none does. */ @@ -198,13 +227,27 @@ export function parseCommentCreate(payload: unknown): { url: string | null } { return { url: parsed.comment?.url ?? null }; } -export function parseIssueUpdate(payload: unknown): { identifier: string; state: string | null } { +export type IssueUpdated = { identifier: string; state: string | null; assignee: string | null; labels: string[]; priority: number | null }; + +export function parseIssueUpdate(payload: unknown): IssueUpdated { const data = dataOf(payload); const parsed = z - .object({ success: z.boolean(), issue: z.object({ identifier: z.string(), state: z.object({ name: z.string() }).nullish() }).nullish() }) + .object({ + success: z.boolean(), + issue: z + .object({ + identifier: z.string(), + state: z.object({ name: z.string() }).nullish(), + assignee: person, + labels: z.object({ nodes: z.array(z.object({ name: z.string() })) }).nullish(), + priority: z.number().nullish(), + }) + .nullish(), + }) .parse(data.issueUpdate); if (!parsed.success || parsed.issue === null || parsed.issue === undefined) throw new Error("Linear did not update the issue"); - return { identifier: parsed.issue.identifier, state: parsed.issue.state?.name ?? null }; + const issue = parsed.issue; + return { identifier: issue.identifier, state: issue.state?.name ?? null, assignee: personName(issue.assignee), labels: (issue.labels?.nodes ?? []).map((l) => l.name), priority: issue.priority ?? null }; } export function parseIssueCreate(payload: unknown): { identifier: string; url: string | null } { @@ -225,8 +268,6 @@ export type Team = { labels: Array<{ id: string; name: string }>; }; -const labelNodes = z.object({ nodes: z.array(z.object({ id: z.string(), name: z.string() })) }); - export function parseTeam(payload: unknown): Team | null { const data = dataOf(payload); const parsed = z @@ -281,6 +322,7 @@ export function parseUsers(payload: unknown): User[] { /** Linear's priority numbers: 0 is none, 1 urgent, 4 low. */ export const PRIORITIES = { none: 0, urgent: 1, high: 2, medium: 3, low: 4 } as const; +export const PRIORITY_NAMES = Object.fromEntries(Object.entries(PRIORITIES).map(([name, n]) => [n, name])) as Record; export type PriorityName = keyof typeof PRIORITIES; // ---- search filters -------------------------------------------------------- diff --git a/plugins/linear/server.test.ts b/plugins/linear/server.test.ts index 1d3f6287..62e639c4 100644 --- a/plugins/linear/server.test.ts +++ b/plugins/linear/server.test.ts @@ -170,7 +170,7 @@ describe("tools", () => { it("are registered with the names the skill documents", async () => { const { harness } = await setup(); const names = harness.registrations.agentTools.map((t: { name: string }) => t.name).sort(); - expect(names).toEqual(["linear_comment", "linear_create_issue", "linear_issue", "linear_query", "linear_search", "linear_set_state"]); + expect(names).toEqual(["linear_comment", "linear_create_issue", "linear_issue", "linear_query", "linear_search", "linear_update_issue"]); }); it("say how to connect when there is no token", async () => { @@ -233,22 +233,58 @@ describe("tools", () => { expect(input.body).toMatch(/^PR opened: https:\/\/github\.com\/x\/y\/pull\/1\n\n_— from bb thread .+_$/u); }); - it("linear_set_state matches a state by name and lists the team's states otherwise", async () => { + it("linear_update_issue applies state, assignee, labels and priority together", async () => { + let lastInput: Record = {}; + const ref = issue({ + labels: { nodes: [{ id: "l-bug", name: "Bug" }, { id: "l-ready", name: "build-ready" }] }, + team: { ...(issue().team as object), labels: { nodes: [{ id: "l-bug", name: "Bug" }, { id: "l-ready", name: "build-ready" }, { id: "l-agent", name: "agent" }] } }, + }); const { tool, text, linear } = await setup({ settings: { accessToken: "at-0" }, linear: { - answer: (body) => - body.query.startsWith("mutation($id: String!, $input: IssueUpdateInput!)") - ? { data: { issueUpdate: { success: true, issue: { identifier: "ENG-123", state: { name: "Done" } } } } } - : { data: { issue: issue() } }, + answer: (body) => { + if (body.query.startsWith("mutation($id: String!, $input: IssueUpdateInput!)")) { + lastInput = body.variables!.input as Record; + const who = lastInput.assigneeId === "u1" ? { displayName: "jane" } : lastInput.assigneeId === "u-bob" ? { name: "Bob" } : null; + const labels = Array.isArray(lastInput.labelIds) ? (lastInput.labelIds as string[]).map((id) => ({ name: id.replace(/^l-/u, "") })) : [{ name: "Bug" }, { name: "build-ready" }]; + return { data: { issueUpdate: { success: true, issue: { identifier: "ENG-123", state: { name: lastInput.stateId === "s-done" ? "Done" : "Todo" }, assignee: who, labels: { nodes: labels }, priority: lastInput.priority ?? 0 } } } }; + } + if (body.query.startsWith("query($who: String!) { users")) { + const who = String(body.variables!.who); + const all = [{ id: "u-bob", name: "Bob", displayName: "Bob", email: "bob@acme.test", active: true }, { id: "u-bobby", name: "Bobby", displayName: "Bobby", email: "bobby@acme.test", active: true }]; + return { data: { users: { nodes: all.filter((u) => u.email === who || u.name.toLowerCase().includes(who.toLowerCase())) } } }; + } + return { data: { issue: body.variables!.id === "ENG-999" ? null : ref, issueLabels: { nodes: [{ id: "l-ws", name: "Workspace" }] } } }; + }, }, }); - expect(text(await tool("linear_set_state", { key: "ENG-123", state: "done" }))).toBe("ENG-123 is now Done."); - expect(linear.calls.at(-1)!.body!.variables).toEqual({ id: "uuid-1", input: { stateId: "s-done" } }); - const miss = await tool("linear_set_state", { key: "ENG-123", state: "Shipped" }); - expect(miss).toMatchObject({ isError: true }); - expect(text(miss)).toContain("Todo (unstarted), Done (completed)"); + // Claiming a ticket: state and assignee in one mutation. + expect(text(await tool("linear_update_issue", { key: "eng-123", state: "done", assignee: "me" }))).toBe("ENG-123: now Done; assigned to jane."); + expect(linear.calls.at(-1)!.body!.variables).toEqual({ id: "uuid-1", input: { stateId: "s-done", assigneeId: "u1" } }); + + // Handing it back: unassign, relabel, reprioritize. Labels are the issue's current set, minus removed, plus added. + expect(text(await tool("linear_update_issue", { key: "ENG-123", assignee: "Nobody", removeLabels: ["BUILD-READY"], addLabels: ["agent", "workspace"], priority: "high" }))).toBe( + "ENG-123: unassigned; labels bug, agent, ws; priority high.", + ); + expect(lastInput).toEqual({ assigneeId: null, labelIds: ["l-bug", "l-agent", "l-ws"], priority: 2 }); + + // A person by email. + expect(text(await tool("linear_update_issue", { key: "ENG-123", assignee: "bob@acme.test" }))).toBe("ENG-123: assigned to Bob."); + expect(lastInput).toEqual({ assigneeId: "u-bob" }); + + // Misses list the choices and change nothing. + const state = await tool("linear_update_issue", { key: "ENG-123", state: "Shipped" }); + expect(state).toMatchObject({ isError: true }); + expect(text(state)).toContain("Todo (unstarted), Done (completed)"); + const label = await tool("linear_update_issue", { key: "ENG-123", addLabels: ["perf"] }); + expect(label).toMatchObject({ isError: true }); + expect(text(label)).toContain("Bug, build-ready, agent, Workspace"); + const ambiguous = await tool("linear_update_issue", { key: "ENG-123", assignee: "bo" }); + expect(ambiguous).toMatchObject({ isError: true }); + expect(text(ambiguous)).toContain("Give an email"); + expect(await tool("linear_update_issue", { key: "ENG-999", state: "Done" })).toMatchObject({ isError: true }); + await expect(tool("linear_update_issue", { key: "ENG-123" })).rejects.toThrow(/at least one of/u); }); it("linear_create_issue resolves the team, state, labels, assignee and parent, and signs the description", async () => { diff --git a/plugins/linear/server.ts b/plugins/linear/server.ts index 74f1b6c6..f69769ed 100644 --- a/plugins/linear/server.ts +++ b/plugins/linear/server.ts @@ -20,6 +20,7 @@ import { ISSUES_QUERY, LinearRequestError, PRIORITIES, + PRIORITY_NAMES, SEARCH_LIMIT_MAX, SEARCH_QUERY, TEAM_QUERY, @@ -353,12 +354,31 @@ export function createLinearPlugin(deps: LinearPluginDeps): (bb: BbPluginApi) => // reader in Linear can find the conversation. const signature = (threadId: string) => `\n\n_— from bb thread ${threadId}_`; + // "me" is the connected user. Anyone else is matched by exact name or + // email first, then as the only partial match; several matches ask for + // an email rather than guessing. + async function resolveAssignee(who: string, signal: AbortSignal): Promise<{ id: string } | { error: string }> { + if (who.toLowerCase() === "me") return { id: parseViewer(await query(VIEWER_QUERY, undefined, signal)).user.id }; + const users = parseUsers(await query(USERS_QUERY, { who }, signal)).filter((u) => u.active); + const exact = users.filter((u) => u.name.toLowerCase() === who.toLowerCase() || u.email?.toLowerCase() === who.toLowerCase()); + const chosen = exact.length === 1 ? exact[0] : users.length === 1 ? users[0] : null; + if (chosen === null) { + return { + error: + users.length === 0 + ? `No Linear user matches ${JSON.stringify(who)}.` + : `${JSON.stringify(who)} matches several Linear users: ${users.map((u) => (u.email === null ? u.name : `${u.name} <${u.email}>`)).join(", ")}. Give an email.`, + }; + } + return { id: chosen.id }; + } + bb.agents.registerTool({ name: "linear_issue", description: "Read one Linear issue by key (for example ENG-123): title, state, assignee, labels, project, parent and sub-issues, the description, and the latest comments.", instructions: - "Linear is connected to this bb server as the user. Use linear_issue to read a ticket named in the task, a branch or a PR before working on it, and linear_search to find tickets; prefer them over asking the user to paste ticket contents. Use linear_create_issue when the user asks to file, create or open a ticket.", + "Linear is connected to this bb server as the user. Use linear_issue to read a ticket named in the task, a branch or a PR before working on it, and linear_search to find tickets; prefer them over asking the user to paste ticket contents. Use linear_create_issue when the user asks to file, create or open a ticket, and linear_update_issue to move, assign, relabel or reprioritize one.", presentation: { label: { pending: "Reading a Linear issue", completed: "Read a Linear issue" } }, parameters: z.object({ key: issueKey.describe("The issue key, such as ENG-123.") }), async execute({ key }, { signal }) { @@ -425,24 +445,71 @@ export function createLinearPlugin(deps: LinearPluginDeps): (bb: BbPluginApi) => }); bb.agents.registerTool({ - name: "linear_set_state", - description: "Move a Linear issue to a workflow state by name (for example In Progress, In Review, Done). The names a team uses are listed when the name does not match.", - presentation: { label: { pending: "Moving a Linear issue", completed: "Moved a Linear issue" } }, - parameters: z.object({ - key: issueKey.describe("The issue key, such as ENG-123."), - state: z.string().trim().min(1).max(60).describe("The state's name, matched ignoring case."), - }), - async execute({ key, state }, { signal }) { + name: "linear_update_issue", + description: + "Change a Linear issue: its workflow state (for example In Progress, Done), assignee ('me' for the connected user, a name or email, or 'nobody' to clear), labels to add or remove, and priority. Give only the fields to change; they are applied together. A state, label or person that does not match is an error that lists the choices.", + presentation: { label: { pending: "Updating a Linear issue", completed: "Updated a Linear issue" } }, + parameters: z + .object({ + key: issueKey.describe("The issue key, such as ENG-123."), + state: z.string().trim().min(1).max(60).optional().describe("A workflow state name, matched ignoring case."), + assignee: z.string().trim().min(1).max(100).optional().describe("A person's name or email, 'me' for the connected user, or 'nobody' to unassign."), + addLabels: z.array(z.string().trim().min(1).max(100)).max(20).optional().describe("Label names to add, matched ignoring case."), + removeLabels: z.array(z.string().trim().min(1).max(100)).max(20).optional().describe("Label names to remove, matched ignoring case."), + priority: z.enum(["none", "urgent", "high", "medium", "low"]).optional().describe("The priority."), + }) + .refine((v) => v.state !== undefined || v.assignee !== undefined || (v.addLabels?.length ?? 0) > 0 || (v.removeLabels?.length ?? 0) > 0 || v.priority !== undefined, { + message: "Give at least one of state, assignee, addLabels, removeLabels or priority.", + }), + async execute(input, { signal }) { try { - const ref = parseIssueRef(await query(ISSUE_REF_QUERY, { id: key }, signal)); - if (ref === null) return toolError(new Error(`No Linear issue ${key}, or it is not visible to the connected user.`)); - const target = findState(ref.team.states, state); - if (target === null) { - const names = [...ref.team.states].sort((a, b) => a.position - b.position).map((s) => `${s.name} (${s.type})`); - return toolError(new Error(`Team ${ref.team.key} has no state named ${JSON.stringify(state)}. Its states: ${names.join(", ")}.`)); + const ref = parseIssueRef(await query(ISSUE_REF_QUERY, { id: input.key }, signal)); + if (ref === null) return toolError(new Error(`No Linear issue ${input.key}, or it is not visible to the connected user.`)); + const update: Record = {}; + const changed: string[] = []; + + if (input.state !== undefined) { + const target = findState(ref.team.states, input.state); + if (target === null) { + const names = [...ref.team.states].sort((a, b) => a.position - b.position).map((s) => `${s.name} (${s.type})`); + return toolError(new Error(`Team ${ref.team.key} has no state named ${JSON.stringify(input.state)}. Its states: ${names.join(", ")}.`)); + } + update.stateId = target.id; + } + + if (input.assignee !== undefined) { + if (input.assignee.toLowerCase() === "nobody") { + update.assigneeId = null; + } else { + const resolved = await resolveAssignee(input.assignee, signal); + if ("error" in resolved) return toolError(new Error(resolved.error)); + update.assigneeId = resolved.id; + } + } + + const adding = (input.addLabels ?? []).filter((l) => l !== ""); + const removing = (input.removeLabels ?? []).filter((l) => l !== ""); + if (adding.length > 0 || removing.length > 0) { + const add = findLabels(ref.team.labels, adding); + const remove = findLabels([...ref.labels, ...ref.team.labels], removing); + const missing = [...add.missing, ...remove.missing]; + if (missing.length > 0) { + const names = ref.team.labels.map((l) => l.name); + return toolError(new Error(`No label named ${missing.map((m) => JSON.stringify(m)).join(", ")} for team ${ref.team.key}. Its labels: ${names.length > 0 ? names.join(", ") : "(none)"}.`)); + } + const ids = ref.labels.map((l) => l.id).filter((id) => !remove.ids.includes(id)); + for (const id of add.ids) if (!ids.includes(id)) ids.push(id); + update.labelIds = ids; } - const updated = parseIssueUpdate(await query(ISSUE_UPDATE, { id: ref.id, input: { stateId: target.id } }, signal)); - return `${updated.identifier} is now ${updated.state ?? target.name}.`; + + if (input.priority !== undefined) update.priority = PRIORITIES[input.priority]; + + const updated = parseIssueUpdate(await query(ISSUE_UPDATE, { id: ref.id, input: update }, signal)); + if (input.state !== undefined) changed.push(`now ${updated.state ?? input.state}`); + if (input.assignee !== undefined) changed.push(updated.assignee === null ? "unassigned" : `assigned to ${updated.assignee}`); + if (update.labelIds !== undefined) changed.push(updated.labels.length === 0 ? "no labels" : `labels ${updated.labels.join(", ")}`); + if (input.priority !== undefined) changed.push(`priority ${updated.priority === null ? input.priority : (PRIORITY_NAMES[updated.priority] ?? String(updated.priority))}`); + return `${updated.identifier}: ${changed.join("; ")}.`; } catch (error) { return toolError(error); } @@ -496,23 +563,9 @@ export function createLinearPlugin(deps: LinearPluginDeps): (bb: BbPluginApi) => const assignee = input.assignee?.trim() ?? ""; if (assignee !== "") { - if (assignee.toLowerCase() === "me") { - create.assigneeId = parseViewer(await query(VIEWER_QUERY, undefined, signal)).user.id; - } else { - const users = parseUsers(await query(USERS_QUERY, { who: assignee }, signal)).filter((u) => u.active); - const exact = users.filter((u) => u.name.toLowerCase() === assignee.toLowerCase() || u.email?.toLowerCase() === assignee.toLowerCase()); - const chosen = exact.length === 1 ? exact[0] : users.length === 1 ? users[0] : null; - if (chosen === null) { - return toolError( - new Error( - users.length === 0 - ? `No Linear user matches ${JSON.stringify(assignee)}.` - : `${JSON.stringify(assignee)} matches several Linear users: ${users.map((u) => (u.email === null ? u.name : `${u.name} <${u.email}>`)).join(", ")}. Give an email.`, - ), - ); - } - create.assigneeId = chosen.id; - } + const resolved = await resolveAssignee(assignee, signal); + if ("error" in resolved) return toolError(new Error(resolved.error)); + create.assigneeId = resolved.id; } if (input.priority !== undefined) create.priority = PRIORITIES[input.priority]; @@ -543,7 +596,7 @@ export function createLinearPlugin(deps: LinearPluginDeps): (bb: BbPluginApi) => }), async execute({ query: document, variables }, { signal }) { if (!isReadOnlyDocument(document)) { - return toolError(new Error("linear_query runs queries only. Use linear_create_issue, linear_comment or linear_set_state to change issues.")); + return toolError(new Error("linear_query runs queries only. Use linear_create_issue, linear_comment or linear_update_issue to change issues.")); } try { const payload = await query(document, variables, signal); diff --git a/plugins/linear/skills/linear/SKILL.md b/plugins/linear/skills/linear/SKILL.md index 41873101..ebd8d110 100644 --- a/plugins/linear/skills/linear/SKILL.md +++ b/plugins/linear/skills/linear/SKILL.md @@ -1,6 +1,6 @@ --- name: linear -description: Read, search, file, comment on, or move Linear issues from a bb thread through the Linear plugin's tools, or diagnose why they say Linear is not connected. +description: Read, search, file, comment on, or update Linear issues from a bb thread through the Linear plugin's tools, or diagnose why they say Linear is not connected. --- # Linear @@ -17,7 +17,7 @@ token stays on the server; a thread never sees it and needs no API key. | `linear_search` | Find issues by free text and/or team key, state name, assignee (`me` for the connected user). Open issues only by default. | | `linear_create_issue` | File a new issue in a team by key: title, Markdown description, and optionally a state, assignee (`me`), labels, priority and parent issue. The description is signed with the thread id. | | `linear_comment` | Add a Markdown comment. It is signed with the thread id so a reader can find the conversation. | -| `linear_set_state` | Move an issue to a state by name. On a mismatch the error lists the team's states. | +| `linear_update_issue` | Change an issue: state by name, assignee (`me`, a name or email, `nobody`), labels to add or remove, priority. Give only the fields to change; a name that does not match is an error listing the choices. | | `linear_query` | Any read-only GraphQL query, for projects, cycles, teams, documents and anything the tools above lack. Mutations are refused. | Ticket keys appear in branch names, PR titles and thread titles @@ -29,7 +29,9 @@ one, and prefer these tools over asking the user to paste its contents. Comment when there is something a reader in Linear needs: a PR link, a decision, a question for the reporter. Do not narrate progress. Move an issue's state only when the user asked for it or the team's convention is -clear (for example In Review when the PR opens). +clear (for example In Review when the PR opens). Assign an issue when +taking it on is the point of the task — picking up a ticket, handing it to +someone — not as a side effect of reading it. File an issue only when the user asks for one. Put the team key, a short title and a description with the reproduction or the ask in it; the plugin