Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## [0.4.0] - 04/04/2026
- Set api key

## [0.3.9] - 04/04/2026
- Secrets bypass

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codeant-cli",
"version": "0.3.9",
"version": "0.4.0",
"description": "Code review CLI tool",
"type": "module",
"bin": {
Expand Down
30 changes: 30 additions & 0 deletions src/commands/getApiKey.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React, { useEffect } from 'react';
import { Text, Box, useApp } from 'ink';
import { getConfigValue } from '../utils/config.js';

export default function GetApiKey() {
const { exit } = useApp();

const apiKey = getConfigValue('apiKeyV2');

useEffect(() => {
exit();
}, []);

if (!apiKey) {
return React.createElement(
Box,
{ flexDirection: 'column', padding: 1 },
React.createElement(Text, { color: 'yellow' }, 'No CodeAnt API key configured.'),
React.createElement(Text, { color: 'gray' }, 'Set one with: codeant set-codeant-api-key <key>')
);
}

const masked = apiKey.slice(0, 4) + '…' + apiKey.slice(-4);

return React.createElement(
Box,
{ flexDirection: 'column', padding: 1 },
React.createElement(Text, { bold: true }, 'CodeAnt API Key: ', masked)
);
}
37 changes: 37 additions & 0 deletions src/commands/setApiKey.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React, { useEffect } from 'react';
import { Text, Box, useApp } from 'ink';
import { setConfigValue, CONFIG_FILE } from '../utils/config.js';

export default function SetApiKey({ apiKey }) {
const { exit } = useApp();

useEffect(() => {
if (!apiKey) {
exit(new Error('API key is required'));
return;
}

try {
setConfigValue('apiKeyV2', apiKey);
exit();
} catch (err) {
exit(err);
}
}, []);

if (!apiKey) {
return React.createElement(
Box,
{ flexDirection: 'column', padding: 1 },
React.createElement(Text, { color: 'red' }, '✗ Error: API key is required'),
React.createElement(Text, { color: 'gray' }, 'Usage: codeant set-codeant-api-key <key>')
);
}

return React.createElement(
Box,
{ flexDirection: 'column', padding: 1 },
React.createElement(Text, { color: 'green' }, '✓ CodeAnt API key saved.'),
React.createElement(Text, { color: 'gray' }, 'Saved to: ', CONFIG_FILE)
);
}
16 changes: 16 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { createRequire } from 'module';
import Secrets from './commands/secrets.js';
import SetBaseUrl from './commands/setBaseUrl.js';
import GetBaseUrl from './commands/getBaseUrl.js';
import SetApiKey from './commands/setApiKey.js';
import GetApiKey from './commands/getApiKey.js';
import Login from './commands/login.js';
import Logout from './commands/logout.js';
import Review from './commands/review.js';
Expand Down Expand Up @@ -183,6 +185,20 @@ program
render(React.createElement(GetBaseUrl));
});

program
.command('set-codeant-api-key <key>')
.description('Set the CodeAnt API key')
.action((key) => {
render(React.createElement(SetApiKey, { apiKey: key }));
});

program
.command('get-codeant-api-key')
.description('Show the current CodeAnt API key')
.action(() => {
render(React.createElement(GetApiKey));
});

program
.command('login')
.description('Login to CodeAnt')
Expand Down