pi-soly 0.5.6 → 0.5.8
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/package.json +1 -1
- package/switch/index.ts +26 -9
package/package.json
CHANGED
package/switch/index.ts
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
// =============================================================================
|
|
4
4
|
//
|
|
5
5
|
// Wires the agent switcher into pi as a compact footer pill:
|
|
6
|
-
// - Footer status pill: "⚡ worker" (or
|
|
6
|
+
// - Footer status pill: "▶ ⚡ worker" (or "· ⚡ worker" for the default)
|
|
7
7
|
// - Click pill or `/agent` → open full picker modal (SelectList)
|
|
8
|
-
// - Ctrl+
|
|
8
|
+
// - Ctrl+Tab → cycle to next agent (no popup, hot switch)
|
|
9
|
+
// - F2 → same, fallback if your terminal doesn't pass Ctrl+Tab through
|
|
9
10
|
// - Persists current agent to .soly/agent or ~/.pi-switch/agent
|
|
10
11
|
// - Exposes `globalThis.__PI_SWITCH_AGENT__` for other extensions
|
|
11
12
|
// - Injects a short system-prompt section so the LLM knows the current
|
|
@@ -102,14 +103,30 @@ export default function piSwitchExtension(pi: ExtensionAPI) {
|
|
|
102
103
|
};
|
|
103
104
|
});
|
|
104
105
|
|
|
105
|
-
// -----
|
|
106
|
-
|
|
106
|
+
// ----- Hot cycle (no popup, no confirmation) -----
|
|
107
|
+
// Ctrl+Tab is the primary shortcut (most terminals support it).
|
|
108
|
+
// F2 is kept as a backup for terminals that don't pass Ctrl+Tab through.
|
|
109
|
+
// Debounced: 180ms — terminal key auto-repeat can fire the same key 5+
|
|
110
|
+
// times per second, which would spam the chat with the same agent
|
|
111
|
+
// notification. The window covers auto-repeat but allows deliberate
|
|
112
|
+
// sequential presses.
|
|
113
|
+
let lastCycleTs = 0;
|
|
114
|
+
const CYCLE_DEBOUNCE_MS = 180;
|
|
115
|
+
const cycleShortcut = (sctx: { ui: ExtensionUIContext }): void => {
|
|
116
|
+
const now = Date.now();
|
|
117
|
+
if (now - lastCycleTs < CYCLE_DEBOUNCE_MS) return;
|
|
118
|
+
lastCycleTs = now;
|
|
119
|
+
lastUi = sctx.ui;
|
|
120
|
+
refreshCycle();
|
|
121
|
+
setAgent(nextAgent(currentAgent, cycle));
|
|
122
|
+
};
|
|
123
|
+
pi.registerShortcut("ctrl+tab", {
|
|
107
124
|
description: "Cycle to next agent (worker → oracle → scout → …)",
|
|
108
|
-
handler: (sctx) =>
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
125
|
+
handler: (sctx) => cycleShortcut(sctx),
|
|
126
|
+
});
|
|
127
|
+
pi.registerShortcut("f2", {
|
|
128
|
+
description: "Cycle to next agent (F2 fallback if Ctrl+Tab isn't passed by your terminal)",
|
|
129
|
+
handler: (sctx) => cycleShortcut(sctx),
|
|
113
130
|
});
|
|
114
131
|
|
|
115
132
|
// ----- /agent: open picker, or subcommands (create / doctor / recommend / set) -----
|