Skip to content

Commit ce2a3be

Browse files
authored
Merge pull request #221 from drivecore/default-github-mode-on
Default GitHub mode on
2 parents 792c58f + 4cabfad commit ce2a3be

18 files changed

+99
-63
lines changed

packages/agent/src/core/toolAgent.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const toolContext: ToolContext = {
1414
userSession: false,
1515
pageFilter: 'simple',
1616
tokenTracker: new TokenTracker(),
17-
githubMode: false,
17+
githubMode: true,
1818
};
1919

2020
// Mock tool for testing

packages/agent/src/tools/interaction/agentMessage.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { z } from 'zod';
22
import { zodToJsonSchema } from 'zod-to-json-schema';
33

4-
import { backgroundToolRegistry, BackgroundToolStatus } from '../../core/backgroundTools.js';
4+
import {
5+
backgroundToolRegistry,
6+
BackgroundToolStatus,
7+
} from '../../core/backgroundTools.js';
58
import { Tool } from '../../core/types.js';
69

710
import { agentStates } from './agentStart.js';
@@ -76,11 +79,15 @@ export const agentMessageTool: Tool<Parameters, ReturnType> = {
7679
if (terminate) {
7780
agentState.aborted = true;
7881
agentState.completed = true;
79-
82+
8083
// Update background tool registry with terminated status
81-
backgroundToolRegistry.updateToolStatus(instanceId, BackgroundToolStatus.TERMINATED, {
82-
terminatedByUser: true
83-
});
84+
backgroundToolRegistry.updateToolStatus(
85+
instanceId,
86+
BackgroundToolStatus.TERMINATED,
87+
{
88+
terminatedByUser: true,
89+
},
90+
);
8491

8592
return {
8693
output: agentState.output || 'Sub-agent terminated before completion',

packages/agent/src/tools/interaction/agentStart.ts

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { v4 as uuidv4 } from 'uuid';
22
import { z } from 'zod';
33
import { zodToJsonSchema } from 'zod-to-json-schema';
44

5-
import { backgroundToolRegistry, BackgroundToolStatus, BackgroundToolType } from '../../core/backgroundTools.js';
5+
import {
6+
backgroundToolRegistry,
7+
BackgroundToolStatus,
8+
} from '../../core/backgroundTools.js';
69
import {
710
getDefaultSystemPrompt,
811
getModel,
@@ -92,7 +95,7 @@ export const agentStartTool: Tool<Parameters, ReturnType> = {
9295
returnsJsonSchema: zodToJsonSchema(returnSchema),
9396
execute: async (params, context) => {
9497
const { logger, agentId } = context;
95-
98+
9699
// Validate parameters
97100
const {
98101
description,
@@ -102,10 +105,10 @@ export const agentStartTool: Tool<Parameters, ReturnType> = {
102105
relevantFilesDirectories,
103106
enableUserPrompt = false,
104107
} = parameterSchema.parse(params);
105-
108+
106109
// Create an instance ID
107110
const instanceId = uuidv4();
108-
111+
109112
// Register this agent with the background tool registry
110113
backgroundToolRegistry.registerAgent(agentId || 'unknown', goal);
111114
logger.verbose(`Registered agent with ID: ${instanceId}`);
@@ -154,23 +157,33 @@ export const agentStartTool: Tool<Parameters, ReturnType> = {
154157
state.completed = true;
155158
state.result = result;
156159
state.output = result.result;
157-
160+
158161
// Update background tool registry with completed status
159-
backgroundToolRegistry.updateToolStatus(instanceId, BackgroundToolStatus.COMPLETED, {
160-
result: result.result.substring(0, 100) + (result.result.length > 100 ? '...' : '')
161-
});
162+
backgroundToolRegistry.updateToolStatus(
163+
instanceId,
164+
BackgroundToolStatus.COMPLETED,
165+
{
166+
result:
167+
result.result.substring(0, 100) +
168+
(result.result.length > 100 ? '...' : ''),
169+
},
170+
);
162171
}
163172
} catch (error) {
164173
// Update agent state with the error
165174
const state = agentStates.get(instanceId);
166175
if (state && !state.aborted) {
167176
state.completed = true;
168177
state.error = error instanceof Error ? error.message : String(error);
169-
178+
170179
// Update background tool registry with error status
171-
backgroundToolRegistry.updateToolStatus(instanceId, BackgroundToolStatus.ERROR, {
172-
error: error instanceof Error ? error.message : String(error)
173-
});
180+
backgroundToolRegistry.updateToolStatus(
181+
instanceId,
182+
BackgroundToolStatus.ERROR,
183+
{
184+
error: error instanceof Error ? error.message : String(error),
185+
},
186+
);
174187
}
175188
}
176189
return true;

packages/agent/src/tools/interaction/agentTools.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const mockContext: ToolContext = {
2323
headless: true,
2424
userSession: false,
2525
pageFilter: 'none',
26-
githubMode: false,
26+
githubMode: true,
2727
};
2828

2929
describe('Agent Tools', () => {

packages/agent/src/tools/interaction/subAgent.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const mockContext: ToolContext = {
2727
headless: true,
2828
userSession: false,
2929
pageFilter: 'none',
30-
githubMode: false,
30+
githubMode: true,
3131
};
3232

3333
describe('subAgentTool', () => {

packages/agent/src/tools/interaction/subAgent.ts

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { z } from 'zod';
22
import { zodToJsonSchema } from 'zod-to-json-schema';
33

4-
import { backgroundToolRegistry, BackgroundToolStatus, BackgroundToolType } from '../../core/backgroundTools.js';
4+
import {
5+
backgroundToolRegistry,
6+
BackgroundToolStatus,
7+
} from '../../core/backgroundTools.js';
58
import {
69
getDefaultSystemPrompt,
710
getModel,
@@ -70,7 +73,7 @@ export const subAgentTool: Tool<Parameters, ReturnType> = {
7073
returnsJsonSchema: zodToJsonSchema(returnSchema),
7174
execute: async (params, context) => {
7275
const { logger, agentId } = context;
73-
76+
7477
// Validate parameters
7578
const {
7679
description,
@@ -79,9 +82,12 @@ export const subAgentTool: Tool<Parameters, ReturnType> = {
7982
workingDirectory,
8083
relevantFilesDirectories,
8184
} = parameterSchema.parse(params);
82-
85+
8386
// Register this sub-agent with the background tool registry
84-
const subAgentId = backgroundToolRegistry.registerAgent(agentId || 'unknown', goal);
87+
const subAgentId = backgroundToolRegistry.registerAgent(
88+
agentId || 'unknown',
89+
goal,
90+
);
8591
logger.verbose(`Registered sub-agent with ID: ${subAgentId}`);
8692

8793
// Construct a well-structured prompt
@@ -109,19 +115,29 @@ export const subAgentTool: Tool<Parameters, ReturnType> = {
109115
...context,
110116
workingDirectory: workingDirectory ?? context.workingDirectory,
111117
});
112-
118+
113119
// Update background tool registry with completed status
114-
backgroundToolRegistry.updateToolStatus(subAgentId, BackgroundToolStatus.COMPLETED, {
115-
result: result.result.substring(0, 100) + (result.result.length > 100 ? '...' : '')
116-
});
117-
120+
backgroundToolRegistry.updateToolStatus(
121+
subAgentId,
122+
BackgroundToolStatus.COMPLETED,
123+
{
124+
result:
125+
result.result.substring(0, 100) +
126+
(result.result.length > 100 ? '...' : ''),
127+
},
128+
);
129+
118130
return { response: result.result };
119131
} catch (error) {
120132
// Update background tool registry with error status
121-
backgroundToolRegistry.updateToolStatus(subAgentId, BackgroundToolStatus.ERROR, {
122-
error: error instanceof Error ? error.message : String(error)
123-
});
124-
133+
backgroundToolRegistry.updateToolStatus(
134+
subAgentId,
135+
BackgroundToolStatus.ERROR,
136+
{
137+
error: error instanceof Error ? error.message : String(error),
138+
},
139+
);
140+
125141
throw error;
126142
}
127143
},

packages/agent/src/tools/interaction/userPrompt.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const mockContext: ToolContext = {
1919
headless: true,
2020
userSession: false,
2121
pageFilter: 'none',
22-
githubMode: false,
22+
githubMode: true,
2323
};
2424

2525
describe('userPromptTool', () => {

packages/agent/src/tools/io/textEditor.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const toolContext: ToolContext = {
1919
userSession: false,
2020
pageFilter: 'simple',
2121
tokenTracker: new TokenTracker(),
22-
githubMode: false,
22+
githubMode: true,
2323
};
2424

2525
describe('textEditor', () => {

packages/agent/src/tools/system/respawn.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const toolContext: ToolContext = {
1313
userSession: false,
1414
pageFilter: 'simple',
1515
tokenTracker: new TokenTracker(),
16-
githubMode: false,
16+
githubMode: true,
1717
};
1818
describe('respawnTool', () => {
1919
it('should have correct name and description', () => {

packages/agent/src/tools/system/shellExecute.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const toolContext: ToolContext = {
1313
userSession: false,
1414
pageFilter: 'simple',
1515
tokenTracker: new TokenTracker(),
16-
githubMode: false,
16+
githubMode: true,
1717
};
1818

1919
describe('shellExecute', () => {

packages/agent/src/tools/system/shellMessage.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const toolContext: ToolContext = {
1515
userSession: false,
1616
pageFilter: 'simple',
1717
tokenTracker: new TokenTracker(),
18-
githubMode: false,
18+
githubMode: true,
1919
};
2020

2121
// Helper function to get instanceId from shellStart result

packages/agent/src/tools/system/shellStart.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const toolContext: ToolContext = {
1414
userSession: false,
1515
pageFilter: 'simple',
1616
tokenTracker: new TokenTracker(),
17-
githubMode: false,
17+
githubMode: true,
1818
};
1919
describe('shellStartTool', () => {
2020
beforeEach(() => {

packages/agent/src/tools/system/sleep.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const toolContext: ToolContext = {
1313
userSession: false,
1414
pageFilter: 'simple',
1515
tokenTracker: new TokenTracker(),
16-
githubMode: false,
16+
githubMode: true,
1717
};
1818

1919
describe('sleep tool', () => {

packages/cli/src/settings/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const projectConfigFile = (): string => getProjectConfigFile();
4343
// Default configuration
4444
const defaultConfig = {
4545
// Add default configuration values here
46-
githubMode: false,
46+
githubMode: true,
4747
headless: true,
4848
userSession: false,
4949
pageFilter: 'none' as 'simple' | 'none' | 'readability',

packages/cli/tests/commands/config.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,18 @@ describe('Config Command', () => {
6969
warn: vi.fn(),
7070
};
7171
vi.mocked(Logger).mockImplementation(() => mockLogger as unknown as Logger);
72-
vi.mocked(getConfig).mockReturnValue({ githubMode: false });
72+
vi.mocked(getConfig).mockReturnValue({ githubMode: true });
7373
vi.mocked(getDefaultConfig).mockReturnValue({
74-
githubMode: false,
74+
githubMode: true,
7575
customPrompt: '',
7676
});
7777
vi.mocked(updateConfig).mockImplementation((config) => ({
78-
githubMode: false,
78+
githubMode: true,
7979
...config,
8080
}));
8181
vi.mocked(getConfigAtLevel).mockReturnValue({});
82-
vi.mocked(clearConfigKey).mockImplementation(() => ({ githubMode: false }));
83-
vi.mocked(clearConfigKey).mockImplementation(() => ({ githubMode: false }));
82+
vi.mocked(clearConfigKey).mockImplementation(() => ({ githubMode: true }));
83+
vi.mocked(clearConfigKey).mockImplementation(() => ({ githubMode: true }));
8484
});
8585

8686
afterEach(() => {
@@ -107,13 +107,13 @@ describe('Config Command', () => {
107107
it('should filter out invalid config keys in list command', async () => {
108108
// Mock getConfig to return config with invalid keys
109109
vi.mocked(getConfig).mockReturnValue({
110-
githubMode: false,
110+
githubMode: true,
111111
invalidKey: 'some value',
112112
} as any);
113113

114114
// Mock getDefaultConfig to return only valid keys
115115
vi.mocked(getDefaultConfig).mockReturnValue({
116-
githubMode: false,
116+
githubMode: true,
117117
});
118118

119119
await command.handler!({
@@ -249,13 +249,13 @@ describe('Config Command', () => {
249249
it('should clear a configuration value', async () => {
250250
// Mock getConfig to include the key we want to clear
251251
vi.mocked(getConfig).mockReturnValue({
252-
githubMode: false,
252+
githubMode: true,
253253
customPrompt: 'custom value',
254254
});
255255

256256
// Mock getDefaultConfig to include the key we want to clear
257257
vi.mocked(getDefaultConfig).mockReturnValue({
258-
githubMode: false,
258+
githubMode: true,
259259
customPrompt: '',
260260
});
261261

@@ -333,7 +333,7 @@ describe('Config Command', () => {
333333

334334
it('should handle non-existent key for clear command', async () => {
335335
vi.mocked(getConfig).mockReturnValue({
336-
githubMode: false,
336+
githubMode: true,
337337
});
338338

339339
await command.handler!({
@@ -370,13 +370,13 @@ describe('Config Command', () => {
370370
it('should list all configuration values with default indicators', async () => {
371371
// Mock getConfig to return a mix of default and custom values
372372
vi.mocked(getConfig).mockReturnValue({
373-
githubMode: false, // default value
373+
githubMode: true, // default value
374374
customPrompt: 'custom value', // custom value
375375
});
376376

377377
// Mock getDefaultConfig to return the default values
378378
vi.mocked(getDefaultConfig).mockReturnValue({
379-
githubMode: false,
379+
githubMode: true,
380380
customPrompt: '',
381381
});
382382

packages/cli/tests/settings/config-defaults.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('Config Defaults for CLI Options', () => {
5454
it('should use config values for headless, userSession, and pageFilter when not provided in args', async () => {
5555
// Setup mock config with default values
5656
vi.mocked(getConfig).mockReturnValue({
57-
githubMode: false,
57+
githubMode: true,
5858
headless: true,
5959
userSession: false,
6060
pageFilter: 'none',
@@ -96,7 +96,7 @@ describe('Config Defaults for CLI Options', () => {
9696
it('should use command line args for headless, userSession, and pageFilter when provided', async () => {
9797
// Setup mock config with default values
9898
vi.mocked(getConfig).mockReturnValue({
99-
githubMode: false,
99+
githubMode: true,
100100
headless: true, // Default is true
101101
userSession: false, // Default is false
102102
pageFilter: 'none', // Default is none
@@ -132,7 +132,7 @@ describe('Config Defaults for CLI Options', () => {
132132
it('should test the actual toolAgent call with config defaults', async () => {
133133
// Setup mock config with default values
134134
vi.mocked(getConfig).mockReturnValue({
135-
githubMode: false,
135+
githubMode: true,
136136
headless: true,
137137
userSession: false,
138138
pageFilter: 'none',
@@ -180,7 +180,7 @@ describe('Config Defaults for CLI Options', () => {
180180
it('should test the actual toolAgent call with command line args', async () => {
181181
// Setup mock config with default values
182182
vi.mocked(getConfig).mockReturnValue({
183-
githubMode: false,
183+
githubMode: true,
184184
headless: true, // Default is true
185185
userSession: false, // Default is false
186186
pageFilter: 'none', // Default is none

0 commit comments

Comments
 (0)