@yannelli/paseo-linear-plugin 0.1.0 → 0.3.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.
Files changed (49) hide show
  1. package/NOTICE +8 -4
  2. package/OVERVIEW.md +22 -13
  3. package/README.md +134 -29
  4. package/client/agent-options.ts +200 -0
  5. package/client/breadcrumbs.tsx +110 -0
  6. package/client/browser.tsx +275 -0
  7. package/client/compat.ts +107 -0
  8. package/client/connect.tsx +136 -0
  9. package/client/create-issue.tsx +291 -0
  10. package/client/glyphs.tsx +117 -0
  11. package/client/issue-detail.tsx +366 -0
  12. package/client/issue-list.tsx +373 -0
  13. package/client/issue-row.tsx +152 -0
  14. package/client/issue-sections.tsx +325 -0
  15. package/client/issue-tree.ts +132 -0
  16. package/client/key-scope.tsx +23 -0
  17. package/client/launch-choices.ts +125 -0
  18. package/client/launch-fields.tsx +152 -0
  19. package/client/launch-plan.ts +227 -0
  20. package/client/launch.tsx +484 -0
  21. package/client/markdown.tsx +240 -0
  22. package/client/model-browser.tsx +296 -0
  23. package/client/pickers.tsx +238 -0
  24. package/client/provider-icon.tsx +78 -0
  25. package/client/queries.ts +211 -0
  26. package/client/settings-connection.tsx +109 -0
  27. package/client/settings-fields.tsx +173 -0
  28. package/client/settings-keys.tsx +117 -0
  29. package/client/settings-projects.tsx +281 -0
  30. package/client/settings-prompts.tsx +198 -0
  31. package/client/store.ts +71 -0
  32. package/client/timeline-card.tsx +63 -0
  33. package/client/ui.tsx +352 -0
  34. package/index.client.tsx +111 -0
  35. package/index.server.ts +7 -3
  36. package/package.json +4 -3
  37. package/paseo-plugin.json +2 -2
  38. package/server/cache.ts +68 -0
  39. package/server/credentials.ts +101 -0
  40. package/server/graphql.ts +68 -0
  41. package/server/handlers.ts +172 -0
  42. package/server/linear.ts +11 -64
  43. package/server/queries.ts +280 -0
  44. package/shared/linear.ts +268 -0
  45. package/shared/markdown.ts +416 -0
  46. package/shared/prompts.ts +150 -0
  47. package/shared/settings.ts +68 -0
  48. package/index.client.ts +0 -7
  49. package/server/issues.ts +0 -10
package/NOTICE CHANGED
@@ -3,7 +3,11 @@ Copyright 2026 Ryan Yannelli
3
3
 
