paseo-quick-prompts 0.1.2 → 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.
package/OVERVIEW.md CHANGED
@@ -1,22 +1,26 @@
1
- Quick prompts turns the messages you send often into pills above every agent's composer. Tap a pill and its text goes to that agent as your next message, the same as typing it and pressing send. If you prefer a tidier composer, show them all in one **Prompts** pill that opens a menu instead.
1
+ Quick prompts turns the messages you send often into pills above every agent's composer. Tap a pill and, by default, its text goes to that agent as your next message, the same as typing it and pressing send. If you prefer a tidier composer, show them all in one **Prompts** pill that opens a menu instead.
2
+
3
+ To edit a prompt before it goes out, turn off **Send right away**: tapping a pill or menu item then puts the prompt in that agent's composer at the cursor, ready for you to change and send.
2
4
 
3
5
  Use it for prompts you repeat across agents, such as "Review the uncommitted changes", "Run the tests and fix failures", or "Summarize what changed and open a PR".
4
6
 
5
7
  ## Settings
6
8
 
7
- Quick prompts needs Paseo 0.11.0 or later, with plugins enabled.
9
+ Quick prompts needs Paseo 0.16.0 or later, with plugins enabled.
8
10
 
9
- Open **Settings → Plugins → paseo-quick-prompts → Quick prompts** to add, edit, reorder, and delete prompts and to choose how they appear. Each one has a label, shown on the pill or menu item, and the prompt text that is sent. Changes save automatically: deleting, reordering, and the display option save right away, and an edited label or prompt saves when you leave the field. New prompts go in the last row and are added with **Add**. If another device deletes a prompt you were editing, your text stays on the page so you can copy it.
11
+ Open **Settings → Plugins → paseo-quick-prompts → Quick prompts** to add, edit, reorder, and delete prompts and to choose how they appear. Each one has a label, shown on the pill or menu item, and the prompt text that is sent (or inserted). Changes save automatically: deleting, reordering, and the display and **Send right away** options save right away, and an edited label or prompt saves when you leave the field. New prompts go in the last row and are added with **Add**. If another device deletes a prompt you were editing, your text stays on the page so you can copy it.
10
12
 
11
13
  - Up to 20 prompts. Labels can be up to 40 characters.
12
14
  - **Show prompts as** picks **Separate pills** (the default) or **One menu pill**. Either way, prompts follow the order of the list, on every agent that belongs to a workspace. The menu also has a **Manage prompts** item that opens the settings page.
15
+ - **Send right away** is on by default. Turn it off to have pills insert their prompt into the composer instead of sending it.
13
16
  - With no prompts saved, each agent shows an **Add quick prompt** pill that opens the settings page.
14
17
 
18
+ To use the same prompts on another Paseo host, press **Export → Copy**, then on the other host's settings page press **Import…**, paste the text, and choose **Add** to put the prompts after the existing ones or **Replace all** to replace them.
19
+
15
20
  The settings page also has a tip with a prompt you can copy and send to an agent, which reads your Paseo agent history and suggests the quick prompts you would use most.
16
21
 
17
22
  Prompts are stored on the Paseo host and shared by every app connected to it.
18
23
 
19
24
  ## Limits
20
25
 
21
- - A pill sends right away. It does not put the text in the composer for editing first.
22
26
  - Pills appear on existing agents, not in the composer for a new agent.
package/README.md CHANGED
@@ -4,7 +4,8 @@
4
4
 
5
5
  Save the messages you send often, like "Review the uncommitted changes" or "Run the tests and fix
6
6
  failures". Each one becomes a pill above every agent's composer; tapping it sends the prompt to that
7
- agent as a normal user message.
7
+ agent as a normal user message, or, with **Send right away** off, puts it in that agent's composer so
8
+ you can edit it first.
8
9
 
9
10
  ## Screenshots
10
11
 
@@ -20,8 +21,12 @@ agent as a normal user message.
20
21
 
21
22
  - **One pill per prompt** on every agent with a workspace, in the order you set, or **one menu
22
23
  pill** (Prompts) that lists them all with a **Manage prompts** shortcut.
