paseo-quick-prompts 0.1.1 → 0.2.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 +2 -1
- package/README.md +25 -12
- package/assets/menu.png +0 -0
- package/assets/pills.png +0 -0
- package/assets/settings-light.png +0 -0
- package/assets/settings.png +0 -0
- package/client/settings-screen.tsx +135 -1
- package/client/transfer.ts +53 -0
- package/package.json +2 -1
- package/paseo-plugin.json +6 -1
package/OVERVIEW.md
CHANGED
|
@@ -12,11 +12,12 @@ Open **Settings → Plugins → paseo-quick-prompts → Quick prompts** to add,
|
|
|
12
12
|
- **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.
|
|
13
13
|
- With no prompts saved, each agent shows an **Add quick prompt** pill that opens the settings page.
|
|
14
14
|
|
|
15
|
+
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.
|
|
16
|
+
|
|
15
17
|
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
18
|
|
|
17
19
|
Prompts are stored on the Paseo host and shared by every app connected to it.
|
|
18
20
|
|
|
19
21
|
## Limits
|
|
20
22
|
|
|
21
|
-
- A pill sends right away. It does not put the text in the composer for editing first.
|
|
22
23
|
- Pills appear on existing agents, not in the composer for a new agent.
|
package/README.md
CHANGED
|
@@ -6,12 +6,24 @@ Save the messages you send often, like "Review the uncommitted changes" or "Run
|
|
|
6
6
|
failures". Each one becomes a pill above every agent's composer; tapping it sends the prompt to that
|
|
7
7
|
agent as a normal user message.
|
|
8
8
|
|
|
9
|
+
## Screenshots
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
<p align="center"><img src="assets/settings-light.png" width="320" alt="The Quick prompts settings screen in the light theme on a narrow window"></p>
|
|
18
|
+
|
|
9
19
|
## Features
|
|
10
20
|
|
|
11
21
|
- **One pill per prompt** on every agent with a workspace, in the order you set, or **one menu
|
|
12
22
|
pill** (Prompts) that lists them all with a **Manage prompts** shortcut.
|
|
13
23
|
- **Settings screen** under **Settings → Plugins → paseo-quick-prompts → Quick prompts** to add, edit, reorder, and delete
|
|
14
24
|
prompts and choose how they appear. Changes save automatically.
|
|
25
|
+
- **Export and import.** Copy your prompts as text and paste them into Quick prompts on another
|
|
26
|
+
host, adding them to its prompts or replacing them.
|
|
15
27
|
- **Prompt ideas.** A copyable prompt on the settings screen asks an agent to read your Paseo agent
|
|
16
28
|
history and suggest the quick prompts you would use most.
|
|
17
29
|
- **Shared per host.** Prompts are stored on the daemon and every connected app sees the same list;
|
|
@@ -57,6 +69,11 @@ edits** card with **Copy** and **Dismiss**.
|
|
|
57
69
|
**Show prompts as** is **Separate pills** (default) or **One menu pill**. Settings saved before this
|
|
58
70
|
option existed keep separate pills.
|
|
59
71
|
|
|
72
|
+
**Export → Copy** copies the prompts' labels and text as JSON. **Import → Import…** opens a dialog
|
|
73
|
+
to paste that text. **Add** puts the prompts after the saved ones, skipping any whose label and prompt
|
|
74
|
+
are already saved; an import that would go over 20 prompts is not saved. **Replace all** replaces the
|
|
75
|
+
saved prompts with the pasted ones. **Show prompts as** is not exported or changed by an import.
|
|
76
|
+
|
|
60
77
|
## How it works
|
|
61
78
|
|
|
62
79
|
- The settings document (`prompts`, host scope) is registered by the daemon entry and stored by Paseo.
|
|
@@ -69,8 +86,7 @@ option existed keep separate pills.
|
|
|
69
86
|
send settles and reports failures in a toast. A prompt is not sent to the same agent again while its
|
|
70
87
|
previous send is pending.
|
|
71
88
|
|
|
72
|
-
Not supported: pills in the new-agent composer
|
|
73
|
-
import or export.
|
|
89
|
+
Not supported: pills in the new-agent composer and inserting text into the composer for editing.
|
|
74
90
|
|
|
75
91
|
## Development
|
|
76
92
|
|
|
@@ -89,22 +105,19 @@ paseo plugin logs paseo-quick-prompts
|
|
|
89
105
|
| `index.client.tsx` | App entry: settings screen and composer pills |
|
|
90
106
|
| `client/pills.ts` | Keeps each agent's pills in sync with the saved prompts |
|
|
91
107
|
| `client/follow.ts` | Follows the agent directory and settings changes |
|
|
92
|
-
| `client/settings-screen.tsx` | Autosaving editor for the prompts and display option, and the prompt-ideas tip |
|
|
108
|
+
| `client/settings-screen.tsx` | Autosaving editor for the prompts and display option, export and import, and the prompt-ideas tip |
|
|
93
109
|
| `client/autosave.ts` | Save queue for the settings screen: latest values, typed drafts, the new-prompt form, conflict retry |
|
|
94
110
|
| `client/edits.ts` | Prompt edits applied to the latest values |
|
|
111
|
+
| `client/transfer.ts` | Export text, and parsing and applying an import |
|
|
95
112
|
| `shared/prompts.ts` | Settings schema and limits |
|
|
113
|
+
| `assets/` | Screenshots for this README and the plugin listing (`media` in `paseo-plugin.json`) |
|
|
96
114
|
|
|
97
115
|
## Releasing
|
|
98
116
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
`quick-prompts-v<version
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
git tag quick-prompts-v<version> && git push origin quick-prompts-v<version>
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
See the [repository README](../../README.md#releasing) for how the publish workflow works.
|
|
117
|
+
Title PRs `fix(quick-prompts): ...` or `feat(quick-prompts): ...`, then merge the release PR that
|
|
118
|
+
release-please opens. It bumps the version, updates [`CHANGELOG.md`](CHANGELOG.md), tags
|
|
119
|
+
`quick-prompts-v<version>`, creates the GitHub Release, and publishes to npm. See the
|
|
120
|
+
[repository README](../../README.md#releasing) for details.
|
|
108
121
|
|
|
109
122
|
## License
|
|
110
123
|
|
package/assets/menu.png
ADDED
|
Binary file
|
package/assets/pills.png
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,5 +1,5 @@
|
|
|
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";
|
|
2
|
+
import { copyText, Icon, Modal, TextInput as ModalTextInput, useToast } from "@getpaseo/plugin/client/react-native";
|
|
3
3
|
import { SettingsAction, SettingsCard, SettingsSection, SettingsSelect } from "@getpaseo/plugin/client/ui";
|
|
4
4
|
import { useEffect, useMemo, useRef, useState, useSyncExternalStore, type ReactNode } from "react";
|
|
5
5
|
import {
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
import { createAutosave, draftKey, orphanedDrafts, type Autosave, type AutosaveState, type Field } from "./autosave";
|
|
23
23
|
import { movePrompt, setDisplay, settingsContract, type SettingsDoc } from "./edits";
|
|
24
24
|
import { followPromptChanges } from "./follow";
|
|
25
|
+
import { exportPrompts, importPrompts, parseImport } from "./transfer";
|
|
25
26
|
|
|
26
27
|
type Settings = SettingsState<typeof quickPromptsSettings.schema>;
|
|
27
28
|
type Theme = PluginSurfaceProps["theme"];
|
|
@@ -85,6 +86,16 @@ function useStyles(theme: Theme, compact: boolean) {
|
|
|
85
86
|
backgroundColor: theme.colors.accent,
|
|
86
87
|
},
|
|
87
88
|
addText: { color: theme.colors.accentForeground, fontSize: 13 },
|
|
89
|
+
secondaryButton: {
|
|
90
|
+
height: 34,
|
|
91
|
+
paddingHorizontal: 12,
|
|
92
|
+
borderRadius: 6,
|
|
93
|
+
justifyContent: "center" as const,
|
|
94
|
+
borderWidth: 1,
|
|
95
|
+
borderColor: theme.colors.border,
|
|
96
|
+
},
|
|
97
|
+
dangerText: { color: theme.colors.statusDanger, fontSize: 13 },
|
|
98
|
+
modalActions: { flexDirection: "row" as const, justifyContent: "flex-end" as const, gap: 8 },
|
|
88
99
|
disabled: { opacity: 0.4 },
|
|
89
100
|
tipPrompt: { color: theme.colors.foreground, fontSize: 13, lineHeight: 18 },
|
|
90
101
|
}),
|
|
@@ -384,6 +395,128 @@ function UnsavedEdits({ state, store, styles }: { state: AutosaveState; store: A
|
|
|
384
395
|
);
|
|
385
396
|
}
|
|
386
397
|
|
|
398
|
+
/** Copies the prompts as text, and adds or replaces prompts from text copied on another host. */
|
|
399
|
+
function TransferPrompts({
|
|
400
|
+
state,
|
|
401
|
+
store,
|
|
402
|
+
theme,
|
|
403
|
+
styles,
|
|
404
|
+
}: {
|
|
405
|
+
state: AutosaveState;
|
|
406
|
+
store: Autosave;
|
|
407
|
+
theme: Theme;
|
|
408
|
+
styles: Styles;
|
|
409
|
+
}) {
|
|
410
|
+
const toast = useToast();
|
|
411
|
+
const [open, setOpen] = useState(false);
|
|
412
|
+
const [text, setText] = useState("");
|
|
413
|
+
const [error, setError] = useState<string | null>(null);
|
|
414
|
+
const [importing, setImporting] = useState(false);
|
|
415
|
+
// State updates land on the next render, so a second press in the same frame would save twice.
|
|
416
|
+
const busy = useRef(false);
|
|
417
|
+
const copy = async (): Promise<void> => {
|
|
418
|
+
try {
|
|
419
|
+
await copyText(exportPrompts(state.doc.values));
|
|
420
|
+
toast.show("Copied", { variant: "success" });
|
|
421
|
+
} catch {
|
|
422
|
+
toast.error("Could not copy. Try again.");
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
const runImport = async (replace: boolean): Promise<void> => {
|
|
426
|
+
if (busy.current) return;
|
|
427
|
+
const parsed = parseImport(text);
|
|
428
|
+
if ("error" in parsed) {
|
|
429
|
+
setError(parsed.error);
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
setError(null);
|
|
433
|
+
busy.current = true;
|
|
434
|
+
setImporting(true);
|
|
435
|
+
const edit = importPrompts(parsed.prompts, replace);
|
|
436
|
+
const result = await store.save(edit);
|
|
437
|
+
busy.current = false;
|
|
438
|
+
setImporting(false);
|
|
439
|
+
if (result === "saved") {
|
|
440
|
+
setText("");
|
|
441
|
+
setOpen(false);
|
|
442
|
+
toast.show(replace ? "Prompts replaced" : "Prompts added", { variant: "success" });
|
|
443
|
+
} else if (result === "unchanged") {
|
|
444
|
+
// Adding would go over the maximum, or every prompt is already saved.
|
|
445
|
+
setError(
|
|
446
|
+
edit(store.getState().doc.values)
|
|
447
|
+
? "These prompts are already saved."
|
|
448
|
+
: `That would be more than ${MAX_PROMPTS} quick prompts. Use Replace all, or delete some first.`,
|
|
449
|
+
);
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
const disabled = importing || text.trim() === "";
|
|
453
|
+
return (
|
|
454
|
+
<SettingsCard>
|
|
455
|
+
<SettingsAction
|
|
456
|
+
label="Export"
|
|
457
|
+
hint="Copy your quick prompts to import on another host."
|
|
458
|
+
actionLabel="Copy"
|
|
459
|
+
disabled={state.doc.values.prompts.length === 0}
|
|
460
|
+
onPress={() => void copy()}
|
|
461
|
+
/>
|
|
462
|
+
<SettingsAction
|
|
463
|
+
label="Import"
|
|
464
|
+
hint="Add or replace prompts with ones copied on another host."
|
|
465
|
+
actionLabel="Import…"
|
|
466
|
+
onPress={() => {
|
|
467
|
+
setError(null);
|
|
468
|
+
setOpen(true);
|
|
469
|
+
}}
|
|
470
|
+
/>
|
|
471
|
+
<Modal title="Import quick prompts" open={open} onOpenChange={setOpen}>
|
|
472
|
+
<Modal.Content>
|
|
473
|
+
<Text style={styles.intro}>
|
|
474
|
+
Paste the text copied with Export. Add puts the prompts after yours and skips ones already saved; Replace
|
|
475
|
+
all deletes your prompts first.
|
|
476
|
+
</Text>
|
|
477
|
+
<View>
|
|
478
|
+
<View style={styles.field}>
|
|
479
|
+
<ModalTextInput
|
|
480
|
+
multiline
|
|
481
|
+
accessibilityLabel="Quick prompts to import"
|
|
482
|
+
value={text}
|
|
483
|
+
placeholder="Paste prompts copied with Export"
|
|
484
|
+
placeholderTextColor={theme.colors.foregroundMuted}
|
|
485
|
+
onChangeText={(value) => {
|
|
486
|
+
setText(value);
|
|
487
|
+
setError(null);
|
|
488
|
+
}}
|
|
489
|
+
style={[styles.input, { height: LINE_HEIGHT * MAX_LINES }]}
|
|
490
|
+
/>
|
|
491
|
+
</View>
|
|
492
|
+
{error ? <Text style={styles.error}>{error}</Text> : null}
|
|
493
|
+
</View>
|
|
494
|
+
<View style={styles.modalActions}>
|
|
495
|
+
<Pressable
|
|
496
|
+
accessibilityRole="button"
|
|
497
|
+
accessibilityState={{ disabled, busy: importing }}
|
|
498
|
+
disabled={disabled}
|
|
499
|
+
onPress={() => void runImport(true)}
|
|
500
|
+
style={disabled ? [styles.secondaryButton, styles.disabled] : styles.secondaryButton}
|
|
501
|
+
>
|
|
502
|
+
<Text style={styles.dangerText}>Replace all</Text>
|
|
503
|
+
</Pressable>
|
|
504
|
+
<Pressable
|
|
505
|
+
accessibilityRole="button"
|
|
506
|
+
accessibilityState={{ disabled, busy: importing }}
|
|
507
|
+
disabled={disabled}
|
|
508
|
+
onPress={() => void runImport(false)}
|
|
509
|
+
style={disabled ? [styles.addButton, styles.disabled] : styles.addButton}
|
|
510
|
+
>
|
|
511
|
+
<Text style={styles.addText}>{importing ? "Importing…" : "Add"}</Text>
|
|
512
|
+
</Pressable>
|
|
513
|
+
</View>
|
|
514
|
+
</Modal.Content>
|
|
515
|
+
</Modal>
|
|
516
|
+
</SettingsCard>
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
|
|
387
520
|
function FindPromptsTip({ styles }: { styles: Styles }) {
|
|
388
521
|
const toast = useToast();
|
|
389
522
|
const copy = async (): Promise<void> => {
|
|
@@ -540,6 +673,7 @@ function PromptLibrary({
|
|
|
540
673
|
onValueChange={(display) => void store.save(setDisplay(display))}
|
|
541
674
|
/>
|
|
542
675
|
</SettingsCard>
|
|
676
|
+
<TransferPrompts state={state} store={store} theme={theme} styles={styles} />
|
|
543
677
|
<FindPromptsTip styles={styles} />
|
|
544
678
|
</SettingsSection>
|
|
545
679
|
);
|
|
@@ -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paseo-quick-prompts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Saved prompts as one-tap pills above every agent's composer.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"index.client.tsx",
|
|
11
11
|
"index.server.ts",
|
|
12
12
|
"index.server.tsx",
|
|
13
|
+
"assets/",
|
|
13
14
|
"client/",
|
|
14
15
|
"server/",
|
|
15
16
|
"shared/"
|