Skip to content

Commit a00d1cb

Browse files
authored
agent refactoring (#27)
* feat(context): restructure context module by creating a dedicated context directory and moving related functions to improve organization and maintainability refactor(agent): simplify agent logic by modularizing action execution and communication functions for better readability and separation of concerns chore: remove unused utils directory and update imports across the codebase to reflect new structure * refactor(agent): reorganize action and error types into separate files for better modularity and maintainability chore(agent): remove deprecated types.ts file to clean up the codebase and avoid redundancy
1 parent dd4a4ff commit a00d1cb

File tree

13 files changed

+1380
-1233
lines changed

13 files changed

+1380
-1233
lines changed

app/api/projects/[id]/chat/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ export async function POST(
288288
}
289289

290290
// Count tokens for input message using tiktoken
291-
const { countTokens } = await import('@/lib/llm/utils/context');
291+
const { countTokens } = await import('@/lib/llm/context');
292292
const messageTokens = countTokens(messageContent);
293293

294294
// Calculate cumulative token totals

lib/llm/context/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Context Module
3+
*
4+
* This module handles project context gathering, analysis, and preparation
5+
* for LLM processing. It contains utilities for parsing project structure,
6+
* analyzing TypeScript code, and creating comprehensive context for AI.
7+
*/
8+
9+
// Re-export context functionality
10+
export {
11+
countTokens,
12+
extractMethodSignatures,
13+
getProjectContextWithDirectoryStructureAndAnalysis,
14+
} from './projectContext';
15+
16+
// Re-export TypeScript analysis types and functions
17+
export { analyzeTsWithMorph, type Relationship } from './tsAnalysis';
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { encoding_for_model } from 'tiktoken';
33

44
import { CONTEXT } from '@/lib/constants';
55
import { readFile, listFilesRecursively, getProjectPath } from '../../fs/operations';
6-
import { analyzeTsWithMorph, Relationship } from './analysis/analyzeTsWithMorph';
6+
import { analyzeTsWithMorph, Relationship } from './tsAnalysis';
77

88
/**
99
* Count tokens using tiktoken library
@@ -457,7 +457,7 @@ export async function getProjectContextWithDirectoryStructureAndAnalysis(
457457
filteredRelationships[name] = {
458458
...originalRel,
459459
// Filter 'usedBy' to only include reachable components
460-
usedBy: (originalRel.usedBy || []).filter(user => reachable.has(user)),
460+
usedBy: (originalRel.usedBy || []).filter((user: string) => reachable.has(user)),
461461
};
462462
}
463463
}
File renamed without changes.

0 commit comments

Comments
 (0)