Skip to content

Commit 818fbc9

Browse files
authored
Merge pull request #87 from 2501-ai/ISS-168-discord-message-and-loop-threshold
Updated join discord message and increased loop threshold
2 parents 85697cc + b6fdba7 commit 818fbc9

File tree

8 files changed

+33
-13
lines changed

8 files changed

+33
-13
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@2501-ai/cli",
3-
"version": "0.0.51",
3+
"version": "0.0.52",
44
"description": "",
55
"main": "dist/index.js",
66
"bin": {

src/commands/init.ts

+19-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import axios from 'axios';
22
import fs from 'fs';
3-
import { addAgent, readConfig } from '../utils/conf';
3+
import { terminal } from 'terminal-kit';
4+
import { addAgent, readConfig, setValue } from '../utils/conf';
45

56
import Logger from '../utils/logger';
67

78
import { API_HOST, API_VERSION } from '../constants';
89
import { isDirUnsafe } from '../helpers/security';
910
import { Configuration } from '../utils/types';
1011
import { createAgent } from '../helpers/api';
11-
import { JOIN_DISCORD_MESSAGE } from '../utils/messaging';
12+
import { DISCORD_LINK } from '../utils/messaging';
1213

1314
axios.defaults.baseURL = `${API_HOST}${API_VERSION}`;
1415
axios.defaults.timeout = 120 * 1000;
@@ -84,11 +85,26 @@ async function getWorkspacePath(options?: InitCommandOptions): Promise<string> {
8485
export async function initCommand(options?: InitCommandOptions) {
8586
try {
8687
const workspace = await getWorkspacePath(options);
88+
const config = readConfig();
89+
90+
if (!config?.join_discord_shown) {
91+
const term = terminal;
92+
93+
term('\n');
94+
term.gray('🔗 Join our Discord\n');
95+
term
96+
.gray('│ ')
97+
.gray(
98+
'Connect with the 2501 team and community for updates, support, and insights:\n'
99+
);
100+
term.gray('│ ').gray.underline(`${DISCORD_LINK}\n`);
101+
102+
setValue('join_discord_shown', true);
103+
}
87104

88105
logger.start('Creating agent');
89106
const configKey = options?.config || 'CODING_AGENT';
90107
const configuration = await getConfiguration(configKey);
91-
const config = readConfig();
92108

93109
const createResponse = await createAgent(
94110
workspace,
@@ -108,8 +124,6 @@ export async function initCommand(options?: InitCommandOptions) {
108124
});
109125

110126
logger.stop(`Agent ${createResponse.id} created`);
111-
112-
Logger.log(JOIN_DISCORD_MESSAGE);
113127
} catch (e: unknown) {
114128
logger.handleError(e as Error, (e as Error).message);
115129
}

src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { jobSubscriptionCommand } from './commands/jobs';
1212
import { authMiddleware } from './middleware/auth';
1313
import { isLatestVersion } from './utils/versioning';
1414
import Logger from './utils/logger';
15-
import { JOIN_DISCORD_MESSAGE } from './utils/messaging';
15+
import { DISCORD_LINK } from './utils/messaging';
1616

1717
process.on('SIGINT', () => {
1818
console.log('Process interrupted with Ctrl+C');
@@ -35,7 +35,7 @@ program
3535
3636
---- AI Autonomous Systems ----
3737
38-
${JOIN_DISCORD_MESSAGE}
38+
Join our Discord server: ${DISCORD_LINK}
3939
`
4040
)
4141
// eslint-disable-next-line @typescript-eslint/no-var-requires

src/middleware/auth.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ Before we begin, you need to configure your API key. (You can get your API key b
3333
'string'
3434
);
3535
if (res) {
36-
writeConfig({ api_key: res, workspace_disabled: false, agents: [] });
36+
writeConfig({
37+
api_key: res,
38+
workspace_disabled: false,
39+
agents: [],
40+
join_discord_shown: false,
41+
});
3742

3843
logger.log(
3944
`The CLI will now create a workspace and synchronize your files with the 2501 platform before creating your first agent.`

src/utils/loopDetection.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createHash } from 'crypto';
22
import { FunctionAction } from './types';
33

4-
const REPETITION_THRESHOLD = 5;
4+
const REPETITION_THRESHOLD = 15;
55

66
const actionHashes = new Map<string, number>();
77

src/utils/messaging.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export const CHUNK_MESSAGE_CLEAR = 'CHUNK_CLEAR';
22

3-
export const JOIN_DISCORD_MESSAGE = `Join our Discord server: \u001b[34m\u001b[4mhttps://discord.gg/uuCma4eHBF\u001b[0m`;
3+
export const DISCORD_LINK = `https://discord.gg/uuCma4eHBF`;

src/utils/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export type LocalConfig = {
101101
engine?: EngineType;
102102
stream?: boolean;
103103
agents: AgentConfig[];
104+
join_discord_shown: boolean;
104105
};
105106

106107
export type AgentCallbackType = (...args: unknown[]) => Promise<void>;

0 commit comments

Comments
 (0)