Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,29 @@ and this project aims to adhere to [Semantic Versioning](https://semver.org/spec

_(Future changes will go here)_

## [0.7.12] - 2025-07-05

### Changed

- **Migrated to genai-lite v0.1.3 Preset System**: Refactored model preset management to use genai-lite's configurable preset system with 'replace' mode. This eliminates code duplication while maintaining full control over Athanor's model configurations. ([275e792](https://github.com/lacerbi/athanor/commit/275e792))
- Removed local `AthanorModelPreset` type and `athanorPresetService`
- Added IPC channel for fetching presets from the LLM service
- Updated UI components to use genai-lite's `ModelPreset` type
- Configuration now centralized through `src/config/athanorModelPresets.json`

- **Migrated Template Rendering to genai-lite**: Refactored to use genai-lite's `renderTemplate` function for variable substitution in prompts. ([ac7d986](https://github.com/lacerbi/athanor/commit/ac7d986))
- Removed local `substituteVariables` function from `promptTemplates.ts`
- Updated `buildPrompt.ts` to use `renderTemplate` from genai-lite
- Template rendering now provided by the shared library

### Fixed

- **Build Configuration**: Added JSON module resolution support to TypeScript and webpack configurations to properly handle preset configuration imports.

### Dependencies

- Updated `genai-lite` from v0.1.1 to v0.1.4

## [0.7.11] - 2025-07-04

### Added
Expand Down
9 changes: 9 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ Athanor is an Electron desktop application for AI-assisted development workflows
- Conventional Commits for commit messages
- **DCO Sign-off Required**: All commits must be signed with DCO. Always use `git commit -s` when committing. If git config is not set (check with `git config user.name` and `git config user.email`), inform the user that these need to be configured before committing. For fixing unsigned commits, use `git rebase --signoff` or `git commit --amend -s`

**Important Notes on External Package Imports:**

When importing from `genai-lite` or similar external packages in the renderer process (`src/` directory):
- Use the package's exported paths as defined in their `package.json` exports field (e.g., `genai-lite/utils`)
- Add `// @ts-ignore - webpack module resolution issue` if TypeScript complains
- Do NOT use deep imports like `genai-lite/dist/utils/templateEngine` as webpack will reject these
- Check existing imports in the codebase for the correct pattern (e.g., see `RelevanceEngineService.ts`)
- Main process imports (`electron/` directory) typically work without issues

## Key Dependencies

- **Electron 33+** - Desktop app framework
Expand Down
1 change: 1 addition & 0 deletions common/types/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const LLM_IPC_CHANNELS = {
GET_MODELS: 'llm:get-models',
SEND_MESSAGE: 'llm:send-message',
IS_KEY_AVAILABLE: 'llm:is-key-available',
GET_PRESETS: 'llm:get-presets',
} as const;

/**
Expand Down
12 changes: 11 additions & 1 deletion electron/handlers/llmIpc.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// AI Summary: IPC handlers for LLM operations, routing requests between renderer and main process.
// Registers handlers for getting providers/models and sending messages to LLMs.
// Registers handlers for getting providers/models, sending messages to LLMs, and fetching presets.

import { ipcMain } from 'electron';
import type { LLMService, LLMChatRequest, ApiProviderId } from 'genai-lite';
Expand Down Expand Up @@ -73,5 +73,15 @@ export function registerLlmIpc(llmService: LLMService, apiKeyService: ApiKeyServ
}
);

// Handler for getting configured presets
ipcMain.handle(LLM_IPC_CHANNELS.GET_PRESETS, async () => {
try {
return llmService.getPresets();
} catch (error) {
console.error('Error in GET_PRESETS handler:', error);
throw error;
}
});

console.log('LLM IPC handlers registered successfully');
}
9 changes: 7 additions & 2 deletions electron/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// AI Summary: Main electron process that coordinates window management, file system operations,
// and IPC communication between processes. Handles application lifecycle events, path resolution,
// and uncaught exception handling with proper cleanup of file watchers.
// Configures genai-lite LLM service with Athanor's model presets using replace mode.
import { app, BrowserWindow, Menu, nativeTheme, ipcMain } from 'electron';
import fixPath from 'fix-path';
import { Worker } from 'worker_threads';
Expand All @@ -14,7 +15,7 @@ import {
ApiKeyServiceMain,
registerSecureApiKeyIpc,
} from 'genai-key-storage-lite';
import { LLMService, type ApiKeyProvider } from 'genai-lite';
import { LLMService, type ApiKeyProvider, type ModelPreset } from 'genai-lite';
import { RelevanceEngineService } from './services/RelevanceEngineService';
import { GitService } from './services/GitService';
import { UserActivityService } from './services/UserActivityService';
Expand All @@ -25,6 +26,7 @@ import {
} from './services/ProjectGraphService';
import { PROJECT_ANALYSIS } from '../src/utils/constants';
import type { ApplicationSettings } from '../src/types/global';
import athanorPresets from '../src/config/athanorModelPresets.json';

// --- WSL Graphics Fix Start ---
// This addresses a specific rendering issue on WSL where Electron may default
Expand Down Expand Up @@ -332,7 +334,10 @@ app.whenReady().then(async () => {
return envKey || null;
}
};
llmService = new LLMService(electronKeyProvider);
llmService = new LLMService(electronKeyProvider, {
presets: athanorPresets as ModelPreset[],
presetMode: 'replace'
});

// Register IPC handlers from the external package
registerSecureApiKeyIpc(apiKeyService);
Expand Down
1 change: 1 addition & 0 deletions electron/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ contextBridge.exposeInMainWorld('electronBridge', {
getModels: (providerId: string) => ipcRenderer.invoke(LLM_IPC_CHANNELS.GET_MODELS, providerId),
sendMessage: (request: any) => ipcRenderer.invoke(LLM_IPC_CHANNELS.SEND_MESSAGE, request),
isKeyAvailable: (providerId: string) => ipcRenderer.invoke(LLM_IPC_CHANNELS.IS_KEY_AVAILABLE, providerId),
getPresets: () => ipcRenderer.invoke(LLM_IPC_CHANNELS.GET_PRESETS),
},
userActivity: () => ipcRenderer.send('user-activity'),
context: {
Expand Down
14 changes: 1 addition & 13 deletions electron/services/.summary_long.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ Sophisticated context selection engine:
- Incorporates UserActivityService signals
- Respects GitService history
- Applies TaskAnalysisUtils keywords
- Uses genai-lite/utils for token counting and smart preview

### TaskAnalysisUtils.ts

Expand Down Expand Up @@ -230,19 +231,6 @@ Import path resolution:

## Utility Services

### PromptUtils.ts

Token management utilities:

**Core Functions:**
- `countTokens()`: GPT-4 tokenizer usage
- `getSmartPreview()`: Intelligent truncation

**Smart Preview Algorithm:**
- Respects code boundaries
- Looks for natural breaks
- Configurable line limits

### wordFilters.ts

Keyword filtering data:
Expand Down
3 changes: 1 addition & 2 deletions electron/services/.summary_short.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ This directory contains core services that power Athanor's file system operation
- **PathUtils.test.ts** - Unit tests for PathUtils validating cross-platform path manipulation functions.
- **PathUtils.ts** - Stateless utilities for consistent cross-platform path manipulation with Unix-style normalization.
- **ProjectGraphService.ts** - Analyzes project structure to build dependency graphs, file mentions, and commit relationships for relevance scoring.
- **PromptUtils.ts** - Utilities for prompt construction including token counting and smart content preview generation.
- **RelevanceEngineService.ts** - Two-phase scoring engine that identifies relevant context files using multiple heuristics and token budgeting.
- **RelevanceEngineService.ts** - Two-phase scoring engine that identifies relevant context files using multiple heuristics and token budgeting (uses genai-lite/utils for prompt utilities).
- **SettingsService.ts** - Manages reading/writing of project and application settings JSON files with proper error handling.
- **ShellService.ts** - Manages persistent pseudo-terminal sessions for integrated CLI functionality with buffered output.
- **TaskAnalysisUtils.test.ts** - Unit tests for task analysis utilities validating keyword extraction and path mention detection.
Expand Down
71 changes: 0 additions & 71 deletions electron/services/PromptUtils.ts

This file was deleted.

7 changes: 4 additions & 3 deletions electron/services/RelevanceEngineService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import type { IGitService } from '../../common/types/git-service';
import { DependencyScanner } from './DependencyScanner';
import { PathUtils } from './PathUtils';
import { CONTEXT_BUILDER, SETTINGS } from '../../src/utils/constants';
import * as PromptUtils from './PromptUtils';
// @ts-ignore - webpack module resolution issue
import { countTokens, getSmartPreview } from 'genai-lite/utils';
import { ProjectGraphService } from './ProjectGraphService';
import { analyzeTaskDescription } from './TaskAnalysisUtils';
import { UserActivityService } from './UserActivityService';
Expand Down Expand Up @@ -354,11 +355,11 @@ export class RelevanceEngineService {
const content = (await this.fileService.read(filePath, {
encoding: 'utf-8',
})) as string;
const preview = PromptUtils.getSmartPreview(
const preview = getSmartPreview(
content,
smartPreviewConfig
);
const tokenCount = PromptUtils.countTokens(preview);
const tokenCount = countTokens(preview);

if (currentTokens + tokenCount <= options.maxNeighborTokens) {
promptNeighbors.push(filePath);
Expand Down
47 changes: 39 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "athanor",
"version": "0.7.11",
"version": "0.7.12",
"bugs": {
"url": "https://github.com/lacerbi/athanor/issues"
},
Expand Down Expand Up @@ -107,7 +107,7 @@
"diff-match-patch": "^1.0.5",
"fix-path": "^4.0.0",
"genai-key-storage-lite": "^0.1.4",
"genai-lite": "^0.1.0",
"genai-lite": "^0.1.4",
"ignore": "^7.0.0",
"js-tiktoken": "^1.0.16",
"lucide-react": "^0.469.0",
Expand Down
4 changes: 2 additions & 2 deletions src/components/ApiKeyManagementPane.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// AI Summary: Dedicated component for secure API key management with provider selection,
// key storage/deletion, validation, and display functionality. Uses secure storage via IPC bridge.
// Updated for enhanced security - no longer has access to plaintext keys in renderer process.
// Fetches model presets from genai-lite LLM service to determine available providers.

import React, { useEffect, useState, useCallback } from 'react';
import { HelpCircle, Eye, EyeOff, Save, Trash2, Check } from 'lucide-react';
Expand All @@ -9,7 +10,6 @@ import { ApiKeyServiceRenderer } from 'genai-key-storage-lite/renderer';
// Once common export is added to the package, use these imports:
import type { ApiProvider } from 'genai-key-storage-lite/common';
import { ApiKeyStorageError } from 'genai-key-storage-lite/common';
import { getAllAthanorPresets } from '../services/athanorPresetService';

const ApiKeyManagementPane: React.FC = () => {
// API Key Management state
Expand Down Expand Up @@ -96,7 +96,7 @@ const ApiKeyManagementPane: React.FC = () => {
setKeyOpError(null);

// Fetch Athanor presets and filter providers
getAllAthanorPresets()
window.electronBridge.llmService.getPresets()
.then((presets) => {
// Extract unique provider IDs from presets
const presetProviderIdSet = new Set<string>(
Expand Down
Loading