@koinzhang/paseo-plugin-commands 0.2.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/CHANGELOG.md CHANGED
@@ -5,6 +5,19 @@ All notable changes to `@koinzhang/paseo-plugin-commands` are documented in this
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.3.0] - 2026-11-30
9
+
10
+ Requires Paseo **>= 0.16.0**.
11
+
12
+ ### Added
13
+
14
+ - `/agent [agent]` inserts another workspace agent's `paseo agent id: <id> ` into the current prompt without sending it. The picker lists other visible, unarchived agents in the same workspace, including closed agents that have not been opened on this client; passing a title or ID skips the picker.
15
+
16
+ ### Fixed
17
+
18
+ - Web pickers anchor to the measured composer icon instead of an inferred pill box.
19
+ - The picker keeps its first measured width while open, preventing the `/agent` popover from shrinking frame by frame; later layout changes still update its height.
20
+
8
21
  ## [0.2.2] - 2026-11-26
9
22
 
10
23
  Requires Paseo **>= 0.16.0**.
@@ -43,6 +56,7 @@ Requires Paseo **>= 0.9.0**.
43
56
  - `/resend [text]` agent slash command to resend the latest non-empty user prompt, appending optional text on a new line.
44
57
  - Settings → Plugins → commands → Settings: turn each slash command on or off, grouped into Runtime, Session, and Prompt sections, with a short description of what it does.
45
58
 
59
+ [0.3.0]: https://github.com/koinzhang/paseo-plugins/releases/tag/commands-v0.3.0
46
60
  [0.2.2]: https://github.com/koinzhang/paseo-plugins/releases/tag/commands-v0.2.2
47
61
  [0.2.1]: https://github.com/koinzhang/paseo-plugins/releases/tag/commands-v0.2.1
48
62
  [0.2.0]: https://github.com/koinzhang/paseo-plugins/releases/tag/commands-v0.2.0
package/README.md CHANGED
@@ -12,6 +12,7 @@ Commands:
12
12
  - `/rename [-t|-w] <title>` — rename the current tab, or the workspace with `-w`
13
13
  - `/cancel` — cancel the running turn
14
14
  - `/resend [text]` — resend the latest non-empty user prompt, appending any text on a new line
15
+ - `/agent [agent]` — insert another workspace agent's `paseo agent id: <id> ` into the current prompt
15
16
 
16
17
  Options come from what the agent's provider reports; nothing is hardcoded. Without an argument,
17
18
  a command opens a menu right away, anchored above the composer on desktop and as a sheet on
@@ -20,6 +21,9 @@ alias: an exact match wins, then a unique prefix, then a unique substring (model
20
21
  substring stage). Ambiguous input lists the candidates. `/rename` without a flag renames the
21
22
  current tab; `-t` and `--tab` do the same, and `-w` or `--workspace` renames the workspace.
22
23
  `/resend` resends the latest prompt as text, appending extra text after one newline.
24
+ `/agent` lists other visible, unarchived agents in the same workspace, including closed agents
25
+ that have not been opened on this client. Selecting one inserts its paseo agent id without sending
26
+ the prompt. Pass an agent title or ID to skip the picker.
23
27
 
24
28
  Turn individual commands on or off in **Settings → Plugins → commands → Settings**. A disabled command disappears
25
29
  from slash autocomplete, so the provider's own command of the same name (if any) takes over.
@@ -34,6 +38,7 @@ from slash autocomplete, so the provider's own command of the same name (if any)
34
38
  /rename Payment Review
35
39
  /rename -w Payments work
36
40
  /resend Also cover the empty input
