summon-cli 0.1.0 → 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/README.md +4 -5
- package/bin/cli.mjs +26 -24
- package/package.json +1 -1
- package/src/app.mjs +5 -2
package/README.md
CHANGED
|
@@ -21,14 +21,13 @@ Move with arrows or `j/k` or `1-9`. `Enter` launches, `Esc` quits.
|
|
|
21
21
|
|
|
22
22
|
## Commands
|
|
23
23
|
|
|
24
|
-
- `summon` open the picker
|
|
25
|
-
- `summon menu` always open the picker
|
|
24
|
+
- `summon` open the picker
|
|
26
25
|
- `summon reorder` set the order
|
|
27
|
-
- `summon default <tool>`
|
|
28
|
-
- `summon alias <name>` add another command name (e.g. `summon alias cli`)
|
|
26
|
+
- `summon default <tool>` start the cursor on it (`off` clears, no arg = pick)
|
|
27
|
+
- `summon alias <name>` add another command name (e.g. `summon alias cli`), or shortcut `summon --add <name>`
|
|
29
28
|
- `summon help`
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
Flags: `--no-logo` / `--logo` toggle the side logo (remembered). Args after `--` go to the launched tool.
|
|
32
31
|
|
|
33
32
|
## Config
|
|
34
33
|
|
package/bin/cli.mjs
CHANGED
|
@@ -23,7 +23,14 @@ const args = rawArgs.filter(arg => !arg.startsWith('-'));
|
|
|
23
23
|
const command = args[0];
|
|
24
24
|
|
|
25
25
|
const config = loadConfig();
|
|
26
|
-
|
|
26
|
+
let logo = config.logo;
|
|
27
|
+
if (flags.has('--no-logo')) {
|
|
28
|
+
logo = false;
|
|
29
|
+
saveConfig({logo: false});
|
|
30
|
+
} else if (flags.has('--logo')) {
|
|
31
|
+
logo = true;
|
|
32
|
+
saveConfig({logo: true});
|
|
33
|
+
}
|
|
27
34
|
const items = orderTools(config.order);
|
|
28
35
|
|
|
29
36
|
if (process.env.CLI_LEVEL_SNAPSHOT === '1') {
|
|
@@ -36,6 +43,11 @@ if (flags.has('--help') || flags.has('-h') || command === 'help') {
|
|
|
36
43
|
process.exit(0);
|
|
37
44
|
}
|
|
38
45
|
|
|
46
|
+
if (flags.has('--add')) {
|
|
47
|
+
runAlias(args[0]);
|
|
48
|
+
process.exit(0);
|
|
49
|
+
}
|
|
50
|
+
|
|
39
51
|
const canRenderTui = Boolean(process.stdin.isTTY && process.stdout.isTTY && process.env.TERM !== 'dumb');
|
|
40
52
|
|
|
41
53
|
switch (command) {
|
|
@@ -48,27 +60,15 @@ switch (command) {
|
|
|
48
60
|
case 'alias':
|
|
49
61
|
runAlias(args[1]);
|
|
50
62
|
break;
|
|
51
|
-
case 'menu':
|
|
52
|
-
await runMenu({forceMenu: true});
|
|
53
|
-
break;
|
|
54
63
|
case undefined:
|
|
55
|
-
await runMenu(
|
|
64
|
+
await runMenu();
|
|
56
65
|
break;
|
|
57
66
|
default:
|
|
58
67
|
process.stderr.write(`${PROG}: unknown command '${command}'. Try '${PROG} --help'.\n`);
|
|
59
68
|
process.exit(2);
|
|
60
69
|
}
|
|
61
70
|
|
|
62
|
-
async function runMenu(
|
|
63
|
-
if (!forceMenu && config.default) {
|
|
64
|
-
const tool = tools.find(item => item.id === config.default);
|
|
65
|
-
if (tool && commandExists(tool.command)) {
|
|
66
|
-
process.exitCode = await runCommand(tool.command, forwardedArgs);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
process.stderr.write(`${PROG}: default '${config.default}' unavailable, opening menu.\n`);
|
|
70
|
-
}
|
|
71
|
-
|
|
71
|
+
async function runMenu() {
|
|
72
72
|
if (!canRenderTui) {
|
|
73
73
|
process.stdout.write(renderSnapshot(0));
|
|
74
74
|
process.stderr.write(`${PROG}: interactive terminal required for selection.\n`);
|
|
@@ -114,7 +114,7 @@ async function runReorder() {
|
|
|
114
114
|
async function runDefault(target) {
|
|
115
115
|
if (target === 'off' || target === 'none') {
|
|
116
116
|
saveConfig({default: null});
|
|
117
|
-
process.stdout.write(`Default cleared.
|
|
117
|
+
process.stdout.write(`Default cleared. The cursor starts on the first tool.\n`);
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
120
|
|
|
@@ -125,7 +125,7 @@ async function runDefault(target) {
|
|
|
125
125
|
process.exit(2);
|
|
126
126
|
}
|
|
127
127
|
saveConfig({default: tool.id});
|
|
128
|
-
process.stdout.write(`Default set to ${tool.label}.
|
|
128
|
+
process.stdout.write(`Default set to ${tool.label}. The menu now opens with the cursor on it.\n`);
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
131
131
|
|
|
@@ -137,12 +137,12 @@ async function runDefault(target) {
|
|
|
137
137
|
return;
|
|
138
138
|
}
|
|
139
139
|
saveConfig({default: selected.id});
|
|
140
|
-
process.stdout.write(`Default set to ${selected.label}.
|
|
140
|
+
process.stdout.write(`Default set to ${selected.label}. The menu now opens with the cursor on it.\n`);
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
function runAlias(name) {
|
|
144
144
|
if (!name || !/^[a-zA-Z0-9._-]+$/.test(name)) {
|
|
145
|
-
process.stderr.write(`${PROG}: usage: ${PROG} alias <name
|
|
145
|
+
process.stderr.write(`${PROG}: usage: ${PROG} alias <name> (or ${PROG} --add <name>)\n`);
|
|
146
146
|
process.exit(2);
|
|
147
147
|
}
|
|
148
148
|
|
|
@@ -165,6 +165,7 @@ function chooseTool() {
|
|
|
165
165
|
instance = render(React.createElement(App, {
|
|
166
166
|
items,
|
|
167
167
|
logo,
|
|
168
|
+
initialId: config.default,
|
|
168
169
|
onCancel: () => {
|
|
169
170
|
instance.unmount();
|
|
170
171
|
resolve(null);
|
|
@@ -239,16 +240,17 @@ function printHelp() {
|
|
|
239
240
|
Summon your AI CLI. A terminal launcher.
|
|
240
241
|
|
|
241
242
|
Commands:
|
|
242
|
-
(none) Open the picker
|
|
243
|
-
menu Always open the picker (ignore the default)
|
|
243
|
+
(none) Open the picker
|
|
244
244
|
reorder Set the order tools appear in
|
|
245
|
-
default [tool]
|
|
246
|
-
'off' clears it
|
|
245
|
+
default [tool] Start the cursor on <tool>; no tool = pick one; 'off' clears
|
|
247
246
|
alias <name> Install a second command name for this launcher
|
|
247
|
+
(shortcut: ${PROG} --add <name>)
|
|
248
248
|
help Show this help
|
|
249
249
|
|
|
250
250
|
Options:
|
|
251
|
-
--
|
|
251
|
+
--add <name> Install a second command name (same as 'alias')
|
|
252
|
+
--no-logo Hide the side logo and remember it
|
|
253
|
+
--logo Show the side logo and remember it
|
|
252
254
|
|
|
253
255
|
Anything after -- is passed to the launched tool, e.g. ${PROG} -- --version
|
|
254
256
|
Config: ${configLocation()}
|
package/package.json
CHANGED
package/src/app.mjs
CHANGED
|
@@ -149,10 +149,13 @@ function LogoPanel({tool}) {
|
|
|
149
149
|
);
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
export function App({items = tools, logo = false, onSelect, onCancel}) {
|
|
152
|
+
export function App({items = tools, logo = false, initialId = null, onSelect, onCancel}) {
|
|
153
153
|
const {exit} = useApp();
|
|
154
154
|
const {stdout} = useStdout();
|
|
155
|
-
const [active, setActive] = useState(
|
|
155
|
+
const [active, setActive] = useState(() => {
|
|
156
|
+
const idx = items.findIndex(tool => tool.id === initialId);
|
|
157
|
+
return idx >= 0 ? idx : 0;
|
|
158
|
+
});
|
|
156
159
|
const [tick, setTick] = useState(0);
|
|
157
160
|
const [spin, setSpin] = useState(0);
|
|
158
161
|
const [flash, setFlash] = useState(0);
|