@kana-ai/edgar-ext-linear 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,7 +4,7 @@ The Linear extension of EDGAR. It implements the engine's tracker port over Line
4
4
 
5
5
  ## Tracker port
6
6
 
7
- All 12 methods: `list_cards`, `card`, `comments`, `mentions`, `attachments`, `comment`, `move`, `set_labels`, `create_card`, `close`, `whoami` and `person`. `mentions` reads at most 50 comments, on any card the token can read, made after `since` whose text holds `@` and the display name of the token's user, oldest first. A card's `id` is its Linear identifier, such as `ENG-12`, and its `column` is the engine state its Linear column maps to. Its `assignee` is the Linear `displayName` of the person the issue is assigned to, and a card with no assignee has no `assignee`. Its `taken_by` is the same name when the assignee is not one of EDGAR's own users (the user of `LINEAR_TOKEN`, which `list_cards` and `card` ask as `viewer` in the same request, and `assignee`), so the engine knows when a person holds the card. Its `taken_by_id` is that person's email, which only their own account can change: `[people.<name>] ids.linear` matches it to find the person's saved keys, while a display name, which any member can set, never does. The email goes into no comment, note or prompt. Its `trust` is `team` when the issue's creator is a member of the workspace (Linear's `guest` is false) or one of EDGAR's own users, and `outside` for a guest or for an issue an integration made for someone with no Linear account. A comment's `trust` follows the same rule for its writer: a comment that an integration brings in, with a `botActor` and no `user`, is `outside`. Its `priority` is `urgent` for Linear's Urgent and `high` for High, absent for Medium, Low and No priority, and the engine starts the queued runs of those cards first. EDGAR writes a Linear priority only with `set_priority`, from the analysis (`urgent` 1, `high` 2, `medium` 3, `low` 4), and only on an issue with No priority: one that a person set stays. The display name is the name Linear shows and a person writes after `@`, so a note or a prompt can name the person; an email would put an address that a person never reads into each agent's input and each Slack note. `list_cards` takes engine states in `columns`, the way the engine's sweep sends them, asks Linear for the columns `[extensions.linear.columns]` maps them to, and answers each card with its engine state. A name that is not an engine state, such as `Todo`, makes `list_cards` answer `invalid` with that name in `cause`, before any request. For example, with `ready = "Todo"`, the request `{"columns": ["intake", "ready"], "cursor": null}` asks Linear for `Triage` and `Todo`, and a card in `Todo` comes back with `"column": "ready"`. `list_cards` reads 50 cards a page and reports `budget_remaining` from `X-RateLimit-Requests-Remaining`. `comments` sets `mentioned` when the body holds `@` and the display name of the `whoami` actor. It asks for the comments updated after `since`, archived ones included, so an edit or a delete is read too: `edited_at` is the comment's `editedAt`, or its `archivedAt` for a deleted comment, which also has `deleted: true`. `attachments` lists the issue's attachments, then each file a person uploaded into a live comment, a Markdown link or image to `uploads.linear.app`, once by url and named by its link text, so the engine fetches it with the attachments, under the same byte caps, once `[tracker] attachment_hosts` holds `uploads.linear.app`.
7
+ All 12 methods: `list_cards`, `card`, `comments`, `mentions`, `attachments`, `comment`, `move`, `set_labels`, `create_card`, `close`, `whoami` and `person`. `mentions` reads at most 50 comments, on any card the token can read, made after `since` whose text holds `@` and the display name of the token's user, oldest first. A card's `id` is its Linear identifier, such as `ENG-12`, and its `column` is the engine state its Linear column maps to. Its `assignee` is the Linear `displayName` of the person the issue is assigned to, and a card with no assignee has no `assignee`. Its `taken_by` is the same name when the assignee is not one of EDGAR's own users (the user of `LINEAR_TOKEN`, which `list_cards` and `card` ask as `viewer` in the same request, and `assignee`), so the engine knows when a person holds the card. Its `taken_by_id` is that person's email, which only their own account can change: `[people.<name>] ids.linear` matches it to find the person's saved keys, while a display name, which any member can set, never does. The email goes into no comment, note or prompt. Its `trust` is `team` when the issue's creator is a member of the workspace (Linear's `guest` is false) or one of EDGAR's own users, and `outside` for a guest or for an issue an integration made for someone with no Linear account. A comment's `trust` follows the same rule for its writer: a comment that an integration brings in, with a `botActor` and no `user`, is `outside`. Its `priority` is `urgent` for Linear's Urgent and `high` for High, absent for Medium, Low and No priority, and the engine starts the queued runs of those cards first. EDGAR writes a Linear priority only with `set_priority`, from the analysis (`urgent` 1, `high` 2, `medium` 3, `low` 4), and only on an issue with No priority: one that a person set stays. The display name is the name Linear shows and a person writes after `@`, so a note or a prompt can name the person; an email would put an address that a person never reads into each agent's input and each Slack note. `list_cards` takes engine states in `columns`, the way the engine's sweep sends them, asks Linear for the columns `[extensions.linear.columns]` maps them to, and answers each card with its engine state. A name that is not an engine state, such as `Todo`, makes `list_cards` answer `invalid` with that name in `cause`, before any request. For example, with `ready = "Todo"`, the request `{"columns": ["intake", "ready"], "cursor": null}` asks Linear for `Triage` and `Todo`, and a card in `Todo` comes back with `"column": "ready"`. `list_cards` reads 50 cards a page and reports `budget_remaining` from `X-RateLimit-Requests-Remaining`. The extension sets `updated_since`, so the engine asks most sweeps only for the cards changed since its last listing: with `updated_since`, `list_cards` adds `updatedAt: { gte: <time> }` to the filter. A sweep that finds nothing new then reads one page, whatever the size of the board, and a full listing runs at the first sweep and every 10 minutes. `comments` sets `mentioned` when the body holds `@` and the display name of the `whoami` actor. It asks for the comments updated after `since`, archived ones included, so an edit or a delete is read too: `edited_at` is the comment's `editedAt`, or its `archivedAt` for a deleted comment, which also has `deleted: true`. `attachments` lists the issue's attachments, then each file a person uploaded into a live comment, a Markdown link or image to `uploads.linear.app`, once by url and named by its link text, so the engine fetches it with the attachments, under the same byte caps, once `[tracker] attachment_hosts` holds `uploads.linear.app`.
8
8
 
9
9
  ## Tools
10
10
 
@@ -17,8 +17,8 @@ All 12 methods: `list_cards`, `card`, `comments`, `mentions`, `attachments`, `co
17
17
  | `count_sighting` | `card`, `seen_at` (optional) | `id` | Counts one more sighting on the card `card`: raises `occurrences` and moves `last_seen` to `seen_at`, else now, in the card's block. A sighting no newer than `last_seen` writes nothing, so a retry counts once. A card with no block is left as it is; a card that Linear does not have is `not_found`. A write that Linear refuses for good goes to the runtime log. |
18
18
  | `set_priority` | `card`, `priority` | `id` | Sets the card's Linear priority to the one the analysis gave: `urgent` 1, `high` 2, `medium` 3, `low` 4. `skipped` when the card has a priority already, which stays; a card that Linear does not have is `not_found`. |
19
19
  | `retitle` | `card`, `text` | `id`, `title` | For a card a feeder filed (its block names `decided.opened_by`): sets the title to the first sentence of `text`, cut at a word to 100 characters, after `title_prefix`, and changes nothing else: the block keeps the feeder's title in `decided.filed_as`, and a new title alone starts no run again. A card a person wrote, or one already titled so, is `skipped`. |
20
- | `batch_cards` | `batch`, `except`, `only` | `cards`, `skipped` | The other open cards of the table's team and scope (with `assignee_only`, only the cards of `assignee` or labelled `edgar:waiting`) whose block holds `batch` in `decided.batch`, such as the scanner cards of one repository: at most 20, each with `id`, `title`, `url` and `description`. The card `except` is left out, and so is a done or canceled card, and a card whose description holds the text but whose block does not name the batch. Read-only. With `only`, just those ids, and `skipped` lists the ids of `only` that are not open cards of the batch. |
21
- | `find_cards` | `text`, `except` (optional) | `cards` | Searches the open cards of the table's team and scope (`project`, `title_prefix`, `labels`, and with `assignee_only` only the cards of `assignee` or labelled `edgar:waiting`) with Linear's `searchIssues`, which matches words and meaning, and answers at most 10, the best match first: `id`, `title`, `url`, `state` (the engine state, else the Linear column name) and `created_at`. A done or canceled card is left out. With `except`, that card and each card made after it are left out, so two new cards never name each other; a card `except` that Linear does not have is `not_found`. `text` holds 1 to 1,024 characters. Linear allows 30 searches a minute. Read-only. |
20
+ | `batch_cards` | `batch`, `except`, `only` | `cards`, `skipped` | The other open cards of the table's teams and scope (with `assignee_only`, only the cards of `assignee` or labelled `edgar:waiting`) whose block holds `batch` in `decided.batch`, such as the scanner cards of one repository: at most 20, each with `id`, `title`, `url` and `description`. The card `except` is left out, and so is a done or canceled card, and a card whose description holds the text but whose block does not name the batch. Read-only. With `only`, just those ids, and `skipped` lists the ids of `only` that are not open cards of the batch. |
21
+ | `find_cards` | `text`, `except` (optional) | `cards` | Searches the open cards of the table's teams and scope (`project`, `title_prefix`, `labels`, and with `assignee_only` only the cards of `assignee` or labelled `edgar:waiting`) with Linear's `searchIssues`, which matches words and meaning, and answers at most 10, the best match first: `id`, `title`, `url`, `state` (the engine state, else the Linear column name) and `created_at`. A done or canceled card is left out. With `except`, that card and each card made after it are left out, so two new cards never name each other; a card `except` that Linear does not have is `not_found`. `text` holds 1 to 1,024 characters. Linear allows 30 searches a minute. Read-only. |
22
22
  | `park` | `card`, `waits_for` | `id` | Moves the card to the `intake` column from any column, then writes `waits_for = "<card>"` into its block, a `request` block when it has none, so `release_follow_ups` of that card releases it. A card out of the table's scope is skipped, with nothing written. |
23
23
  | `release_follow_ups` | `card`, `pull_request`, `column?` | `released` | Moves each card in the `intake` column whose block has `waits_for = "<card>"` to `ready`, or to `column` (`waiting_on_person` after a close with no merge), and leaves a card out of the table's scope where it is. Follow-up cards wait in `intake`. |
24
24
  | `update_description` | `card`, `description` | `id`, `previous` | Replaces the card's description and keeps its `edgar:v0` block, so the fingerprint and `waits_for` stay. `previous` is the description before the write. A description that already reads so is not written again. Side effect, undone by `restore_description`, found by `find_description`. |
@@ -95,7 +95,7 @@ waits_for = "ENG-7"
95
95
 
96
96
  ```toml
97
97
  [extensions.linear]
98
- team = "ENG" # the team key
98
+ team = "ENG" # the team key; or teams = ["ENG", "PRD"] for several teams, never both
99
99
  project = "Platform" # optional
100
100
  title_prefix = "[edgar]" # optional
101
101
  labels = ["edgar"] # optional
@@ -114,13 +114,14 @@ done = "Done"
114
114
  cancelled = "Canceled"
115
115
  ```
116
116
 
117
+ - `team` or `teams`: the Linear team whose cards EDGAR works, by its key, or several teams in `teams`. Write one of the two, never both: each call of the extension answers `invalid` for a table with both or neither. With `teams`, EDGAR sweeps, reads, searches and moves the cards of every team in the list, and files its own cards (from feeders, alerts, follow-ups and Slack) in the first team. The sweep asks for the cards of all the teams in the same request, with `team: { key: { in: [...] } }`, so it costs the same number of requests as one team. The fingerprint search before `create_card` files a card looks in every team, so a fault already filed in one of them is not filed twice. Linear gives each team its own columns, and `[extensions.linear.columns]` names them once for every team, by name. The sweep reads each team's columns in the same request and answers `invalid` when a team lacks one, with a message that names the team and each missing column, such as `linear: [extensions.linear.columns] names columns that the team PRD does not have: in_testing = "Testing"`, or when Linear has no team with that key or the key cannot read it. Each card names its team as its `board`, so adding a team never starts work on the cards it already had: the first sweep after the restart records them, and starts runs only for those in `intake`.
117
118
  - `project`: EDGAR picks only the cards in this project, by name or URL key, and files its own cards there.
118
119
  - `title_prefix`: EDGAR picks only the cards whose title starts with this text, and adds it to the cards it files.
119
120
  - `labels`: EDGAR picks only the cards that carry every label in the list, and adds them to the cards it files.
120
121
 
121
- With none of the three set and `assignee_only` off, EDGAR picks every card of the team in the mapped columns.
122
+ With none of the three set and `assignee_only` off, EDGAR picks every card of the teams in the mapped columns.
122
123
 
123
- - `assignee_only`: with `true`, a card is in scope only while it is assigned to `assignee`, in every mapped column. Set it when the team in `team` also holds cards that people work on, so that EDGAR takes only the cards that someone gave to its user. The default is `false`. The value is a boolean, and `edgar check` refuses any other value. The user is `assignee`, so the smallest setting is `assignee_only = true` with no `assignee`, which takes the cards assigned to the user of `LINEAR_TOKEN`.
124
+ - `assignee_only`: with `true`, a card is in scope only while it is assigned to `assignee`, in every mapped column. Set it when the teams in `team` or `teams` also hold cards that people work on, so that EDGAR takes only the cards that someone gave to its user. The default is `false`. The value is a boolean, and `edgar check` refuses any other value. The user is `assignee`, so the smallest setting is `assignee_only = true` with no `assignee`, which takes the cards assigned to the user of `LINEAR_TOKEN`.
124
125
  - The listing filters in Linear: `list_cards` adds `assignee: { id: { eq: <user> } }` to the filter of every column, so a card of another user, or of nobody, is never read.
125
126
  - A card that carries the label `edgar:waiting` is in scope too, whoever holds it. `hand_back` adds the label when it gives a card to a person, so the person's reply on the card is still read and starts the work again. `move` out of `waiting_on_person` and `close` take it off. A card that a person moves or closes in Linear keeps it. The listing asks for `or: [{ assignee }, { labels: edgar:waiting }]` inside its `and` list.
126
127
  - A card that a person assigns to another user, or to nobody, leaves the scope the same way a card that leaves the board does. The next listing does not have it, the engine then asks `card` for it, and `card` answers `not_found` with the message `linear: card <id> is not assigned to the user of [extensions.linear] assignee`. The engine stores the card as closed and stops each run that was open on it, with the work kept. A card that is assigned back is a card again at the next sweep.
@@ -136,7 +137,7 @@ With none of the three set and `assignee_only` off, EDGAR picks every card of th
136
137
 
137
138
  ### What the key must be able to do
138
139
 
139
- Make the key in Linear, Settings, Security & access, Personal API keys. A key with only Read lets EDGAR sweep and read cards, and every write fails. Give it the Write permission and access to the team in `[extensions.linear] team`. `edgar check` prints this text with `X004` when the project has no source for the key.
140
+ Make the key in Linear, Settings, Security & access, Personal API keys. A key with only Read lets EDGAR sweep and read cards, and every write fails. Give it the Write permission and access to each team in `[extensions.linear] team` or `teams`. `edgar check` prints this text with `X004` when the project has no source for the key.
140
141
 
141
142
  | Write | Linear operation | Scope it needs |
142
143
  | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------ | ---------------------------- |
@@ -159,7 +160,7 @@ Linear's API has no read of a key's scopes: its GraphQL schema has no scopes fie
159
160
 
160
161
  ## Linked cards
161
162
 
162
- The extension reads a card of `[extensions.linear] team` that a card or its comments link, such as `https://linear.app/<workspace>/issue/ENG-12`, into the run's inbox (`read_link`, for `linear.app`). The text holds the card's column, link, description and comments, with the same `card` and `comments` reads as the tracker port, so a card that the port does not read, such as one of another assignee with `assignee_only`, is a failure that the inbox shows in one line. A card of another team, and any other Linear link, such as a project, are not read.
163
+ The extension reads a card of a team in `[extensions.linear] team` or `teams` that a card or its comments link, such as `https://linear.app/<workspace>/issue/ENG-12`, into the run's inbox (`read_link`, for `linear.app`). The text holds the card's column, link, description and comments, with the same `card` and `comments` reads as the tracker port, so a card that the port does not read, such as one of another assignee with `assignee_only`, is a failure that the inbox shows in one line. A card of a team the table does not name, and any other Linear link, such as a project, are not read.
163
164
 
164
165
  ## Webhook
165
166
 
package/dist/src/index.js CHANGED
@@ -11,7 +11,7 @@ export default defineExtension({
11
11
  secrets: {
12
12
  [TOKEN]: {
13
13
  hosts: [HOST],
14
- help: "Make a personal API key in Linear, Settings, Security & access, with the Write permission (comments, moves, closes and descriptions need it) and access to the team in [extensions.linear] team.",
14
+ help: "Make a personal API key in Linear, Settings, Security & access, with the Write permission (comments, moves, closes and descriptions need it) and access to each team in [extensions.linear] team or teams.",
15
15
  },
16
16
  LINEAR_WEBHOOK_SECRET: {
17
17
  hosts: [],
@@ -1,7 +1,8 @@
1
1
  import { z } from "zod";
2
- /** The extension's `[extensions.linear]` table: the team key, the optional card scope, the Linear column of each engine state, the columns where a card assigned to `assignee` counts as intake, and the switch that keeps every card of another assignee out. */
2
+ /** The extension's `[extensions.linear]` table: the team keys, the optional card scope, the Linear column of each engine state, the columns where a card assigned to `assignee` counts as intake, and the switch that keeps every card of another assignee out. */
3
3
  export declare const config: z.ZodObject<{
4
- team: z.ZodString;
4
+ team: z.ZodOptional<z.ZodString>;
5
+ teams: z.ZodOptional<z.ZodArray<z.ZodString>>;
5
6
  project: z.ZodOptional<z.ZodString>;
6
7
  title_prefix: z.ZodOptional<z.ZodString>;
7
8
  labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -1,12 +1,18 @@
1
1
  import { z } from "zod";
2
2
  const column = z.string().min(1);
3
- /** The extension's `[extensions.linear]` table: the team key, the optional card scope, the Linear column of each engine state, the columns where a card assigned to `assignee` counts as intake, and the switch that keeps every card of another assignee out. */
3
+ /** The extension's `[extensions.linear]` table: the team keys, the optional card scope, the Linear column of each engine state, the columns where a card assigned to `assignee` counts as intake, and the switch that keeps every card of another assignee out. */
4
4
  export const config = z
5
5
  .strictObject({
6
6
  team: z
7
7
  .string()
8
8
  .min(1)
9
- .describe("The key of the Linear team whose cards EDGAR works, such as ENG."),
9
+ .optional()
10
+ .describe("The key of the one Linear team whose cards EDGAR works, such as ENG. Write `team` or `teams`, not both."),
11
+ teams: z
12
+ .array(z.string().min(1))
13
+ .min(1)
14
+ .optional()
15
+ .describe('The keys of the Linear teams whose cards EDGAR works, such as ["ENG", "PRD"]. EDGAR files its own cards in the first. Write `team` or `teams`, not both.'),
10
16
  project: z
11
17
  .string()
12
18
  .min(1)
@@ -46,6 +52,10 @@ export const config = z
46
52
  .array(column)
47
53
  .default([])
48
54
  .describe("The Linear columns where a card assigned to `assignee` counts as intake. Default none."),
55
+ })
56
+ .refine((table) => (table.team === undefined) !== (table.teams === undefined), {
57
+ message: "write one of `team` and `teams`, not both",
58
+ path: ["teams"],
49
59
  })
50
60
  .refine((table) => !table.assigned.some((name) => Object.values(table.columns).includes(name)), {
51
61
  message: "a column of `assigned` is a column of `columns` already",
@@ -15,7 +15,7 @@ export type GraphqlError = NonNullable<z.infer<typeof envelope>["errors"]>[numbe
15
15
  * The GraphQL selection of an issue that `issue` parses, with its newest changes, which say who gave it to its assignee.
16
16
  * shortcut: 10 changes keep a page of 50 issues far below Linear's query complexity; a card changed more often since it was given to EDGAR names its writer instead.
17
17
  */
18
- export declare const issueFields = "id identifier title description url state { name } labels { nodes { name } } assignee { id displayName email } priority creator { id guest email displayName } history(first: 10) { nodes { createdAt actor { id displayName email } toAssignee { id } } }";
18
+ export declare const issueFields = "id identifier title description url team { key } state { name } labels { nodes { name } } assignee { id displayName email } priority creator { id guest email displayName } history(first: 10) { nodes { createdAt actor { id displayName email } toAssignee { id } } }";
19
19
  /** An issue with the fields a `Card` needs. */
20
20
  export declare const issue: z.ZodObject<{
21
21
  id: z.ZodString;
@@ -23,6 +23,9 @@ export declare const issue: z.ZodObject<{
23
23
  title: z.ZodString;
24
24
  description: z.ZodNullable<z.ZodString>;
25
25
  url: z.ZodString;
26
+ team: z.ZodObject<{
27
+ key: z.ZodString;
28
+ }, z.core.$strip>;
26
29
  state: z.ZodObject<{
27
30
  name: z.ZodString;
28
31
  }, z.core.$strip>;
@@ -58,7 +61,7 @@ export declare const issue: z.ZodObject<{
58
61
  }, z.core.$strip>>>;
59
62
  }, z.core.$strip>;
60
63
  /** The selection of one issue read by its id. Linear answers an archived issue there, and never in a listing. */
61
- export declare const oneIssueFields = "id identifier title description url state { name } labels { nodes { name } } assignee { id displayName email } priority creator { id guest email displayName } history(first: 10) { nodes { createdAt actor { id displayName email } toAssignee { id } } } archivedAt trashed";
64
+ export declare const oneIssueFields = "id identifier title description url team { key } state { name } labels { nodes { name } } assignee { id displayName email } priority creator { id guest email displayName } history(first: 10) { nodes { createdAt actor { id displayName email } toAssignee { id } } } archivedAt trashed";
62
65
  /** One issue read by its id, with the two fields that say it left the board. */
63
66
  export declare const oneIssue: z.ZodObject<{
64
67
  id: z.ZodString;
@@ -66,6 +69,9 @@ export declare const oneIssue: z.ZodObject<{
66
69
  title: z.ZodString;
67
70
  description: z.ZodNullable<z.ZodString>;
68
71
  url: z.ZodString;
72
+ team: z.ZodObject<{
73
+ key: z.ZodString;
74
+ }, z.core.$strip>;
69
75
  state: z.ZodObject<{
70
76
  name: z.ZodString;
71
77
  }, z.core.$strip>;
@@ -109,6 +115,18 @@ export declare const idNames: z.ZodObject<{
109
115
  name: z.ZodString;
110
116
  }, z.core.$strip>>;
111
117
  }, z.core.$strip>;
118
+ /** The teams a `teams` filter matches, each by its key with its workflow states. */
119
+ export declare const teamBoards: z.ZodObject<{
120
+ nodes: z.ZodArray<z.ZodObject<{
121
+ key: z.ZodString;
122
+ states: z.ZodObject<{
123
+ nodes: z.ZodArray<z.ZodObject<{
124
+ id: z.ZodString;
125
+ name: z.ZodString;
126
+ }, z.core.$strip>>;
127
+ }, z.core.$strip>;
128
+ }, z.core.$strip>>;
129
+ }, z.core.$strip>;
112
130
  /** The identifier and URL of a created or found issue. */
113
131
  export declare const created: z.ZodObject<{
114
132
  identifier: z.ZodString;
@@ -13,7 +13,7 @@ export const envelope = z.object({
13
13
  * The GraphQL selection of an issue that `issue` parses, with its newest changes, which say who gave it to its assignee.
14
14
  * shortcut: 10 changes keep a page of 50 issues far below Linear's query complexity; a card changed more often since it was given to EDGAR names its writer instead.
15
15
  */
16
- export const issueFields = "id identifier title description url state { name } labels { nodes { name } } assignee { id displayName email } priority creator { id guest email displayName } history(first: 10) { nodes { createdAt actor { id displayName email } toAssignee { id } } }";
16
+ export const issueFields = "id identifier title description url team { key } state { name } labels { nodes { name } } assignee { id displayName email } priority creator { id guest email displayName } history(first: 10) { nodes { createdAt actor { id displayName email } toAssignee { id } } }";
17
17
  /** A person as Linear names them in an issue's change. */
18
18
  const person = z.object({ id: z.string(), displayName: z.string(), email: z.string().nullish() });
19
19
  /** An issue with the fields a `Card` needs. */
@@ -23,6 +23,7 @@ export const issue = z.object({
23
23
  title: z.string(),
24
24
  description: z.string().nullable(),
25
25
  url: z.string(),
26
+ team: z.object({ key: z.string() }),
26
27
  state: z.object({ name: z.string() }),
27
28
  labels: z.object({ nodes: z.array(z.object({ name: z.string() })) }),
28
29
  assignee: z
@@ -58,6 +59,10 @@ export const oneIssue = issue.extend({
58
59
  export const idNames = z.object({
59
60
  nodes: z.array(z.object({ id: z.string(), name: z.string() })),
60
61
  });
62
+ /** The teams a `teams` filter matches, each by its key with its workflow states. */
63
+ export const teamBoards = z.object({
64
+ nodes: z.array(z.object({ key: z.string(), states: idNames })),
65
+ });
61
66
  /** The identifier and URL of a created or found issue. */
62
67
  export const created = z.object({ identifier: z.string(), url: z.string() });
63
68
  /** An open card that holds a fingerprint, with the description its block is in. */
@@ -7,10 +7,11 @@ import type { batchCardsTool, findCardsTool, setPriorityTool } from "#schemas/to
7
7
  export declare function issueId(ctx: LinearCtx, card: string): Promise<Result<string, Failure>>;
8
8
  /** The ids of the labels named `names`, the first match per name; a missing name is `invalid`. */
9
9
  export declare function labelIds(ctx: LinearCtx, names: readonly string[]): Promise<Result<string[], Failure>>;
10
- /** One page of the cards in the engine states `columns` and in the table's scope, with the cursor of the next and the requests left; a name that is not an engine state is `invalid`. `intake` also takes each card assigned to `assignee` in a column of `assigned`. With `assignee_only`, Linear answers only the cards assigned to `assignee` or labelled `edgar:waiting`. */
10
+ /** One page of the cards of every team of the table in the engine states `columns` and in the table's scope, with the cursor of the next and the requests left; a name that is not an engine state, and a team that Linear does not have or that lacks a mapped column, are `invalid`, read in the same request. `intake` also takes each card assigned to `assignee` in a column of `assigned`. With `assignee_only`, Linear answers only the cards assigned to `assignee` or labelled `edgar:waiting`. With `updated_since`, only the cards Linear updated at or after it. */
11
11
  export declare function listCards(ctx: LinearCtx, input: {
12
12
  readonly columns: readonly string[];
13
13
  readonly cursor: string | null;
14
+ readonly updated_since?: string;
14
15
  }): Promise<Outcome<{
15
16
  cards: Card[];
16
17
  next: string | null;
@@ -18,9 +19,9 @@ export declare function listCards(ctx: LinearCtx, input: {
18
19
  }>>;
19
20
  /** The card `id`; a missing, archived or trashed card is `not_found` and a bad block `invalid`. With `assignee_only`, a card that is not assigned to `assignee` and not labelled `edgar:waiting` is `not_found` too, so the engine reads it as a card that left the board. */
20
21
  export declare function readCard(ctx: LinearCtx, id: string): Promise<Outcome<Card>>;
21
- /** At most 10 open cards of the table's team and scope that Linear's search matches with `text`, the best match first; with `assignee_only`, only EDGAR's cards and those handed back. With `except`, that card and each card made after it are left out, so two cards never point at each other; a missing `except` is `not_found`. */
22
+ /** At most 10 open cards of the table's teams and scope that Linear's search matches with `text`, the best match first; with `assignee_only`, only EDGAR's cards and those handed back. With `except`, that card and each card made after it are left out, so two cards never point at each other; a missing `except` is `not_found`. */
22
23
  export declare function findCards(ctx: LinearCtx, text: string, except?: string): Promise<Outcome<z.infer<typeof findCardsTool.output>>>;
23
- /** At most 20 open cards of the table's team and scope whose block names `batch` in `decided.batch`, with `except` left out; with `assignee_only`, only EDGAR's cards and those handed back. A card whose block does not read is left out. */
24
+ /** At most 20 open cards of the table's teams and scope whose block names `batch` in `decided.batch`, with `except` left out; with `assignee_only`, only EDGAR's cards and those handed back. A card whose block does not read is left out. */
24
25
  export declare function batchCards(ctx: LinearCtx, batch: string, except: string, ids?: readonly string[]): Promise<Outcome<z.infer<typeof batchCardsTool.output>>>;
25
26
  /** Gives the card `card` the Linear priority of `priority`, unless it has one already, which stays: then `skipped`. */
26
27
  export declare function setPriority(ctx: LinearCtx, card: string, priority: z.infer<typeof setPriorityTool.input>["priority"]): Promise<Outcome<{
@@ -1,12 +1,12 @@
1
1
  import { blockLine, done, earlierLine, lastNote, err, invalidBlock, ok, oneAtATime, permanentFailure, readBlock, reopenedDescription, reopens, sighted, skipped, withBlock, } from "@kana-ai/edgar-sdk";
2
2
  import { z } from "zod";
3
3
  import { keyOf, linear } from "#api/client";
4
- import { created, closedIssue, heldIssue, idNames, issue, issueFields, oneIssue, oneIssueFields, } from "#schemas/linear";
5
- import { WAITING, assigneeOf, columnOf, isState, settingsOf, trustOf } from "#tracker/states";
4
+ import { created, closedIssue, heldIssue, idNames, issue, issueFields, oneIssue, oneIssueFields, teamBoards, } from "#schemas/linear";
5
+ import { WAITING, assigneeOf, columnOf, columnsHeld, isState, settingsOf, teamsOf, trustOf, } from "#tracker/states";
6
6
  import { transition, update } from "#tracker/transitions";
7
7
  /** The card priority of each Linear priority a person sets: 1 is urgent and 2 high; medium, low and none give the card no priority. */
8
8
  const priorities = { 1: "urgent", 2: "high" };
9
- /** The card of an issue; a block that does not read is `invalid` when `strict`, else carried as why, for the engine to refuse. `own` holds the ids of EDGAR's own users, so `taken_by` is the assignee only when the assignee is a person. `taken_by_id` is that person's email, which only their own account can change, so the engine finds their keys by it; a display name any member can set. `trust` is the trust of the card's creator by `trustOf`, and `written_by_id` is the creator's email, as `taken_by_id` is the holder's. */
9
+ /** The card of an issue; a block that does not read is `invalid` when `strict`, else carried as why, for the engine to refuse. `own` holds the ids of EDGAR's own users, so `taken_by` is the assignee only when the assignee is a person. `taken_by_id` is that person's email, which only their own account can change, so the engine finds their keys by it; a display name any member can set. `board` is the issue's team key, so the engine seeds a team it sweeps for the first time. `trust` is the trust of the card's creator by `trustOf`, and `written_by_id` is the creator's email, as `taken_by_id` is the holder's. */
10
10
  function toCard(settings, value, strict, assignee, own) {
11
11
  const description = value.description ?? "";
12
12
  const block = readBlock(description);
@@ -35,6 +35,7 @@ function toCard(settings, value, strict, assignee, own) {
35
35
  ...(writerId === undefined ? {} : { written_by_id: writerId }),
36
36
  ...(asked === undefined ? {} : { requested_by: asked.name }),
37
37
  ...(asked?.id === undefined ? {} : { requested_by_id: asked.id }),
38
+ board: value.team.key,
38
39
  });
39
40
  }
40
41
  /** Who asked for the work on an issue: the person, not one of EDGAR's own users in `own`, who last gave it to one of them, else its writer when that is a person; the id is their email. */
@@ -126,7 +127,7 @@ async function projectId(ctx, project) {
126
127
  ? err(permanentFailure("invalid", `linear: no project ${project}`, { cause: project }))
127
128
  : ok(match.id);
128
129
  }
129
- /** One page of the cards in the engine states `columns` and in the table's scope, with the cursor of the next and the requests left; a name that is not an engine state is `invalid`. `intake` also takes each card assigned to `assignee` in a column of `assigned`. With `assignee_only`, Linear answers only the cards assigned to `assignee` or labelled `edgar:waiting`. */
130
+ /** One page of the cards of every team of the table in the engine states `columns` and in the table's scope, with the cursor of the next and the requests left; a name that is not an engine state, and a team that Linear does not have or that lacks a mapped column, are `invalid`, read in the same request. `intake` also takes each card assigned to `assignee` in a column of `assigned`. With `assignee_only`, Linear answers only the cards assigned to `assignee` or labelled `edgar:waiting`. With `updated_since`, only the cards Linear updated at or after it. */
130
131
  export async function listCards(ctx, input) {
131
132
  const settings = settingsOf(ctx);
132
133
  if (!settings.ok)
@@ -151,19 +152,23 @@ export async function listCards(ctx, input) {
151
152
  ? byState
152
153
  : `or: [{ ${byState} }, { state: { name: { in: $assigned } }, ${byUser} }]`;
153
154
  const narrow = scope(settings.value, only === undefined ? [] : [mineOrWaiting]);
154
- const params = `${taken === undefined ? "" : ", $assigned: [String!]!"}${user === undefined ? "" : ", $assignee: ID!"}${narrow.params}`;
155
+ const since = input.updated_since;
156
+ const changed = since === undefined ? "" : ", updatedAt: { gte: $since }";
157
+ const params = `${taken === undefined ? "" : ", $assigned: [String!]!"}${user === undefined ? "" : ", $assignee: ID!"}${since === undefined ? "" : ", $since: DateTimeOrDuration!"}${narrow.params}`;
155
158
  const extra = {
156
159
  ...(taken === undefined ? {} : { assigned }),
157
160
  ...(user === undefined ? {} : { assignee: user }),
161
+ ...(since === undefined ? {} : { since }),
158
162
  };
159
- const listed = await linear(ctx, `query Cards($team: String!, $states: [String!]!, $after: String${params}) { viewer { id } issues(first: 50, after: $after, filter: { team: { key: { eq: $team } }, ${state}${narrow.clauses} }) { nodes { ${issueFields} } pageInfo { hasNextPage endCursor } } }`, {
160
- team: settings.value.team,
163
+ const listed = await linear(ctx, `query Cards($teams: [String!]!, $states: [String!]!, $after: String${params}) { viewer { id } teams(filter: { key: { in: $teams } }) { nodes { key states { nodes { id name } } } } issues(first: 50, after: $after, filter: { team: { key: { in: $teams } }, ${state}${changed}${narrow.clauses} }) { nodes { ${issueFields} } pageInfo { hasNextPage endCursor } } }`, {
164
+ teams: teamsOf(settings.value),
161
165
  states: names,
162
166
  after: input.cursor,
163
167
  ...extra,
164
168
  ...narrow.variables,
165
169
  }, z.object({
166
170
  viewer: z.object({ id: z.string() }),
171
+ teams: teamBoards,
167
172
  issues: z.object({
168
173
  nodes: z.array(issue),
169
174
  pageInfo: z.object({ hasNextPage: z.boolean(), endCursor: z.string().nullable() }),
@@ -171,6 +176,9 @@ export async function listCards(ctx, input) {
171
176
  }));
172
177
  if (!listed.ok)
173
178
  return listed.error;
179
+ const held = columnsHeld(settings.value, listed.value.teams);
180
+ if (!held.ok)
181
+ return held.error;
174
182
  const own = ownOf(listed.value.viewer, assignee.value);
175
183
  const cards = listed.value.issues.nodes.flatMap((node) => {
176
184
  const read = toCard(settings.value, node, false, taken, own);
@@ -211,7 +219,7 @@ const found = z.object({
211
219
  createdAt: z.string(),
212
220
  state: z.object({ name: z.string() }),
213
221
  });
214
- /** At most 10 open cards of the table's team and scope that Linear's search matches with `text`, the best match first; with `assignee_only`, only EDGAR's cards and those handed back. With `except`, that card and each card made after it are left out, so two cards never point at each other; a missing `except` is `not_found`. */
222
+ /** At most 10 open cards of the table's teams and scope that Linear's search matches with `text`, the best match first; with `assignee_only`, only EDGAR's cards and those handed back. With `except`, that card and each card made after it are left out, so two cards never point at each other; a missing `except` is `not_found`. */
215
223
  export async function findCards(ctx, text, except) {
216
224
  const settings = settingsOf(ctx);
217
225
  if (!settings.ok)
@@ -234,9 +242,9 @@ export async function findCards(ctx, text, except) {
234
242
  ...(only === undefined ? [] : [mineOrWaiting]),
235
243
  ]);
236
244
  const params = `${before === undefined ? "" : ", $before: DateTimeOrDuration!"}${only === undefined ? "" : ", $assignee: ID!"}${narrow.params}`;
237
- const searched = await linear(ctx, `query FindCards($text: String!, $team: String!${params}) { searchIssues(term: $text, first: 10, filter: { team: { key: { eq: $team } }, state: { type: { nin: ["completed", "canceled"] } }${narrow.clauses} }) { nodes { identifier title url createdAt state { name } } } }`, {
245
+ const searched = await linear(ctx, `query FindCards($text: String!, $teams: [String!]!${params}) { searchIssues(term: $text, first: 10, filter: { team: { key: { in: $teams } }, state: { type: { nin: ["completed", "canceled"] } }${narrow.clauses} }) { nodes { identifier title url createdAt state { name } } } }`, {
238
246
  text,
239
- team: settings.value.team,
247
+ teams: teamsOf(settings.value),
240
248
  ...(before === undefined ? {} : { before }),
241
249
  ...(only === undefined ? {} : { assignee: only }),
242
250
  ...narrow.variables,
@@ -259,7 +267,7 @@ const batched = z.object({
259
267
  url: z.string(),
260
268
  description: z.string().nullable(),
261
269
  });
262
- /** At most 20 open cards of the table's team and scope whose block names `batch` in `decided.batch`, with `except` left out; with `assignee_only`, only EDGAR's cards and those handed back. A card whose block does not read is left out. */
270
+ /** At most 20 open cards of the table's teams and scope whose block names `batch` in `decided.batch`, with `except` left out; with `assignee_only`, only EDGAR's cards and those handed back. A card whose block does not read is left out. */
263
271
  export async function batchCards(ctx, batch, except, ids) {
264
272
  const settings = settingsOf(ctx);
265
273
  if (!settings.ok)
@@ -270,9 +278,9 @@ export async function batchCards(ctx, batch, except, ids) {
270
278
  const only = settings.value.assignee_only ? assignee.value : undefined;
271
279
  const narrow = scope(settings.value, only === undefined ? [] : [mineOrWaiting]);
272
280
  const params = `${only === undefined ? "" : ", $assignee: ID!"}${narrow.params}`;
273
- const listed = await linear(ctx, `query BatchCards($text: String!, $team: String!${params}) { issues(first: 21, filter: { team: { key: { eq: $team } }, description: { contains: $text }, state: { type: { nin: ["completed", "canceled"] } }${narrow.clauses} }) { nodes { identifier title url description } } }`, {
281
+ const listed = await linear(ctx, `query BatchCards($text: String!, $teams: [String!]!${params}) { issues(first: 21, filter: { team: { key: { in: $teams } }, description: { contains: $text }, state: { type: { nin: ["completed", "canceled"] } }${narrow.clauses} }) { nodes { identifier title url description } } }`, {
274
282
  text: blockLine("batch", batch),
275
- team: settings.value.team,
283
+ teams: teamsOf(settings.value),
276
284
  ...(only === undefined ? {} : { assignee: only }),
277
285
  ...narrow.variables,
278
286
  }, z.object({ issues: z.object({ nodes: z.array(batched) }) }));
@@ -377,16 +385,17 @@ async function comeBack(ctx, last, me, at) {
377
385
  });
378
386
  return written.ok ? done({ id: last.identifier, url: last.url }) : written.error;
379
387
  }
380
- /** One `create_card` call: the search for the open and the newest closed holder, then the new card. */
388
+ /** One `create_card` call: the search for the open and the newest closed holder in every team of the table, then the new card in the first team. */
381
389
  async function fileCard(ctx, asked, parent) {
382
390
  const settings = settingsOf(ctx);
383
391
  if (!settings.ok)
384
392
  return settings.error;
385
- const team = settings.value.team;
393
+ const teams = teamsOf(settings.value);
394
+ const [team] = teams;
386
395
  const fingerprint = asked.block.fingerprint;
387
396
  let spec = asked;
388
397
  if (fingerprint !== undefined) {
389
- const held = await linear(ctx, `query Holder($team: String!, $text: String!) { viewer { id } issues(first: 1, filter: { team: { key: { eq: $team } }, description: { contains: $text }, state: { type: { nin: ["completed", "canceled"] } } }) { nodes { id identifier url description } } closed: issues(first: 1, orderBy: updatedAt, filter: { team: { key: { eq: $team } }, description: { contains: $text }, state: { type: { in: ["completed", "canceled"] } } }) { nodes { id identifier url description completedAt canceledAt comments(last: 20) { nodes { body createdAt user { id } } } } } }`, { team, text: blockLine("fingerprint", fingerprint) }, z.object({
398
+ const held = await linear(ctx, `query Holder($teams: [String!]!, $text: String!) { viewer { id } issues(first: 1, filter: { team: { key: { in: $teams } }, description: { contains: $text }, state: { type: { nin: ["completed", "canceled"] } } }) { nodes { id identifier url description } } closed: issues(first: 1, orderBy: updatedAt, filter: { team: { key: { in: $teams } }, description: { contains: $text }, state: { type: { in: ["completed", "canceled"] } } }) { nodes { id identifier url description completedAt canceledAt comments(last: 20) { nodes { body createdAt user { id } } } } } }`, { teams, text: blockLine("fingerprint", fingerprint) }, z.object({
390
399
  viewer: z.object({ id: z.string() }),
391
400
  issues: z.object({ nodes: z.array(heldIssue) }),
392
401
  closed: z.object({ nodes: z.array(closedIssue) }),
@@ -13,6 +13,7 @@ function asCreated(outcome) {
13
13
  /** The tracker port over Linear's GraphQL API. */
14
14
  export const tracker = defineTracker({
15
15
  ...apiAccess,
16
+ updated_since: true,
16
17
  list_cards: async (input, ctx) => await listCards(ctx, input),
17
18
  card: async ({ id }, ctx) => await readCard(ctx, id),
18
19
  comments: async ({ id, since }, ctx) => await listComments(ctx, id, since),
@@ -1,2 +1,2 @@
1
- /** Reads a card of `[extensions.linear] team` that a card or its comments link, for a run's inbox, under the same rules as the tracker's card read: a card out of the scope is a failure. A link to a card of another team, or to anything else in Linear, is not this reader's. */
1
+ /** Reads a card of a team of `[extensions.linear]` that a card or its comments link, for a run's inbox, under the same rules as the tracker's card read: a card out of the scope is a failure. A link to a card of a team the table does not name, or to anything else in Linear, is not this reader's. */
2
2
  export declare const readLink: import("@kana-ai/edgar-sdk").ReadLink;
@@ -2,10 +2,10 @@ import { cardRead, defineReadLink, ok } from "@kana-ai/edgar-sdk";
2
2
  import { apiAccess } from "#api/client";
3
3
  import { readCard } from "#tracker/cards";
4
4
  import { listComments } from "#tracker/comments";
5
- import { settingsOf } from "#tracker/states";
5
+ import { settingsOf, teamsOf } from "#tracker/states";
6
6
  /** The link of a Linear card, `https://linear.app/<workspace>/issue/<TEAM>-<number>`, with an optional title after it. */
7
7
  const CARD_LINK = /^https:\/\/linear\.app\/[\w-]+\/issue\/([A-Z][A-Z0-9]*)-([1-9]\d*)(?:[/?#]|$)/;
8
- /** Reads a card of `[extensions.linear] team` that a card or its comments link, for a run's inbox, under the same rules as the tracker's card read: a card out of the scope is a failure. A link to a card of another team, or to anything else in Linear, is not this reader's. */
8
+ /** Reads a card of a team of `[extensions.linear]` that a card or its comments link, for a run's inbox, under the same rules as the tracker's card read: a card out of the scope is a failure. A link to a card of a team the table does not name, or to anything else in Linear, is not this reader's. */
9
9
  export const readLink = defineReadLink({
10
10
  hosts: ["linear.app"],
11
11
  ...apiAccess,
@@ -14,7 +14,7 @@ export const readLink = defineReadLink({
14
14
  if (!settings.ok)
15
15
  return settings;
16
16
  const [, team, number] = CARD_LINK.exec(url) ?? [];
17
- if (team !== settings.value.team || number === undefined)
17
+ if (team === undefined || number === undefined || !teamsOf(settings.value).includes(team))
18
18
  return ok({ kind: "not_mine" });
19
19
  const id = `${team}-${number}`;
20
20
  return cardRead(await readCard(ctx, id), await listComments(ctx, id, null));
@@ -1,7 +1,9 @@
1
1
  import type { Trust } from "@kana-ai/edgar-contracts/rpc";
2
2
  import { type Failure, type Result } from "@kana-ai/edgar-sdk";
3
+ import type { z } from "zod";
3
4
  import { type LinearCtx } from "#api/client";
4
5
  import { type Config, type State } from "#schemas/config";
6
+ import { type teamBoards } from "#schemas/linear";
5
7
  /** The label of a card that EDGAR handed to a person; with `assignee_only`, it keeps the card in scope while the person holds it. */
6
8
  export declare const WAITING = "edgar:waiting";
7
9
  /** The engine states in their forward order. */
@@ -16,6 +18,10 @@ export declare function isState(value: string): value is State;
16
18
  export declare function stateOf(settings: Config, name: string): State | undefined;
17
19
  /** True when moving from `from` to `to` goes forward in the mapping. A card that waits on a person goes on to any other column: the person's answer decides which. */
18
20
  export declare function forward(from: State, to: State): boolean;
21
+ /** The keys of the table's teams, from `team` or `teams`, which the schema holds to exactly one; EDGAR files its own cards in the first. */
22
+ export declare function teamsOf(settings: Config): readonly [string, ...string[]];
23
+ /** `invalid` for the first team of the table that Linear does not answer in `boards`, or whose states lack a column of `[extensions.linear.columns]`, naming the team and each missing column. */
24
+ export declare function columnsHeld(settings: Config, boards: z.infer<typeof teamBoards>): Result<null, Failure>;
19
25
  /** The call's `[extensions.linear]` table, or `invalid` with the fields that do not match. */
20
26
  export declare function settingsOf(ctx: LinearCtx): Result<Config, Failure>;
21
27
  /** The engine state of a card in column `name`: the mapped state, or `intake` for a card in a column of `assigned` whose assignee is `assignee`. */
@@ -33,6 +33,29 @@ export function forward(from, to) {
33
33
  return to !== from;
34
34
  return states.indexOf(to) > states.indexOf(from);
35
35
  }
36
+ /** The keys of the table's teams, from `team` or `teams`, which the schema holds to exactly one; EDGAR files its own cards in the first. */
37
+ export function teamsOf(settings) {
38
+ const [first, ...rest] = settings.teams ?? (settings.team === undefined ? [] : [settings.team]);
39
+ if (first === undefined)
40
+ throw new Error("the [extensions.linear] schema passed a table with no team");
41
+ return [first, ...rest];
42
+ }
43
+ /** `invalid` for the first team of the table that Linear does not answer in `boards`, or whose states lack a column of `[extensions.linear.columns]`, naming the team and each missing column. */
44
+ export function columnsHeld(settings, boards) {
45
+ for (const team of teamsOf(settings)) {
46
+ const board = boards.nodes.find((found) => found.key === team);
47
+ if (board === undefined) {
48
+ return err(permanentFailure("invalid", `linear: no team ${team} in this Linear workspace, or LINEAR_TOKEN cannot read it`, { cause: team }));
49
+ }
50
+ const names = new Set(board.states.nodes.map((state) => state.name));
51
+ const missing = states.filter((state) => !names.has(settings.columns[state]));
52
+ if (missing.length > 0) {
53
+ const columns = missing.map((state) => `${state} = ${JSON.stringify(settings.columns[state])}`);
54
+ return err(permanentFailure("invalid", `linear: [extensions.linear.columns] names columns that the team ${team} does not have: ${columns.join(", ")}`, { cause: team }));
55
+ }
56
+ }
57
+ return ok(null);
58
+ }
36
59
  /** The call's `[extensions.linear]` table, or `invalid` with the fields that do not match. */
37
60
  export function settingsOf(ctx) {
38
61
  const parsed = config.safeParse(ctx.config);
@@ -12,7 +12,7 @@ export declare function update(ctx: LinearCtx, id: string, input: Readonly<Recor
12
12
  export declare function park(ctx: LinearCtx, card: string, waitsFor: string): Promise<Outcome<{
13
13
  id: string;
14
14
  }>>;
15
- /** Moves each card in `intake` whose block waits for `card` to `column`, and returns the ids it moved. */
15
+ /** Moves each card of the table's teams in `intake` whose block waits for `card` to `column`, and returns the ids it moved. */
16
16
  export declare function releaseFollowUps(ctx: LinearCtx, card: string, column: FollowUpColumn): Promise<Outcome<{
17
17
  released: string[];
18
18
  }>>;
@@ -2,7 +2,7 @@ import { blockLine, done, err, ok, permanentFailure, readBlock, skipped, withBlo
2
2
  import { z } from "zod";
3
3
  import { linear } from "#api/client";
4
4
  import { idNames } from "#schemas/linear";
5
- import { WAITING, assigneeOf, columnOf, forward, inScope, isState, settingsOf, } from "#tracker/states";
5
+ import { WAITING, assigneeOf, columnOf, forward, inScope, isState, settingsOf, teamsOf, } from "#tracker/states";
6
6
  /** Moves a card to the column of `target`: forward only unless `force`, and `skipped` for a move the mapping does not cover or a card out of the table's scope, even with `force`, so a merged pull request on another project's `edgar/` branch never moves its card. A move to any column but `waiting_on_person`, and a close, take `edgar:waiting` off, so the card no longer waits on a person. */
7
7
  export async function transition(ctx, card, target, force = false) {
8
8
  const settings = settingsOf(ctx);
@@ -10,7 +10,7 @@ export async function transition(ctx, card, target, force = false) {
10
10
  return settings.error;
11
11
  if (!isState(target))
12
12
  return skipped();
13
- const read = await linear(ctx, "query Move($id: String!) { issue(id: $id) { id title project { name slugId } state { name } assignee { id } labels { nodes { id name } } team { states { nodes { id name } } } } }", { id: card }, z.object({
13
+ const read = await linear(ctx, "query Move($id: String!) { issue(id: $id) { id title project { name slugId } state { name } assignee { id } labels { nodes { id name } } team { key states { nodes { id name } } } } }", { id: card }, z.object({
14
14
  issue: z
15
15
  .object({
16
16
  id: z.string(),
@@ -19,7 +19,7 @@ export async function transition(ctx, card, target, force = false) {
19
19
  state: z.object({ name: z.string() }),
20
20
  assignee: z.object({ id: z.string() }).nullish(),
21
21
  labels: idNames,
22
- team: z.object({ states: idNames }),
22
+ team: z.object({ key: z.string(), states: idNames }),
23
23
  })
24
24
  .nullable(),
25
25
  }));
@@ -51,7 +51,9 @@ export async function transition(ctx, card, target, force = false) {
51
51
  const name = settings.value.columns[target];
52
52
  const stateId = found.team.states.nodes.find((state) => state.name === name)?.id;
53
53
  if (stateId === undefined) {
54
- return permanentFailure("invalid", `linear: the team has no column ${name}`, { cause: name });
54
+ return permanentFailure("invalid", `linear: the team ${found.team.key} has no column ${name}`, {
55
+ cause: name,
56
+ });
55
57
  }
56
58
  const moved = await update(ctx, found.id, labelIds === undefined ? { stateId } : { stateId, labelIds });
57
59
  return moved.ok ? done({ column: target }) : moved.error;
@@ -90,13 +92,13 @@ export async function park(ctx, card, waitsFor) {
90
92
  const written = await update(ctx, found.id, { description: next });
91
93
  return written.ok ? done({ id: card }) : written.error;
92
94
  }
93
- /** Moves each card in `intake` whose block waits for `card` to `column`, and returns the ids it moved. */
95
+ /** Moves each card of the table's teams in `intake` whose block waits for `card` to `column`, and returns the ids it moved. */
94
96
  export async function releaseFollowUps(ctx, card, column) {
95
97
  const settings = settingsOf(ctx);
96
98
  if (!settings.ok)
97
99
  return settings.error;
98
- const waiting = await linear(ctx, `query Waiting($team: String!, $text: String!, $intake: String!) { issues(first: 50, filter: { team: { key: { eq: $team } }, description: { contains: $text }, state: { name: { eq: $intake } } }) { nodes { identifier description } } }`, {
99
- team: settings.value.team,
100
+ const waiting = await linear(ctx, `query Waiting($teams: [String!]!, $text: String!, $intake: String!) { issues(first: 50, filter: { team: { key: { in: $teams } }, description: { contains: $text }, state: { name: { eq: $intake } } }) { nodes { identifier description } } }`, {
101
+ teams: teamsOf(settings.value),
100
102
  text: blockLine("waits_for", card),
101
103
  intake: settings.value.columns.intake,
102
104
  }, z.object({
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "contract": 1,
3
3
  "name": "linear",
4
- "version": "0.1.5",
4
+ "version": "0.1.7",
5
5
  "config_schema": "schemas/config.json",
6
6
  "secrets": [
7
7
  {
8
8
  "name": "LINEAR_TOKEN",
9
9
  "hosts": ["api.linear.app"],
10
- "help": "Make a personal API key in Linear, Settings, Security & access, with the Write permission (comments, moves, closes and descriptions need it) and access to the team in [extensions.linear] team."
10
+ "help": "Make a personal API key in Linear, Settings, Security & access, with the Write permission (comments, moves, closes and descriptions need it) and access to each team in [extensions.linear] team or teams."
11
11
  },
12
12
  {
13
13
  "name": "LINEAR_WEBHOOK_SECRET",
@@ -264,7 +264,8 @@
264
264
  "person"
265
265
  ],
266
266
  "secrets": ["LINEAR_TOKEN"],
267
- "capabilities": ["network:api.linear.app"]
267
+ "capabilities": ["network:api.linear.app"],
268
+ "updated_since": true
268
269
  },
269
270
  "environments": [],
270
271
  "hooks": [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kana-ai/edgar-ext-linear",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "EDGAR extension for Linear: the tracker port, comments, column moves, cards and follow-ups.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -21,8 +21,8 @@
21
21
  ".": "./dist/src/index.js"
22
22
  },
23
23
  "dependencies": {
24
- "@kana-ai/edgar-contracts": "0.1.5",
25
- "@kana-ai/edgar-sdk": "0.1.5",
24
+ "@kana-ai/edgar-contracts": "0.1.7",
25
+ "@kana-ai/edgar-sdk": "0.1.7",
26
26
  "zod": "4.6.7"
27
27
  },
28
28
  "devDependencies": {
@@ -3,9 +3,18 @@
3
3
  "type": "object",
4
4
  "properties": {
5
5
  "team": {
6
+ "description": "The key of the one Linear team whose cards EDGAR works, such as ENG. Write `team` or `teams`, not both.",
6
7
  "type": "string",
7
- "minLength": 1,
8
- "description": "The key of the Linear team whose cards EDGAR works, such as ENG."
8
+ "minLength": 1
9
+ },
10
+ "teams": {
11
+ "description": "The keys of the Linear teams whose cards EDGAR works, such as [\"ENG\", \"PRD\"]. EDGAR files its own cards in the first. Write `team` or `teams`, not both.",
12
+ "minItems": 1,
13
+ "type": "array",
14
+ "items": {
15
+ "type": "string",
16
+ "minLength": 1
17
+ }
9
18
  },
10
19
  "project": {
11
20
  "description": "Only the cards in this Linear project, by name or URL key, are in scope, and EDGAR files its own cards there. Not set: every project.",
@@ -102,6 +111,6 @@
102
111
  }
103
112
  }
104
113
  },
105
- "required": ["team", "columns"],
114
+ "required": ["columns"],
106
115
  "additionalProperties": false
107
116
  }
@@ -94,6 +94,14 @@
94
94
  "trust": {
95
95
  "type": "string",
96
96
  "enum": ["team", "outside"]
97
+ },
98
+ "requested_by": {
99
+ "type": "string",
100
+ "minLength": 1
101
+ },
102
+ "requested_by_id": {
103
+ "type": "string",
104
+ "minLength": 1
97
105
  }
98
106
  },
99
107
  "required": ["kind"],