@plosson/agentio 0.1.30 → 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/package.json +1 -1
- package/src/commands/config.ts +52 -1
- package/src/commands/status.ts +30 -4
- package/src/config/config-manager.ts +29 -0
- package/src/types/config.ts +1 -0
package/package.json
CHANGED
package/src/commands/config.ts
CHANGED
|
@@ -3,7 +3,7 @@ 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 { loadConfig, saveConfig } from '../config/config-manager';
|
|
6
|
+
import { loadConfig, saveConfig, setEnv, unsetEnv, listEnv } from '../config/config-manager';
|
|
7
7
|
import { getAllCredentials, setAllCredentials } from '../auth/token-store';
|
|
8
8
|
import { CliError, handleError } from '../utils/errors';
|
|
9
9
|
import type { Config } from '../types/config';
|
|
@@ -245,4 +245,55 @@ export function registerConfigCommands(program: Command): void {
|
|
|
245
245
|
handleError(error);
|
|
246
246
|
}
|
|
247
247
|
});
|
|
248
|
+
|
|
249
|
+
// Environment variable management
|
|
250
|
+
const env = config
|
|
251
|
+
.command('env')
|
|
252
|
+
.description('Manage environment variables')
|
|
253
|
+
.action(async () => {
|
|
254
|
+
try {
|
|
255
|
+
const vars = await listEnv();
|
|
256
|
+
const entries = Object.entries(vars).sort(([a], [b]) => a.localeCompare(b));
|
|
257
|
+
if (entries.length === 0) {
|
|
258
|
+
console.log('No environment variables configured');
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
for (const [key, value] of entries) {
|
|
262
|
+
console.log(`${key}=${value}`);
|
|
263
|
+
}
|
|
264
|
+
} catch (error) {
|
|
265
|
+
handleError(error);
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
env
|
|
270
|
+
.command('set')
|
|
271
|
+
.description('Set an environment variable')
|
|
272
|
+
.argument('<key>', 'Variable name')
|
|
273
|
+
.argument('<value>', 'Variable value')
|
|
274
|
+
.action(async (key, value) => {
|
|
275
|
+
try {
|
|
276
|
+
await setEnv(key, value);
|
|
277
|
+
console.log(`Set ${key}`);
|
|
278
|
+
} catch (error) {
|
|
279
|
+
handleError(error);
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
env
|
|
284
|
+
.command('unset')
|
|
285
|
+
.description('Remove an environment variable')
|
|
286
|
+
.argument('<key>', 'Variable name')
|
|
287
|
+
.action(async (key) => {
|
|
288
|
+
try {
|
|
289
|
+
const removed = await unsetEnv(key);
|
|
290
|
+
if (removed) {
|
|
291
|
+
console.log(`Removed ${key}`);
|
|
292
|
+
} else {
|
|
293
|
+
throw new CliError('NOT_FOUND', `Variable not found: ${key}`);
|
|
294
|
+
}
|
|
295
|
+
} catch (error) {
|
|
296
|
+
handleError(error);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
248
299
|
}
|
package/src/commands/status.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { listProfiles, CONFIG_DIR } from '../config/config-manager';
|
|
2
|
+
import { listProfiles, listEnv, CONFIG_DIR } from '../config/config-manager';
|
|
3
3
|
import { getCredentials, setCredentials } from '../auth/token-store';
|
|
4
4
|
import { createGoogleAuth } from '../auth/token-manager';
|
|
5
5
|
import { refreshJiraToken } from '../auth/jira-oauth';
|
|
@@ -115,13 +115,13 @@ export function registerStatusCommand(program: Command): void {
|
|
|
115
115
|
.command('status')
|
|
116
116
|
.description('Show configured profiles and credential status')
|
|
117
117
|
.option('--no-test', 'Skip credential testing')
|
|
118
|
+
.option('--json', 'Output in JSON format')
|
|
118
119
|
.action(async (options) => {
|
|
119
120
|
try {
|
|
120
121
|
const allProfiles = await listProfiles();
|
|
121
122
|
const version = program.version();
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
console.log(`Config: ${CONFIG_DIR}\n`);
|
|
123
|
+
const envVars = await listEnv();
|
|
124
|
+
const envKeys = Object.keys(envVars).sort();
|
|
125
125
|
|
|
126
126
|
// Collect all profile statuses
|
|
127
127
|
const statuses: ProfileStatus[] = [];
|
|
@@ -170,6 +170,32 @@ export function registerStatusCommand(program: Command): void {
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
// JSON output mode
|
|
174
|
+
if (options.json) {
|
|
175
|
+
// Group profiles by service
|
|
176
|
+
const services: Record<string, Array<Omit<ProfileStatus, 'service'>>> = {};
|
|
177
|
+
for (const s of statuses) {
|
|
178
|
+
const { service, ...rest } = s;
|
|
179
|
+
if (!services[service]) {
|
|
180
|
+
services[service] = [];
|
|
181
|
+
}
|
|
182
|
+
services[service].push(rest);
|
|
183
|
+
}
|
|
184
|
+
const output = {
|
|
185
|
+
version,
|
|
186
|
+
configDir: CONFIG_DIR,
|
|
187
|
+
env: envKeys,
|
|
188
|
+
services,
|
|
189
|
+
};
|
|
190
|
+
console.log(JSON.stringify(output, null, 2));
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Human-readable output
|
|
195
|
+
console.log(`agentio v${version}`);
|
|
196
|
+
console.log(`Config: ${CONFIG_DIR}`);
|
|
197
|
+
console.log(`Env: ${envKeys.length > 0 ? envKeys.join(', ') : 'none'}\n`);
|
|
198
|
+
|
|
173
199
|
if (statuses.length === 0) {
|
|
174
200
|
console.log('No profiles configured.');
|
|
175
201
|
console.log('Run: agentio <service> profile add');
|
|
@@ -142,4 +142,33 @@ export async function listProfiles(service?: ServiceName): Promise<{
|
|
|
142
142
|
}));
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
export async function getEnv(key: string): Promise<string | undefined> {
|
|
146
|
+
const config = await loadConfig();
|
|
147
|
+
return config.env?.[key];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export async function setEnv(key: string, value: string): Promise<void> {
|
|
151
|
+
const config = await loadConfig();
|
|
152
|
+
if (!config.env) {
|
|
153
|
+
config.env = {};
|
|
154
|
+
}
|
|
155
|
+
config.env[key] = value;
|
|
156
|
+
await saveConfig(config);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export async function unsetEnv(key: string): Promise<boolean> {
|
|
160
|
+
const config = await loadConfig();
|
|
161
|
+
if (!config.env || !(key in config.env)) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
delete config.env[key];
|
|
165
|
+
await saveConfig(config);
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export async function listEnv(): Promise<Record<string, string>> {
|
|
170
|
+
const config = await loadConfig();
|
|
171
|
+
return config.env || {};
|
|
172
|
+
}
|
|
173
|
+
|
|
145
174
|
export { CONFIG_DIR, CONFIG_FILE };
|