41
+ /agent Reviewer
37
42
  ```
38
43
 
39
44
  ## Install
@@ -0,0 +1,23 @@
1
+ import type { PluginClientContext } from "@getpaseo/plugin/client";
2
+ import type { AgentDirectoryOption } from "../shared/agent-command.ts";
3
+
4
+ export async function loadAgentOptions(
5
+ paseo: PluginClientContext["paseo"],
6
+ ): Promise<AgentDirectoryOption[]> {
7
+ const agents = new Map<string, AgentDirectoryOption>();
8
+ let page = await paseo.agents.list({
9
+ filter: { includeArchived: true },
10
+ page: { limit: 200 },
11
+ });
12
+ for (let pages = 0; ; pages++) {
13
+ for (const { agent } of page.entries) agents.set(agent.id, agent);
14
+ if (!page.pageInfo.hasMore) return [...agents.values()];
15
+ if (!page.pageInfo.nextCursor || pages >= 99) {
16
+ throw new Error("The agent directory pagination is incomplete.");
17
+ }
18
+ page = await paseo.agents.list({
19
+ filter: { includeArchived: true },
20
+ page: { limit: 200, cursor: page.pageInfo.nextCursor },
21
+ });
22
+ }
23
+ }
@@ -9,10 +9,12 @@ import {
9
9
  planRename,
10
10
  type Plan,
11
11
  } from "../shared/commands.ts";
12
+ import { agentPromptText, listAgentOptions, planAgent } from "../shared/agent-command.ts";
12
13
  import { agentControl } from "../shared/rpc.ts";
13
14
  import { composeResendPrompt, latestUserPrompt } from "../shared/resend.ts";
15
+ import { loadAgentOptions } from "./agent-picker.ts";
14
16
  import { loadAgentState, loadProfiles } from "./agent-state.ts";
15
- import type { PickerHost, RunControl } from "./picker.tsx";
17
+ import type { PickerHost, RunPicker } from "./picker.tsx";
16
18
  import { runtimeControlNotice } from "./runtime-notice.ts";
17
19
  import { getDisabledCommands, subscribeDisabledCommands } from "./settings-store.ts";
18
20
 
@@ -37,6 +39,7 @@ type CommandSpec = CommandMetadata &
37
39
  (
38
40
  | { plan(context: Context): Promise<Plan>; execute?: never }
39
41
  | { execute(context: Context): Promise<void>; plan?: never }
42
+ | { agentPicker: true; plan?: never; execute?: never }
40
43
  );
41
44
 
42
45
  async function renameCurrent(ctx: Context): Promise<void> {
@@ -73,6 +76,16 @@ async function resendLastPrompt(ctx: Context): Promise<void> {
73
76
  }
74
77
  }
75
78
 
79
+ const AGENT_COMMAND: CommandSpec = {
80
+ name: "agent",
81
+ description: "Insert another workspace agent's paseo agent id",
82
+ details:
83
+ "Pick another visible agent in this workspace, or pass its title or ID. The ID is inserted into the current prompt without sending it.",
84
+ argumentHint: "[agent]",
85
+ section: "prompt",
86
+ agentPicker: true,
87
+ };
88
+
76
89
  export const COMMANDS: readonly CommandSpec[] = [
77
90
  {
78
91
  name: "model",
@@ -155,18 +168,23 @@ export const COMMANDS: readonly CommandSpec[] = [
155
168
  section: "prompt",
156
169
  execute: resendLastPrompt,
157
170
  },
171
+ AGENT_COMMAND,
158
172
  ];
159
173
 
160
- function controlRunner(ctx: Context): RunControl {
161
- return async (control, note) => {
174
+ function controlRunner(ctx: Context): RunPicker {
175
+ return async (entry) => {
176
+ const { control, note } = entry;
177
+ if (!control) throw new Error("This option is unavailable.");
162
178
  const { notice } = await ctx.rpc(agentControl, control);
163
179
  const warning = notice && notice.type !== "info" ? notice.message : null;
164
180
  return [note, warning].filter(Boolean).join("\n") || null;
165
181
  };
166
182
  }
167
183
 
168
- function runtimeRunner(ctx: Context): RunControl {
169
- return async (control, note) => {
184
+ function runtimeRunner(ctx: Context): RunPicker {
185
+ return async (entry) => {
186
+ const { control, note } = entry;
187
+ if (!control) throw new Error("This option is unavailable.");
170
188
  if (control.op !== "model" && control.op !== "thinking" && control.op !== "mode") {
171
189
  throw new Error("This command must use the agent control RPC.");
172
190
  }
@@ -180,6 +198,38 @@ function runtimeRunner(ctx: Context): RunControl {
180
198
  };
181
199
  }
182
200
 
201
+ async function insertAgentId(
202
+ client: PluginClientContext,
203
+ agentId: string,
204
+ targetAgentId: string,
205
+ ): Promise<void> {
206
+ const [composer] = client.composers({ agentId });
207
+ if (!composer) throw new Error("The agent's composer is unavailable.");
208
+ composer.insertText(agentPromptText(targetAgentId));
209
+ await composer.focus();
210
+ }
211
+
212
+ async function executeAgentCommand(
213
+ ctx: Context,
214
+ client: PluginClientContext,
215
+ pickers: PickerHost,
216
+ ): Promise<void> {
217
+ const options = listAgentOptions(await loadAgentOptions(ctx.paseo), {
218
+ workspaceId: ctx.workspace.id,
219
+ currentAgentId: ctx.agent.id,
220
+ });
221
+ const result = planAgent(ctx.args, options);
222
+ if (result.kind === "insert") {
223
+ await insertAgentId(client, ctx.agent.id, result.agentId);
224
+ return;
225
+ }
226
+ pickers.show({ workspaceId: ctx.workspace.id, agentId: ctx.agent.id }, result.plan, async (entry) => {
227
+ if (!entry.agentId) throw new Error("This option is unavailable.");
228
+ await insertAgentId(client, ctx.agent.id, entry.agentId);
229
+ return null;
230
+ });
231
+ }
232
+
183
233
  function addCommand(client: PluginClientContext, pickers: PickerHost, command: CommandSpec) {
184
234
  return client.addSlashCommand({
185
235
  name: command.name,
@@ -187,6 +237,10 @@ function addCommand(client: PluginClientContext, pickers: PickerHost, command: C
187
237
  argumentHint: command.argumentHint,
188
238
  context: "agent",
189
239
  async onSubmit(ctx) {
240
+ if ("agentPicker" in command) {
241
+ await executeAgentCommand({ ...ctx, args: ctx.args }, client, pickers);
242
+ return;
243
+ }
190
244
  if (command.execute) {
191
245
  await command.execute(ctx);
192
246
  return;
@@ -199,7 +253,7 @@ function addCommand(client: PluginClientContext, pickers: PickerHost, command: C
199
253
  pickers.show({ workspaceId: ctx.agent.workspaceId, agentId: ctx.agent.id }, plan, run);
200
254
  return;
201
255
  }
202
- const message = await run(plan.control, plan.note);
256
+ const message = await run({ id: plan.control.op, title: "", control: plan.control, note: plan.note });
203
257
  if (message) throw new Error(message);
204
258
  },
205
259
  });
@@ -48,6 +48,11 @@ function createStyles(theme: PluginTheme, compact: boolean) {
48
48
  color: colors.foreground,
49
49
  fontWeight: "400" as const,
50
50
  },
51
+ subtitle: {
52
+ fontSize: 11,
53
+ lineHeight: LINE_HEIGHT,
54
+ color: colors.foregroundMuted,
55
+ },
51
56
  trailing: {
52
57
  marginLeft: "auto" as const,
53
58
  alignItems: "center" as const,
@@ -89,10 +94,7 @@ export function MenuList({
89
94
  }
90
95
  return rows;
91
96
  }, [items]);
92
- const enabled = useMemo(
93
- () => leaves.filter(({ entry }) => entry.disabled !== true && entry.control),
94
- [leaves],
95
- );
97
+ const enabled = useMemo(() => leaves.filter(({ entry }) => entry.disabled !== true), [leaves]);
96
98
 
97
99
  useEffect(() => {
98
100
  if (!autoFocus) return undefined;
@@ -135,7 +137,7 @@ export function MenuList({
135
137
  }
136
138
 
137
139
  function renderRow(key: string, entry: PickerLeaf) {
138
- const disabled = entry.disabled === true || !entry.control;
140
+ const disabled = entry.disabled === true;
139
141
  return (
140
142
  <Pressable
141
143
  key={key}
@@ -163,6 +165,11 @@ export function MenuList({
163
165
  <Text numberOfLines={1} style={styles.text}>
164
166
  {entry.title}
165
167
  </Text>
168
+ {entry.subtitle ? (
169
+ <Text numberOfLines={1} style={styles.subtitle}>
170
+ {entry.subtitle}
171
+ </Text>
172
+ ) : null}
166
173
  </View>
167
174
  {entry.current ? (
168
175
  <View style={styles.trailing}>
package/client/picker.tsx CHANGED
@@ -19,19 +19,18 @@ import {
19
19
  } from "react-native";
20
20
  import type { Plan } from "../shared/commands.ts";
21
21
  import {
22
- pillRectFromIcon,
22
+ anchorRectFromIcon,
23
23
  placePopover,
24
24
  visibleHeight,
25
25
  type Rect,
26
26
  type Size,
27
27
  } from "../shared/popover-geometry.ts";
28
- import type { AgentControl } from "../shared/rpc.ts";
29
28
  import { MenuList, type PickerLeaf } from "./menu-list.tsx";
30
29
  import { openPickerPopover } from "./popover-lifecycle.ts";
31
30
 
32
31
  type PickerPlan = Extract<Plan, { kind: "picker" }>;
33
- /** Applies a control and resolves to a message to show, if any. */
34
- export type RunControl = (control: AgentControl, note?: string) => Promise<string | null>;
32
+ /** Applies a picker choice and resolves to a message to show, if any. */
33
+ export type RunPicker = (entry: PickerLeaf) => Promise<string | null>;
35
34
 
36
35
  export interface PickerTarget {
37
36
  workspaceId: string;
@@ -40,7 +39,7 @@ export interface PickerTarget {
40
39
 
41
40
  interface PickerState {
42
41
  plan: PickerPlan;
43
- run: RunControl;
42
+ run: RunPicker;
44
43
  open: boolean;
45
44
  close(): void;
46
45
  }
@@ -103,10 +102,9 @@ function surfaceStyle(theme: PluginTheme) {
103
102
  function useChoose(state: PickerState) {
104
103
  const toast = useToast();
105
104
  return (entry: PickerLeaf) => {
106
- if (!entry.control) return;
107
- const { control, note } = entry;
105
+ if (entry.disabled) return;
108
106
  state.close();
109
- state.run(control, note).then(
107
+ state.run(entry).then(
110
108
  (message) => {
111
109
  if (message) toast.show(message, { variant: "warning" });
112
110
  },
@@ -142,7 +140,9 @@ function PickerPopover({
142
140
  const statusBar = Platform.OS === "android" ? (StatusBar.currentHeight ?? 0) : 0;
143
141
  let cancelled = false;
144
142
  anchor.current?.measureInWindow((x, y, width, height) => {
145
- if (!cancelled) setTrigger(pillRectFromIcon({ x, y: y + statusBar, width, height }));
143
+ if (!cancelled) {
144
+ setTrigger(anchorRectFromIcon({ x, y: y + statusBar, width, height }, Platform.OS === "web"));
145
+ }
146
146
  });
147
147
  return () => {
148
148
  cancelled = true;
@@ -226,9 +226,9 @@ function PickerPopover({
226
226
  onLayout={(event) => {
227
227
  const { width, height } = event.nativeEvent.layout;
228
228
  setContent((current) =>
229
- current && current.width === width && current.height === height
229
+ current && current.height === height
230
230
  ? current
231
- : { width, height },
231
+ : { width: current?.width ?? width, height },
232
232
  );
233
233
  }}
234
234
  >
@@ -306,7 +306,7 @@ export function createPickerHost(client: PluginClientContext) {
306
306
  setState(agentId, null);
307
307
  }
308
308
 
309
- function show(target: PickerTarget, plan: PickerPlan, run: RunControl) {
309
+ function show(target: PickerTarget, plan: PickerPlan, run: RunPicker) {
310
310
  const { agentId } = target;
311
311
  setState(agentId, { plan, run, open: true, close: () => remove(agentId) });
312
312
  const button: PluginButton = {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@koinzhang/paseo-plugin-commands",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@koinzhang/paseo-plugin-commands",
9
- "version": "0.2.2",
9
+ "version": "0.3.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@getpaseo/client": "0.17.4",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koinzhang/paseo-plugin-commands",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "Essential client-side slash commands for controlling the current Paseo agent.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/paseo-plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "commands",
3
- "description": "Slash commands for the current agent: /model, /effort, /profile, /mode, /feature, /rename, /cancel, /resend",
3
+ "description": "Slash commands for the current agent: /model, /effort, /profile, /mode, /feature, /rename, /cancel, /resend, /agent",
4
4
  "requirements": {
5
5
  "paseo": ">=0.16.0"
6
6
  }
@@ -0,0 +1,71 @@
1
+ import type { PickerEntry, Plan } from "./commands.ts";
2
+ import { requireOption } from "./resolve-option.ts";
3
+
4
+ export interface AgentDirectoryOption {
5
+ id: string;
6
+ workspaceId?: string;
7
+ title: string | null;
8
+ provider: string;
9
+ status: string;
10
+ archivedAt?: string | null;
11
+ background?: boolean;
12
+ internal?: boolean;
13
+ }
14
+
15
+ export interface AgentPickerOption {
16
+ id: string;
17
+ label: string;
18
+ title: string;
19
+ subtitle: string;
20
+ }
21
+
22
+ export type AgentCommandPlan =
23
+ | { kind: "picker"; plan: Extract<Plan, { kind: "picker" }> }
24
+ | { kind: "insert"; agentId: string };
25
+
26
+ export function agentPromptText(agentId: string): string {
27
+ return `paseo agent id: ${agentId} `;
28
+ }
29
+
30
+ export function listAgentOptions(
31
+ agents: readonly AgentDirectoryOption[],
32
+ input: { workspaceId: string; currentAgentId: string },
33
+ ): AgentPickerOption[] {
34
+ return agents
35
+ .filter(
36
+ (agent) =>
37
+ agent.workspaceId === input.workspaceId &&
38
+ agent.id !== input.currentAgentId &&
39
+ !agent.archivedAt &&
40
+ agent.background !== true &&
41
+ agent.internal !== true,
42
+ )
43
+ .sort((left, right) => (left.title ?? left.id).localeCompare(right.title ?? right.id))
44
+ .map((agent) => {
45
+ const label = agent.title?.trim() || agent.id;
46
+ return {
47
+ id: agent.id,
48
+ label,
49
+ title: label,
50
+ subtitle: `${agent.provider} · ${agent.status} · ${agent.id}`,
51
+ };
52
+ });
53
+ }
54
+
55
+ export function planAgent(
56
+ args: string,
57
+ options: readonly AgentPickerOption[],
58
+ ): AgentCommandPlan {
59
+ if (!args.trim()) {
60
+ const items: PickerEntry[] = options.length
61
+ ? options.map((option) => ({
62
+ id: option.id,
63
+ title: option.title,
64
+ subtitle: option.subtitle,
65
+ agentId: option.id,
66
+ }))
67
+ : [{ id: "empty", title: "No other agents in this workspace", disabled: true }];
68
+ return { kind: "picker", plan: { kind: "picker", title: "Agents", icon: "Bot", items } };
69
+ }
70
+ return { kind: "insert", agentId: requireOption("agent", args, options).id };
71
+ }
@@ -56,6 +56,8 @@ export type PickerEntry =
56
56
  title: string;
57
57
  current?: boolean;
58
58
  disabled?: boolean;
59
+ subtitle?: string;
60
+ agentId?: string;
59
61
  control?: AgentControl;
60
62
  note?: string;
61
63
  }
@@ -19,8 +19,9 @@ const EDGE_PADDING = 8;
19
19
  const PILL_INSET_X = 13;
20
20
  const PILL_HEIGHT = 32;
21
21
 
22
- /** The pill's box, derived from its centred icon since only the icon is plugin-owned. */
23
- export function pillRectFromIcon(icon: Rect): Rect {
22
+ /** Web uses the measured anchor directly; other platforms retain the inferred pill box. */
23
+ export function anchorRectFromIcon(icon: Rect, isWeb: boolean): Rect {
24
+ if (isWeb) return icon;
24
25
  return {
25
26
  x: icon.x - PILL_INSET_X,
26
27
  y: icon.y + icon.height / 2 - PILL_HEIGHT / 2,