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: 20 additions & 3 deletions .claude/plans/custom-prompting-feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,26 @@ class ChatSession:
- Safety and security measures
- Documentation and examples

## Built-in Prompt Library

### Writing & Communication (15 prompts)
## Revised Built-in Prompt Library

### Phase 0.5: Essential Prompts (5 prompts)
- `email`: Professional email drafting
- `code-review`: Basic code review
- `summarize`: Content summarization
- `explain`: Concept explanation
- `analyze`: General analysis framework

### Phase 1: Core Library (10 prompts)
- Previous 5 plus:
- `debug-help`: Debugging assistance
- `technical-doc`: Technical documentation
- `meeting-notes`: Meeting summarization
- `creative-writing`: Creative writing assistance
- `data-analysis`: Data interpretation

### Phase 2: Complete Library (30+ prompts)

#### Writing & Communication (10 prompts)
- `email-professional`: Professional email drafting
- `email-followup`: Follow-up email templates
- `technical-documentation`: Technical doc generation
Expand Down
14 changes: 13 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ Nova is an AI research and personal assistant written in Python that provides:
- YAML-based configuration management
- Chat history saved to markdown files
- **Multi-provider AI integration** (OpenAI, Anthropic, Ollama)
- **Custom prompt templating system** with built-in templates and user-defined prompts
- Modular architecture for extensibility

**Current Status:** Phase 2 complete (AI integration), supports OpenAI, Anthropic, and Ollama.
**Current Status:** Phase 3 complete (Custom Prompting), supports OpenAI, Anthropic, and Ollama with custom prompt templates.

## Package Management Commands

Expand All @@ -37,6 +38,13 @@ Use these commands:
- Show configuration: `uv run nova config show`
- Initialize config: `uv run nova config init`

## Prompt Management Commands

- List available prompt templates: `/prompts`
- Search prompt templates: `/prompts search <query>`
- Apply a prompt template: `/prompt <name>`
- Templates are stored in `~/.nova/prompts/user/custom/` (user-defined) and built-in templates

## Testing Commands

- Run all tests: `uv run pytest`
Expand Down Expand Up @@ -107,6 +115,9 @@ Use these commands:
- **Clean logic**: Keep core logic clean and push implementation details to the edges
- **File Organsiation**: Balance file organization with simplicity - use an appropriate number of files for the project scale
- **Input Handling**: Use `prompt-toolkit` for enhanced terminal input with arrow key navigation and history support
- **Template Security**: Always validate user-provided templates for dangerous patterns and length limits
- **Path Security**: Ensure file paths are properly sanitized to prevent directory traversal attacks
- **Variable Validation**: Use type checking for template variables and validate required fields
- **YAML Security**: Always use `yaml.safe_load()` instead of `yaml.load()` to prevent code injection
- **Error Handling**: Use specific exception types and provide meaningful error messages; avoid silent failures
- **Metadata Validation**: Validate user-provided metadata to prevent oversized or malicious content
Expand All @@ -126,6 +137,7 @@ Use these commands:
- Chat history persistence in markdown format with YAML frontmatter metadata
- Interactive chat sessions with commands (/help, /save, etc.)
- Enhanced input handling with arrow key navigation and message history
- **Custom prompt templating system** with validation, categories, and variable substitution
- Comprehensive test suite with unit and integration tests

**Chat History Format:**
Expand Down
152 changes: 149 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Nova - AI Research Assistant

Nova is a configurable command-line AI assistant that provides multi-provider AI integration, conversation history, and extensible chat capabilities. Built with Python and Typer, Nova supports OpenAI, Anthropic, and Ollama providers with a profile-based configuration system and persistent chat history saved in markdown format.
Nova is a configurable command-line AI assistant that provides multi-provider AI integration, conversation history, and extensible chat capabilities. Built with Python and Typer, Nova supports OpenAI, Anthropic, and Ollama providers with a profile-based configuration system, custom prompting templates, and persistent chat history saved in markdown format.

## Features

- **Multi-provider AI Integration**: Support for OpenAI, Anthropic, and Ollama
- **Profile-based Configuration**: Easy switching between different AI models and providers
- **Custom Prompting System**: Built-in prompt library with interactive templates and system prompts
- **Interactive CLI**: Built with Typer for a rich command-line experience
- **Intelligent Chat History**: Conversations saved as markdown files with smart content-based titles
- **Session Management**: Resume your most recent conversation with a single command
Expand Down Expand Up @@ -142,6 +143,7 @@ uv run nova --verbose chat start

While in a chat session, you can use these commands:

**General Commands:**
- `/help` - Show available commands
- `/save` - Save current conversation
- `/history` - View conversation history
Expand All @@ -152,8 +154,129 @@ While in a chat session, you can use these commands:
- `/tag <tags>` - Add tags to conversation
- `/stats` - Show memory statistics

**Prompt Commands:**
- `/prompt <name>` - Apply a prompt template interactively
- `/prompts` - List all available prompt templates
- `/prompts search <query>` - Search prompt templates by keywords

