shortcutxl 0.2.12 → 0.2.13
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/README.md +26 -26
- package/agent-docs/README.md +397 -397
- package/agent-docs/docs/compaction.md +390 -390
- package/agent-docs/docs/custom-provider.md +580 -580
- package/agent-docs/docs/extensions.md +1971 -1971
- package/agent-docs/docs/packages.md +209 -209
- package/agent-docs/docs/rpc.md +1317 -1317
- package/agent-docs/docs/sdk.md +962 -962
- package/agent-docs/docs/session.md +412 -412
- package/agent-docs/docs/termux.md +127 -127
- package/agent-docs/docs/tui.md +887 -887
- package/agent-docs/examples/README.md +25 -25
- package/agent-docs/examples/extensions/README.md +205 -205
- package/agent-docs/examples/extensions/antigravity-image-gen.ts +447 -447
- package/agent-docs/examples/extensions/auto-commit-on-exit.ts +49 -49
- package/agent-docs/examples/extensions/bash-spawn-hook.ts +30 -30
- package/agent-docs/examples/extensions/bookmark.ts +50 -50
- package/agent-docs/examples/extensions/built-in-tool-renderer.ts +256 -256
- package/agent-docs/examples/extensions/claude-rules.ts +86 -86
- package/agent-docs/examples/extensions/commands.ts +75 -75
- package/agent-docs/examples/extensions/confirm-destructive.ts +59 -59
- package/agent-docs/examples/extensions/custom-compaction.ts +126 -126
- package/agent-docs/examples/extensions/custom-footer.ts +63 -63
- package/agent-docs/examples/extensions/custom-header.ts +73 -73
- package/agent-docs/examples/extensions/custom-provider-anthropic/index.ts +660 -660
- package/agent-docs/examples/extensions/custom-provider-gitlab-duo/index.ts +362 -362
- package/agent-docs/examples/extensions/custom-provider-gitlab-duo/test.ts +88 -88
- package/agent-docs/examples/extensions/custom-provider-qwen-cli/index.ts +349 -349
- package/agent-docs/examples/extensions/dirty-repo-guard.ts +56 -56
- package/agent-docs/examples/extensions/doom-overlay/doom-component.ts +133 -133
- package/agent-docs/examples/extensions/doom-overlay/doom-keys.ts +108 -108
- package/agent-docs/examples/extensions/doom-overlay/index.ts +74 -74
- package/agent-docs/examples/extensions/dynamic-resources/index.ts +15 -15
- package/agent-docs/examples/extensions/dynamic-tools.ts +77 -77
- package/agent-docs/examples/extensions/event-bus.ts +43 -43
- package/agent-docs/examples/extensions/file-trigger.ts +41 -41
- package/agent-docs/examples/extensions/git-checkpoint.ts +53 -53
- package/agent-docs/examples/extensions/handoff.ts +155 -155
- package/agent-docs/examples/extensions/hello.ts +25 -25
- package/agent-docs/examples/extensions/inline-bash.ts +94 -94
- package/agent-docs/examples/extensions/input-transform.ts +43 -43
- package/agent-docs/examples/extensions/interactive-shell.ts +209 -209
- package/agent-docs/examples/extensions/mac-system-theme.ts +47 -47
- package/agent-docs/examples/extensions/message-renderer.ts +59 -59
- package/agent-docs/examples/extensions/minimal-mode.ts +430 -430
- package/agent-docs/examples/extensions/modal-editor.ts +90 -90
- package/agent-docs/examples/extensions/model-status.ts +31 -31
- package/agent-docs/examples/extensions/notify.ts +55 -55
- package/agent-docs/examples/extensions/overlay-qa-tests.ts +936 -936
- package/agent-docs/examples/extensions/overlay-test.ts +159 -159
- package/agent-docs/examples/extensions/permission-gate.ts +37 -37
- package/agent-docs/examples/extensions/pirate.ts +47 -47
- package/agent-docs/examples/extensions/plan-mode/index.ts +363 -363
- package/agent-docs/examples/extensions/preset.ts +418 -418
- package/agent-docs/examples/extensions/protected-paths.ts +30 -30
- package/agent-docs/examples/extensions/qna.ts +122 -122
- package/agent-docs/examples/extensions/question.ts +278 -278
- package/agent-docs/examples/extensions/questionnaire.ts +440 -440
- package/agent-docs/examples/extensions/rainbow-editor.ts +90 -90
- package/agent-docs/examples/extensions/reload-runtime.ts +37 -37
- package/agent-docs/examples/extensions/rpc-demo.ts +124 -124
- package/agent-docs/examples/extensions/sandbox/index.ts +324 -324
- package/agent-docs/examples/extensions/send-user-message.ts +97 -97
- package/agent-docs/examples/extensions/session-name.ts +27 -27
- package/agent-docs/examples/extensions/shutdown-command.ts +69 -69
- package/agent-docs/examples/extensions/snake.ts +343 -343
- package/agent-docs/examples/extensions/space-invaders.ts +566 -566
- package/agent-docs/examples/extensions/ssh.ts +233 -233
- package/agent-docs/examples/extensions/status-line.ts +40 -40
- package/agent-docs/examples/extensions/subagent/agents.ts +130 -130
- package/agent-docs/examples/extensions/subagent/index.ts +1068 -1068
- package/agent-docs/examples/extensions/summarize.ts +206 -206
- package/agent-docs/examples/extensions/system-prompt-header.ts +17 -17
- package/agent-docs/examples/extensions/timed-confirm.ts +72 -72
- package/agent-docs/examples/extensions/titlebar-spinner.ts +58 -58
- package/agent-docs/examples/extensions/todo.ts +314 -314
- package/agent-docs/examples/extensions/tool-override.ts +146 -146
- package/agent-docs/examples/extensions/tools.ts +145 -145
- package/agent-docs/examples/extensions/trigger-compact.ts +40 -40
- package/agent-docs/examples/extensions/truncated-tool.ts +194 -194
- package/agent-docs/examples/extensions/widget-placement.ts +17 -17
- package/agent-docs/examples/extensions/with-deps/index.ts +37 -37
- package/agent-docs/examples/rpc-extension-ui.ts +654 -654
- package/agent-docs/examples/sdk/01-minimal.ts +22 -22
- package/agent-docs/examples/sdk/02-custom-model.ts +48 -48
- package/agent-docs/examples/sdk/03-custom-prompt.ts +55 -55
- package/agent-docs/examples/sdk/04-skills.ts +53 -53
- package/agent-docs/examples/sdk/05-tools.ts +56 -56
- package/agent-docs/examples/sdk/06-extensions.ts +88 -88
- package/agent-docs/examples/sdk/07-context-files.ts +40 -40
- package/agent-docs/examples/sdk/08-prompt-templates.ts +47 -47
- package/agent-docs/examples/sdk/09-api-keys-and-oauth.ts +48 -48
- package/agent-docs/examples/sdk/10-settings.ts +54 -54
- package/agent-docs/examples/sdk/11-sessions.ts +48 -48
- package/agent-docs/examples/sdk/12-full-control.ts +82 -82
- package/agent-docs/examples/sdk/README.md +144 -144
- package/agent-docs/xll-spec.md +110 -110
- package/dist/core/auth-storage.js +21 -2
- package/package.json +1 -1
- package/xll/ShortcutXL.xll +0 -0
- package/xll/modules/debug_render.py +272 -272
- package/xll/modules/gameboy.py +241 -241
- package/xll/modules/pong.py +188 -188
- package/xll/modules/shortcut_xl/_diff_highlight.py +176 -0
- package/xll/modules/shortcut_xl/_log.py +12 -12
- package/xll/modules/shortcut_xl/_registry.py +44 -44
- package/xll/modules/stocks.py +100 -100
- /package/skills/{com-advanced-api → COM-advanced-api}/SKILL.md +0 -0
- /package/skills/{com-advanced-api → COM-advanced-api}/excel-type-library.py +0 -0
- /package/skills/{com-advanced-api → COM-advanced-api}/office-type-library.py +0 -0
|
@@ -1,206 +1,206 @@
|
|
|
1
|
-
import type { ExtensionAPI, ExtensionCommandContext } from 'shortcutxl';
|
|
2
|
-
import {
|
|
3
|
-
complete,
|
|
4
|
-
Container,
|
|
5
|
-
DynamicBorder,
|
|
6
|
-
getMarkdownTheme,
|
|
7
|
-
getModel,
|
|
8
|
-
Markdown,
|
|
9
|
-
matchesKey,
|
|
10
|
-
Text
|
|
11
|
-
} from 'shortcutxl';
|
|
12
|
-
|
|
13
|
-
type ContentBlock = {
|
|
14
|
-
type?: string;
|
|
15
|
-
text?: string;
|
|
16
|
-
name?: string;
|
|
17
|
-
arguments?: Record<string, unknown>;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
type SessionEntry = {
|
|
21
|
-
type: string;
|
|
22
|
-
message?: {
|
|
23
|
-
role?: string;
|
|
24
|
-
content?: unknown;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const extractTextParts = (content: unknown): string[] => {
|
|
29
|
-
if (typeof content === 'string') {
|
|
30
|
-
return [content];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (!Array.isArray(content)) {
|
|
34
|
-
return [];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const textParts: string[] = [];
|
|
38
|
-
for (const part of content) {
|
|
39
|
-
if (!part || typeof part !== 'object') {
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const block = part as ContentBlock;
|
|
44
|
-
if (block.type === 'text' && typeof block.text === 'string') {
|
|
45
|
-
textParts.push(block.text);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return textParts;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const extractToolCallLines = (content: unknown): string[] => {
|
|
53
|
-
if (!Array.isArray(content)) {
|
|
54
|
-
return [];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const toolCalls: string[] = [];
|
|
58
|
-
for (const part of content) {
|
|
59
|
-
if (!part || typeof part !== 'object') {
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const block = part as ContentBlock;
|
|
64
|
-
if (block.type !== 'toolCall' || typeof block.name !== 'string') {
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const args = block.arguments ?? {};
|
|
69
|
-
toolCalls.push(`Tool ${block.name} was called with args ${JSON.stringify(args)}`);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return toolCalls;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const buildConversationText = (entries: SessionEntry[]): string => {
|
|
76
|
-
const sections: string[] = [];
|
|
77
|
-
|
|
78
|
-
for (const entry of entries) {
|
|
79
|
-
if (entry.type !== 'message' || !entry.message?.role) {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const role = entry.message.role;
|
|
84
|
-
const isUser = role === 'user';
|
|
85
|
-
const isAssistant = role === 'assistant';
|
|
86
|
-
|
|
87
|
-
if (!isUser && !isAssistant) {
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const entryLines: string[] = [];
|
|
92
|
-
const textParts = extractTextParts(entry.message.content);
|
|
93
|
-
if (textParts.length > 0) {
|
|
94
|
-
const roleLabel = isUser ? 'User' : 'Assistant';
|
|
95
|
-
const messageText = textParts.join('\n').trim();
|
|
96
|
-
if (messageText.length > 0) {
|
|
97
|
-
entryLines.push(`${roleLabel}: ${messageText}`);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (isAssistant) {
|
|
102
|
-
entryLines.push(...extractToolCallLines(entry.message.content));
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (entryLines.length > 0) {
|
|
106
|
-
sections.push(entryLines.join('\n'));
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return sections.join('\n\n');
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const buildSummaryPrompt = (conversationText: string): string =>
|
|
114
|
-
[
|
|
115
|
-
'Summarize this conversation so I can resume it later.',
|
|
116
|
-
'Include goals, key decisions, progress, open questions, and next steps.',
|
|
117
|
-
'Keep it concise and structured with headings.',
|
|
118
|
-
'',
|
|
119
|
-
'<conversation>',
|
|
120
|
-
conversationText,
|
|
121
|
-
'</conversation>'
|
|
122
|
-
].join('\n');
|
|
123
|
-
|
|
124
|
-
const showSummaryUi = async (summary: string, ctx: ExtensionCommandContext) => {
|
|
125
|
-
if (!ctx.hasUI) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
await ctx.ui.custom((_tui, theme, _kb, done) => {
|
|
130
|
-
const container = new Container();
|
|
131
|
-
const border = new DynamicBorder((s: string) => theme.fg('accent', s));
|
|
132
|
-
const mdTheme = getMarkdownTheme();
|
|
133
|
-
|
|
134
|
-
container.addChild(border);
|
|
135
|
-
container.addChild(new Text(theme.fg('accent', theme.bold('Conversation Summary')), 1, 0));
|
|
136
|
-
container.addChild(new Markdown(summary, 1, 1, mdTheme));
|
|
137
|
-
container.addChild(new Text(theme.fg('dim', 'Press Enter or Esc to close'), 1, 0));
|
|
138
|
-
container.addChild(border);
|
|
139
|
-
|
|
140
|
-
return {
|
|
141
|
-
render: (width: number) => container.render(width),
|
|
142
|
-
invalidate: () => container.invalidate(),
|
|
143
|
-
handleInput: (data: string) => {
|
|
144
|
-
if (matchesKey(data, 'enter') || matchesKey(data, 'escape')) {
|
|
145
|
-
done(undefined);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
});
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
export default function (shortcut: ExtensionAPI) {
|
|
153
|
-
shortcut.registerCommand('summarize', {
|
|
154
|
-
description: 'Summarize the current conversation in a custom UI',
|
|
155
|
-
handler: async (_args, ctx) => {
|
|
156
|
-
const branch = ctx.sessionManager.getBranch();
|
|
157
|
-
const conversationText = buildConversationText(branch);
|
|
158
|
-
|
|
159
|
-
if (!conversationText.trim()) {
|
|
160
|
-
if (ctx.hasUI) {
|
|
161
|
-
ctx.ui.notify('No conversation text found', 'warning');
|
|
162
|
-
}
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (ctx.hasUI) {
|
|
167
|
-
ctx.ui.notify('Preparing summary...', 'info');
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const model = getModel('openai', 'gpt-5.2');
|
|
171
|
-
if (!model && ctx.hasUI) {
|
|
172
|
-
ctx.ui.notify('Model openai/gpt-5.2 not found', 'warning');
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const apiKey = model ? await ctx.modelRegistry.getApiKey(model) : undefined;
|
|
176
|
-
if (!apiKey && ctx.hasUI) {
|
|
177
|
-
ctx.ui.notify('No API key for openai/gpt-5.2', 'warning');
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (!model || !apiKey) {
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const summaryMessages = [
|
|
185
|
-
{
|
|
186
|
-
role: 'user' as const,
|
|
187
|
-
content: [{ type: 'text' as const, text: buildSummaryPrompt(conversationText) }],
|
|
188
|
-
timestamp: Date.now()
|
|
189
|
-
}
|
|
190
|
-
];
|
|
191
|
-
|
|
192
|
-
const response = await complete(
|
|
193
|
-
model,
|
|
194
|
-
{ messages: summaryMessages },
|
|
195
|
-
{ apiKey, reasoningEffort: 'high' }
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
const summary = response.content
|
|
199
|
-
.filter((c): c is { type: 'text'; text: string } => c.type === 'text')
|
|
200
|
-
.map((c) => c.text)
|
|
201
|
-
.join('\n');
|
|
202
|
-
|
|
203
|
-
await showSummaryUi(summary, ctx);
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
}
|
|
1
|
+
import type { ExtensionAPI, ExtensionCommandContext } from 'shortcutxl';
|
|
2
|
+
import {
|
|
3
|
+
complete,
|
|
4
|
+
Container,
|
|
5
|
+
DynamicBorder,
|
|
6
|
+
getMarkdownTheme,
|
|
7
|
+
getModel,
|
|
8
|
+
Markdown,
|
|
9
|
+
matchesKey,
|
|
10
|
+
Text
|
|
11
|
+
} from 'shortcutxl';
|
|
12
|
+
|
|
13
|
+
type ContentBlock = {
|
|
14
|
+
type?: string;
|
|
15
|
+
text?: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
arguments?: Record<string, unknown>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type SessionEntry = {
|
|
21
|
+
type: string;
|
|
22
|
+
message?: {
|
|
23
|
+
role?: string;
|
|
24
|
+
content?: unknown;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const extractTextParts = (content: unknown): string[] => {
|
|
29
|
+
if (typeof content === 'string') {
|
|
30
|
+
return [content];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (!Array.isArray(content)) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const textParts: string[] = [];
|
|
38
|
+
for (const part of content) {
|
|
39
|
+
if (!part || typeof part !== 'object') {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const block = part as ContentBlock;
|
|
44
|
+
if (block.type === 'text' && typeof block.text === 'string') {
|
|
45
|
+
textParts.push(block.text);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return textParts;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const extractToolCallLines = (content: unknown): string[] => {
|
|
53
|
+
if (!Array.isArray(content)) {
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const toolCalls: string[] = [];
|
|
58
|
+
for (const part of content) {
|
|
59
|
+
if (!part || typeof part !== 'object') {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const block = part as ContentBlock;
|
|
64
|
+
if (block.type !== 'toolCall' || typeof block.name !== 'string') {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const args = block.arguments ?? {};
|
|
69
|
+
toolCalls.push(`Tool ${block.name} was called with args ${JSON.stringify(args)}`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return toolCalls;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const buildConversationText = (entries: SessionEntry[]): string => {
|
|
76
|
+
const sections: string[] = [];
|
|
77
|
+
|
|
78
|
+
for (const entry of entries) {
|
|
79
|
+
if (entry.type !== 'message' || !entry.message?.role) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const role = entry.message.role;
|
|
84
|
+
const isUser = role === 'user';
|
|
85
|
+
const isAssistant = role === 'assistant';
|
|
86
|
+
|
|
87
|
+
if (!isUser && !isAssistant) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const entryLines: string[] = [];
|
|
92
|
+
const textParts = extractTextParts(entry.message.content);
|
|
93
|
+
if (textParts.length > 0) {
|
|
94
|
+
const roleLabel = isUser ? 'User' : 'Assistant';
|
|
95
|
+
const messageText = textParts.join('\n').trim();
|
|
96
|
+
if (messageText.length > 0) {
|
|
97
|
+
entryLines.push(`${roleLabel}: ${messageText}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (isAssistant) {
|
|
102
|
+
entryLines.push(...extractToolCallLines(entry.message.content));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (entryLines.length > 0) {
|
|
106
|
+
sections.push(entryLines.join('\n'));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return sections.join('\n\n');
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const buildSummaryPrompt = (conversationText: string): string =>
|
|
114
|
+
[
|
|
115
|
+
'Summarize this conversation so I can resume it later.',
|
|
116
|
+
'Include goals, key decisions, progress, open questions, and next steps.',
|
|
117
|
+
'Keep it concise and structured with headings.',
|
|
118
|
+
'',
|
|
119
|
+
'<conversation>',
|
|
120
|
+
conversationText,
|
|
121
|
+
'</conversation>'
|
|
122
|
+
].join('\n');
|
|
123
|
+
|
|
124
|
+
const showSummaryUi = async (summary: string, ctx: ExtensionCommandContext) => {
|
|
125
|
+
if (!ctx.hasUI) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
await ctx.ui.custom((_tui, theme, _kb, done) => {
|
|
130
|
+
const container = new Container();
|
|
131
|
+
const border = new DynamicBorder((s: string) => theme.fg('accent', s));
|
|
132
|
+
const mdTheme = getMarkdownTheme();
|
|
133
|
+
|
|
134
|
+
container.addChild(border);
|
|
135
|
+
container.addChild(new Text(theme.fg('accent', theme.bold('Conversation Summary')), 1, 0));
|
|
136
|
+
container.addChild(new Markdown(summary, 1, 1, mdTheme));
|
|
137
|
+
container.addChild(new Text(theme.fg('dim', 'Press Enter or Esc to close'), 1, 0));
|
|
138
|
+
container.addChild(border);
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
render: (width: number) => container.render(width),
|
|
142
|
+
invalidate: () => container.invalidate(),
|
|
143
|
+
handleInput: (data: string) => {
|
|
144
|
+
if (matchesKey(data, 'enter') || matchesKey(data, 'escape')) {
|
|
145
|
+
done(undefined);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export default function (shortcut: ExtensionAPI) {
|
|
153
|
+
shortcut.registerCommand('summarize', {
|
|
154
|
+
description: 'Summarize the current conversation in a custom UI',
|
|
155
|
+
handler: async (_args, ctx) => {
|
|
156
|
+
const branch = ctx.sessionManager.getBranch();
|
|
157
|
+
const conversationText = buildConversationText(branch);
|
|
158
|
+
|
|
159
|
+
if (!conversationText.trim()) {
|
|
160
|
+
if (ctx.hasUI) {
|
|
161
|
+
ctx.ui.notify('No conversation text found', 'warning');
|
|
162
|
+
}
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (ctx.hasUI) {
|
|
167
|
+
ctx.ui.notify('Preparing summary...', 'info');
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const model = getModel('openai', 'gpt-5.2');
|
|
171
|
+
if (!model && ctx.hasUI) {
|
|
172
|
+
ctx.ui.notify('Model openai/gpt-5.2 not found', 'warning');
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const apiKey = model ? await ctx.modelRegistry.getApiKey(model) : undefined;
|
|
176
|
+
if (!apiKey && ctx.hasUI) {
|
|
177
|
+
ctx.ui.notify('No API key for openai/gpt-5.2', 'warning');
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (!model || !apiKey) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const summaryMessages = [
|
|
185
|
+
{
|
|
186
|
+
role: 'user' as const,
|
|
187
|
+
content: [{ type: 'text' as const, text: buildSummaryPrompt(conversationText) }],
|
|
188
|
+
timestamp: Date.now()
|
|
189
|
+
}
|
|
190
|
+
];
|
|
191
|
+
|
|
192
|
+
const response = await complete(
|
|
193
|
+
model,
|
|
194
|
+
{ messages: summaryMessages },
|
|
195
|
+
{ apiKey, reasoningEffort: 'high' }
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
const summary = response.content
|
|
199
|
+
.filter((c): c is { type: 'text'; text: string } => c.type === 'text')
|
|
200
|
+
.map((c) => c.text)
|
|
201
|
+
.join('\n');
|
|
202
|
+
|
|
203
|
+
await showSummaryUi(summary, ctx);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Displays a status widget showing the system prompt length.
|
|
3
|
-
*
|
|
4
|
-
* Demonstrates ctx.getSystemPrompt() for accessing the effective system prompt.
|
|
5
|
-
*/
|
|
6
|
-
import type { ExtensionAPI } from 'shortcutxl';
|
|
7
|
-
|
|
8
|
-
export default function (shortcut: ExtensionAPI) {
|
|
9
|
-
shortcut.on('agent_start', (_event, ctx) => {
|
|
10
|
-
const prompt = ctx.getSystemPrompt();
|
|
11
|
-
ctx.ui.setStatus('system-prompt', `System: ${prompt.length} chars`);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
shortcut.on('session_shutdown', (_event, ctx) => {
|
|
15
|
-
ctx.ui.setStatus('system-prompt', undefined);
|
|
16
|
-
});
|
|
17
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Displays a status widget showing the system prompt length.
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates ctx.getSystemPrompt() for accessing the effective system prompt.
|
|
5
|
+
*/
|
|
6
|
+
import type { ExtensionAPI } from 'shortcutxl';
|
|
7
|
+
|
|
8
|
+
export default function (shortcut: ExtensionAPI) {
|
|
9
|
+
shortcut.on('agent_start', (_event, ctx) => {
|
|
10
|
+
const prompt = ctx.getSystemPrompt();
|
|
11
|
+
ctx.ui.setStatus('system-prompt', `System: ${prompt.length} chars`);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
shortcut.on('session_shutdown', (_event, ctx) => {
|
|
15
|
+
ctx.ui.setStatus('system-prompt', undefined);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Example extension demonstrating timed dialogs with live countdown.
|
|
3
|
-
*
|
|
4
|
-
* Commands:
|
|
5
|
-
* - /timed - Shows confirm dialog that auto-cancels after 5 seconds with countdown
|
|
6
|
-
* - /timed-select - Shows select dialog that auto-cancels after 10 seconds with countdown
|
|
7
|
-
* - /timed-signal - Shows confirm using AbortSignal (manual approach)
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type { ExtensionAPI } from 'shortcutxl';
|
|
11
|
-
|
|
12
|
-
export default function (shortcut: ExtensionAPI) {
|
|
13
|
-
// Simple approach: use timeout option (recommended)
|
|
14
|
-
shortcut.registerCommand('timed', {
|
|
15
|
-
description: 'Show a timed confirmation dialog (auto-cancels in 5s with countdown)',
|
|
16
|
-
handler: async (_args, ctx) => {
|
|
17
|
-
const confirmed = await ctx.ui.confirm(
|
|
18
|
-
'Timed Confirmation',
|
|
19
|
-
'This dialog will auto-cancel in 5 seconds. Confirm?',
|
|
20
|
-
{ timeout: 5000 }
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
if (confirmed) {
|
|
24
|
-
ctx.ui.notify('Confirmed by user!', 'info');
|
|
25
|
-
} else {
|
|
26
|
-
ctx.ui.notify('Cancelled or timed out', 'info');
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
shortcut.registerCommand('timed-select', {
|
|
32
|
-
description: 'Show a timed select dialog (auto-cancels in 10s with countdown)',
|
|
33
|
-
handler: async (_args, ctx) => {
|
|
34
|
-
const choice = await ctx.ui.select('Pick an option', ['Option A', 'Option B', 'Option C'], {
|
|
35
|
-
timeout: 10000
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
if (choice) {
|
|
39
|
-
ctx.ui.notify(`Selected: ${choice}`, 'info');
|
|
40
|
-
} else {
|
|
41
|
-
ctx.ui.notify('Selection cancelled or timed out', 'info');
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// Manual approach: use AbortSignal for more control
|
|
47
|
-
shortcut.registerCommand('timed-signal', {
|
|
48
|
-
description: 'Show a timed confirm using AbortSignal (manual approach)',
|
|
49
|
-
handler: async (_args, ctx) => {
|
|
50
|
-
const controller = new AbortController();
|
|
51
|
-
const timeoutId = setTimeout(() => controller.abort(), 5000);
|
|
52
|
-
|
|
53
|
-
ctx.ui.notify('Dialog will auto-cancel in 5 seconds...', 'info');
|
|
54
|
-
|
|
55
|
-
const confirmed = await ctx.ui.confirm(
|
|
56
|
-
'Timed Confirmation',
|
|
57
|
-
'This dialog will auto-cancel in 5 seconds. Confirm?',
|
|
58
|
-
{ signal: controller.signal }
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
clearTimeout(timeoutId);
|
|
62
|
-
|
|
63
|
-
if (confirmed) {
|
|
64
|
-
ctx.ui.notify('Confirmed by user!', 'info');
|
|
65
|
-
} else if (controller.signal.aborted) {
|
|
66
|
-
ctx.ui.notify('Dialog timed out (auto-cancelled)', 'warning');
|
|
67
|
-
} else {
|
|
68
|
-
ctx.ui.notify('Cancelled by user', 'info');
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Example extension demonstrating timed dialogs with live countdown.
|
|
3
|
+
*
|
|
4
|
+
* Commands:
|
|
5
|
+
* - /timed - Shows confirm dialog that auto-cancels after 5 seconds with countdown
|
|
6
|
+
* - /timed-select - Shows select dialog that auto-cancels after 10 seconds with countdown
|
|
7
|
+
* - /timed-signal - Shows confirm using AbortSignal (manual approach)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { ExtensionAPI } from 'shortcutxl';
|
|
11
|
+
|
|
12
|
+
export default function (shortcut: ExtensionAPI) {
|
|
13
|
+
// Simple approach: use timeout option (recommended)
|
|
14
|
+
shortcut.registerCommand('timed', {
|
|
15
|
+
description: 'Show a timed confirmation dialog (auto-cancels in 5s with countdown)',
|
|
16
|
+
handler: async (_args, ctx) => {
|
|
17
|
+
const confirmed = await ctx.ui.confirm(
|
|
18
|
+
'Timed Confirmation',
|
|
19
|
+
'This dialog will auto-cancel in 5 seconds. Confirm?',
|
|
20
|
+
{ timeout: 5000 }
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
if (confirmed) {
|
|
24
|
+
ctx.ui.notify('Confirmed by user!', 'info');
|
|
25
|
+
} else {
|
|
26
|
+
ctx.ui.notify('Cancelled or timed out', 'info');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
shortcut.registerCommand('timed-select', {
|
|
32
|
+
description: 'Show a timed select dialog (auto-cancels in 10s with countdown)',
|
|
33
|
+
handler: async (_args, ctx) => {
|
|
34
|
+
const choice = await ctx.ui.select('Pick an option', ['Option A', 'Option B', 'Option C'], {
|
|
35
|
+
timeout: 10000
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (choice) {
|
|
39
|
+
ctx.ui.notify(`Selected: ${choice}`, 'info');
|
|
40
|
+
} else {
|
|
41
|
+
ctx.ui.notify('Selection cancelled or timed out', 'info');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Manual approach: use AbortSignal for more control
|
|
47
|
+
shortcut.registerCommand('timed-signal', {
|
|
48
|
+
description: 'Show a timed confirm using AbortSignal (manual approach)',
|
|
49
|
+
handler: async (_args, ctx) => {
|
|
50
|
+
const controller = new AbortController();
|
|
51
|
+
const timeoutId = setTimeout(() => controller.abort(), 5000);
|
|
52
|
+
|
|
53
|
+
ctx.ui.notify('Dialog will auto-cancel in 5 seconds...', 'info');
|
|
54
|
+
|
|
55
|
+
const confirmed = await ctx.ui.confirm(
|
|
56
|
+
'Timed Confirmation',
|
|
57
|
+
'This dialog will auto-cancel in 5 seconds. Confirm?',
|
|
58
|
+
{ signal: controller.signal }
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
clearTimeout(timeoutId);
|
|
62
|
+
|
|
63
|
+
if (confirmed) {
|
|
64
|
+
ctx.ui.notify('Confirmed by user!', 'info');
|
|
65
|
+
} else if (controller.signal.aborted) {
|
|
66
|
+
ctx.ui.notify('Dialog timed out (auto-cancelled)', 'warning');
|
|
67
|
+
} else {
|
|
68
|
+
ctx.ui.notify('Cancelled by user', 'info');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|