Skip to content

Commit 4f66f32

Browse files
Add development conventions documentation and update VSCode settings for Copilot integration
1 parent f4ac2f1 commit 4f66f32

2 files changed

Lines changed: 115 additions & 2 deletions

File tree

.vscode/settings.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
// ],
88
"github.copilot.editor.enableCodeActions": true,
99
"chat.promptFiles": {
10-
"prompts": true
11-
}
10+
"prompts/": true
11+
},
12+
"github.copilot.chat.codeGeneration.instructions": [
13+
{
14+
"file": "CONVENTIONS.md"
15+
}
16+
],
17+
"github.copilot.chat.codeGeneration.useInstructionFiles": true,
1218
}

CONVENTIONS.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Development Conventions
2+
3+
## Project Overview
4+
5+
ComputerUseAgent is an AI-powered CLI tool that enables controlled execution of
6+
system operations through LLM guidance. At its core, the project uses the Claude
7+
3 API to interpret user requests and execute them through predefined tools.
8+
9+
## Key Components
10+
11+
- [`HybridSession`](src/modules/hybrid/hybrid_session.ts): The primary execution
12+
engine
13+
- [`ToolHandler`](src/utils/tool_handler.ts): Manages tool registration and
14+
execution
15+
- [`PlannerModule`](src/modules/planner/planner.ts): Creates execution plans for
16+
complex operations
17+
18+
## Core Conventions
19+
20+
### Session Management
21+
22+
- All operations must go through the planning phase first
23+
- Each session generates a unique ID for tracking and logging
24+
- Sessions maintain their own message history and token usage
25+
26+
### Tool Implementation
27+
28+
```typescript
29+
interface ToolConfig {
30+
toolName: string;
31+
command: string;
32+
output: string;
33+
inputs: ToolInputConfig[];
34+
description: string;
35+
enabled: boolean;
36+
}
37+
```
38+
39+
### Command Implementation
40+
41+
When adding new commands:
42+
43+
1. Create a new file in `src/commands/` following existing patterns (see
44+
`history.ts`, `export.ts`)
45+
2. Define command flags using `ParseOptions` interface
46+
3. Update help text in `parseFlagForHelp` function
47+
4. Register command in `main.ts` command handler section
48+
49+
Example command structure:
50+
51+
```typescript
52+
export async function handleNewCommand(args: string[]) {
53+
const commandFlags = {
54+
string: ["option1", "option2"],
55+
boolean: ["flag1"],
56+
default: {
57+
option1: "default",
58+
flag1: false,
59+
},
60+
};
61+
const flags = parseArgs(args, commandFlags);
62+
63+
if (flags.help || flags._[1] === "help") {
64+
console.log(parseFlagForHelp(commandFlags));
65+
return;
66+
}
67+
// Command implementation
68+
}
69+
```
70+
71+
### Error Handling
72+
73+
- Tool errors should be captured and logged, not thrown
74+
- All errors must be logged with proper context
75+
- Sessions should gracefully handle tool failures
76+
77+
### Logging
78+
79+
- Use structured logging via `log`
80+
- Token usage must be tracked for all API calls
81+
- Session steps must be logged for audit trails
82+
83+
84+
### LLM Interactions
85+
86+
- Keep system prompts in `constants.ts`
87+
- Messages must maintain conversation context
88+
- Tool calls should be processed sequentially
89+
90+
## Best Practices
91+
92+
1. Always use typed interfaces for tool inputs/outputs
93+
2. Log execution steps and tool usage
94+
3. Validate tool configurations before use
95+
4. Handle API rate limits gracefully
96+
5. Maintain clear session boundaries
97+
98+
## Anti-Patterns
99+
100+
- Directly executing shell commands without planning
101+
- Mixing session contexts
102+
- Bypassing the tool handler interface
103+
- Hardcoding system prompts in code
104+
- Ignoring token usage tracking
105+
106+
Note: Editor and Bash sessions are legacy components scheduled for deprecation.
107+
New features should focus on extending the HybridSession functionality.

0 commit comments

Comments
 (0)