24
+ - **Send right away** (on by default). Turn it off and a pill or menu item inserts its prompt into
25
+ that agent's composer at the cursor and focuses the composer, without sending.
23
26
  - **Settings screen** under **Settings → Plugins → paseo-quick-prompts → Quick prompts** to add, edit, reorder, and delete
24
27
  prompts and choose how they appear. Changes save automatically.
28
+ - **Export and import.** Copy your prompts as text and paste them into Quick prompts on another
29
+ host, adding them to its prompts or replacing them.
25
30
  - **Prompt ideas.** A copyable prompt on the settings screen asks an agent to read your Paseo agent
26
31
  history and suggest the quick prompts you would use most.
27
32
  - **Shared per host.** Prompts are stored on the daemon and every connected app sees the same list;
@@ -31,7 +36,7 @@ agent as a normal user message.
31
36
 
32
37
  ## Requirements
33
38
 
34
- - Paseo **0.11.0** or later, with plugins enabled (**Settings → Plugins → Enable plugins**, or
39
+ - Paseo **0.16.0** or later, with plugins enabled (**Settings → Plugins → Enable plugins**, or
35
40
  `"pluginsEnabled": true` in `~/.paseo/config.json`)
36
41
 
37
42
  ## Install
@@ -48,12 +53,12 @@ the latest source with `paseo plugin install github:kingsleydon/paseo-plugins:pl
48
53
  | Field | Limit | Description |
49
54
  |---|---|---|
50
55
  | Label | 1–40 characters | Text on the pill |
51
- | Prompt | 1–10,000 characters | Message sent to the agent |
56
+ | Prompt | 1–10,000 characters | Message sent to the agent, or inserted into its composer |
52
57
 
53
58
  Up to 20 prompts. Leading and trailing whitespace is trimmed when you save.
54
59
 
55
60
  Each prompt is one compact row: label, prompt text (which grows to five lines, then scrolls), and
56
- move up, move down, and delete buttons. Moving, deleting, and **Show prompts as** save right away.
61
+ move up, move down, and delete buttons. Moving, deleting, **Show prompts as**, and **Send right away** save right away.
57
62
  An edited label or prompt saves when the field loses focus, if it is valid; an invalid value shows
58
63
  an error under the field and is not saved. New prompts go in the last row and are saved with
59
64
  **Add**. The section header shows **Saving…**, **Saved**, or **Not saved** for the latest save.
@@ -67,6 +72,16 @@ edits** card with **Copy** and **Dismiss**.
67
72
  **Show prompts as** is **Separate pills** (default) or **One menu pill**. Settings saved before this
68
73
  option existed keep separate pills.
69
74
 
75
+ **Send right away** is on by default: a pill or menu item sends its prompt. Off, it inserts the
76
+ prompt into that agent's composer at the cursor (replacing any selection) and focuses the composer;
77
+ nothing is sent until you send it. It saves right away. Settings saved before this option existed
78
+ keep sending.
79
+
80
+ **Export → Copy** copies the prompts' labels and text as JSON. **Import → Import…** opens a dialog
81
+ to paste that text. **Add** puts the prompts after the saved ones, skipping any whose label and prompt
82
+ are already saved; an import that would go over 20 prompts is not saved. **Replace all** replaces the
83
+ saved prompts with the pasted ones. **Show prompts as** and **Send right away** are not exported or changed by an import.
84
+
70
85
  ## How it works
71
86
 
72
87
  - The settings document (`prompts`, host scope) is registered by the daemon entry and stored by Paseo.
@@ -75,12 +90,14 @@ option existed keep separate pills.
75
90
  prompt (or one menu pill) on each non-archived agent that has a workspace. Prompt changes update
76
91
  existing pills in place; a reorder of separate pills or a display switch re-registers that agent's
77
92
  pills. A failed observation starts again after 1, 5, 15, and 60 seconds, then stops.
78
- - A pill press or menu choice calls `paseo.agents.ref(agentId).send(text)`. Paseo shows the pill as busy until the
79
- send settles and reports failures in a toast. A prompt is not sent to the same agent again while its
80
- previous send is pending.
93
+ - A pill press or menu choice calls `paseo.agents.ref(agentId).send(text)`, or, with **Send right
94
+ away** off, takes the agent's composer from `client.composers({ agentId })` (which reaches it whether
95
+ or not its tab is open) and calls `insertText(text)` and then `focus()`, which opens the agent if it is
96
+ not on screen. Paseo shows the pill as busy until the press settles and reports failures (including
97
+ no composer for the agent) in a toast. A prompt is not sent or inserted to the same agent again
98
+ while its previous press is pending.
81
99
 
82
- Not supported: pills in the new-agent composer, inserting text into the composer for editing, and
83
- import or export.
100
+ Not supported: pills in the new-agent composer.
84
101
 
85
102
  ## Development
86
103
 
@@ -97,25 +114,21 @@ paseo plugin logs paseo-quick-prompts
97
114
  |---|---|
98
115
  | `index.server.ts` | Daemon entry: registers the settings document |
99
116
  | `index.client.tsx` | App entry: settings screen and composer pills |
100
- | `client/pills.ts` | Keeps each agent's pills in sync with the saved prompts |
117
+ | `client/pills.ts` | Keeps each agent's pills in sync with the saved prompts, and inserts into a composer |
101
118
  | `client/follow.ts` | Follows the agent directory and settings changes |
102
- | `client/settings-screen.tsx` | Autosaving editor for the prompts and display option, and the prompt-ideas tip |
119
+ | `client/settings-screen.tsx` | Autosaving editor for the prompts, display, and Send right away options, export and import, and the prompt-ideas tip |
103
120
  | `client/autosave.ts` | Save queue for the settings screen: latest values, typed drafts, the new-prompt form, conflict retry |
104
121
  | `client/edits.ts` | Prompt edits applied to the latest values |
122
+ | `client/transfer.ts` | Export text, and parsing and applying an import |
105
123
  | `shared/prompts.ts` | Settings schema and limits |
106
124
  | `assets/` | Screenshots for this README and the plugin listing (`media` in `paseo-plugin.json`) |
107
125
 
108
126
  ## Releasing
109
127
 
110
- Bump `version` in `package.json` and the two root `version` fields in `package-lock.json` in a PR
111
- (`npm version <version> --no-git-tag-version` does both), merge it, then tag the merged commit with
112
- `quick-prompts-v<version>`:
113
-
114
- ```bash
115
- git tag quick-prompts-v<version> && git push origin quick-prompts-v<version>
116
- ```
117
-
118
- See the [repository README](../../README.md#releasing) for how the publish workflow works.
128
+ Title PRs `fix(quick-prompts): ...` or `feat(quick-prompts): ...`, then merge the release PR that
129
+ release-please opens. It bumps the version, updates [`CHANGELOG.md`](CHANGELOG.md), tags
130
+ `quick-prompts-v<version>`, creates the GitHub Release, and publishes to npm. See the
131
+ [repository README](../../README.md#releasing) for details.
119
132
 
120
133
  ## License
121
134
 
package/client/edits.ts CHANGED
@@ -46,6 +46,10 @@ export function setDisplay(display: PromptDisplay): Edit {
46
46
  return (values) => ({ ...values, display });
47
47
  }
48
48
 
49
+ export function setSendRightAway(sendRightAway: boolean): Edit {
50
+ return (values) => ({ ...values, sendRightAway });
51
+ }
52
+
49
53
  /** The edit applied to `values`, or `null` when it no longer applies or the result would not save. */
50
54
  export function applyEdit(edit: Edit, values: QuickPromptsSettings): QuickPromptsSettings | null {
51
55
  const next = edit(values);
package/client/pills.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import type {
2
2
  PluginButton,
3
3
  PluginButtonRegistration,
4
+ PluginComposer,
4
5
  PluginComposerPillContribution,
6
+ PluginComposerSelector,
5
7
  } from "@getpaseo/plugin/client";
6
8
  import type { QuickPrompt, QuickPromptsSettings } from "../shared/prompts";
7
9
 
@@ -11,9 +13,26 @@ const MENU_PILL_ID = "quick-prompts";
11
13
  export interface PromptPillHost {
12
14
  addComposerPill(contribution: PluginComposerPillContribution): PluginButtonRegistration;
13
15
  send(agentId: string, text: string): Promise<void>;
16
+ /** Puts the text in the agent's composer without sending it. */
17
+ insert(agentId: string, text: string): Promise<void>;
14
18
  openSettings(): void;
15
19
  }
16
20
 
21
+ /**
22
+ * Inserts the text at the cursor of the agent's composer and focuses it. Rejects when Paseo has no
23
+ * composer for the agent or the composer refuses the text or focus; the pill shows that in a toast.
24
+ */
25
+ export async function insertIntoComposer(
26
+ composers: (selector: PluginComposerSelector) => readonly Pick<PluginComposer, "insertText" | "focus">[],
27
+ agentId: string,
28
+ text: string,
29
+ ): Promise<void> {
30
+ const [composer] = composers({ agentId });
31
+ if (!composer) throw new Error("This agent's composer is not available.");
32
+ composer.insertText(text);
33
+ await composer.focus();
34
+ }
35
+
17
36
  export interface PillAgent {
18
37
  id: string;
19
38
  workspaceId?: string | null;
@@ -63,17 +82,19 @@ export function createPromptPills(host: PromptPillHost): PromptPills {
63
82
  const targets = new Map<string, string>();
64
83
  const registered = new Map<string, AgentPills>();
65
84
  /**
66
- * Sends in flight by agent and prompt. Kept outside the registrations, which a reorder or display
67
- * switch replaces, so a replacement pill cannot send the same prompt again before the first settles.
85
+ * Sends and inserts in flight by agent, prompt, and action. Kept outside the registrations, which a
86
+ * reorder or display switch replaces, so a replacement pill cannot repeat a prompt before the first
87
+ * press settles.
68
88
  */
69
- const sending = new Map<string, Promise<void>>();
89
+ const pending = new Map<string, Promise<void>>();
70
90
 
71
- const send = (agentId: string, prompt: QuickPrompt): Promise<void> => {
72
- const key = JSON.stringify([agentId, prompt.id]);
73
- const current = sending.get(key);
91
+ const run = (agentId: string, prompt: QuickPrompt, sendRightAway: boolean): Promise<void> => {
92
+ const key = JSON.stringify([agentId, prompt.id, sendRightAway]);
93
+ const current = pending.get(key);
74
94
  if (current) return current;
75
- const next = host.send(agentId, prompt.text).finally(() => sending.delete(key));
76
- sending.set(key, next);
95
+ const press = sendRightAway ? host.send(agentId, prompt.text) : host.insert(agentId, prompt.text);
96
+ const next = press.finally(() => pending.delete(key));
97
+ pending.set(key, next);
77
98
  return next;
78
99
  };
79
100
 
@@ -88,23 +109,23 @@ export function createPromptPills(host: PromptPillHost): PromptPills {
88
109
  }),
89
110
  };
90
111
 
91
- const promptSpec = (prompt: QuickPrompt): PillSpec => ({
112
+ const promptSpec = (prompt: QuickPrompt, sendRightAway: boolean): PillSpec => ({
92
113
  id: `prompt-${prompt.id}`,
93
- content: JSON.stringify([prompt.label, prompt.text]),
114
+ content: JSON.stringify([prompt.label, prompt.text, sendRightAway]),
94
115
  button: (agentId) => ({
95
- title: `Send quick prompt: ${prompt.label}`,
116
+ title: `${sendRightAway ? "Send" : "Insert"} quick prompt: ${prompt.label}`,
96
117
  icon: "Zap",
97
118
  label: prompt.label,
98
- // Paseo marks the pill busy until the send settles and shows a failure in a toast.
99
- behavior: { kind: "action", onPress: () => send(agentId, prompt) },
119
+ // Paseo marks the pill busy until the press settles and shows a failure in a toast.
120
+ behavior: { kind: "action", onPress: () => run(agentId, prompt, sendRightAway) },
100
121
  }),
101
122
  });
102
123
 
103
- const menuSpec = (prompts: readonly QuickPrompt[]): PillSpec => ({
124
+ const menuSpec = (prompts: readonly QuickPrompt[], sendRightAway: boolean): PillSpec => ({
104
125
  id: MENU_PILL_ID,
105
- content: JSON.stringify(prompts),
126
+ content: JSON.stringify([prompts, sendRightAway]),
106
127
  button: (agentId) => ({
107
- title: "Send a quick prompt",
128
+ title: sendRightAway ? "Send a quick prompt" : "Insert a quick prompt",
108
129
  icon: "Zap",
109
130
  label: "Prompts",
110
131
  behavior: {
@@ -114,7 +135,7 @@ export function createPromptPills(host: PromptPillHost): PromptPills {
114
135
  kind: "item" as const,
115
136
  id: `prompt-${prompt.id}`,
116
137
  title: prompt.label,
117
- behavior: { kind: "action" as const, onPress: () => send(agentId, prompt) },
138
+ behavior: { kind: "action" as const, onPress: () => run(agentId, prompt, sendRightAway) },
118
139
  })),
119
140
  { kind: "separator", id: "manage-divider" },
120
141
  {
@@ -174,9 +195,10 @@ export function createPromptPills(host: PromptPillHost): PromptPills {
174
195
  };
175
196
 
176
197
  return {
177
- setSettings({ prompts, display }) {
198
+ setSettings({ prompts, display, sendRightAway }) {
178
199
  if (prompts.length === 0) specs = [addSpec];
179
- else specs = display === "menu" ? [menuSpec(prompts)] : prompts.map(promptSpec);
200
+ else if (display === "menu") specs = [menuSpec(prompts, sendRightAway)];
201
+ else specs = prompts.map((prompt) => promptSpec(prompt, sendRightAway));
180
202
  for (const [agentId, workspaceId] of targets) sync(agentId, workspaceId);
181
203
  },
182
204
  setAgents(list) {
@@ -1,6 +1,16 @@
1
1
  import { usePaseo, useRpc, useSettings, type PluginSurfaceProps, type SettingsState } from "@getpaseo/plugin/client";
2
- import { copyText, Icon, useToast } from "@getpaseo/plugin/client/react-native";
3
- import { SettingsAction, SettingsCard, SettingsSection, SettingsSelect } from "@getpaseo/plugin/client/ui";
2
+ import {
3
+ copyText,
4
+ Icon,
5
+ Modal,
6
+ TextInput as ModalTextInput,
7
+ SettingsAction,
8
+ SettingsCard,
9
+ SettingsSection,
10
+ SettingsSelect,
11
+ SettingsSwitch,
12
+ useToast,
13
+ } from "@getpaseo/plugin/client/ui";
4
14
  import { useEffect, useMemo, useRef, useState, useSyncExternalStore, type ReactNode } from "react";
5
15
  import {
6
16
  ActivityIndicator,
@@ -20,8 +30,9 @@ import {
20
30
  type QuickPrompt,
21
31
  } from "../shared/prompts";
22
32
  import { createAutosave, draftKey, orphanedDrafts, type Autosave, type AutosaveState, type Field } from "./autosave";
23
- import { movePrompt, setDisplay, settingsContract, type SettingsDoc } from "./edits";
33
+ import { movePrompt, setDisplay, setSendRightAway, settingsContract, type SettingsDoc } from "./edits";
24
34
  import { followPromptChanges } from "./follow";
35
+ import { exportPrompts, importPrompts, parseImport } from "./transfer";
25
36
 
26
37
  type Settings = SettingsState<typeof quickPromptsSettings.schema>;
27
38
  type Theme = PluginSurfaceProps["theme"];
@@ -85,6 +96,16 @@ function useStyles(theme: Theme, compact: boolean) {
85
96
  backgroundColor: theme.colors.accent,
86
97
  },
87
98
  addText: { color: theme.colors.accentForeground, fontSize: 13 },
99
+ secondaryButton: {
100
+ height: 34,
101
+ paddingHorizontal: 12,
102
+ borderRadius: 6,
103
+ justifyContent: "center" as const,
104
+ borderWidth: 1,
105
+ borderColor: theme.colors.border,
106
+ },
107
+ dangerText: { color: theme.colors.statusDanger, fontSize: 13 },
108
+ modalActions: { flexDirection: "row" as const, justifyContent: "flex-end" as const, gap: 8 },
88
109
  disabled: { opacity: 0.4 },
89
110
  tipPrompt: { color: theme.colors.foreground, fontSize: 13, lineHeight: 18 },
90
111
  }),
@@ -384,6 +405,128 @@ function UnsavedEdits({ state, store, styles }: { state: AutosaveState; store: A
384
405
  );
385
406
  }
386
407
 
408
+ /** Copies the prompts as text, and adds or replaces prompts from text copied on another host. */
409
+ function TransferPrompts({
410
+ state,
411
+ store,
412
+ theme,
413
+ styles,
414
+ }: {
415
+ state: AutosaveState;
416
+ store: Autosave;
417
+ theme: Theme;
418
+ styles: Styles;
419
+ }) {
420
+ const toast = useToast();
421
+ const [open, setOpen] = useState(false);
422
+ const [text, setText] = useState("");
423
+ const [error, setError] = useState<string | null>(null);
424
+ const [importing, setImporting] = useState(false);
425
+ // State updates land on the next render, so a second press in the same frame would save twice.
426
+ const busy = useRef(false);
427
+ const copy = async (): Promise<void> => {
428
+ try {
429
+ await copyText(exportPrompts(state.doc.values));
430
+ toast.show("Copied", { variant: "success" });
431
+ } catch {
432
+ toast.error("Could not copy. Try again.");
433
+ }
434
+ };
435
+ const runImport = async (replace: boolean): Promise<void> => {
436
+ if (busy.current) return;
437
+ const parsed = parseImport(text);
438
+ if ("error" in parsed) {
439
+ setError(parsed.error);
440
+ return;
441
+ }
442
+ setError(null);
443
+ busy.current = true;
444
+ setImporting(true);
445
+ const edit = importPrompts(parsed.prompts, replace);
446
+ const result = await store.save(edit);
447
+ busy.current = false;
448
+ setImporting(false);
449
+ if (result === "saved") {
450
+ setText("");
451
+ setOpen(false);
452
+ toast.show(replace ? "Prompts replaced" : "Prompts added", { variant: "success" });
453
+ } else if (result === "unchanged") {
454
+ // Adding would go over the maximum, or every prompt is already saved.
455
+ setError(
456
+ edit(store.getState().doc.values)
457
+ ? "These prompts are already saved."
458
+ : `That would be more than ${MAX_PROMPTS} quick prompts. Use Replace all, or delete some first.`,
459
+ );
460
+ }
461
+ };
462
+ const disabled = importing || text.trim() === "";
463
+ return (
464
+ <SettingsCard>
465
+ <SettingsAction
466
+ label="Export"
467
+ hint="Copy your quick prompts to import on another host."
468
+ actionLabel="Copy"
469
+ disabled={state.doc.values.prompts.length === 0}
470
+ onPress={() => void copy()}
471
+ />
472
+ <SettingsAction
473
+ label="Import"
474
+ hint="Add or replace prompts with ones copied on another host."
475
+ actionLabel="Import…"
476
+ onPress={() => {
477
+ setError(null);
478
+ setOpen(true);
479
+ }}
480
+ />
481
+ <Modal title="Import quick prompts" open={open} onOpenChange={setOpen}>
482
+ <Modal.Content>
483
+ <Text style={styles.intro}>
484
+ Paste the text copied with Export. Add puts the prompts after yours and skips ones already saved; Replace
485
+ all deletes your prompts first.
486
+ </Text>
487
+ <View>
488
+ <View style={styles.field}>
489
+ <ModalTextInput
490
+ multiline
491
+ accessibilityLabel="Quick prompts to import"
492
+ value={text}
493
+ placeholder="Paste prompts copied with Export"
494
+ placeholderTextColor={theme.colors.foregroundMuted}
495
+ onChangeText={(value) => {
496
+ setText(value);
497
+ setError(null);
498
+ }}
499
+ style={[styles.input, { height: LINE_HEIGHT * MAX_LINES }]}
500
+ />
501
+ </View>
502
+ {error ? <Text style={styles.error}>{error}</Text> : null}
503
+ </View>
504
+ <View style={styles.modalActions}>
505
+ <Pressable
506
+ accessibilityRole="button"
507
+ accessibilityState={{ disabled, busy: importing }}
508
+ disabled={disabled}
509
+ onPress={() => void runImport(true)}
510
+ style={disabled ? [styles.secondaryButton, styles.disabled] : styles.secondaryButton}
511
+ >
512
+ <Text style={styles.dangerText}>Replace all</Text>
513
+ </Pressable>
514
+ <Pressable
515
+ accessibilityRole="button"
516
+ accessibilityState={{ disabled, busy: importing }}
517
+ disabled={disabled}
518
+ onPress={() => void runImport(false)}
519
+ style={disabled ? [styles.addButton, styles.disabled] : styles.addButton}
520
+ >
521
+ <Text style={styles.addText}>{importing ? "Importing…" : "Add"}</Text>
522
+ </Pressable>
523
+ </View>
524
+ </Modal.Content>
525
+ </Modal>
526
+ </SettingsCard>
527
+ );
528
+ }
529
+
387
530
  function FindPromptsTip({ styles }: { styles: Styles }) {
388
531
  const toast = useToast();
389
532
  const copy = async (): Promise<void> => {
@@ -493,7 +636,8 @@ function PromptLibrary({
493
636
  >
494
637
  <Text style={styles.intro}>
495
638
  Quick prompts appear above every agent's composer, as separate pills or in one Prompts menu. Choosing one
496
- sends the prompt to that agent as your message. Changes save automatically.
639
+ sends the prompt to that agent, or with Send right away off, puts it in the composer. Changes save
640
+ automatically.
497
641
  </Text>
498
642
  <LoadProblem
499
643
  settings={settings}
@@ -539,7 +683,14 @@ function PromptLibrary({
539
683
  options={DISPLAY_OPTIONS}
540
684
  onValueChange={(display) => void store.save(setDisplay(display))}
541
685
  />
686
+ <SettingsSwitch
687
+ label="Send right away"
688
+ hint="On: a prompt is sent when you tap it. Off: it goes into the composer so you can edit it first."
689
+ value={state.doc.values.sendRightAway}
690
+ onValueChange={(sendRightAway) => void store.save(setSendRightAway(sendRightAway))}
691
+ />
542
692
  </SettingsCard>
693
+ <TransferPrompts state={state} store={store} theme={theme} styles={styles} />
543
694
  <FindPromptsTip styles={styles} />
544
695
  </SettingsSection>
545
696
  );
@@ -0,0 +1,53 @@
1
+ import { MAX_PROMPTS, newPromptId, QuickPromptSchema, type QuickPrompt, type QuickPromptsSettings } from "../shared/prompts";
2
+ import type { Edit } from "./edits";
3
+
4
+ /** Names the exported text so it is recognizable when pasted elsewhere. */
5
+ const EXPORT_FORMAT = "paseo-quick-prompts";
6
+
7
+ const ImportedPromptSchema = QuickPromptSchema.omit({ id: true });
8
+
9
+ type ImportedPrompt = Omit<QuickPrompt, "id">;
10
+
11
+ /** The prompts as JSON text, without ids, for importing on another host. */
12
+ export function exportPrompts(values: QuickPromptsSettings): string {
13
+ const prompts = values.prompts.map(({ label, text }) => ({ label, text }));
14
+ return JSON.stringify({ format: EXPORT_FORMAT, version: 1, prompts }, null, 2);
15
+ }
16
+
17
+ /** The prompts in exported text, or the first problem with it. */
18
+ export function parseImport(text: string): { prompts: ImportedPrompt[] } | { error: string } {
19
+ let data: unknown;
20
+ try {
21
+ data = JSON.parse(text);
22
+ } catch {
23
+ return { error: "Paste the text copied with Export." };
24
+ }
25
+ const list = typeof data === "object" && data !== null && "prompts" in data ? data.prompts : undefined;
26
+ if (!Array.isArray(list)) return { error: "Paste the text copied with Export." };
27
+ if (list.length === 0) return { error: "There are no prompts to import." };
28
+ if (list.length > MAX_PROMPTS) return { error: `Import at most ${MAX_PROMPTS} quick prompts.` };
29
+ const prompts: ImportedPrompt[] = [];
30
+ for (const [index, item] of list.entries()) {
31
+ const parsed = ImportedPromptSchema.safeParse(item);
32
+ if (!parsed.success) {
33
+ return { error: `Prompt ${index + 1}: ${parsed.error.issues[0]?.message ?? "Invalid prompt"}` };
34
+ }
35
+ prompts.push(parsed.data);
36
+ }
37
+ return { prompts };
38
+ }
39
+
40
+ /**
41
+ * Replaces the saved prompts with `imported`, or adds the ones not saved yet (same label and
42
+ * prompt) after them. Adding does not apply when the result would be over the maximum.
43
+ */
44
+ export function importPrompts(imported: ImportedPrompt[], replace: boolean): Edit {
45
+ // Ids are made once so a retried save sends the same prompts. The index keeps them unique.
46
+ const withIds = imported.map((prompt, index) => ({ id: newPromptId() + index.toString(36), ...prompt }));
47
+ return (values) => {
48
+ if (replace) return { ...values, prompts: withIds };
49
+ const saved = new Set(values.prompts.map(({ label, text }) => JSON.stringify([label, text])));
50
+ const added = withIds.filter(({ label, text }) => !saved.has(JSON.stringify([label, text])));
51
+ return values.prompts.length + added.length <= MAX_PROMPTS ? { ...values, prompts: [...values.prompts, ...added] } : null;
52
+ };
53
+ }
package/index.client.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { PluginClientContext } from "@getpaseo/plugin/client";
2
2
  import { followAgents, followPrompts } from "./client/follow";
3
- import { createPromptPills } from "./client/pills";
3
+ import { createPromptPills, insertIntoComposer } from "./client/pills";
4
4
  import { QuickPromptsSettingsScreen } from "./client/settings-screen";
5
5
 
6
6
  const SETTINGS_SCREEN_ID = "quick-prompts";
@@ -16,6 +16,7 @@ export default function contribute(client: PluginClientContext) {
16
16
  const pills = createPromptPills({
17
17
  addComposerPill: (contribution) => client.addComposerPill(contribution),
18
18
  send: (agentId, text) => client.paseo.agents.ref(agentId).send(text),
19
+ insert: (agentId, text) => insertIntoComposer((selector) => client.composers(selector), agentId, text),
19
20
  openSettings: () => client.openSettings(SETTINGS_SCREEN_ID),
20
21
  });
21
22
  const lifetime = new AbortController();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paseo-quick-prompts",
3
- "version": "0.1.2",
3
+ "version": "0.3.0",
4
4
  "description": "Saved prompts as one-tap pills above every agent's composer.",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -20,7 +20,7 @@
20
20
  "test": "vitest run"
21
21
  },
22
22
  "devDependencies": {
23
- "@getpaseo/plugin": "0.11.2",
23
+ "@getpaseo/plugin": "0.17.5",
24
24
  "@tanstack/react-query": "^5.90.11",
25
25
  "@types/react": "~19.2.0",
26
26
  "react": "19.1.0",
package/paseo-plugin.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "Quick prompts",
4
4
  "description": "Saved prompts as one-tap pills above every agent's composer.",
5
5
  "requirements": {
6
- "paseo": ">=0.11.0"
6
+ "paseo": ">=0.16.0"
7
7
  },
8
8
  "media": [
9
9
  "assets/pills.png",
package/shared/prompts.ts CHANGED
@@ -41,6 +41,9 @@ export const quickPromptsSettings = defineSettings({
41
41
  // Documents saved before this field existed, or with a display this version does not know,
42
42
  // keep separate pills and their prompts.
43
43
  display: z.enum(PROMPT_DISPLAYS).catch("pills"),
44
+ // Whether a prompt pill sends its prompt or inserts it into the composer. Documents saved
45
+ // before this field existed keep sending.
46
+ sendRightAway: z.boolean().catch(true),
44
47
  }),
45
48
  });
46
49