@koinzhang/paseo-plugin-commands 0.2.0 → 0.2.2
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 +21 -0
- package/README.md +7 -5
- package/client/agent-state.ts +4 -1
- package/client/commands.ts +19 -1
- package/client/picker.tsx +19 -0
- package/client/popover-lifecycle.ts +90 -0
- package/client/runtime-notice.ts +13 -0
- package/npm-shrinkwrap.json +4098 -0
- package/package.json +6 -5
- package/paseo-plugin.json +1 -1
- package/server/control.ts +30 -14
- package/shared/agent-options.ts +25 -0
- package/shared/commands.ts +19 -5
- package/shared/rpc.ts +1 -5
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,25 @@ 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.2.2] - 2026-11-26
|
|
9
|
+
|
|
10
|
+
Requires Paseo **>= 0.16.0**.
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- `/model`, `/effort`, and `/mode` use the public Composer API instead of the plugin's private daemon control connection.
|
|
15
|
+
- Align the plugin SDK and daemon client with Paseo 0.17.4.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- Desktop pickers use the native Popover lifecycle so Escape closes the menu without also triggering Paseo's global agent interrupt shortcut.
|
|
20
|
+
|
|
21
|
+
## [0.2.1] - 2026-11-06
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- Publish `npm-shrinkwrap.json` so the installed `@getpaseo/client` and `ws` tree is locked.
|
|
26
|
+
|
|
8
27
|
## [0.2.0] - 2026-11-05
|
|
9
28
|
|
|
10
29
|
Requires Paseo **>= 0.15.0**.
|
|
@@ -24,5 +43,7 @@ Requires Paseo **>= 0.9.0**.
|
|
|
24
43
|
- `/resend [text]` agent slash command to resend the latest non-empty user prompt, appending optional text on a new line.
|
|
25
44
|
- 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.
|
|
26
45
|
|
|
46
|
+
[0.2.2]: https://github.com/koinzhang/paseo-plugins/releases/tag/commands-v0.2.2
|
|
47
|
+
[0.2.1]: https://github.com/koinzhang/paseo-plugins/releases/tag/commands-v0.2.1
|
|
27
48
|
[0.2.0]: https://github.com/koinzhang/paseo-plugins/releases/tag/commands-v0.2.0
|
|
28
49
|
[0.1.0]: https://github.com/koinzhang/paseo-plugins/releases/tag/commands-v0.1.0
|
package/README.md
CHANGED
|
@@ -44,9 +44,10 @@ paseo plugin add npm:@koinzhang/paseo-plugin-commands
|
|
|
44
44
|
|
|
45
45
|
To install from GitHub, use `paseo plugin add github:koinzhang/paseo-plugins:commands`.
|
|
46
46
|
|
|
47
|
-
Requires Paseo >= 0.
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
Requires Paseo >= 0.16.0. `/model`, `/effort`, and `/mode` use the public Composer API. Profile,
|
|
48
|
+
feature, rename, and cancel controls use the daemon side of the plugin, which connects to its local
|
|
49
|
+
daemon (`PASEO_LISTEN` or `$PASEO_HOME/paseo.pid`). If the daemon requires a password, set
|
|
50
|
+
`PASEO_PASSWORD` for it.
|
|
50
51
|
|
|
51
52
|
## Development
|
|
52
53
|
|
|
@@ -60,5 +61,6 @@ paseo plugin reload commands
|
|
|
60
61
|
```
|
|
61
62
|
|
|
62
63
|
Command definitions and option matching live in `shared/` (`commands.ts`, `parse.ts`,
|
|
63
|
-
`resolve-option.ts`),
|
|
64
|
-
settings UI in `client/`. Specs are
|
|
64
|
+
`resolve-option.ts`), model / effort / mode writes use the public Composer API, the remaining
|
|
65
|
+
daemon-side controls live in `server/`, and the menus plus settings UI live in `client/`. Specs are
|
|
66
|
+
in [`specs/`](./specs/).
|
package/client/agent-state.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PluginAgentCommandContext } from "@getpaseo/plugin/client";
|
|
2
2
|
import type { AgentState, Feature, ModelOption, Profile, SelectOption } from "../shared/commands.ts";
|
|
3
|
+
import { optionFeatures } from "../shared/agent-options.ts";
|
|
3
4
|
|
|
4
5
|
type Paseo = PluginAgentCommandContext["paseo"];
|
|
5
6
|
|
|
@@ -44,7 +45,7 @@ export async function loadAgentState(
|
|
|
44
45
|
modes = (catalog.modes ?? []).map(toSelectOption);
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
const features: Feature[] = (agent
|
|
48
|
+
const features: Feature[] = optionFeatures(agent).map((feature) =>
|
|
48
49
|
feature.type === "toggle"
|
|
49
50
|
? { type: "toggle", id: feature.id, label: feature.label, value: feature.value }
|
|
50
51
|
: {
|
|
@@ -70,6 +71,8 @@ export async function loadAgentState(
|
|
|
70
71
|
models,
|
|
71
72
|
modes,
|
|
72
73
|
features,
|
|
74
|
+
controls: agent.controls,
|
|
75
|
+
options: agent.options,
|
|
73
76
|
};
|
|
74
77
|
}
|
|
75
78
|
|
package/client/commands.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { agentControl } from "../shared/rpc.ts";
|
|
|
13
13
|
import { composeResendPrompt, latestUserPrompt } from "../shared/resend.ts";
|
|
14
14
|
import { loadAgentState, loadProfiles } from "./agent-state.ts";
|
|
15
15
|
import type { PickerHost, RunControl } from "./picker.tsx";
|
|
16
|
+
import { runtimeControlNotice } from "./runtime-notice.ts";
|
|
16
17
|
import { getDisabledCommands, subscribeDisabledCommands } from "./settings-store.ts";
|
|
17
18
|
|
|
18
19
|
type Context = PluginAgentCommandContext & { args: string };
|
|
@@ -164,6 +165,21 @@ function controlRunner(ctx: Context): RunControl {
|
|
|
164
165
|
};
|
|
165
166
|
}
|
|
166
167
|
|
|
168
|
+
function runtimeRunner(ctx: Context): RunControl {
|
|
169
|
+
return async (control, note) => {
|
|
170
|
+
if (control.op !== "model" && control.op !== "thinking" && control.op !== "mode") {
|
|
171
|
+
throw new Error("This command must use the agent control RPC.");
|
|
172
|
+
}
|
|
173
|
+
const state = await loadAgentState(ctx.paseo, ctx.agent.id);
|
|
174
|
+
const [composer] = ctx.composers({ agentId: ctx.agent.id });
|
|
175
|
+
if (!composer) throw new Error("The agent's composer is unavailable.");
|
|
176
|
+
if (control.op === "model") await composer.setModel(control.modelId);
|
|
177
|
+
else if (control.op === "thinking") await composer.setThinking(control.thinkingOptionId);
|
|
178
|
+
else await composer.setMode(control.modeId);
|
|
179
|
+
return [note, runtimeControlNotice(state, control)].filter(Boolean).join("\n") || null;
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
167
183
|
function addCommand(client: PluginClientContext, pickers: PickerHost, command: CommandSpec) {
|
|
168
184
|
return client.addSlashCommand({
|
|
169
185
|
name: command.name,
|
|
@@ -176,7 +192,9 @@ function addCommand(client: PluginClientContext, pickers: PickerHost, command: C
|
|
|
176
192
|
return;
|
|
177
193
|
}
|
|
178
194
|
const plan = await command.plan(ctx);
|
|
179
|
-
const run =
|
|
195
|
+
const run = ["model", "effort", "mode"].includes(command.name)
|
|
196
|
+
? runtimeRunner(ctx)
|
|
197
|
+
: controlRunner(ctx);
|
|
180
198
|
if (plan.kind === "picker") {
|
|
181
199
|
pickers.show({ workspaceId: ctx.agent.workspaceId, agentId: ctx.agent.id }, plan, run);
|
|
182
200
|
return;
|
package/client/picker.tsx
CHANGED
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
} from "../shared/popover-geometry.ts";
|
|
28
28
|
import type { AgentControl } from "../shared/rpc.ts";
|
|
29
29
|
import { MenuList, type PickerLeaf } from "./menu-list.tsx";
|
|
30
|
+
import { openPickerPopover } from "./popover-lifecycle.ts";
|
|
30
31
|
|
|
31
32
|
type PickerPlan = Extract<Plan, { kind: "picker" }>;
|
|
32
33
|
/** Applies a control and resolves to a message to show, if any. */
|
|
@@ -128,7 +129,9 @@ function PickerPopover({
|
|
|
128
129
|
const [trigger, setTrigger] = useState<Rect | null>(null);
|
|
129
130
|
const [content, setContent] = useState<Size | null>(null);
|
|
130
131
|
const progress = useRef(new Animated.Value(0)).current;
|
|
132
|
+
const surfaceRef = useRef<View>(null);
|
|
131
133
|
const surface = useMemo(() => surfaceStyle(theme), [theme]);
|
|
134
|
+
const close = state.close;
|
|
132
135
|
|
|
133
136
|
useEffect(() => {
|
|
134
137
|
if (!state.open) {
|
|
@@ -155,6 +158,11 @@ function PickerPopover({
|
|
|
155
158
|
: null;
|
|
156
159
|
const placed = position !== null;
|
|
157
160
|
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
if (Platform.OS !== "web" || !state.open || !placed) return undefined;
|
|
163
|
+
return openPickerPopover(surfaceRef.current, close) ?? undefined;
|
|
164
|
+
}, [close, placed, state.open]);
|
|
165
|
+
|
|
158
166
|
useEffect(() => {
|
|
159
167
|
if (!placed) {
|
|
160
168
|
progress.setValue(0);
|
|
@@ -182,9 +190,20 @@ function PickerPopover({
|
|
|
182
190
|
onPress={state.close}
|
|
183
191
|
/>
|
|
184
192
|
<Animated.View
|
|
193
|
+
ref={surfaceRef}
|
|
185
194
|
accessibilityRole="menu"
|
|
186
195
|
style={[
|
|
187
196
|
surface,
|
|
197
|
+
Platform.OS === "web"
|
|
198
|
+
? {
|
|
199
|
+
right: "auto" as const,
|
|
200
|
+
bottom: "auto" as const,
|
|
201
|
+
width: visible?.width,
|
|
202
|
+
height: visible?.height,
|
|
203
|
+
margin: 0,
|
|
204
|
+
padding: 0,
|
|
205
|
+
}
|
|
206
|
+
: null,
|
|
188
207
|
{
|
|
189
208
|
left: position?.x ?? -9999,
|
|
190
209
|
top: position?.y ?? -9999,
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
interface PopoverToggleEvent {
|
|
2
|
+
newState?: string;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
interface FocusableElement {
|
|
6
|
+
focus(): void;
|
|
7
|
+
isConnected?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface PickerDocument {
|
|
11
|
+
activeElement?: unknown;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface PickerKeyboardEvent {
|
|
15
|
+
key?: string;
|
|
16
|
+
preventDefault(): void;
|
|
17
|
+
stopImmediatePropagation(): void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface PickerWindow {
|
|
21
|
+
addEventListener(type: "keydown", listener: (event: PickerKeyboardEvent) => void, capture?: boolean): void;
|
|
22
|
+
removeEventListener(type: "keydown", listener: (event: PickerKeyboardEvent) => void, capture?: boolean): void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface PopoverElement {
|
|
26
|
+
setAttribute(name: string, value: string): void;
|
|
27
|
+
addEventListener(type: "toggle", listener: (event: PopoverToggleEvent) => void): void;
|
|
28
|
+
removeEventListener(type: "toggle", listener: (event: PopoverToggleEvent) => void): void;
|
|
29
|
+
showPopover(): void;
|
|
30
|
+
hidePopover(): void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function focusable(value: unknown): FocusableElement | null {
|
|
34
|
+
return typeof value === "object" && value !== null && "focus" in value && typeof value.focus === "function"
|
|
35
|
+
? (value as FocusableElement)
|
|
36
|
+
: null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function closePicker(close: () => void, previousFocus: FocusableElement | null) {
|
|
40
|
+
close();
|
|
41
|
+
if (previousFocus?.isConnected !== false) previousFocus?.focus();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function escapeFallback(close: () => void, previousFocus: FocusableElement | null): () => void {
|
|
45
|
+
const host = globalThis as { window?: PickerWindow };
|
|
46
|
+
const target = host.window;
|
|
47
|
+
if (!target) return () => {};
|
|
48
|
+
const onKeyDown = (event: PickerKeyboardEvent) => {
|
|
49
|
+
if (event.key !== "Escape") return;
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
event.stopImmediatePropagation();
|
|
52
|
+
closePicker(close, previousFocus);
|
|
53
|
+
};
|
|
54
|
+
target.addEventListener("keydown", onKeyDown, true);
|
|
55
|
+
return () => target.removeEventListener("keydown", onKeyDown, true);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function isPopoverElement(value: unknown): value is PopoverElement {
|
|
59
|
+
if (typeof value !== "object" || value === null) return false;
|
|
60
|
+
const candidate = value as Partial<PopoverElement>;
|
|
61
|
+
return (
|
|
62
|
+
typeof candidate.setAttribute === "function" &&
|
|
63
|
+
typeof candidate.addEventListener === "function" &&
|
|
64
|
+
typeof candidate.removeEventListener === "function" &&
|
|
65
|
+
typeof candidate.showPopover === "function" &&
|
|
66
|
+
typeof candidate.hidePopover === "function"
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function openPickerPopover(element: unknown, close: () => void): (() => void) | null {
|
|
71
|
+
const host = globalThis as { document?: PickerDocument };
|
|
72
|
+
const previousFocus = focusable(host.document?.activeElement);
|
|
73
|
+
if (!isPopoverElement(element)) return escapeFallback(close, previousFocus);
|
|
74
|
+
const onToggle = (event: PopoverToggleEvent) => {
|
|
75
|
+
if (event.newState === "closed") closePicker(close, previousFocus);
|
|
76
|
+
};
|
|
77
|
+
element.setAttribute("popover", "auto");
|
|
78
|
+
element.addEventListener("toggle", onToggle);
|
|
79
|
+
try {
|
|
80
|
+
element.showPopover();
|
|
81
|
+
} catch {
|
|
82
|
+
element.removeEventListener("toggle", onToggle);
|
|
83
|
+
return escapeFallback(close, previousFocus);
|
|
84
|
+
}
|
|
85
|
+
return () => {
|
|
86
|
+
element.removeEventListener("toggle", onToggle);
|
|
87
|
+
element.hidePopover();
|
|
88
|
+
if (previousFocus?.isConnected !== false) previousFocus?.focus();
|
|
89
|
+
};
|
|
90
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AgentState } from "../shared/commands.ts";
|
|
2
|
+
import type { AgentControl } from "../shared/rpc.ts";
|
|
3
|
+
|
|
4
|
+
export function runtimeControlNotice(state: AgentState, control: AgentControl): string | null {
|
|
5
|
+
if (state.status !== "running") return null;
|
|
6
|
+
if (control.op === "thinking" && (state.provider === "codex" || state.provider === "claude")) {
|
|
7
|
+
return "Thinking level applies next turn";
|
|
8
|
+
}
|
|
9
|
+
if (control.op === "mode" && state.provider === "codex") {
|
|
10
|
+
return "Permission mode applies next turn";
|
|
11
|
+
}
|
|
12
|
+
return null;
|
|
13
|
+
}
|