@plosson/agentio 0.3.0 → 0.3.1
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/src/commands/config.ts +43 -0
package/package.json
CHANGED
package/src/commands/config.ts
CHANGED
|
@@ -3,12 +3,27 @@ import { createCipheriv, createDecipheriv, randomBytes, scryptSync } from 'crypt
|
|
|
3
3
|
import { readFile, writeFile } from 'fs/promises';
|
|
4
4
|
import { existsSync } from 'fs';
|
|
5
5
|
import { join } from 'path';
|
|
6
|
+
import { createInterface } from 'readline';
|
|
6
7
|
import { loadConfig, saveConfig, setEnv, unsetEnv, listEnv } from '../config/config-manager';
|
|
7
8
|
import { getAllCredentials, setAllCredentials } from '../auth/token-store';
|
|
8
9
|
import { CliError, handleError } from '../utils/errors';
|
|
9
10
|
import type { Config } from '../types/config';
|
|
10
11
|
import type { StoredCredentials } from '../types/tokens';
|
|
11
12
|
|
|
13
|
+
async function confirm(message: string): Promise<boolean> {
|
|
14
|
+
const rl = createInterface({
|
|
15
|
+
input: process.stdin,
|
|
16
|
+
output: process.stderr,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return new Promise((resolve) => {
|
|
20
|
+
rl.question(`${message} [y/N] `, (answer) => {
|
|
21
|
+
rl.close();
|
|
22
|
+
resolve(answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes');
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
12
27
|
const ALGORITHM = 'aes-256-gcm';
|
|
13
28
|
|
|
14
29
|
interface ExportedData {
|
|
@@ -308,4 +323,32 @@ export function registerConfigCommands(program: Command): void {
|
|
|
308
323
|
handleError(error);
|
|
309
324
|
}
|
|
310
325
|
});
|
|
326
|
+
|
|
327
|
+
config
|
|
328
|
+
.command('clear')
|
|
329
|
+
.description('Clear all configuration and credentials')
|
|
330
|
+
.option('--force', 'Skip confirmation prompt')
|
|
331
|
+
.action(async (options) => {
|
|
332
|
+
try {
|
|
333
|
+
if (!options.force) {
|
|
334
|
+
const confirmed = await confirm(
|
|
335
|
+
'This will delete all profiles and credentials. Are you sure?'
|
|
336
|
+
);
|
|
337
|
+
if (!confirmed) {
|
|
338
|
+
console.error('Aborted');
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// Reset config to default (empty profiles)
|
|
344
|
+
await saveConfig({ profiles: {} });
|
|
345
|
+
|
|
346
|
+
// Clear all credentials
|
|
347
|
+
await setAllCredentials({});
|
|
348
|
+
|
|
349
|
+
console.log('Configuration cleared');
|
|
350
|
+
} catch (error) {
|
|
351
|
+
handleError(error);
|
|
352
|
+
}
|
|
353
|
+
});
|
|
311
354
|
}
|