@aeye/cletus 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +624 -0
  2. package/dist/index.js +35391 -0
  3. package/package.json +94 -0
package/README.md ADDED
@@ -0,0 +1,624 @@
1
+ # @aeye/cletus
2
+
3
+ > **Interactive CLI demo showcasing AITS capabilities - an AI-powered assistant with file management, data operations, and autonomous task execution.**
4
+
5
+ Cletus is a terminal-based AI assistant built with the @aeye library that demonstrates the power of multi-provider AI integration, tool calling, and context management. It features a beautiful TUI (Terminal User Interface) powered by React/Ink and provides specialized AI agents for different domains like file operations, data management, image generation, and web searching.
6
+
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0%2B-blue)](https://www.typescriptlang.org/)
9
+
10
+ ## Features
11
+
12
+ ### 🤖 Specialized AI Agents
13
+
14
+ Cletus organizes its capabilities into specialized agents, each with domain-specific tools:
15
+
16
+ - **Architect** - Type definition management for custom data structures
17
+ - **Artist** - Image generation, editing, analysis, and semantic search
18
+ - **Clerk** - File operations, searching, indexing, and summarization
19
+ - **DBA** - Database-like operations on typed data with CRUD capabilities
20
+ - **Internet** - Web search, page scraping, and REST API calls
21
+ - **Librarian** - Knowledge base management with semantic search
22
+ - **Planner** - Todo list management and task tracking
23
+ - **Secretary** - Assistant persona management and user memory
24
+
25
+ ### 🎨 Interactive Terminal UI
26
+
27
+ - Beautiful React/Ink-based interface
28
+ - Chat history management
29
+ - Real-time streaming responses
30
+ - Syntax-highlighted code blocks
31
+ - Operation approval/rejection system
32
+ - Settings configuration wizard
33
+
34
+ ### 💾 Persistent Storage
35
+
36
+ - Chat history with metadata
37
+ - User preferences and memories
38
+ - Custom data types and records
39
+ - Knowledge base with vector embeddings
40
+ - Multi-provider API configurations
41
+
42
+ ### âš¡ Advanced Capabilities
43
+
44
+ - **Autonomous Mode** - AI can execute multiple operations without asking for approval
45
+ - **Custom Assistants** - Create persona-based assistants with unique prompts (Gollum, Sherlock Holmes, etc.)
46
+ - **Type System** - Define custom data structures with fields and validation
47
+ - **Knowledge Base** - Semantic search over user memories, files, and data records
48
+ - **File Intelligence** - Summarize, index, and search files (PDF, Word, Excel, images, etc.)
49
+ - **Image Operations** - Generate, edit, analyze, and find images
50
+ - **Web Integration** - Search the web, scrape pages, make API calls
51
+
52
+ ## Installation
53
+
54
+ ### Global Installation
55
+
56
+ ```bash
57
+ npm install -g @aeye/cletus
58
+ ```
59
+
60
+ ### From Source
61
+
62
+ ```bash
63
+ # Clone the repository
64
+ git clone https://github.com/ClickerMonkey/aeye.git
65
+ cd aeye/packages/cletus
66
+
67
+ # Install dependencies
68
+ npm install
69
+
70
+ # Build and link
71
+ npm run build
72
+ npm link
73
+
74
+ # Run
75
+ cletus
76
+ ```
77
+
78
+ ### Development Mode
79
+
80
+ ```bash
81
+ # Watch mode with hot reload
82
+ npm run dev
83
+
84
+ # Or run directly with tsx
85
+ npm start
86
+ ```
87
+
88
+ ## Quick Start
89
+
90
+ ### First Launch
91
+
92
+ When you run `cletus` for the first time, an interactive setup wizard will guide you through:
93
+
94
+ 1. **User Information** - Your name and pronouns
95
+ 2. **Provider Setup** - Configure AI providers (OpenAI, OpenRouter, Replicate, AWS Bedrock)
96
+ 3. **API Keys** - Enter your API keys or credentials for each provider
97
+
98
+ The configuration is saved to `~/.cletus/config.json` and can be modified later through the settings menu.
99
+
100
+ ### Basic Usage
101
+
102
+ ```bash
103
+ # Start Cletus
104
+ cletus
105
+
106
+ # The main menu provides options to:
107
+ # - Start a new chat
108
+ # - Continue existing chats
109
+ # - Configure settings
110
+ # - Exit
111
+ ```
112
+
113
+ ### Creating a Chat
114
+
115
+ 1. Select "New Chat" from the main menu
116
+ 2. Optionally choose an assistant persona (or use default)
117
+ 3. Optionally provide a custom system prompt
118
+ 4. Start chatting!
119
+
120
+ ## Configuration
121
+
122
+ Cletus stores its data in `~/.cletus/`:
123
+
124
+ ```
125
+ ~/.cletus/
126
+ ├── config.json # User settings, API keys, assistants
127
+ ├── knowledge.json # Vector embeddings for semantic search
128
+ ├── chats/ # Chat history
129
+ │ ├── {chat-id}.json
130
+ │ └── ...
131
+ ├── data/ # Custom data records
132
+ │ ├── {type-name}.json
133
+ │ └── ...
134
+ └── images/ # Generated and edited images
135
+ ```
136
+
137
+ ### Provider Configuration
138
+
139
+ Cletus supports multiple AI providers:
140
+
141
+ #### OpenAI
142
+
143
+ ```json
144
+ {
145
+ "providers": {
146
+ "openai": {
147
+ "apiKey": "sk-...",
148
+ "organization": "org-...", // Optional
149
+ "project": "proj_...", // Optional
150
+ "defaultModels": {
151
+ "chat": "gpt-4o",
152
+ "imageGenerate": "dall-e-3",
153
+ "transcription": "whisper-1",
154
+ "embedding": "text-embedding-3-large"
155
+ }
156
+ }
157
+ }
158
+ }
159
+ ```
160
+
161
+ #### OpenRouter
162
+
163
+ ```json
164
+ {
165
+ "providers": {
166
+ "openrouter": {
167
+ "apiKey": "sk-or-...",
168
+ "defaultParams": {
169
+ "siteUrl": "https://yoursite.com",
170
+ "appName": "Cletus",
171
+ "providers": {
172
+ "order": ["openai", "anthropic"],
173
+ "allowFallbacks": true
174
+ }
175
+ }
176
+ }
177
+ }
178
+ }
179
+ ```
180
+
181
+ #### Replicate
182
+
183
+ ```json
184
+ {
185
+ "providers": {
186
+ "replicate": {
187
+ "apiKey": "r8_..."
188
+ }
189
+ }
190
+ }
191
+ ```
192
+
193
+ #### AWS Bedrock
194
+
195
+ Access to Claude, Llama, Mistral, and other models via AWS Bedrock. Supports credential auto-discovery from environment variables or IAM roles.
196
+
197
+ ```json
198
+ {
199
+ "providers": {
200
+ "aws": {
201
+ "region": "us-east-1",
202
+ "credentials": {
203
+ "accessKeyId": "AKIA...",
204
+ "secretAccessKey": "..."
205
+ }
206
+ }
207
+ }
208
+ }
209
+ ```
210
+
211
+ Alternatively, set environment variables (recommended):
212
+ ```bash
213
+ export AWS_REGION=us-east-1
214
+ export AWS_ACCESS_KEY_ID=AKIA...
215
+ export AWS_SECRET_ACCESS_KEY=...
216
+ ```
217
+
218
+ #### Tavily (Web Search)
219
+
220
+ ```json
221
+ {
222
+ "tavily": {
223
+ "apiKey": "tvly-..."
224
+ }
225
+ }
226
+ ```
227
+
228
+ ### Model Selection
229
+
230
+ Override default models in the user configuration:
231
+
232
+ ```json
233
+ {
234
+ "user": {
235
+ "models": {
236
+ "chat": "gpt-4o-mini",
237
+ "imageGenerate": "dall-e-3",
238
+ "imageAnalyze": "gpt-4o",
239
+ "embedding": "text-embedding-3-small",
240
+ "summary": "gpt-4o-mini"
241
+ }
242
+ }
243
+ }
244
+ ```
245
+
246
+ ### Autonomous Mode
247
+
248
+ Configure how the AI handles operations:
249
+
250
+ ```json
251
+ {
252
+ "user": {
253
+ "autonomous": {
254
+ "maxIterations": 10, // Max tool calls without approval
255
+ "timeout": 300000 // 5 minutes in milliseconds
256
+ }
257
+ }
258
+ }
259
+ ```
260
+
261
+ ## Tool Categories
262
+
263
+ ### Architect Tools
264
+
265
+ Manage custom data type definitions:
266
+
267
+ - `type_info` - View type schema and fields
268
+ - `type_create` - Create new type definitions
269
+ - `type_update` - Update types (backwards compatible)
270
+
271
+ ### Artist Tools
272
+
273
+ Image operations:
274
+
275
+ - `image_generate` - Generate images from prompts
276
+ - `image_edit` - Edit existing images
277
+ - `image_analyze` - Ask questions about images
278
+ - `image_describe` - Get detailed image descriptions
279
+ - `image_find` - Semantic search over images
280
+
281
+ ### Clerk Tools
282
+
283
+ File management:
284
+
285
+ - `file_search` - Find files with glob patterns
286
+ - `file_summary` - AI-generated file summaries
287
+ - `file_index` - Index files for semantic search
288
+ - `file_create` - Create new files
289
+ - `file_read` - Read file contents
290
+ - `file_edit` - Edit file contents
291
+ - `file_copy` - Copy files
292
+ - `file_move` - Move/rename files
293
+ - `file_delete` - Delete files
294
+ - `file_stats` - Get file metadata
295
+ - `text_search` - Search text content with regex
296
+ - `dir_create` - Create directories
297
+
298
+ ### DBA Tools
299
+
300
+ Data operations (dynamically generated for each custom type):
301
+
302
+ - `data_create` - Create new records
303
+ - `data_update` - Update records by ID
304
+ - `data_delete` - Delete records by ID
305
+ - `data_select` - Query records with filters
306
+ - `data_update_many` - Bulk update operations
307
+ - `data_delete_many` - Bulk delete operations
308
+ - `data_aggregate` - Count and aggregate data
309
+ - `data_index` - Reindex knowledge base
310
+ - `data_import` - Import from files (CSV, JSON, etc.)
311
+ - `data_search` - Semantic search over records
312
+
313
+ ### Internet Tools
314
+
315
+ Web operations:
316
+
317
+ - `web_search` - Search the web (via Tavily)
318
+ - `web_get_page` - Scrape web pages
319
+ - `web_api_call` - Make REST API requests
320
+
321
+ ### Librarian Tools
322
+
323
+ Knowledge base management:
324
+
325
+ - `knowledge_search` - Semantic search
326
+ - `knowledge_sources` - List knowledge sources
327
+ - `knowledge_add` - Add user memories
328
+ - `knowledge_delete` - Remove knowledge entries
329
+
330
+ ### Planner Tools
331
+
332
+ Task management:
333
+
334
+ - `todos_list` - List all todos
335
+ - `todos_add` - Add new todo
336
+ - `todos_done` - Mark todo complete
337
+ - `todos_get` - Get todo details
338
+ - `todos_remove` - Delete todo
339
+ - `todos_clear` - Clear all todos
340
+ - `todos_replace` - Replace entire todo list
341
+
342
+ ### Secretary Tools
343
+
344
+ Assistant and memory management:
345
+
346
+ - `assistant_switch` - Change assistant persona
347
+ - `assistant_update` - Modify assistant prompt
348
+ - `assistant_add` - Create new assistant
349
+ - `memory_list` - View user memories
350
+ - `memory_update` - Add/update memories
351
+
352
+ ## Examples
353
+
354
+ ### File Operations
355
+
356
+ ```
357
+ You: Summarize all TypeScript files in the src directory
358
+
359
+ Cletus: I'll search for TypeScript files and summarize them...
360
+ [Uses file_search and file_summary tools]
361
+ ```
362
+
363
+ ### Data Management
364
+
365
+ ```
366
+ You: Create a new type for tracking books with title, author, and year
367
+
368
+ Cletus: I'll create a book type definition...
369
+ [Uses type_create tool]
370
+
371
+ You: Add "1984" by George Orwell published in 1949
372
+
373
+ Cletus: I'll create a new book record...
374
+ [Uses data_create tool with the book type]
375
+ ```
376
+
377
+ ### Image Generation
378
+
379
+ ```
380
+ You: Generate an image of a sunset over mountains
381
+
382
+ Cletus: I'll generate that image for you...
383
+ [Uses image_generate tool, saves to .cletus/images/]
384
+ [Generated image: sunset_mountains_abc123.png](~/.cletus/images/sunset_mountains_abc123.png)
385
+ ```
386
+
387
+ ### Web Research
388
+
389
+ ```
390
+ You: Search for recent TypeScript 5.0 features and summarize them
391
+
392
+ Cletus: Let me search for that information...
393
+ [Uses web_search tool]
394
+ [Summarizes findings from multiple sources]
395
+ ```
396
+
397
+ ### Knowledge Base
398
+
399
+ ```
400
+ You: Remember that I prefer using async/await over promises
401
+
402
+ Cletus: I'll add that to your memories...
403
+ [Uses knowledge_add tool]
404
+
405
+ You: What are my coding preferences?
406
+
407
+ Cletus: Let me search your memories...
408
+ [Uses knowledge_search tool]
409
+ You prefer using async/await over promises...
410
+ ```
411
+
412
+ ## Custom Assistants
413
+
414
+ Cletus comes with built-in assistant personas:
415
+
416
+ - **Gollum** - Speaks like Gollum from LOTR (helpful but tricksy)
417
+ - **Harry Potter** - Adds magical spell casting to responses
418
+ - **Sherlock Holmes** - Analytical and deductive reasoning style
419
+ - **Comic** - Makes jokes while helping
420
+
421
+ Create your own:
422
+
423
+ ```
424
+ You: Create an assistant named "Poet" that responds in verse
425
+
426
+ Cletus: I'll create that assistant...
427
+ [Uses assistant_add tool]
428
+ ```
429
+
430
+ Switch assistants mid-chat:
431
+
432
+ ```
433
+ You: Switch to Sherlock Holmes
434
+
435
+ Cletus: Switching assistant...
436
+ [Uses assistant_switch tool]
437
+ ```
438
+
439
+ ## Advanced Features
440
+
441
+ ### Custom Data Types
442
+
443
+ Define structured data with validation:
444
+
445
+ ```typescript
446
+ // Example type definition
447
+ {
448
+ name: "project",
449
+ friendlyName: "Project",
450
+ description: "Software project tracking",
451
+ knowledgeTemplate: "Project: {{name}}\nStatus: {{status}}\n{{#if description}}Description: {{description}}{{/if}}",
452
+ fields: [
453
+ {
454
+ name: "name",
455
+ friendlyName: "Name",
456
+ type: "string",
457
+ required: true
458
+ },
459
+ {
460
+ name: "status",
461
+ friendlyName: "Status",
462
+ type: "enum",
463
+ enumOptions: ["planning", "active", "completed"],
464
+ required: true,
465
+ default: "planning"
466
+ },
467
+ {
468
+ name: "description",
469
+ friendlyName: "Description",
470
+ type: "string",
471
+ required: false
472
+ }
473
+ ]
474
+ }
475
+ ```
476
+
477
+ ### Semantic Search
478
+
479
+ Files, data records, and user memories are automatically embedded and searchable:
480
+
481
+ - Full-text semantic search across all knowledge
482
+ - Source filtering (user memories, specific files, data types)
483
+ - Relevant context retrieval for AI responses
484
+
485
+ ### File Intelligence
486
+
487
+ Supported file types:
488
+
489
+ - **Documents**: PDF, DOCX, XLSX, TXT, MD, JSON, CSV
490
+ - **Images**: PNG, JPG, GIF, BMP, WEBP
491
+ - **Archives**: ZIP (auto-extraction and indexing)
492
+ - **Code**: Any text-based code files
493
+
494
+ Operations:
495
+
496
+ - AI-generated summaries
497
+ - Semantic indexing and search
498
+ - Content extraction (text, images, tables)
499
+ - OCR for images in documents
500
+ - Image description and analysis
501
+
502
+ ## Keyboard Shortcuts
503
+
504
+ - **Ctrl+C** - Exit current view (returns to main menu)
505
+ - **Arrow Keys** - Navigate menus
506
+ - **Enter** - Select menu item
507
+ - **Type** - In chat view, type messages
508
+
509
+ ## Troubleshooting
510
+
511
+ ### "No provider configured"
512
+
513
+ Add at least one provider in settings or edit `~/.cletus/config.json` to include API keys.
514
+
515
+ ### "Tavily API key required"
516
+
517
+ Web search requires a Tavily API key. Get one at [tavily.com](https://tavily.com) and add it in settings.
518
+
519
+ ### "Model not found"
520
+
521
+ Check that your configured models are available for your provider. See provider documentation for available models.
522
+
523
+ ### Chat history missing
524
+
525
+ Chat files are stored in `~/.cletus/chats/`. If they're deleted, history is lost. Consider backing up this directory.
526
+
527
+ ### Large knowledge base
528
+
529
+ The knowledge base (`~/.cletus/knowledge.json`) grows as you index files and data. You can delete specific sources using the `knowledge_delete` tool.
530
+
531
+ ## Development
532
+
533
+ ### Project Structure
534
+
535
+ ```
536
+ packages/cletus/
537
+ ├── src/
538
+ │ ├── agents/ # AI agent definitions
539
+ │ ├── components/ # React/Ink UI components
540
+ │ ├── helpers/ # Utility functions
541
+ │ ├── operations/ # Tool operation implementations
542
+ │ ├── tools/ # Tool definitions
543
+ │ ├── ai.ts # AI setup and configuration
544
+ │ ├── chat.ts # Chat management
545
+ │ ├── config.ts # Configuration handling
546
+ │ ├── data.ts # Data storage
547
+ │ ├── knowledge.ts # Knowledge base
548
+ │ ├── schemas.ts # Zod schemas
549
+ │ └── index.tsx # Entry point
550
+ ├── docs/ # Additional documentation
551
+ ├── dist/ # Built files
552
+ ├── package.json
553
+ ├── tsconfig.json
554
+ └── README.md
555
+ ```
556
+
557
+ ### Adding a New Tool
558
+
559
+ 1. **Add to schemas** - Update `OperationKindSchema` in `schemas.ts`
560
+ 2. **Define tool** - Add tool definition in `tools/{agent}.ts`
561
+ 3. **Implement operation** - Add implementation in `operations/{agent}.tsx`
562
+
563
+ Example:
564
+
565
+ ```typescript
566
+ // 1. schemas.ts
567
+ export const OperationKindSchema = z.enum([
568
+ // ...
569
+ 'my_new_tool',
570
+ ]);
571
+
572
+ // 2. tools/clerk.ts
573
+ const myNewTool = ai.tool({
574
+ name: 'my_new_tool',
575
+ description: 'Does something useful',
576
+ instructions: `Use this to...`,
577
+ schema: z.object({
578
+ input: z.string().describe('The input'),
579
+ }),
580
+ call: async (input, _, ctx) =>
581
+ ctx.ops.handle({ type: 'my_new_tool', input }, ctx),
582
+ });
583
+
584
+ // 3. operations/clerk.tsx
585
+ case 'my_new_tool': {
586
+ const result = await doSomething(operation.input);
587
+ return { output: result };
588
+ }
589
+ ```
590
+
591
+ ### Building
592
+
593
+ ```bash
594
+ # Clean build
595
+ npm run clean
596
+ npm run build
597
+
598
+ # Type checking
599
+ npm run typecheck
600
+ ```
601
+
602
+ ## Contributing
603
+
604
+ Contributions are welcome! Please see the main [AITS repository](https://github.com/ClickerMonkey/aeye) for contribution guidelines.
605
+
606
+ ## License
607
+
608
+ MIT © ClickerMonkey
609
+
610
+ ## Related Packages
611
+
612
+ - [@aeye/ai](../ai) - Core AI library
613
+ - [@aeye/core](../core) - Shared utilities and types
614
+ - [@aeye/models](../models) - Model registry and definitions
615
+ - [@aeye/openai](../openai) - OpenAI provider
616
+ - [@aeye/openrouter](../openrouter) - OpenRouter provider
617
+ - [@aeye/replicate](../replicate) - Replicate provider
618
+ - [@aeye/aws](../aws) - AWS Bedrock provider
619
+
620
+ ## Support
621
+
622
+ - [GitHub Issues](https://github.com/ClickerMonkey/aeye/issues)
623
+ - [Discussions](https://github.com/ClickerMonkey/aeye/discussions)
624
+ - [Documentation](https://github.com/ClickerMonkey/aeye#readme)