Skip to content

Commit 54c884a

Browse files
authored
Merge pull request #7 from CodeAnt-AI/feat/set-telemetry
api key set
2 parents efc19e6 + 5bc002b commit 54c884a

File tree

5 files changed

+87
-1
lines changed

5 files changed

+87
-1
lines changed

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## [0.4.0] - 04/04/2026
4+
- Set api key
5+
36
## [0.3.9] - 04/04/2026
47
- Secrets bypass
58

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codeant-cli",
3-
"version": "0.3.9",
3+
"version": "0.4.0",
44
"description": "Code review CLI tool",
55
"type": "module",
66
"bin": {

src/commands/getApiKey.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React, { useEffect } from 'react';
2+
import { Text, Box, useApp } from 'ink';
3+
import { getConfigValue } from '../utils/config.js';
4+
5+
export default function GetApiKey() {
6+
const { exit } = useApp();
7+
8+
const apiKey = getConfigValue('apiKeyV2');
9+
10+
useEffect(() => {
11+
exit();
12+
}, []);
13+
14+
if (!apiKey) {
15+
return React.createElement(
16+
Box,
17+
{ flexDirection: 'column', padding: 1 },
18+
React.createElement(Text, { color: 'yellow' }, 'No CodeAnt API key configured.'),
19+
React.createElement(Text, { color: 'gray' }, 'Set one with: codeant set-codeant-api-key <key>')
20+
);
21+
}
22+
23+
const masked = apiKey.slice(0, 4) + '…' + apiKey.slice(-4);
24+
25+
return React.createElement(
26+
Box,
27+
{ flexDirection: 'column', padding: 1 },
28+
React.createElement(Text, { bold: true }, 'CodeAnt API Key: ', masked)
29+
);
30+
}

src/commands/setApiKey.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React, { useEffect } from 'react';
2+
import { Text, Box, useApp } from 'ink';
3+
import { setConfigValue, CONFIG_FILE } from '../utils/config.js';
4+
5+
export default function SetApiKey({ apiKey }) {
6+
const { exit } = useApp();
7+
8+
useEffect(() => {
9+
if (!apiKey) {
10+
exit(new Error('API key is required'));
11+
return;
12+
}
13+
14+
try {
15+
setConfigValue('apiKeyV2', apiKey);
16+
exit();
17+
} catch (err) {
18+
exit(err);
19+
}
20+
}, []);
21+
22+
if (!apiKey) {
23+
return React.createElement(
24+
Box,
25+
{ flexDirection: 'column', padding: 1 },
26+
React.createElement(Text, { color: 'red' }, '✗ Error: API key is required'),
27+
React.createElement(Text, { color: 'gray' }, 'Usage: codeant set-codeant-api-key <key>')
28+
);
29+
}
30+
31+
return React.createElement(
32+
Box,
33+
{ flexDirection: 'column', padding: 1 },
34+
React.createElement(Text, { color: 'green' }, '✓ CodeAnt API key saved.'),
35+
React.createElement(Text, { color: 'gray' }, 'Saved to: ', CONFIG_FILE)
36+
);
37+
}

src/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { createRequire } from 'module';
77
import Secrets from './commands/secrets.js';
88
import SetBaseUrl from './commands/setBaseUrl.js';
99
import GetBaseUrl from './commands/getBaseUrl.js';
10+
import SetApiKey from './commands/setApiKey.js';
11+
import GetApiKey from './commands/getApiKey.js';
1012
import Login from './commands/login.js';
1113
import Logout from './commands/logout.js';
1214
import Review from './commands/review.js';
@@ -183,6 +185,20 @@ program
183185
render(React.createElement(GetBaseUrl));
184186
});
185187

188+
program
189+
.command('set-codeant-api-key <key>')
190+
.description('Set the CodeAnt API key')
191+
.action((key) => {
192+
render(React.createElement(SetApiKey, { apiKey: key }));
193+
});
194+
195+
program
196+
.command('get-codeant-api-key')
197+
.description('Show the current CodeAnt API key')
198+
.action(() => {
199+
render(React.createElement(GetApiKey));
200+
});
201+
186202
program
187203
.command('login')
188204
.description('Login to CodeAnt')

0 commit comments

Comments
 (0)