Skip to content

Commit 3ae3453

Browse files
committed
green initial prompt and consent based warning.
1 parent 3c4ab38 commit 3ae3453

File tree

4 files changed

+48
-9
lines changed

4 files changed

+48
-9
lines changed

packages/cli/CHANGELOG.md

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

3+
## 0.2.0
4+
5+
### Minor Changes
6+
7+
- Make the warning a consent based single show to reduce distractions. Made the initial user prompt green to better conform to the user prompts from the agents being green.
8+
39
## 0.1.3
410

511
### Patch Changes

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mycoder",
33
"description": "A command line tool using agent that can do arbitrary tasks, including coding tasks",
4-
"version": "0.1.3",
4+
"version": "0.2.0",
55
"type": "module",
66
"bin": "./bin/cli.js",
77
"main": "./dist/index.js",

packages/cli/src/commands/$default.ts

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as fs from 'fs/promises';
22
import { createInterface } from 'readline/promises';
33

4+
import chalk from 'chalk';
45
import {
56
toolAgent,
67
Logger,
@@ -9,6 +10,7 @@ import {
910
} from 'mycoder-agent';
1011

1112
import { SharedOptions } from '../options.js';
13+
import { hasUserConsented, saveUserConsent } from '../settings/settings.js';
1214
import { getPackageInfo } from '../utils/versionCheck.js';
1315

1416
import type { CommandModule, Argv } from 'yargs';
@@ -33,12 +35,29 @@ export const command: CommandModule<object, DefaultArgs> = {
3335
logger.info(
3436
`MyCoder v${packageInfo.version} - AI-powered coding assistant`,
3537
);
36-
logger.warn(
37-
'WARNING: This tool can do anything on your command line that you ask it to.',
38-
'It can delete files, install software, and even send data to remote servers.',
39-
'It is a powerful tool that should be used with caution.',
40-
'By using this tool, you agree that the authors and contributors are not responsible for any damage that may occur as a result of using this tool.',
41-
);
38+
if (!hasUserConsented()) {
39+
const readline = createInterface({
40+
input: process.stdin,
41+
output: process.stdout,
42+
});
43+
44+
logger.warn(
45+
'This tool can do anything on your command line that you ask it to.',
46+
'It can delete files, install software, and even send data to remote servers.',
47+
'It is a powerful tool that should be used with caution.',
48+
'Do you consent to using this tool at your own risk? (y/N)',
49+
);
50+
51+
const answer = (await readline.question('> ')).trim().toLowerCase();
52+
readline.close();
53+
54+
if (answer === 'y' || answer === 'yes') {
55+
saveUserConsent();
56+
} else {
57+
logger.info('User did not consent. Exiting.');
58+
process.exit(0);
59+
}
60+
}
4261
try {
4362
// Early API key check
4463
if (!process.env.ANTHROPIC_API_KEY) {
@@ -68,8 +87,10 @@ export const command: CommandModule<object, DefaultArgs> = {
6887
});
6988

7089
try {
71-
logger.info(
72-
"Type your request below or 'help' for usage information. Use Ctrl+C to exit.",
90+
console.log(
91+
chalk.green(
92+
"Type your request below or 'help' for usage information. Use Ctrl+C to exit.",
93+
),
7394
);
7495
prompt = await readline.question('\n> ');
7596
} finally {

packages/cli/src/settings/settings.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,15 @@ export const getSettingsDir = (): string => {
1010
}
1111
return settingsDir;
1212
};
13+
14+
const consentFile = path.join(settingsDir, 'consent.json');
15+
16+
export const hasUserConsented = (): boolean => {
17+
return fs.existsSync(consentFile);
18+
};
19+
20+
export const saveUserConsent = (): void => {
21+
const timestamp = new Date().toISOString();
22+
const data = JSON.stringify({ timestamp }, null, 2);
23+
fs.writeFileSync(consentFile, data);
24+
};

0 commit comments

Comments
 (0)