4
4
  This product includes software from Paseo (https://github.com/getpaseo/paseo),
5
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.
6
+ Version 2.0. The plugin source in index.client.tsx, index.server.ts, client/,
7
+ server/, shared/, and test/linear.test.ts started as the Linear example plugin
8
+ (plugin-examples/linear) in the Paseo repository. This repository adds Linear keys per Paseo project, a
9
+ response cache, list sorting, sub-issue nesting and breadcrumbs, Markdown
10
+ rendering, and the agent setup page. It also changes the package metadata.
11
+
12
+ client/provider-icon.tsx contains the provider icons from the Paseo app
13
+ (packages/app/src/components/icons). Each icon is a mark of its owner.
package/OVERVIEW.md CHANGED
@@ -1,24 +1,33 @@
1
1
  # Linear issues
2
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.
3
+ Browse and edit Linear issues in Paseo, and start agents from them. Open **Linear** from the sidebar, or open the Linear panel in a workspace. Requires Paseo 0.10.0 or newer.
4
4
 
5
- ## Setup
5
+ ## Connect Linear
6
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.
7
+ Paste a Linear personal API key in **Settings → Plugins → Linear → Account**. Create the key in Linear under Settings → Security & access → Personal API keys. To change issues, the key must have write access. The daemon saves the key on its host with owner-only permissions. If no key is saved, the plugin uses `LINEAR_API_KEY` from the daemon environment.
8
8
 
9
- ## Search
9
+ To use a different Linear key for one Paseo project, add it under **Project keys**. Workspace panels in that project use its key. The Linear screen shows a key button to switch keys.
10
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.
11
+ ## Browse issues
15
12
 
16
- ## What the agent receives
13
+ - Search titles and descriptions, or type an identifier such as `ENG-123`.
14
+ - Filter by assignee and status. Pick a team to see only its issues.
15
+ - Sort by Last updated, Newest, Priority, Due date, or Title.
16
+ - Select **Sub-issues** to nest sub-issues under their parent. The breadcrumbs above an issue show its team and parent chain.
17
+ - Change the status, priority, and assignee. Add comments, or create an issue.
18
+ - Descriptions and comments show as Markdown.
19
+ - `/linear` opens the panel. `/linear ENG-123` opens an issue.
17
20
 
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.
21
+ ## Start an agent
19
22
 
20
- ## Data and permissions
23
+ Select **Start agent** or **Start review** on an issue. The setup page shows the prompt and the composer controls for the prompt template, model, thinking level, and mode. The model picker lists providers first, and its search covers all models. Choose the project and where the agent runs: a new worktree, a pull request checkout, the issue branch, an existing agent workspace, or the current workspace or project folder. You can include comments in the prompt. For Implement, you can also move the issue to In Progress and assign it to you.
24
+
25
+ The prompt follows the template until you edit it. **Reset prompt** restores it. Edit the templates in **Prompts**, and add project instructions in **Projects**.
26
+
27
+ ## Attach an issue
21
28
 
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.
29
+ Choose **Attach Linear issue** in the composer attachment menu. The agent gets the issue text with your message. This uses the default key.
30
+
31
+ ## Data and permissions
23
32
 
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.
33
+ Only the daemon sends requests to `https://api.linear.app/graphql`. The daemon never sends a key back to the app. Paseo sends the prompt, with the issue snapshot, to the agent provider. The daemon keeps recent Linear responses in memory for up to 24 hours, and the list shows them with **Showing saved results. Updating…** while it gets new data.
package/README.md CHANGED
@@ -1,59 +1,160 @@
1
- ![Linear issues for Paseo: hand your agent the whole issue.](docs/images/social-preview.png)
1
+ ![Linear issues in Paseo: an issue view with Start agent and Start review buttons, next to the install command](docs/images/social-preview.png)
2
2
 
3
3
  # Linear issues for Paseo
4
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.
5
+ A Paseo plugin for Linear. It adds a Linear screen and a workspace panel where you browse and edit Linear issues. From an issue, you can start an agent that implements it or reviews the work. Your Linear API key stays on the daemon host.
6
6
 
7
- ![Attach Linear issue picker with four search results for "plugin"](docs/images/search.png)
7
+ - Browse issues in a list next to the issue view. Search and filter the list, and change its sort order.
8
+ - Nest sub-issues under their parent. Breadcrumbs show the parent chain of an issue.
9
+ - Read descriptions and comments as Markdown.
10
+ - Change the status, priority, and assignee. Add comments and create issues.
11
+ - Start an agent or a review from an issue. Choose the prompt, agent, model, effort, project, and where the agent runs.
12
+ - Use a different Linear key for a Paseo project.
13
+ - See saved results at once while the plugin gets new data from Linear.
14
+ - Attach a Linear issue to a message in the composer.
8
15
 
9
- ![Composer with an attached ENG-123 pill and the issue text sent to the agent](docs/images/attach.png)
16
+ ![Linear screen with an issue list grouped by status on the left and issue ENG-123 open on the right](docs/images/browse.png)
10
17
 
11
- ![Terminal that sets LINEAR_API_KEY and installs the plugin, with the app, daemon, and Linear API in sequence](docs/images/setup.png)
18
+ ![Agent setup page for ENG-123 with the prompt, the prompt, model, thinking, and mode controls, the Project and Run in fields, and three options](docs/images/launch.png)
19
+
20
+ ![Linear account settings with the default key status, the default key form, and a project key for Acme Mobile](docs/images/keys.png)
12
21
 
13
22
  The images are illustrations with sample data. They come from `docs/graphics`; see [Graphics](#graphics).
14
23
 
15
24
  ## What you need
16
25
 
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
26
+ - Paseo 0.10.0 or newer, with **Enable plugins** turned on in **Settings → Plugins**.
27
+ - A Linear personal API key. Create one in Linear under **Settings → Security & access → Personal API keys**. To change issues, add comments, or create issues, the key must have write access.
21
28
 
22
- Set the key in the environment that starts the Paseo daemon:
29
+ ## Install
23
30
 
24
31
  ```sh
25
- export LINEAR_API_KEY="lin_api_..."
32
+ paseo plugin add npm:@yannelli/paseo-linear-plugin
33
+ paseo plugin ls linear
26
34
  ```
27
35
 
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.
36
+ 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.
29
37
 
30
- ## Install
38
+ ## Connect Linear
39
+
40
+ ### Default key
41
+
42
+ Open **Settings → Plugins → Linear → Account**, paste your key, and select **Connect Linear**. The Linear screen shows the same form until a key is set. The plugin checks the key with Linear before it saves it.
43
+
44
+ The daemon saves the key in `$PASEO_HOME/plugin-data/linear/credentials.json`, which is `~/.paseo/plugin-data/linear/credentials.json` by default. The file has mode `0600` and its folder has mode `0700`. A saved key takes effect at once. **Disconnect** deletes the saved key.
45
+
46
+ ### Key from the environment
47
+
48
+ If no key is saved, the plugin uses `LINEAR_API_KEY` from the environment that starts the daemon:
31
49
 
32
50
  ```sh
33
- paseo plugin add npm:@yannelli/paseo-linear-plugin
34
- paseo plugin ls linear
51
+ export LINEAR_API_KEY="lin_api_..."
35
52
  ```
36
53
 
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.
54
+ A saved key takes precedence over the environment. To change the environment key, restart the daemon with the new value.
55
+
56
+ ### Project keys
57
+
58
+ A Paseo project can use a different Linear key, for example for a different Linear workspace. In the **Project keys** section of the Account settings, choose the project, paste the key, and select **Save project key**.
59
+
60
+ - The Linear panel in a workspace of that project uses the project key.
61
+ - When project keys exist, the Linear screen shows a key button in the filter row. Use it to switch between **Default key** and the project keys.
62
+ - The plugin looks for a key in this order: the project key, the saved default key, then `LINEAR_API_KEY`.
63
+ - The composer attachment always uses the default key.
38
64
 
39
65
  ## Use
40
66
 
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.
67
+ ### Browse issues
68
+
69
+ Open **Linear** from the sidebar, or run **Linear: Open issues** in the command center. In a workspace, run **Linear: Show issues in this workspace**, or type `/linear` in the composer. `/linear ENG-123` opens that issue, and `/linear <text>` searches.
45
70
 
46
- The snapshot is taken when you select the issue. Later changes in Linear do not update an attached pill.
71
+ - The search box matches issue titles and descriptions. An identifier such as `ENG-123` shows that issue only.
72
+ - Filter by assignee (**Mine**, **Everyone**, **Unassigned**), by status (**Active**, **Backlog**, **Done**, **All**), and by team.
73
+ - The list groups issues by status and loads more as you scroll.
74
+ - If you map Linear teams to a project in **Settings → Plugins → Linear → Projects**, the panel starts with the first mapped team.
75
+
76
+ ### Sort
77
+
78
+ Select the sort button in the filter row. The options are **Last updated**, **Newest**, **Priority**, **Due date**, and **Title**.
79
+
80
+ ### Sub-issues
81
+
82
+ Select **Sub-issues** in the filter row to nest sub-issues under their parent. A sub-issue shows under its parent when the parent is in the list, even if their statuses differ. Select the chevron to collapse or expand a parent. A collapsed parent shows how many sub-issues it hides.
83
+
84
+ The issue header shows breadcrumbs: the team, the parent chain, then the issue, for example **Engineering › ENG-120 › ENG-123**. Select a parent to open it. A long chain folds its middle into **…**; select it to show all parents.
85
+
86
+ ### Read and edit an issue
87
+
88
+ - Select the status, priority, or assignee chip to change it.
89
+ - Descriptions and comments show as Markdown: headings, lists, task lists, code, quotes, tables, and links.
90
+ - Add a comment in the **Activity** section.
91
+ - The header buttons refresh the issue, copy its branch name, and open it in Linear.
92
+ - Select **New issue**, or run **Linear: Create issue**, to create an issue. Set the team, status, priority, assignee, title, and a Markdown description.
93
+
94
+ ### Start an agent
95
+
96
+ Select **Start agent** or **Start review** in the issue view. The agent setup page opens in the panel or the screen. It works with or without a current workspace.
97
+
98
+ 1. Edit the prompt in the prompt box if you want. The prompt follows the template and options until you edit it. Select **Reset prompt** to go back to the template.
99
+ 2. Use the controls under the prompt box, as in the Paseo composer. They set the prompt template (Implement or Review), the model, the thinking level, and the mode. The thinking level shows when the model has levels, and the mode shows when the agent has modes.
100
+ - The model picker lists the providers first. Select a provider to see its models, or search to find models from all providers.
101
+ - Choosing a model from another provider also changes the agent, and resets the thinking level and mode to that agent's defaults.
102
+ 3. Choose the **Project**. The default is the project of the current workspace. Without a workspace, it is the last project you used for the team, then a project mapped to the team.
103
+ 4. Choose where the agent runs in **Run in**:
104
+ - **New worktree** on the issue branch.
105
+ - **Check out PR #N** for a review, when the issue links a GitHub pull request.
106
+ - **Check out issue branch** for a review.
107
+ - **Existing agent workspace** or **Implementation workspace**, when an agent already works on the issue.
108
+ - **This workspace**, or **Project folder** when you are not in a workspace of that project.
109
+
110
+ The worktree and checkout options show only for a Git project.
111
+ 5. Set the options: **Include comments in the prompt**, **Move the issue to In Progress**, and **Assign the issue to me**. The last two show only for Implement, and only when they would change the issue.
112
+ 6. Select **Start agent** or **Start review**.
113
+
114
+ The plugin starts the agent and then updates Linear. If the Linear update fails, the agent keeps running and a message shows the error. The agent's timeline gets a card that links to the issue. The issue view lists the agents started from it under **Agents on this issue**.
115
+
116
+ Set the default model, where agents run, the default options, and the Implement and Review templates in **Settings → Plugins → Linear → Prompts**. In **Projects**, add instructions and steps for a project, or append to or replace a template for that project.
117
+
118
+ ### Attach an issue to a message
119
+
120
+ In the composer, open the attachment menu and choose **Attach Linear issue**. Type an identifier such as `ENG-123`, or words from a title. An empty search lists the 20 most recently updated issues. The agent gets the issue text with your message. The plugin takes this snapshot when you select the issue.
121
+
122
+ ## Data and permissions
123
+
124
+ - **Your key stays on the daemon host.** When you save a key, the app sends it to the daemon once. The daemon never sends a key back to the app. The app gets only the last four characters, to show which key is in use. Only the daemon sends requests to `https://api.linear.app/graphql`.
125
+ - **Data sent to Linear:** queries for issues, teams, users, and comments, and the changes you make. When you start an agent with the options on, the plugin moves the issue to In Progress and assigns it to you.
126
+ - **Data sent to the agent provider:** the prompt. It holds the template text and an issue snapshot: identifier, title, URL, team, status, priority, assignee, project, labels, parent, description, sub-issues, and links. It holds comments only when **Include comments in the prompt** is on. It also holds the project instructions and steps from the Projects settings. An attached issue sends the identifier, title, URL, status, priority, assignee, project, labels, and description.
127
+ - **Cached results:** the daemon keeps up to 300 recent Linear responses in memory for up to 24 hours. It groups them by a hash of the key, so two keys never share results. The app shows saved results at once with **Showing saved results. Updating…** while it gets new data. An edit clears the cached lists and issues for that key. Saving or removing a key clears the whole cache. The cache is not written to disk, and a daemon restart clears it.
128
+
129
+ Linear errors, such as a rejected key or a rate limit, show in the panel or as a message.
47
130
 
48
131
  ## How it works
49
132
 
50
133
  | File | Runtime | Role |
51
134
  | --- | --- | --- |
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 |
135
+ | `index.client.tsx` | App | Registers the Linear screen, the workspace panel, the Account, Prompts, and Projects settings, the command center items, the `/linear` command, the timeline card, and the composer attachment |
136
+ | `index.server.ts` | Daemon | Registers the settings and the RPC handlers |
137
+ | `client/browser.tsx` | App | Screen and panel: picks the key, then shows the list, the issue, or the agent setup page |
138
+ | `client/issue-list.tsx`, `client/issue-row.tsx`, `client/issue-tree.ts` | App | Search, filters, sort, rows, status groups, and sub-issue nesting |
139
+ | `client/issue-detail.tsx`, `client/issue-sections.tsx`, `client/breadcrumbs.tsx` | App | Issue view: properties, breadcrumbs, sub-issues, links, agents, and comments |
140
+ | `client/markdown.tsx` | App | Renders Markdown |
141
+ | `client/launch.tsx`, `client/launch-fields.tsx`, `client/launch-choices.ts`, `client/launch-plan.ts`, `client/agent-options.ts` | App | Agent setup page, Run in options, and agent start |
142
+ | `client/model-browser.tsx`, `client/provider-icon.tsx` | App | Model picker and provider icons |
143
+ | `client/create-issue.tsx`, `client/pickers.tsx` | App | New issue form and option pickers |
144
+ | `client/connect.tsx`, `client/settings-*.tsx` | App | Key form and settings screens |
145
+ | `client/queries.ts`, `client/store.ts`, `client/key-scope.tsx` | App | Data hooks with saved results, browser state, and the key in use |
146
+ | `client/compat.ts` | App | Registers the screen on Paseo 0.10 and on later releases |
147
+ | `client/timeline-card.tsx`, `client/ui.tsx`, `client/glyphs.tsx` | App | Timeline card, shared controls, and icons |
148
+ | `shared/linear.ts` | Both | RPC contracts and issue schemas |
149
+ | `shared/issues.ts` | Both | The `issues.search` RPC and the composer attachment source |
150
+ | `shared/settings.ts` | Both | Settings schema: templates, agent defaults, and project settings |
151
+ | `shared/prompts.ts` | Both | Default templates and the issue snapshot |
152
+ | `shared/markdown.ts` | Both | Markdown parser |
153
+ | `server/handlers.ts` | Daemon | RPC handlers, key lookup, and cache use |
154
+ | `server/credentials.ts` | Daemon | Key file and key order |
155
+ | `server/cache.ts` | Daemon | Response cache in memory |
156
+ | `server/graphql.ts`, `server/queries.ts` | Daemon | Linear GraphQL client, queries, and changes |
157
+ | `server/linear.ts` | Daemon | Search and snapshot text for the composer attachment |
57
158
 
58
159
  The client bundle holds no credentials and makes no calls to Linear.
59
160
 
@@ -69,7 +170,7 @@ npm run check
69
170
  paseo plugin add "$PWD"
70
171
  ```
71
172
 
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.
173
+ After you edit the source, run `paseo plugin reload linear`. `npm run check` runs the typecheck and the tests. The tests cover the Linear client, the key file, the cache, the handlers, sub-issue nesting, the Markdown parser, the agent options, and the release scripts. They use a local GraphQL server and do not call Linear.
73
174
 
74
175
  ## Graphics
75
176
 
@@ -79,7 +180,7 @@ After you edit the source, run `paseo plugin reload linear`. `npm run check` run
79
180
  node docs/graphics/render.mjs
80
181
  ```
81
182
 
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.
183
+ The script finds Playwright locally or in the global npm root. Set `PLAYWRIGHT_MODULE` to its entry file to choose another copy. It stops if the fonts do not load, if content leaves the frame or is cut off, or if an image is 900 KB or larger. The fonts are Instrument Sans and JetBrains Mono under the [SIL Open Font License](docs/graphics/fonts/OFL.txt). The line icons follow [Lucide](https://lucide.dev), which uses the ISC License. The mark is original and is not the Linear logo.
83
184
 
84
185
  ## Releases
85
186
 
@@ -98,6 +199,10 @@ The highest change since the last release sets the next version. For example, `f
98
199
 
99
200
  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
201
 
202
+ ## Contributing
203
+
204
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for setup, checks, commit message rules, and how releases work.
205
+
101
206
  ## License
102
207
 
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).
208
+ Apache License 2.0. The plugin started as the Linear example plugin (`plugin-examples/linear`) in [getpaseo/paseo](https://github.com/getpaseo/paseo). See [NOTICE](NOTICE).
@@ -0,0 +1,200 @@
1
+ // Turns the daemon's provider snapshot into Agent, Model, Effort, and Mode choices.
2
+
3
+ export interface Choice {
4
+ id: string;
5
+ label: string;
6
+ }
7
+
8
+ export interface ModelChoice extends Choice {
9
+ description: string | null;
10
+ isDefault: boolean;
11
+ efforts: Choice[];
12
+ defaultEffortId: string | null;
13
+ }
14
+
15
+ export interface ModeChoice extends Choice {
16
+ icon: string | null;
17
+ colorTier: string | null;
18
+ }
19
+
20
+ export interface AgentChoice extends Choice {
21
+ /** SVG markup for custom providers. Built-in providers have none. */
22
+ iconSvg: string | null;
23
+ models: ModelChoice[];
24
+ modes: ModeChoice[];
25
+ defaultModeId: string | null;
26
+ }
27
+
28
+ interface ThinkingOption {
29
+ id: string;
30
+ label: string;
31
+ isDefault?: boolean;
32
+ }
33
+
34
+ interface SnapshotModel {
35
+ id: string;
36
+ label: string;
37
+ description?: string;
38
+ isDefault?: boolean;
39
+ isSelectable?: boolean;
40
+ thinkingOptions?: readonly ThinkingOption[];
41
+ defaultThinkingOptionId?: string;
42
+ thinkingSet?: number;
43
+ }
44
+
45
+ interface SnapshotEntry {
46
+ provider: string;
47
+ label?: string;
48
+ iconSvg?: string;
49
+ status: string;
50
+ enabled?: boolean;
51
+ models?: readonly SnapshotModel[];
52
+ modes?: readonly (Choice & { icon?: string; colorTier?: string })[];
53
+ defaultModeId?: string | null;
54
+ }
55
+
56
+ export interface ProviderSnapshot {
57
+ entries: readonly SnapshotEntry[];
58
+ compactSnapshot?: {
59
+ entries: readonly SnapshotEntry[];
60
+ thinkingSets: readonly { options: readonly ThinkingOption[]; defaultOptionId?: string }[];
61
+ } | null;
62
+ }
63
+
64
+ // App connections get the compact catalog, where a model points into a shared list of efforts.
65
+ export function agentChoices(snapshot: ProviderSnapshot): AgentChoice[] {
66
+ const compact = snapshot.entries.length === 0 ? snapshot.compactSnapshot : null;
67
+ const entries = compact ? compact.entries : snapshot.entries;
68
+ return entries
69
+ .filter((entry) => entry.status === "ready" && entry.enabled !== false)
70
+ .map((entry) => ({
71
+ id: entry.provider,
72
+ label: entry.label ?? entry.provider,
73
+ iconSvg: entry.iconSvg ?? null,
74
+ models: (entry.models ?? [])
75
+ .filter((model) => model.isSelectable !== false)
76
+ .map((model) => {
77
+ const set =
78
+ model.thinkingSet === undefined ? null : compact?.thinkingSets[model.thinkingSet];
79
+ const options = set?.options ?? model.thinkingOptions ?? [];
80
+ const fallback = options.find((option) => option.isDefault)?.id ?? null;
81
+ return {
82
+ id: model.id,
83
+ label: model.label,
84
+ description: model.description ?? null,
85
+ isDefault: model.isDefault === true,
86
+ efforts: options.map(({ id, label }) => ({ id, label })),
87
+ defaultEffortId: model.defaultThinkingOptionId ?? set?.defaultOptionId ?? fallback,
88
+ };
89
+ }),
90
+ modes: (entry.modes ?? []).map(({ id, label, icon, colorTier }) => ({
91
+ id,
92
+ label,
93
+ icon: icon ?? null,
94
+ colorTier: colorTier ?? null,
95
+ })),
96
+ defaultModeId: entry.defaultModeId ?? null,
97
+ }))
98
+ .filter((entry) => entry.models.length > 0);
99
+ }
100
+
101
+ export interface AgentSelection {
102
+ agent: AgentChoice;
103
+ model: ModelChoice;
104
+ effort: Choice | null;
105
+ mode: ModeChoice | null;
106
+ }
107
+
108
+ export interface AgentPicks {
109
+ agent: string | null;
110
+ model: string | null;
111
+ effort: string | null;
112
+ mode: string | null;
113
+ }
114
+
115
+ /** `configured` is the settings default in `provider/model` form. Empty uses the first agent. */
116
+ export function resolveAgent(
117
+ agents: readonly AgentChoice[],
118
+ picks: AgentPicks,
119
+ configured: string,
120
+ ): AgentSelection | null {
121
+ const [configuredAgent, ...rest] = configured.split("/");
122
+ const configuredModel = rest.join("/");
123
+ const agent =
124
+ agents.find((entry) => entry.id === picks.agent) ??
125
+ agents.find((entry) => entry.id === configuredAgent) ??
126
+ agents[0];
127
+ if (!agent) return null;
128
+ const preferredModel = agent.id === configuredAgent ? configuredModel : null;
129
+ const model =
130
+ agent.models.find((entry) => entry.id === picks.model) ??
131
+ agent.models.find((entry) => entry.id === preferredModel) ??
132
+ agent.models.find((entry) => entry.isDefault) ??
133
+ agent.models[0];
134
+ if (!model) return null;
135
+ const effort =
136
+ model.efforts.find((entry) => entry.id === picks.effort) ??
137
+ model.efforts.find((entry) => entry.id === model.defaultEffortId) ??
138
+ null;
139
+ const mode =
140
+ agent.modes.find((entry) => entry.id === picks.mode) ??
141
+ agent.modes.find((entry) => entry.id === agent.defaultModeId) ??
142
+ null;
143
+ return { agent, model, effort, mode };
144
+ }
145
+
146
+ /** Config for `agents.create`. Ids come from the selection, so they always fit the model. */
147
+ export function agentConfig(selection: AgentSelection) {
148
+ return {
149
+ provider: `${selection.agent.id}/${selection.model.id}`,
150
+ ...(selection.effort ? { thinkingOptionId: selection.effort.id } : {}),
151
+ ...(selection.mode ? { modeId: selection.mode.id } : {}),
152
+ };
153
+ }
154
+
155
+ export interface ModelMatch {
156
+ agent: AgentChoice;
157
+ model: ModelChoice;
158
+ }
159
+
160
+ /** Models whose name, id, description, or agent name contain every word of the query. */
161
+ export function searchModels(agents: readonly AgentChoice[], query: string): ModelMatch[] {
162
+ const words = query.toLowerCase().split(/\s+/).filter(Boolean);
163
+ if (words.length === 0) return [];
164
+ return agents.flatMap((agent) =>
165
+ agent.models
166
+ .filter((model) => {
167
+ const text = [model.label, model.id, model.description ?? "", agent.label]
168
+ .join(" ")
169
+ .toLowerCase();
170
+ return words.every((word) => text.includes(word));
171
+ })
172
+ .map((model) => ({ agent, model })),
173
+ );
174
+ }
175
+
176
+ const MODE_ICONS = new Set([
177
+ "Bot",
178
+ "Shield",
179
+ "ShieldAlert",
180
+ "ShieldCheck",
181
+ "ShieldEllipsis",
182
+ "ShieldOff",
183
+ "ShieldPlus",
184
+ "ShieldQuestionMark",
185
+ ]);
186
+
187
+ /** The Lucide icon Paseo shows for a mode. */
188
+ export function modeIcon(mode: ModeChoice): string {
189
+ const icon = mode.icon ?? "ShieldCheck";
190
+ return MODE_ICONS.has(icon) ? icon : "Bot";
191
+ }
192
+
193
+ function sentenceCase(text: string): string {
194
+ return text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();
195
+ }
196
+
197
+ /** Effort and mode names as Paseo writes them, for example "Extra high". */
198
+ export function optionLabel(option: Choice): string {
199
+ return option.id === "xhigh" ? "Extra high" : sentenceCase(option.label);
200
+ }
@@ -0,0 +1,110 @@
1
+ import { useCallback, useMemo, useState } from "react";
2
+ import { Pressable, Text, View } from "react-native";
3
+ import type { IssueDetail, IssueRef } from "../shared/linear";
4
+ import { crumbTrail } from "./issue-tree";
5
+ import type { Theme } from "./ui";
6
+
7
+ const ROW = { flex: 1, minWidth: 0, flexDirection: "row", alignItems: "center", gap: 4 } as const;
8
+
9
+ // Team, then the parent chain, then the issue. Each parent opens that issue.
10
+ export function IssueBreadcrumbs(props: {
11
+ theme: Theme;
12
+ compact: boolean;
13
+ issue: IssueDetail;
14
+ onOpenIssue(issueId: string): void;
15
+ }) {
16
+ const { theme, compact, issue, onOpenIssue } = props;
17
+ const { colors } = theme;
18
+ const [expanded, setExpanded] = useState(false);
19
+ const styles = useMemo(
20
+ () =>
21
+ ({
22
+ muted: { color: colors.foregroundMuted, fontSize: 13, flexShrink: 1 },
23
+ link: { color: colors.foregroundMuted, fontSize: 13, textDecorationLine: "underline" },
24
+ current: { color: colors.foreground, fontSize: 13, fontWeight: "500", flexShrink: 0 },
25
+ separator: { color: colors.foregroundMuted, fontSize: 13 },
26
+ }) as const,
27
+ [colors],
28
+ );
29
+ const expand = useCallback(() => setExpanded(true), []);
30
+ const trail = crumbTrail(issue.ancestors, expanded ? issue.ancestors.length : compact ? 2 : 4);
31
+ const showTeam = !compact || issue.ancestors.length === 0;
32
+ return (
33
+ <View style={ROW} accessibilityRole="header">
34
+ {showTeam ? (
35
+ <>
36
+ <Text style={styles.muted} numberOfLines={1}>
37
+ {issue.team.name}
38
+ </Text>
39
+ <Text style={styles.separator}>›</Text>
40
+ </>
41
+ ) : null}
42
+ {trail.map((crumb) =>
43
+ crumb.kind === "more" ? (
44
+ <CrumbLink
45
+ key="more"
46
+ label="…"
47
+ accessibilityLabel={`Show ${crumb.hidden} more parent issues`}
48
+ style={styles.link}
49
+ separator={styles.separator}
50
+ onPress={expand}
51
+ />
52
+ ) : (
53
+ <ParentCrumb
54
+ key={crumb.ref.id}
55
+ parent={crumb.ref}
56
+ style={styles.link}
57
+ separator={styles.separator}
58
+ onOpenIssue={onOpenIssue}
59
+ />
60
+ ),
61
+ )}
62
+ <Text style={styles.current} numberOfLines={1}>
63
+ {issue.identifier}
64
+ </Text>
65
+ </View>
66
+ );
67
+ }
68
+
69
+ function ParentCrumb(props: {
70
+ parent: IssueRef;
71
+ style: object;
72
+ separator: object;
73
+ onOpenIssue(issueId: string): void;
74
+ }) {
75
+ const { parent, onOpenIssue } = props;
76
+ const open = useCallback(() => onOpenIssue(parent.id), [onOpenIssue, parent.id]);
77
+ return (
78
+ <CrumbLink
79
+ label={parent.identifier}
80
+ accessibilityLabel={`Open parent issue ${parent.identifier}: ${parent.title}`}
81
+ style={props.style}
82
+ separator={props.separator}
83
+ onPress={open}
84
+ />
85
+ );
86
+ }
87
+
88
+ function CrumbLink(props: {
89
+ label: string;
90
+ accessibilityLabel: string;
91
+ style: object;
92
+ separator: object;
93
+ onPress(): void;
94
+ }) {
95
+ return (
96
+ <>
97
+ <Pressable
98
+ accessibilityRole="link"
99
+ accessibilityLabel={props.accessibilityLabel}
100
+ hitSlop={4}
101
+ onPress={props.onPress}
102
+ >
103
+ <Text style={props.style} numberOfLines={1}>
104
+ {props.label}
105
+ </Text>
106
+ </Pressable>
107
+ <Text style={props.separator}>›</Text>
108
+ </>
109
+ );
110
+ }