OverviewFilesCommitsIssuesDocsReleasesPeers

ollama_semantic_function_calling commits / db78bdc

Add AI simplification guides with detailed implementation instructions
db78bdc0dfc8f2d82ff915613f762ac898f538c1
by fleeky.ashatron <fleeky@7rnx.net> · 2025-04-19T01:35:58.000Z

Changed files (4) +831 -0

ollamatools-project/ai_simplification_guides/00_INDEX.md +103 -0
……@@ -0,0 +1,103 @@
1# OllamaTools AI Simplification Guide - Index
2
3This is the main index for the AI Simplification Guide, which provides detailed instructions for AI assistants to implement the OllamaTools simplification plan. The guide is broken down into multiple documents to make it more manageable and focused.
4
5## Guide Structure
6
7The AI Simplification Guide is organized into the following documents:
8
9### Core Documents
10
111. **[00_INDEX.md](./00_INDEX.md)** - This index document
122. **[01_ANALYSIS.md](./01_ANALYSIS.md)** - Initial codebase analysis and setup
133. **[02_DIRECTORY_STRUCTURE.md](./02_DIRECTORY_STRUCTURE.md)** - Complete directory structure for the simplified project
14
15### Phase 1: Core Infrastructure
16
174. **[10_CORE_OVERVIEW.md](./10_CORE_OVERVIEW.md)** - Overview of the Core Infrastructure phase
185. **[11_CORE_AGENT.md](./11_CORE_AGENT.md)** - Implementation of the Core Agent
196. **[12_CORE_CONFIG.md](./12_CORE_CONFIG.md)** - Implementation of the Configuration System
207. **[13_CORE_ERRORS.md](./13_CORE_ERRORS.md)** - Implementation of Error Handling
218. **[14_CORE_SECURITY.md](./14_CORE_SECURITY.md)** - Implementation of Security Features
229. **[15_CORE_UTILS.md](./15_CORE_UTILS.md)** - Implementation of Core Utilities
23
24### Phase 2: Plugin System
25
2610. **[20_PLUGIN_OVERVIEW.md](./20_PLUGIN_OVERVIEW.md)** - Overview of the Plugin System phase
2711. **[21_PLUGIN_BASE.md](./21_PLUGIN_BASE.md)** - Implementation of Plugin Base Classes
2812. **[22_PLUGIN_REGISTRY.md](./22_PLUGIN_REGISTRY.md)** - Implementation of Plugin Registry
2913. **[23_PLUGIN_ERRORS.md](./23_PLUGIN_ERRORS.md)** - Implementation of Plugin Error Handling
30
31### Phase 3: Standard Plugins
32
3314. **[30_STANDARD_PLUGINS_OVERVIEW.md](./30_STANDARD_PLUGINS_OVERVIEW.md)** - Overview of Standard Plugins
3415. **[31_SEARCH_PLUGIN.md](./31_SEARCH_PLUGIN.md)** - Implementation of Search Plugin
3516. **[32_COMMANDS_PLUGIN.md](./32_COMMANDS_PLUGIN.md)** - Implementation of Commands Plugin
3617. **[33_CONVERSATION_PLUGINS.md](./33_CONVERSATION_PLUGINS.md)** - Implementation of Conversation Plugins
3718. **[34_FEEDBACK_PLUGIN.md](./34_FEEDBACK_PLUGIN.md)** - Implementation of Feedback Plugin
3819. **[35_ISSUES_PLUGIN.md](./35_ISSUES_PLUGIN.md)** - Implementation of Issues Plugin
3920. **[36_FUNCTION_CALLING_PLUGIN.md](./36_FUNCTION_CALLING_PLUGIN.md)** - Implementation of Function Calling Plugin
40
41### Phase 4: Tool Plugins
42
4321. **[40_TOOL_PLUGINS_OVERVIEW.md](./40_TOOL_PLUGINS_OVERVIEW.md)** - Overview of Tool Plugins
4422. **[41_SYSTEM_TOOLS.md](./41_SYSTEM_TOOLS.md)** - Implementation of System Tools Plugin
4523. **[42_WEB_TOOLS.md](./42_WEB_TOOLS.md)** - Implementation of Web Tools Plugin
4624. **[43_DOC_TOOLS.md](./43_DOC_TOOLS.md)** - Implementation of Documentation Tools Plugin
47
48### Phase 5: Integration Plugins
49
5025. **[50_INTEGRATION_PLUGINS_OVERVIEW.md](./50_INTEGRATION_PLUGINS_OVERVIEW.md)** - Overview of Integration Plugins
5126. **[51_MATRIX_INTEGRATION.md](./51_MATRIX_INTEGRATION.md)** - Implementation of Matrix Integration
5227. **[52_OPENSEARCH_INTEGRATION.md](./52_OPENSEARCH_INTEGRATION.md)** - Implementation of OpenSearch Integration
53
54### Phase 6: Agent Implementations
55
5628. **[60_AGENT_IMPLEMENTATIONS_OVERVIEW.md](./60_AGENT_IMPLEMENTATIONS_OVERVIEW.md)** - Overview of Agent Implementations
5729. **[61_BASIC_AGENT.md](./61_BASIC_AGENT.md)** - Implementation of Basic Agent
5830. **[62_MODULAR_AGENT.md](./62_MODULAR_AGENT.md)** - Implementation of Modular Agent
5931. **[63_EXTENDED_AGENT.md](./63_EXTENDED_AGENT.md)** - Implementation of Extended Agent
60
61### Phase 7: Configuration System
62
6332. **[70_CONFIG_SYSTEM_OVERVIEW.md](./70_CONFIG_SYSTEM_OVERVIEW.md)** - Overview of Configuration System
6433. **[71_CONFIG_SCHEMAS.md](./71_CONFIG_SCHEMAS.md)** - Implementation of Configuration Schemas
6534. **[72_CONFIG_LOADER.md](./72_CONFIG_LOADER.md)** - Implementation of Configuration Loader
6635. **[73_CONFIG_DEFAULTS.md](./73_CONFIG_DEFAULTS.md)** - Implementation of Default Configurations
67
68### Phase 8: Command-Line Interface
69
7036. **[80_CLI_OVERVIEW.md](./80_CLI_OVERVIEW.md)** - Overview of Command-Line Interface
7137. **[81_CLI_IMPLEMENTATION.md](./81_CLI_IMPLEMENTATION.md)** - Implementation of Command-Line Interface
72
73### Migration and Testing
74
7538. **[90_MIGRATION_OVERVIEW.md](./90_MIGRATION_OVERVIEW.md)** - Overview of Migration Strategy
7639. **[91_MIGRATION_CORE.md](./91_MIGRATION_CORE.md)** - Migration of Core Components
7740. **[92_MIGRATION_PLUGINS.md](./92_MIGRATION_PLUGINS.md)** - Migration of Plugins
7841. **[93_MIGRATION_AGENTS.md](./93_MIGRATION_AGENTS.md)** - Migration of Agents
7942. **[94_TESTING_STRATEGY.md](./94_TESTING_STRATEGY.md)** - Testing Strategy and Implementation
80
81## How to Use This Guide
82
83This guide is designed to be followed sequentially, starting with the analysis and directory structure, then implementing each phase in order. Each document provides detailed, step-by-step instructions with complete code examples.
84
85For AI assistants:
861. Start by reading the analysis document to understand the current codebase
872. Review the directory structure document to understand the target architecture
883. Implement each phase in order, following the detailed instructions in each document
894. Use the migration documents to ensure backward compatibility
905. Follow the testing strategy to verify the implementation
91
92For human developers:
931. Use this guide to understand the implementation plan
942. Assign specific documents or phases to AI assistants for implementation
953. Review the AI-generated code before committing
964. Provide feedback to improve the implementation
97
98## Implementation Status
99
100This guide is a work in progress. The following documents are currently complete:
101- [00_INDEX.md](./00_INDEX.md) - This index document
102
103The remaining documents will be created as the implementation progresses.
ollamatools-project/ai_simplification_guides/01_ANALYSIS.md +234 -0
……@@ -0,0 +1,234 @@
1# Initial Codebase Analysis and Setup
2
3This document provides detailed instructions for analyzing the current OllamaTools codebase and setting up the environment for the simplification project.
4
5## Prerequisites
6
7Before beginning the analysis, ensure you have the following:
8
91. A local clone of the OllamaTools repository
102. Python 3.8 or higher installed
113. Git installed
124. A code editor (e.g., VS Code, PyCharm)
13
14## Step 1: Clone the Repository and Create a Branch
15
16```bash
17# Clone the repository (if you haven't already)
18git clone [repository-url]
19cd ollamatools
20
21# Create and checkout a new branch for the simplification project
22git checkout -b simplify
23```
24
25## Step 2: Install Dependencies
26
27```bash
28# Install the package in development mode
29pip install -e .
30
31# Install development dependencies
32pip install pytest pytest-cov black isort flake8
33```
34
35## Step 3: Analyze the Current Directory Structure
36
37Run the following command to get a high-level overview of the directory structure:
38
39```bash
40find . -type d -not -path "*/\.*" -not -path "*/venv*" | sort
41```
42
43The current directory structure should look something like this:
44
45```
46.
47├── build
48│ └── lib
49│ ├── ollamatools
50│ │ ├── agent
51│ │ │ ├── extended
52│ │ │ ├── modular
53│ │ │ ├── plugins
54│ │ │ └── transparent
55│ │ ├── config
56│ │ ├── plugins
57│ │ ├── tools
58│ │ └── utils
59│ └── tests
60├── docs
61├── examples
62│ └── config
63├── ollamatools
64│ ├── agent
65│ │ ├── extended
66│ │ ├── modular
67│ │ ├── plugins
68│ │ └── transparent
69│ ├── config
70│ ├── plugins
71│ ├── tools
72│ └── utils
73├── ollamatools.egg-info
74├── scripts
75└── tests
76```
77
78## Step 4: Identify Key Files
79
80Identify the key files in the codebase that will need to be analyzed in detail:
81
82```bash
83# Find all Python files
84find . -name "*.py" -not -path "*/\.*" -not -path "*/venv*" | sort
85```
86
87Pay special attention to the following files:
88
891. **Core Agent Files**:
90 - `ollamatools/agent.py`
91 - `ollamatools/agent/core.py`
92
932. **Modular Agent Files**:
94 - `ollamatools/agent/modular/agent.py`
95 - `ollamatools/agent/modular/commands.py`
96 - `ollamatools/agent/modular/search.py`
97 - `ollamatools/agent/modular/issues.py`
98 - `ollamatools/agent/modular/feedback.py`
99 - `ollamatools/agent/modular/utils.py`
100
1013. **Extended Agent Files**:
102 - `ollamatools/agent/extended/agent.py`
103
1044. **Plugin System Files**:
105 - `ollamatools/plugins/registry.py`
106 - `ollamatools/plugins/errors.py`
107 - `ollamatools/agent/plugins/*.py`
108
1095. **Tool Files**:
110 - `ollamatools/tools/system_tools.py`
111 - `ollamatools/tools/web_tools.py`
112 - `ollamatools/tools/doc_tools.py`
113 - `ollamatools/tools/matrix_tools.py`
114
1156. **Configuration Files**:
116 - `ollamatools/config/core_config.py`
117 - `ollamatools/config/plugin_config.py`
118 - `ollamatools/config/schemas.py`
119
120## Step 5: Analyze Dependencies Between Components
121
122Create a dependency graph to understand how the different components interact with each other:
123
124```bash
125# Install pipdeptree if you don't have it
126pip install pipdeptree
127
128# Generate a dependency graph
129pipdeptree -p ollamatools
130```
131
132Additionally, analyze the import statements in the codebase to identify internal dependencies:
133
134```bash
135# Find all import statements
136grep -r "^import " --include="*.py" . | grep -v "__pycache__" | sort
137grep -r "^from " --include="*.py" . | grep -v "__pycache__" | sort
138```
139
140Look for circular dependencies, which will need to be resolved in the simplified architecture.
141
142## Step 6: Analyze the Current Plugin System
143
144The current plugin system is implemented across multiple directories:
145
146- `ollamatools/plugins/` - Contains the plugin registry and base classes
147- `ollamatools/agent/plugins/` - Contains agent-specific plugins
148- `ollamatools/tools/` - Contains tool implementations that may be used by plugins
149
150Analyze how plugins are currently registered, loaded, and used:
151
152```bash
153# Find all plugin-related code
154grep -r "Plugin" --include="*.py" . | grep -v "__pycache__" | sort
155```
156
157## Step 7: Analyze the Matrix Integration
158
159The Matrix integration is implemented in:
160
161- `ollamatools/tools/matrix_tools.py`
162- `ollamatools/tools/enhanced_matrix_tools.py`
163- `ollamatools/tools/enhanced_matrix_core.py`
164- `ollamatools/tools/enhanced_matrix_history.py`
165- `ollamatools/tools/enhanced_matrix_search.py`
166
167Analyze how the Matrix integration interacts with the agent and plugin system:
168
169```bash
170# Find all Matrix-related code
171grep -r "Matrix" --include="*.py" . | grep -v "__pycache__" | sort
172```
173
174## Step 8: Analyze the Test Suite
175
176Analyze the test suite to understand what functionality needs to be preserved:
177
178```bash
179# Find all test files
180find . -name "test_*.py" -not -path "*/\.*" -not -path "*/venv*" | sort
181
182# Run the tests to see what's currently working
183pytest
184```
185
186## Step 9: Identify Redundancies and Overlaps
187
188Look for redundant code and overlapping functionality:
189
190```bash
191# Find similar function names across files
192grep -r "def " --include="*.py" . | grep -v "__pycache__" | sort | uniq -c | sort -nr | head -20
193```
194
195Common areas of redundancy include:
196- Configuration handling
197- Error handling
198- Logging
199- Permission checking
200- Command execution
201- File operations
202- Web requests
203
204## Step 10: Document Findings
205
206Document your findings in a structured way, focusing on:
207
2081. **Current Architecture**:
209 - Main components and their responsibilities
210 - Interactions between components
211 - Dependencies between components
212
2132. **Redundancies and Overlaps**:
214 - Duplicate functionality
215 - Similar implementations with slight variations
216 - Overlapping responsibilities
217
2183. **Circular Dependencies**:
219 - Components that depend on each other
220 - Import cycles that need to be broken
221
2224. **Inconsistencies**:
223 - Inconsistent naming conventions
224 - Inconsistent error handling
225 - Inconsistent configuration handling
226
2275. **Strengths to Preserve**:
228 - Well-designed components
229 - Clean interfaces
230 - Comprehensive test coverage
231
232## Next Steps
233
234After completing the analysis, proceed to the [Directory Structure](./02_DIRECTORY_STRUCTURE.md) document to understand the target architecture for the simplified project.
ollamatools-project/ai_simplification_guides/02_DIRECTORY_STRUCTURE.md +412 -0
……@@ -0,0 +1,412 @@
1# Complete Directory Structure for the Simplified Project
2
3This document provides the complete directory structure for the simplified OllamaTools project. This structure serves as a blueprint for the implementation and should be followed closely to ensure consistency.
4
5## Target Directory Structure
6
7```
8ollamatools/
9├── core/ # Core functionality
10│ ├── __init__.py
11│ ├── agent.py # Base agent implementation
12│ ├── config.py # Configuration management
13│ ├── errors.py # Error definitions and handling
14│ ├── security.py # Security utilities and permission system
15│ └── utils/
16│ ├── __init__.py
17│ ├── logger.py # Logging utilities
18│ ├── validators.py # Input validation (combines command/path/url validators)
19│ └── formatting.py # Text formatting utilities
20│
21├── plugins/ # Plugin system and implementations
22│ ├── __init__.py
23│ ├── base.py # Base plugin interfaces
24│ ├── registry.py # Plugin discovery and management
25│ ├── errors.py # Plugin-specific error handling
26│ ├── standard/ # Standard plugins
27│ │ ├── __init__.py
28│ │ ├── search.py # Search functionality
29│ │ ├── commands.py # Command management
30│ │ ├── conversation/
31│ │ │ ├── __init__.py
32│ │ │ ├── history.py # Conversation history tracking
33│ │ │ ├── context.py # Conversation context management
34│ │ │ └── analysis.py # Topic analysis and metrics
35│ │ ├── feedback.py # Feedback collection
36│ │ ├── issues.py # Issue tracking
37│ │ └── function_calling.py # Semantic function calling
38│ │
39│ ├── tools/ # Tool plugins
40│ │ ├── __init__.py
41│ │ ├── system.py # System tools (file operations, commands)
42│ │ ├── web.py # Web tools (HTTP requests, web searches)
43│ │ └── doc.py # Documentation tools
44│ │
45│ └── integrations/ # Integration plugins
46│ ├── __init__.py
47│ ├── matrix/
48│ │ ├── __init__.py
49│ │ ├── client.py # Matrix client core
50│ │ ├── commands.py # Matrix-specific commands
51│ │ ├── config.py # Matrix configuration
52│ │ ├── search.py # Matrix search integration
53│ │ ├── history.py # Matrix history tracking
54│ │ └── rate_limit.py # Rate limiting for Matrix
55│ └── opensearch/
56│ ├── __init__.py
57│ ├── client.py # OpenSearch client
58│ └── tools.py # OpenSearch web tools
59│
60├── agents/ # Agent implementations
61│ ├── __init__.py
62│ ├── basic.py # Basic agent implementation
63│ ├── modular.py # Modular agent implementation
64│ └── extended.py # Extended agent implementation
65│
66├── config/ # Configuration system
67│ ├── __init__.py
68│ ├── schemas.py # Configuration schemas
69│ ├── loader.py # Configuration loading/validation
70│ └── defaults.py # Default configurations
71│
72├── cli/ # Command-line interface
73│ ├── __init__.py
74│ └── main.py # Command-line interface
75│
76├── __init__.py # Package initialization
77└── version.py # Version information
78```
79
80## File Descriptions
81
82### Core Module
83
84#### `core/__init__.py`
85- Exports core components
86- Defines version information
87- Provides convenience imports
88
89#### `core/agent.py`
90- Defines the base `Agent` class
91- Implements core agent functionality
92- Provides plugin management
93- Handles basic chat processing
94- Implements error handling
95- Manages lifecycle (startup/shutdown)
96
97#### `core/config.py`
98- Implements configuration loading and saving
99- Provides configuration validation
100- Handles configuration merging
101- Defines default configuration values
102
103#### `core/errors.py`
104- Defines error types
105- Implements error handling utilities
106- Provides error formatting
107
108#### `core/security.py`
109- Implements permission system
110- Provides security validation
111- Handles secure defaults
112
113#### `core/utils/__init__.py`
114- Exports utility functions
115- Provides convenience imports
116
117#### `core/utils/logger.py`
118- Implements logging configuration
119- Provides logging utilities
120- Handles log formatting
121
122#### `core/utils/validators.py`
123- Implements input validation
124- Combines command/path/url validators
125- Provides security checks
126
127#### `core/utils/formatting.py`
128- Implements text formatting utilities
129- Provides markdown generation
130- Handles output formatting
131
132### Plugin System
133
134#### `plugins/__init__.py`
135- Exports plugin components
136- Provides convenience imports
137
138#### `plugins/base.py`
139- Defines base plugin interfaces
140- Implements plugin lifecycle methods
141- Provides plugin metadata
142
143#### `plugins/registry.py`
144- Implements plugin discovery
145- Handles plugin registration
146- Manages plugin dependencies
147- Provides plugin initialization
148
149#### `plugins/errors.py`
150- Defines plugin-specific error types
151- Implements plugin error handling
152- Provides plugin error reporting
153
154### Standard Plugins
155
156#### `plugins/standard/__init__.py`
157- Exports standard plugins
158- Provides convenience imports
159
160#### `plugins/standard/search.py`
161- Implements search functionality
162- Provides intent detection
163- Handles search result processing
164
165#### `plugins/standard/commands.py`
166- Implements command management
167- Provides command registration
168- Handles command execution
169
170#### `plugins/standard/conversation/__init__.py`
171- Exports conversation plugins
172- Provides convenience imports
173
174#### `plugins/standard/conversation/history.py`
175- Implements conversation history tracking
176- Provides history storage and retrieval
177- Handles history summarization
178
179#### `plugins/standard/conversation/context.py`
180- Implements conversation context management
181- Provides context tracking per user/room
182- Handles context window management
183
184#### `plugins/standard/conversation/analysis.py`
185- Implements topic analysis
186- Provides performance metrics
187- Handles usage statistics
188
189#### `plugins/standard/feedback.py`
190- Implements feedback collection
191- Provides feedback analysis
192- Handles feedback-based improvements
193
194#### `plugins/standard/issues.py`
195- Implements issue tracking
196- Provides issue creation and management
197- Handles issue prioritization
198
199#### `plugins/standard/function_calling.py`
200- Implements semantic function calling
201- Provides function detection
202- Handles function parameter extraction
203
204### Tool Plugins
205
206#### `plugins/tools/__init__.py`
207- Exports tool plugins
208- Provides convenience imports
209
210#### `plugins/tools/system.py`
211- Implements system command execution
212- Provides file operations
213- Handles directory operations
214
215#### `plugins/tools/web.py`
216- Implements HTTP requests
217- Provides web searches
218- Handles API integrations
219
220#### `plugins/tools/doc.py`
221- Implements markdown generation
222- Provides document summarization
223- Handles context extraction
224
225### Integration Plugins
226
227#### `plugins/integrations/__init__.py`
228- Exports integration plugins
229- Provides convenience imports
230
231#### `plugins/integrations/matrix/__init__.py`
232- Exports Matrix integration components
233- Provides convenience imports
234
235#### `plugins/integrations/matrix/client.py`
236- Implements Matrix client
237- Provides connection management
238- Handles message sending/receiving
239
240#### `plugins/integrations/matrix/commands.py`
241- Implements Matrix-specific commands
242- Provides command parsing
243- Handles command execution
244
245#### `plugins/integrations/matrix/config.py`
246- Implements Matrix configuration
247- Provides configuration loading/saving
248- Handles configuration validation
249
250#### `plugins/integrations/matrix/search.py`
251- Implements Matrix search integration
252- Provides search command handling
253- Handles search result formatting
254
255#### `plugins/integrations/matrix/history.py`
256- Implements Matrix history tracking
257- Provides history storage
258- Handles history command handling
259
260#### `plugins/integrations/matrix/rate_limit.py`
261- Implements rate limiting for Matrix
262- Provides backoff strategies
263- Handles error handling for rate limits
264
265#### `plugins/integrations/opensearch/__init__.py`
266- Exports OpenSearch integration components
267- Provides convenience imports
268
269#### `plugins/integrations/opensearch/client.py`
270- Implements OpenSearch client
271- Provides connection management
272- Handles query execution
273
274#### `plugins/integrations/opensearch/tools.py`
275- Implements OpenSearch web tools
276- Provides search query formatting
277- Handles result processing
278
279### Agent Implementations
280
281#### `agents/__init__.py`
282- Exports agent implementations
283- Provides convenience imports
284
285#### `agents/basic.py`
286- Implements basic agent
287- Provides minimal feature set
288- Handles simple chat processing
289
290#### `agents/modular.py`
291- Implements modular agent
292- Provides plugin-based architecture
293- Handles advanced chat processing
294
295#### `agents/extended.py`
296- Implements extended agent
297- Provides advanced features
298- Handles comprehensive functionality
299
300### Configuration System
301
302#### `config/__init__.py`
303- Exports configuration components
304- Provides convenience imports
305
306#### `config/schemas.py`
307- Implements configuration schemas
308- Provides schema validation
309- Handles schema versioning
310
311#### `config/loader.py`
312- Implements configuration loading
313- Provides environment variable integration
314- Handles configuration merging
315
316#### `config/defaults.py`
317- Implements default configurations
318- Provides sensible defaults
319- Handles documentation of configuration options
320
321### Command-Line Interface
322
323#### `cli/__init__.py`
324- Exports CLI components
325- Provides convenience imports
326
327#### `cli/main.py`
328- Implements command-line interface
329- Provides command parsing
330- Handles interactive mode
331
332### Package Root
333
334#### `__init__.py`
335- Exports main components
336- Provides convenience imports
337- Handles package initialization
338
339#### `version.py`
340- Defines version information
341- Provides version checking
342- Handles compatibility information
343
344## Implementation Strategy
345
346When implementing the simplified project, follow these guidelines:
347
3481. **Create the directory structure first**:
349 ```bash
350 mkdir -p ollamatools/core/utils
351 mkdir -p ollamatools/plugins/standard/conversation
352 mkdir -p ollamatools/plugins/tools
353 mkdir -p ollamatools/plugins/integrations/matrix
354 mkdir -p ollamatools/plugins/integrations/opensearch
355 mkdir -p ollamatools/agents
356 mkdir -p ollamatools/config
357 mkdir -p ollamatools/cli
358 ```
359
3602. **Create empty `__init__.py` files**:
361 ```bash
362 touch ollamatools/__init__.py
363 touch ollamatools/core/__init__.py
364 touch ollamatools/core/utils/__init__.py
365 touch ollamatools/plugins/__init__.py
366 touch ollamatools/plugins/standard/__init__.py
367 touch ollamatools/plugins/standard/conversation/__init__.py
368 touch ollamatools/plugins/tools/__init__.py
369 touch ollamatools/plugins/integrations/__init__.py
370 touch ollamatools/plugins/integrations/matrix/__init__.py
371 touch ollamatools/plugins/integrations/opensearch/__init__.py
372 touch ollamatools/agents/__init__.py
373 touch ollamatools/config/__init__.py
374 touch ollamatools/cli/__init__.py
375 ```
376
3773. **Implement core components first**:
378 - Start with `core/errors.py` as other components depend on it
379 - Then implement `core/utils/` modules
380 - Next, implement `core/config.py` and `core/security.py`
381 - Finally, implement `core/agent.py`
382
3834. **Implement the plugin system**:
384 - Start with `plugins/errors.py`
385 - Then implement `plugins/base.py`
386 - Finally, implement `plugins/registry.py`
387
3885. **Implement plugins in order of dependency**:
389 - Start with tool plugins
390 - Then implement standard plugins
391 - Finally, implement integration plugins
392
3936. **Implement agent implementations**:
394 - Start with the basic agent
395 - Then implement the modular agent
396 - Finally, implement the extended agent
397
3987. **Implement the configuration system**:
399 - Start with `config/schemas.py`
400 - Then implement `config/defaults.py`
401 - Finally, implement `config/loader.py`
402
4038. **Implement the command-line interface**:
404 - Implement `cli/main.py`
405
4069. **Implement package root files**:
407 - Implement `__init__.py`
408 - Implement `version.py`
409
410## Next Steps
411
412After understanding the target directory structure, proceed to the [Core Overview](./10_CORE_OVERVIEW.md) document to begin implementing the core infrastructure.
ollamatools-project/ai_simplification_guides/10_CORE_OVERVIEW.md +82 -0
……@@ -0,0 +1,82 @@
1# Core Infrastructure Overview
2
3This document provides an overview of the Core Infrastructure phase of the OllamaTools simplification project. The Core Infrastructure forms the foundation of the simplified architecture and includes the essential components that all other parts of the system depend on.
4
5## Core Components
6
7The Core Infrastructure consists of the following components:
8
91. **Error Handling System** (`core/errors.py`)
10 - Base error classes
11 - Error formatting utilities
12 - Error handling functions
13
142. **Utility Functions** (`core/utils/`)
15 - Logging utilities (`logger.py`)
16 - Input validation (`validators.py`)
17 - Text formatting (`formatting.py`)
18
193. **Configuration Management** (`core/config.py`)
20 - Configuration loading and saving
21 - Configuration validation
22 - Default configuration values
23
244. **Security System** (`core/security.py`)
25 - Permission management
26 - Security validation
27 - Secure defaults
28
295. **Base Agent** (`core/agent.py`)
30 - Plugin management
31 - Basic chat processing
32 - Lifecycle management
33
34## Implementation Order
35
36The Core Infrastructure components should be implemented in the following order:
37
381. **Error Handling System** - This is the most fundamental component that other components depend on.
392. **Utility Functions** - These provide common functionality used by other components.
403. **Configuration Management** - This provides configuration handling used by other components.
414. **Security System** - This builds on the error handling and configuration systems.
425. **Base Agent** - This brings together all the other components.
43
44## Dependencies
45
46The Core Infrastructure components have the following dependencies:
47
48- **Error Handling System**: No dependencies
49- **Utility Functions**: Depends on Error Handling System
50- **Configuration Management**: Depends on Error Handling System
51- **Security System**: Depends on Error Handling System and Configuration Management
52- **Base Agent**: Depends on all other Core Infrastructure components
53
54## Implementation Guidelines
55
56When implementing the Core Infrastructure components, follow these guidelines:
57
581. **Keep it minimal**: The Core Infrastructure should contain only essential functionality that is needed by multiple other components.
59
602. **Avoid circular dependencies**: Ensure that dependencies flow in one direction, from higher-level components to lower-level components.
61
623. **Use clear interfaces**: Define clear interfaces for each component to make them easy to use and understand.
63
644. **Document thoroughly**: Include comprehensive docstrings for all classes, methods, and functions.
65
665. **Write tests**: Include unit tests for all components to ensure they work correctly.
67
686. **Consider backward compatibility**: Where possible, maintain backward compatibility with the existing codebase to ease migration.
69
70## Implementation Details
71
72Each Core Infrastructure component is detailed in its own document:
73
74- [Core Agent](./11_CORE_AGENT.md)
75- [Core Configuration](./12_CORE_CONFIG.md)
76- [Core Errors](./13_CORE_ERRORS.md)
77- [Core Security](./14_CORE_SECURITY.md)
78- [Core Utilities](./15_CORE_UTILS.md)
79
80## Next Steps
81
82After reviewing this overview, proceed to the [Core Errors](./13_CORE_ERRORS.md) document to begin implementing the Error Handling System, which is the foundation of the Core Infrastructure.