forked from TrafficGuard/typedai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.test.ts
59 lines (51 loc) · 2.2 KB
/
cli.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { existsSync } from 'fs';
import { unlinkSync } from 'node:fs';
import { expect } from 'chai';
import { systemDir } from '../appVars';
import { parseUserCliArgs, saveAgentId } from './cli';
import { optimizeProjectStructure } from '#swe/codeEditingAgent';
describe('parseProcessArgs', () => {
beforeEach(() => {
if (existsSync(`${systemDir()}/cli/test.lastRun`)) unlinkSync(`${systemDir()}/cli/test.lastRun`);
// if (existsSync('.nous/cli/test')) unlinkSync('.nous/cli/test');
});
it('should parse -r flag correctly and set resumeAgentId if the state file exists', () => {
saveAgentId('test', 'id');
const result = parseUserCliArgs('test', ['-r', 'some', 'initial', 'prompt']);
expect(result.resumeAgentId).to.equal('id');
expect(result.initialPrompt).to.equal('some initial prompt');
});
it('should handle no -r flag', () => {
const result = parseUserCliArgs('test', ['some', 'initial', 'prompt']);
expect(result.resumeAgentId).to.be.undefined;
expect(result.initialPrompt).to.equal('some initial prompt');
});
it('should ignore -r if no state file exists', () => {
const result = parseUserCliArgs('test', ['-r', 'some', 'initial', 'prompt']);
expect(result.resumeAgentId).to.be.undefined;
expect(result.initialPrompt).to.equal('some initial prompt');
});
it('should handle multiple -r flags', () => {
const result = parseUserCliArgs('test', ['-r', '-r', 'some', 'initial', 'prompt']);
expect(result.initialPrompt).to.equal('some initial prompt');
});
it('should handle empty args', () => {
const result = parseUserCliArgs('test', []);
expect(result.resumeAgentId).to.be.undefined;
expect(result.initialPrompt).to.be.empty;
});
});
describe('optimizeProjectStructure', () => {
it('should optimize project structure with default rules', async () => {
const result = await optimizeProjectStructure({});
expect(result).to.be.undefined;
});
it('should optimize project structure with custom rules', async () => {
const customRules = JSON.stringify([
{ type: 'move', from: 'src/old-folder', to: 'src/new-folder' },
{ type: 'delete', target: 'src/temp-file.ts' },
]);
const result = await optimizeProjectStructure({ rules: customRules });
expect(result).to.be.undefined;
});
});