**Note**: Conversations without manually set titles will automatically generate intelligent titles based on the content of your first message.

## Custom Prompting System

Nova includes a powerful custom prompting system that allows you to use pre-built templates and create custom system prompts for different AI profiles.

### Built-in Prompt Templates

Nova comes with essential prompt templates that you can use immediately:

- **`email`** - Draft professional emails with proper tone and structure
- **`code-review`** - Comprehensive code review focusing on quality and best practices
- **`summarize`** - Summarize content with key points and insights
- **`explain`** - Explain complex concepts in simple terms
- **`analyze`** - General analysis framework for topics and situations

### Using Prompts in Chat

```bash
# List all available prompt templates
/prompts

# Search for specific prompts
/prompts search code
/prompts search email

# Apply a prompt template interactively
/prompt email
# Nova will ask for required variables like purpose, recipient, tone

/prompt code-review
# Nova will ask for code, language, and focus areas
```

### System Prompts per Profile

Configure custom system prompts for each AI profile to get consistent behavior:

```yaml
profiles:
coding-assistant:
name: "Coding Assistant"
provider: "anthropic"
model_name: "claude-3-5-sonnet-20241022"
system_prompt: |
You are an expert software developer and code reviewer.
Focus on writing clean, maintainable, and well-documented code.
Always explain your reasoning and suggest best practices.
Today is ${current_date} and the user is ${user_name}.

creative-writer:
name: "Creative Writer"
provider: "openai"
model_name: "gpt-4"
system_prompt: |
You are a creative writing assistant with expertise in storytelling,
character development, and narrative structure.
Help users craft compelling stories and improve their writing style.
```

### System Prompt Variables

System prompts support variable substitution:

- `${current_date}` - Current date (YYYY-MM-DD)
- `${current_time}` - Current time (HH:MM:SS)
- `${user_name}` - System username
- `${conversation_id}` - Current conversation ID
- `${active_profile}` - Active profile name

### Prompt Configuration

Configure the prompting system in your `config.yaml`:

```yaml
prompts:
enabled: true # Enable/disable prompt system
library_path: ~/.nova/prompts # Where to store custom prompts
allow_user_prompts: true # Allow custom user prompts
validate_prompts: true # Validate prompt templates
max_prompt_length: 8192 # Maximum prompt length
```

### Creating Custom Prompts

Create custom prompt templates by saving YAML files in `~/.nova/prompts/user/custom/`:

```yaml
# ~/.nova/prompts/user/custom/my-prompt.yaml
name: "meeting-prep"
title: "Meeting Preparation Assistant"
description: "Help prepare for meetings with agenda and talking points"
category: "business"
tags: ["meeting", "preparation", "agenda"]
variables:
- name: "meeting_type"
description: "Type of meeting"
required: true
- name: "attendees"
description: "Meeting attendees"
required: false
default: "team members"
- name: "duration"
description: "Meeting duration"
required: false
default: "1 hour"

template: |
Please help me prepare for a ${meeting_type} with ${attendees}.
The meeting is scheduled for ${duration}.

Please provide:
- Suggested agenda items
- Key talking points
- Potential questions to ask
- Follow-up actions to consider
```

## Enhanced Features

### Intelligent Title Generation
Expand Down Expand Up @@ -291,6 +414,14 @@ chat:
max_history_length: 50
auto_save: true

# Custom prompting system
prompts:
enabled: true
library_path: "~/.nova/prompts"
allow_user_prompts: true
validate_prompts: true
max_prompt_length: 8192

# AI profiles for different models and providers
profiles:
default:
Expand All @@ -315,6 +446,18 @@ profiles:
max_tokens: 4000
temperature: 0.7

coding-assistant:
name: "Coding Assistant"
provider: "anthropic"
model_name: "claude-3-5-sonnet-20241022"
max_tokens: 4000
temperature: 0.7
system_prompt: |
You are Nova, an expert software developer and code reviewer.
Focus on writing clean, maintainable, and well-documented code.
Always explain your reasoning and suggest best practices.
Today is ${current_date} and the user is ${user_name}.

llama:
name: "llama"
provider: "ollama"
Expand Down Expand Up @@ -358,15 +501,18 @@ nova/
| | |-- chat.py # Chat functionality
| | |-- config.py # Configuration management
| | |-- history.py # Chat history persistence
| | `-- memory.py # Memory management
| | |-- memory.py # Memory management
| | `-- prompts.py # Prompt management system
| |-- models/ # Pydantic data models
| | |-- config.py # Configuration models
| | `-- message.py # Message models
| | |-- message.py # Message models
| | `-- prompts.py # Prompt data models
| `-- utils/ # Shared utilities
| |-- files.py # File operations
| `-- formatting.py # Output formatting
|-- tests/ # Test suite
| |-- unit/ # Unit tests
| | `-- test_prompts.py # Prompt system tests
| `-- integration/ # Integration tests
`-- config/
`-- default.yaml # Default configuration
Expand Down
Loading