wormclaude 1.0.2 → 1.0.4
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/dist/auth.js +76 -0
- package/dist/cli.js +11 -2
- package/dist/theme.js +1 -1
- package/package.json +2 -2
package/dist/auth.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import * as fs from 'node:fs';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
4
|
import * as os from 'node:os';
|
|
5
|
+
import * as readline from 'node:readline';
|
|
5
6
|
import { spawn } from 'node:child_process';
|
|
6
7
|
export const CONFIG_DIR = path.join(os.homedir(), '.wormclaude');
|
|
7
8
|
export const CONFIG_PATH = path.join(CONFIG_DIR, 'config.json');
|
|
@@ -93,6 +94,81 @@ export function runUpdate() {
|
|
|
93
94
|
child.on('exit', () => resolve());
|
|
94
95
|
});
|
|
95
96
|
}
|
|
97
|
+
// Giriş yapılmamışken `wormclaude` çalışınca gösterilen menü.
|
|
98
|
+
// ↑/↓ ok tuşlarıyla gezin, Enter ile seç. (1/2 tuşları da çalışır.)
|
|
99
|
+
export function promptLoginMenu() {
|
|
100
|
+
const items = [
|
|
101
|
+
{ label: 'Giriş yap', value: 'login' },
|
|
102
|
+
{ label: 'Çıkış', value: 'exit' },
|
|
103
|
+
];
|
|
104
|
+
return new Promise((resolve) => {
|
|
105
|
+
const stdin = process.stdin;
|
|
106
|
+
// TTY yoksa (pipe/otomasyon): tek satır oku — '2' → çıkış, aksi → giriş.
|
|
107
|
+
if (!stdin.isTTY) {
|
|
108
|
+
const rl = readline.createInterface({ input: process.stdin });
|
|
109
|
+
rl.once('line', (line) => { rl.close(); resolve(line.trim() === '2' ? 'exit' : 'login'); });
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
let idx = 0;
|
|
113
|
+
process.stdout.write('\n \x1b[1mWormClaude\x1b[0m\n');
|
|
114
|
+
process.stdout.write(' \x1b[2m↑/↓ ile seç · Enter ile onayla\x1b[0m\n\n');
|
|
115
|
+
const draw = (first) => {
|
|
116
|
+
if (!first)
|
|
117
|
+
process.stdout.write(`\x1b[${items.length}A`); // imleci listenin başına al
|
|
118
|
+
items.forEach((it, i) => {
|
|
119
|
+
const line = i === idx
|
|
120
|
+
? ` \x1b[36m❯ ${it.label}\x1b[0m`
|
|
121
|
+
: ` \x1b[2m${it.label}\x1b[0m`;
|
|
122
|
+
process.stdout.write('\x1b[2K' + line + '\n'); // satırı temizle + yaz
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
draw(true);
|
|
126
|
+
readline.emitKeypressEvents(process.stdin);
|
|
127
|
+
try {
|
|
128
|
+
stdin.setRawMode(true);
|
|
129
|
+
}
|
|
130
|
+
catch { }
|
|
131
|
+
stdin.resume();
|
|
132
|
+
const cleanup = () => {
|
|
133
|
+
process.stdin.off('keypress', onKey);
|
|
134
|
+
try {
|
|
135
|
+
stdin.setRawMode(false);
|
|
136
|
+
}
|
|
137
|
+
catch { }
|
|
138
|
+
stdin.pause();
|
|
139
|
+
process.stdout.write('\x1b[2K\n');
|
|
140
|
+
};
|
|
141
|
+
const onKey = (str, key) => {
|
|
142
|
+
if (!key)
|
|
143
|
+
return;
|
|
144
|
+
if (key.name === 'up' || key.name === 'k') {
|
|
145
|
+
idx = (idx - 1 + items.length) % items.length;
|
|
146
|
+
draw(false);
|
|
147
|
+
}
|
|
148
|
+
else if (key.name === 'down' || key.name === 'j' || key.name === 'tab') {
|
|
149
|
+
idx = (idx + 1) % items.length;
|
|
150
|
+
draw(false);
|
|
151
|
+
}
|
|
152
|
+
else if (str === '1') {
|
|
153
|
+
idx = 0;
|
|
154
|
+
draw(false);
|
|
155
|
+
}
|
|
156
|
+
else if (str === '2') {
|
|
157
|
+
idx = 1;
|
|
158
|
+
draw(false);
|
|
159
|
+
}
|
|
160
|
+
else if (key.name === 'return' || key.name === 'enter') {
|
|
161
|
+
cleanup();
|
|
162
|
+
resolve(items[idx].value);
|
|
163
|
+
}
|
|
164
|
+
else if (key.name === 'escape' || (key.ctrl && key.name === 'c')) {
|
|
165
|
+
cleanup();
|
|
166
|
+
resolve('exit');
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
process.stdin.on('keypress', onKey);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
96
172
|
export async function deviceLogin() {
|
|
97
173
|
const base = process.env.WORMCLAUDE_BASE_URL || loadStored().baseUrl || DEFAULT_BASE_URL;
|
|
98
174
|
const origin = apiOrigin(base);
|
package/dist/cli.js
CHANGED
|
@@ -40,8 +40,17 @@ if (_arg === 'login' || _arg === 'logout' || _arg === 'whoami' || _arg === '--ve
|
|
|
40
40
|
}
|
|
41
41
|
const config = loadConfig();
|
|
42
42
|
if (!config.apiKey) {
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
const _a = await import('./auth.js');
|
|
44
|
+
const _choice = await _a.promptLoginMenu();
|
|
45
|
+
if (_choice !== 'login')
|
|
46
|
+
process.exit(0);
|
|
47
|
+
await _a.deviceLogin();
|
|
48
|
+
const _fresh = loadConfig();
|
|
49
|
+
config.apiKey = _fresh.apiKey;
|
|
50
|
+
config.baseUrl = _fresh.baseUrl;
|
|
51
|
+
config.model = _fresh.model;
|
|
52
|
+
if (!config.apiKey)
|
|
53
|
+
process.exit(0);
|
|
45
54
|
}
|
|
46
55
|
let _updateLatest = null;
|
|
47
56
|
import('./auth.js').then((a) => a.checkForUpdate(VERSION)).then((v) => { _updateLatest = v; }).catch(() => { });
|
package/dist/theme.js
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wormclaude",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "WormClaude CLI - uncensored security+code assistant (ink TUI, Claude-style)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"wormclaude": "
|
|
7
|
+
"wormclaude": "dist/cli.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"dev": "tsx src/cli.tsx",
|