@yannelli/paseo-linear-plugin 0.0.0-stage → 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,9 @@
1
+ paseo-linear-plugin
2
+ Copyright 2026 Ryan Yannelli
3
+
4
+ This product includes software from Paseo (https://github.com/getpaseo/paseo),
5
+ Copyright (c) 2025-present Mohamed Boudra, licensed under the Apache License,
6
+ Version 2.0. The plugin source in index.client.ts, index.server.ts, server/,
7
+ shared/, and test/linear.test.ts comes from plugin-examples/linear at commit
8
+ 8f1091da6. Changes: package metadata, manifest description, Paseo >=0.9.0
9
+ requirement, and the test file location.
package/OVERVIEW.md ADDED
@@ -0,0 +1,24 @@
1
+ # Linear issues
2
+
3
+ Adds **Attach Linear issue** to the message composer. Search your Linear issues, select one, and the agent receives the issue text with your prompt.
4
+
5
+ ## Setup
6
+
7
+ Set `LINEAR_API_KEY` to a Linear personal API key in the environment that starts the Paseo daemon, then restart the daemon. Create the key in Linear under Settings → Security & access → Personal API keys. The plugin only reads issues, so read permission is enough. Requires Paseo 0.9.0 or newer.
8
+
9
+ ## Search
10
+
11
+ - An identifier such as `ENG-123` returns that issue only. Case does not matter.
12
+ - Other text matches issue titles, without case sensitivity. Descriptions and comments are not searched.
13
+ - An empty search lists the 20 most recently updated issues. Title searches also return up to 20 issues.
14
+ - Each result shows its status and assignee.
15
+
16
+ ## What the agent receives
17
+
18
+ The attachment text contains the identifier, title, URL, status, priority, assignee, project, labels, and description. The plugin takes this snapshot when you select the issue. Later changes in Linear do not update it.
19
+
20
+ ## Data and permissions
21
+
22
+ The daemon subprocess sends GraphQL queries to `https://api.linear.app/graphql` with your key. The app never receives the key. Results include any issue the key can read. Paseo sends the selected snapshot to the agent provider with the message.
23
+
24
+ A rejected key, a rate limit, or a GraphQL error appears as the picker's result text. A new key takes effect only after a daemon restart.
package/README.md CHANGED
@@ -1,3 +1,103 @@
1
- # Temporary Holding Version
1
+ ![Linear issues for Paseo: hand your agent the whole issue.](docs/images/social-preview.png)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ # Linear issues for Paseo
4
+
5
+ A Paseo plugin that adds **Attach Linear issue** to the message composer. Search by issue identifier or title, then send a snapshot of the issue to the agent with your prompt. The snapshot holds the title, URL, status, priority, assignee, project, labels, and description.
6
+
7
+ ![Attach Linear issue picker with four search results for "plugin"](docs/images/search.png)
8
+
9
+ ![Composer with an attached ENG-123 pill and the issue text sent to the agent](docs/images/attach.png)
10
+
11
+ ![Terminal that sets LINEAR_API_KEY and installs the plugin, with the app, daemon, and Linear API in sequence](docs/images/setup.png)
12
+
13
+ The images are illustrations with sample data. They come from `docs/graphics`; see [Graphics](#graphics).
14
+
15
+ ## What you need
16
+
17
+ - Paseo 0.9.0 or newer, with **Enable plugins** turned on in **Settings → Plugins**.
18
+ - A Linear personal API key in the daemon environment. Create one in Linear under **Settings → Security & access → Personal API keys**. The plugin only reads issues, so a key with read permission is enough.
19
+
20
+ ## Setup
21
+
22
+ Set the key in the environment that starts the Paseo daemon:
23
+
24
+ ```sh
25
+ export LINEAR_API_KEY="lin_api_..."
26
+ ```
27
+
28
+ Start or restart the daemon from that environment. The key stays on the daemon host. The app calls the plugin over RPC, and only the daemon subprocess sends requests to `api.linear.app`. To change the key, restart the daemon with the new value. Installing or reloading the plugin does not read a new environment.
29
+
30
+ ## Install
31
+
32
+ ```sh
33
+ paseo plugin add npm:@yannelli/paseo-linear-plugin
34
+ paseo plugin ls linear
35
+ ```
36
+
37
+ To pin a version, add it to the source, for example `npm:@yannelli/paseo-linear-plugin@0.1.0`. To install a Git tag instead, run `paseo plugin add github:yannelli/paseo-linear-plugin --ref v0.1.0`. Plugins run trusted code with the daemon user's access.
38
+
39
+ ## Use
40
+
41
+ 1. Open the attachment menu in the composer and choose **Attach Linear issue**.
42
+ 2. Type an identifier, such as `ENG-123`, for an exact match. Type other text to search issue titles. An empty search lists the 20 most recently updated issues.
43
+ 3. Select an issue. A pill with the issue title appears in the composer.
44
+ 4. Send the message. The agent receives the issue text with your prompt.
45
+
46
+ The snapshot is taken when you select the issue. Later changes in Linear do not update an attached pill.
47
+
48
+ ## How it works
49
+
50
+ | File | Runtime | Role |
51
+ | --- | --- | --- |
52
+ | `shared/issues.ts` | Both | The `issues.search` RPC contract and the attachment source definition |
53
+ | `server/linear.ts` | Daemon | Linear GraphQL client, response validation, and snapshot text |
54
+ | `server/issues.ts` | Daemon | RPC handler that reads `LINEAR_API_KEY` |
55
+ | `index.server.ts` | Daemon | Registers the RPC handler |
56
+ | `index.client.ts` | App | Registers the attachment source |
57
+
58
+ The client bundle holds no credentials and makes no calls to Linear.
59
+
60
+ ## Development
61
+
62
+ Use Node.js 24.
63
+
64
+ ```sh
65
+ git clone https://github.com/yannelli/paseo-linear-plugin.git
66
+ cd paseo-linear-plugin
67
+ npm ci
68
+ npm run check
69
+ paseo plugin add "$PWD"
70
+ ```
71
+
72
+ After you edit the source, run `paseo plugin reload linear`. `npm run check` runs the typecheck, the Linear client tests against a local GraphQL server, and the release script tests.
73
+
74
+ ## Graphics
75
+
76
+ `docs/graphics/scene.html` and `scene.css` define the README images, the GitHub social preview, and the icon. Render them into `docs/images` with Playwright and Chromium:
77
+
78
+ ```sh
79
+ node docs/graphics/render.mjs
80
+ ```
81
+
82
+ The script finds Playwright locally or in the global npm root. Set `PLAYWRIGHT_MODULE` to its entry file to choose another copy. The fonts are Instrument Sans and JetBrains Mono under the [SIL Open Font License](docs/graphics/fonts/OFL.txt). The mark is original and is not the Linear logo.
83
+
84
+ ## Releases
85
+
86
+ GitHub Actions runs the checks and publishes a release on qualifying pushes to `main`. The first release is `v0.1.0`. The workflow updates `package.json` and `package-lock.json`, pushes an annotated tag, and publishes release notes. It then publishes [`@yannelli/paseo-linear-plugin`](https://www.npmjs.com/package/@yannelli/paseo-linear-plugin) to npm through trusted publishing (OIDC), with no npm token. See [npm publishing](docs/npm-publishing.md) for the first-publish steps.
87
+
88
+ Use Conventional Commits in commits and squash-merge titles:
89
+
90
+ | Commit | Version change |
91
+ | --- | --- |
92
+ | `fix:`, `perf:`, `revert:` | Patch |
93
+ | `feat:` | Minor |
94
+ | `!` after the type or scope, or a `BREAKING CHANGE:` footer | Major, including before 1.0 |
95
+ | `docs:`, `chore:`, `ci:`, and other types without a breaking marker | No release |
96
+
97
+ The highest change since the last release sets the next version. For example, `fix: trim identifier queries` changes `0.1.0` to `0.1.1`, and `feat: filter by project` changes it to `0.2.0`.
98
+
99
+ Run `npm run release:dry-run` from a clean `main` checkout with all tags fetched to preview the next release. To complete a GitHub or npm publication that stopped after its tag was pushed, run the **Release** workflow again.
100
+
101
+ ## License
102
+
103
+ Apache License 2.0. The plugin source comes from the Linear example in [getpaseo/paseo](https://github.com/getpaseo/paseo/tree/main/plugin-examples/linear). See [NOTICE](NOTICE).
@@ -0,0 +1,7 @@
1
+ import type { PluginClientContext } from "@getpaseo/plugin/client";
2
+ import { issueAttachments } from "./shared/issues";
3
+
4
+ export default function contribute(client: PluginClientContext) {
5
+ client.addAttachmentSource(issueAttachments);
6
+ return () => {};
7
+ }
@@ -0,0 +1,8 @@
1
+ import type { PluginServerContext } from "@getpaseo/plugin/server";
2
+ import { searchIssues } from "./server/issues";
3
+ import { searchIssuesRpc } from "./shared/issues";
4
+
5
+ export default function contribute(server: PluginServerContext) {
6
+ server.handle(searchIssuesRpc, searchIssues);
7
+ return () => {};
8
+ }
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@yannelli/paseo-linear-plugin",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Attach Linear issues to Paseo agent prompts",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "keywords": [
8
+ "paseo",
9
+ "paseo-plugin",
10
+ "linear"
11
+ ],
12
+ "engines": {
13
+ "node": ">=24"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/yannelli/paseo-linear-plugin.git"
18
+ },
19
+ "homepage": "https://github.com/yannelli/paseo-linear-plugin#readme",
20
+ "bugs": {
21
+ "url": "https://github.com/yannelli/paseo-linear-plugin/issues"
22
+ },
23
+ "files": [
24
+ "paseo-plugin.json",
25
+ "OVERVIEW.md",
26
+ "NOTICE",
27
+ "index.client.ts",
28
+ "index.server.ts",
29
+ "server/",
30
+ "shared/"
31
+ ],
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "scripts": {
36
+ "typecheck": "tsc --noEmit",
37
+ "test": "vitest run && node --test test/*.test.mjs",
38
+ "check": "npm run typecheck && npm test",
39
+ "release:dry-run": "node scripts/release.mjs --dry-run"
40
+ },
41
+ "devDependencies": {
42
+ "@getpaseo/plugin": "0.10.3",
43
+ "@tanstack/react-query": "^5.90.11",
44
+ "@types/node": "^24.19.1",
45
+ "@types/react": "~19.2.0",
46
+ "react": "19.1.0",
47
+ "react-native": "0.81.5",
48
+ "typescript": "^5.9.3",
49
+ "vitest": "^4.1.6",
50
+ "zod": "^4.4.3"
51
+ }
52
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "id": "linear",
3
+ "description": "Attach Linear issues to agent prompts",
4
+ "requirements": {
5
+ "paseo": ">=0.9.0"
6
+ }
7
+ }
@@ -0,0 +1,10 @@
1
+ import type { PluginAttachmentSearchPayload, RpcInput } from "@getpaseo/plugin";
2
+ import { searchIssuesRpc } from "../shared/issues";
3
+ import { createLinearIssueSearch } from "./linear";
4
+
5
+ export async function searchIssues({
6
+ query,
7
+ }: RpcInput<typeof searchIssuesRpc>): Promise<PluginAttachmentSearchPayload> {
8
+ const linear = createLinearIssueSearch({ apiKey: process.env.LINEAR_API_KEY ?? "" });
9
+ return linear.search(query);
10
+ }
@@ -0,0 +1,183 @@
1
+ import { z } from "zod";
2
+
3
+ const LinearIssueSchema = z.object({
4
+ id: z.string(),
5
+ identifier: z.string(),
6
+ title: z.string(),
7
+ description: z.string().nullable(),
8
+ url: z.string(),
9
+ priorityLabel: z.string(),
10
+ state: z.object({ name: z.string() }),
11
+ assignee: z.object({ name: z.string() }).nullable(),
12
+ project: z.object({ name: z.string() }).nullable(),
13
+ labels: z.object({ nodes: z.array(z.object({ name: z.string() })) }),
14
+ });
15
+
16
+ const LinearGraphqlErrorSchema = z.object({ message: z.string() }).passthrough();
17
+ const ExactIssueResponseSchema = z.object({
18
+ data: z.object({ issue: LinearIssueSchema.nullable() }).nullable().optional(),
19
+ errors: z.array(LinearGraphqlErrorSchema).optional(),
20
+ });
21
+ const IssueSearchResponseSchema = z.object({
22
+ data: z
23
+ .object({ issues: z.object({ nodes: z.array(LinearIssueSchema) }) })
24
+ .nullable()
25
+ .optional(),
26
+ errors: z.array(LinearGraphqlErrorSchema).optional(),
27
+ });
28
+
29
+ const ISSUE_FIELDS = `
30
+ id
31
+ identifier
32
+ title
33
+ description
34
+ url
35
+ priorityLabel
36
+ state { name }
37
+ assignee { name }
38
+ project { name }
39
+ labels { nodes { name } }
40
+ `;
41
+
42
+ const EXACT_ISSUE_QUERY = `
43
+ query PaseoLinearIssue($id: String!) {
44
+ issue(id: $id) { ${ISSUE_FIELDS} }
45
+ }
46
+ `;
47
+
48
+ const SEARCH_ISSUES_QUERY = `
49
+ query PaseoLinearIssues($filter: IssueFilter) {
50
+ issues(first: 20, filter: $filter, orderBy: updatedAt) {
51
+ nodes { ${ISSUE_FIELDS} }
52
+ }
53
+ }
54
+ `;
55
+
56
+ const LINEAR_IDENTIFIER = /^[A-Z][A-Z0-9]+-\d+$/i;
57
+
58
+ export interface LinearAttachmentItem {
59
+ id: string;
60
+ identifier: string;
61
+ title: string;
62
+ subtitle?: string;
63
+ url: string;
64
+ text: string;
65
+ resourceType: string;
66
+ }
67
+
68
+ export interface LinearIssueSearch {
69
+ search(query: string): Promise<{ items: LinearAttachmentItem[] }>;
70
+ }
71
+
72
+ interface LinearIssueSearchOptions {
73
+ apiKey: string;
74
+ endpoint?: string;
75
+ request?: typeof fetch;
76
+ }
77
+
78
+ interface GraphqlRequest {
79
+ query: string;
80
+ variables: Record<string, unknown>;
81
+ }
82
+
83
+ class LinearApiError extends Error {
84
+ constructor(message: string) {
85
+ super(message);
86
+ this.name = "LinearApiError";
87
+ }
88
+ }
89
+
90
+ function issueSubtitle(issue: z.infer<typeof LinearIssueSchema>): string | undefined {
91
+ const parts = [issue.state.name, issue.assignee?.name].filter(
92
+ (part): part is string => typeof part === "string" && part.length > 0,
93
+ );
94
+ return parts.length > 0 ? parts.join(" · ") : undefined;
95
+ }
96
+
97
+ function issueText(issue: z.infer<typeof LinearIssueSchema>): string {
98
+ const labels = issue.labels.nodes.map((label) => label.name).join(", ");
99
+ const lines = [
100
+ `Linear issue ${issue.identifier}: ${issue.title}`,
101
+ `URL: ${issue.url}`,
102
+ `Status: ${issue.state.name}`,
103
+ `Priority: ${issue.priorityLabel}`,
104
+ ];
105
+ if (issue.assignee) lines.push(`Assignee: ${issue.assignee.name}`);
106
+ if (issue.project) lines.push(`Project: ${issue.project.name}`);
107
+ if (labels) lines.push(`Labels: ${labels}`);
108
+ lines.push("", issue.description ?? "No description.");
109
+ return lines.join("\n");
110
+ }
111
+
112
+ function toAttachmentItem(issue: z.infer<typeof LinearIssueSchema>): LinearAttachmentItem {
113
+ const subtitle = issueSubtitle(issue);
114
+ return {
115
+ id: issue.id,
116
+ identifier: issue.identifier,
117
+ title: issue.title,
118
+ ...(subtitle ? { subtitle } : {}),
119
+ url: issue.url,
120
+ text: issueText(issue),
121
+ resourceType: "issue",
122
+ };
123
+ }
124
+
125
+ function describeHttpFailure(status: number): string {
126
+ if (status === 401 || status === 403) return "Linear rejected LINEAR_API_KEY";
127
+ if (status === 429) return "Linear rate limit reached. Try again shortly";
128
+ return `Linear API request failed with HTTP ${status}`;
129
+ }
130
+
131
+ function throwGraphqlErrors(errors: Array<{ message: string }> | undefined): void {
132
+ if (!errors || errors.length === 0) return;
133
+ throw new LinearApiError(errors.map((error) => error.message).join("; "));
134
+ }
135
+
136
+ export function createLinearIssueSearch(options: LinearIssueSearchOptions): LinearIssueSearch {
137
+ const apiKey = options.apiKey.trim();
138
+ if (!apiKey) throw new LinearApiError("Set LINEAR_API_KEY in the daemon environment");
139
+ const endpoint = options.endpoint ?? "https://api.linear.app/graphql";
140
+ const request = options.request ?? fetch;
141
+
142
+ async function graphql(body: GraphqlRequest): Promise<unknown> {
143
+ const response = await request(endpoint, {
144
+ method: "POST",
145
+ headers: {
146
+ Authorization: apiKey,
147
+ "Content-Type": "application/json",
148
+ },
149
+ body: JSON.stringify(body),
150
+ });
151
+ if (!response.ok) throw new LinearApiError(describeHttpFailure(response.status));
152
+ return response.json();
153
+ }
154
+
155
+ async function findExact(identifier: string): Promise<LinearAttachmentItem[]> {
156
+ const response = ExactIssueResponseSchema.parse(
157
+ await graphql({ query: EXACT_ISSUE_QUERY, variables: { id: identifier } }),
158
+ );
159
+ throwGraphqlErrors(response.errors);
160
+ return response.data?.issue ? [toAttachmentItem(response.data.issue)] : [];
161
+ }
162
+
163
+ async function searchTitles(query: string): Promise<LinearAttachmentItem[]> {
164
+ const filter = query ? { title: { containsIgnoreCase: query } } : null;
165
+ const response = IssueSearchResponseSchema.parse(
166
+ await graphql({ query: SEARCH_ISSUES_QUERY, variables: { filter } }),
167
+ );
168
+ throwGraphqlErrors(response.errors);
169
+ if (!response.data) throw new LinearApiError("Linear returned no issue data");
170
+ return response.data.issues.nodes.map(toAttachmentItem);
171
+ }
172
+
173
+ return {
174
+ async search(query: string) {
175
+ const normalized = query.trim();
176
+ if (LINEAR_IDENTIFIER.test(normalized)) {
177
+ return { items: await findExact(normalized.toUpperCase()) };
178
+ }
179
+ const items = await searchTitles(normalized);
180
+ return { items };
181
+ },
182
+ };
183
+ }
@@ -0,0 +1,31 @@
1
+ import { defineAttachmentSource, defineRpc } from "@getpaseo/plugin";
2
+ import { z } from "zod";
3
+
4
+ const SearchPayloadSchema = z.object({
5
+ items: z.array(
6
+ z.object({
7
+ id: z.string(),
8
+ identifier: z.string(),
9
+ title: z.string(),
10
+ subtitle: z.string().optional(),
11
+ url: z.string().url(),
12
+ text: z.string(),
13
+ resourceType: z.string(),
14
+ }),
15
+ ),
16
+ });
17
+
18
+ export const searchIssuesRpc = defineRpc({
19
+ name: "issues.search",
20
+ input: z.object({ query: z.string() }),
21
+ output: SearchPayloadSchema,
22
+ });
23
+
24
+ export const issueAttachments = defineAttachmentSource({
25
+ id: "issues",
26
+ title: "Linear issue",
27
+ icon: "CircleDot",
28
+ pickerTitle: "Attach Linear issue",
29
+ searchPlaceholder: "Search by identifier or title",
30
+ search: searchIssuesRpc,
31
+ });