aia 1.0.0.pre.beta → 1.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.
- checksums.yaml +4 -4
- data/.version +1 -1
- data/CHANGELOG.md +89 -0
- data/COMMITS.md +192 -11
- data/README.md +327 -110
- data/docs/cli-reference.md +93 -10
- data/docs/configuration.md +29 -36
- data/docs/contributing.md +2 -2
- data/docs/directives-reference.md +49 -27
- data/docs/examples/index.md +2 -2
- data/docs/examples/mcp/index.md +93 -97
- data/docs/examples/prompts/automation/index.md +3 -2
- data/docs/examples/tools/index.md +17 -27
- data/docs/faq.md +9 -12
- data/docs/guides/basic-usage.md +4 -4
- data/docs/guides/chat.md +39 -34
- data/docs/guides/tools.md +4 -4
- data/docs/index.md +36 -62
- data/docs/installation.md +1 -1
- data/docs/mcp-integration.md +75 -139
- data/docs/prompt_management.md +88 -1
- data/docs/security.md +79 -81
- data/docs/tools-and-mcp-examples.md +8 -6
- data/docs/workflows-and-pipelines.md +2 -6
- data/examples/.gitignore +1 -0
- data/examples/README.md +41 -0
- data/examples/run_all.sh +261 -0
- data/lib/aia/adapter/chat_execution.rb +9 -7
- data/lib/aia/adapter/mcp_connector.rb +0 -29
- data/lib/aia/adapter/modality_handlers.rb +23 -15
- data/lib/aia/adapter/tool_filter.rb +21 -0
- data/lib/aia/adapter/tool_loader.rb +1 -9
- data/lib/aia/chat_loop.rb +244 -0
- data/lib/aia/chat_processor_service.rb +6 -3
- data/lib/aia/config/cli_parser.rb +56 -18
- data/lib/aia/config/defaults.yml +17 -2
- data/lib/aia/config/validator.rb +52 -11
- data/lib/aia/config.rb +29 -3
- data/lib/aia/directive.rb +29 -0
- data/lib/aia/directives/configuration_directives.rb +2 -1
- data/lib/aia/directives/execution_directives.rb +1 -1
- data/lib/aia/directives/model_directives.rb +28 -27
- data/lib/aia/directives/web_and_file_directives.rb +78 -40
- data/lib/aia/errors.rb +20 -1
- data/lib/aia/fzf.rb +8 -7
- data/lib/aia/input_collector.rb +24 -0
- data/lib/aia/prompt_handler.rb +36 -8
- data/lib/aia/prompt_pipeline.rb +183 -0
- data/lib/aia/session.rb +22 -372
- data/lib/aia/skill_utils.rb +61 -0
- data/lib/aia/ui_presenter.rb +8 -0
- data/lib/aia.rb +4 -0
- metadata +19 -45
data/docs/mcp-integration.md
CHANGED
|
@@ -103,12 +103,14 @@ Safe file system operations with sandboxing:
|
|
|
103
103
|
# Install filesystem MCP server
|
|
104
104
|
npm install -g @anthropic-ai/mcp-server-filesystem
|
|
105
105
|
|
|
106
|
-
# Configure
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
106
|
+
# Configure in ~/.config/aia/aia.yml
|
|
107
|
+
mcp_servers:
|
|
108
|
+
- name: filesystem
|
|
109
|
+
command: npx
|
|
110
|
+
args:
|
|
111
|
+
- "@anthropic-ai/mcp-server-filesystem"
|
|
112
|
+
- /home/user/projects
|
|
113
|
+
- /tmp/aia-workspace
|
|
112
114
|
```
|
|
113
115
|
|
|
114
116
|
**Capabilities**:
|
|
@@ -152,7 +154,7 @@ async def call_tool(name: str, arguments: dict):
|
|
|
152
154
|
### GitHub Analysis
|
|
153
155
|
```markdown
|
|
154
156
|
# ~/.prompts/github_analysis.md
|
|
155
|
-
|
|
157
|
+
# Requires MCP server "github" configured in ~/.config/aia/aia.yml
|
|
156
158
|
|
|
157
159
|
# GitHub Repository Analysis
|
|
158
160
|
|
|
@@ -179,7 +181,7 @@ Provide comprehensive analysis with actionable recommendations.
|
|
|
179
181
|
### File System Operations
|
|
180
182
|
```markdown
|
|
181
183
|
# ~/.prompts/project_analysis.md
|
|
182
|
-
|
|
184
|
+
# Requires MCP server "filesystem" configured in ~/.config/aia/aia.yml
|
|
183
185
|
|
|
184
186
|
# Project Structure Analysis
|
|
185
187
|
|
|
@@ -206,7 +208,7 @@ Generate detailed project assessment with improvement suggestions.
|
|
|
206
208
|
### Database Schema Analysis
|
|
207
209
|
```markdown
|
|
208
210
|
# ~/.prompts/database_analysis.md
|
|
209
|
-
|
|
211
|
+
# Requires MCP server "database" configured in ~/.config/aia/aia.yml
|
|
210
212
|
|
|
211
213
|
# Database Schema Analysis
|
|
212
214
|
|
|
@@ -236,7 +238,7 @@ Provide recommendations for schema improvements and optimizations.
|
|
|
236
238
|
### Multi-Client Workflows
|
|
237
239
|
```markdown
|
|
238
240
|
# ~/.prompts/full_project_audit.md
|
|
239
|
-
|
|
241
|
+
# Requires MCP server "github" configured in ~/.config/aia/aia.yml,filesystem,database
|
|
240
242
|
|
|
241
243
|
# Comprehensive Project Audit
|
|
242
244
|
|
|
@@ -276,26 +278,27 @@ Generate comprehensive audit report with prioritized recommendations.
|
|
|
276
278
|
```
|
|
277
279
|
|
|
278
280
|
### Conditional MCP Usage
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
mcp_clients << 'github' if is_open_source
|
|
289
|
-
mcp_clients << 'database' if has_database
|
|
290
|
-
|
|
291
|
-
puts "/mcp #{mcp_clients.join(',')}"
|
|
292
|
-
puts "Selected MCP clients for #{project_type} project: #{mcp_clients.join(', ')}"
|
|
281
|
+
|
|
282
|
+
Use `--mcp-use` on the command line to select which MCP servers to activate:
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
# Use only specific MCP servers for a prompt
|
|
286
|
+
aia --mcp-use github,filesystem my_prompt
|
|
287
|
+
|
|
288
|
+
# Skip specific servers
|
|
289
|
+
aia --mcp-skip database my_prompt
|
|
293
290
|
```
|
|
294
291
|
|
|
292
|
+
Within prompts, you can document which MCP servers are expected:
|
|
293
|
+
|
|
294
|
+
```markdown
|
|
295
|
+
# ~/.prompts/adaptive_analysis.md
|
|
296
|
+
# Requires MCP servers: github, filesystem, database
|
|
297
|
+
# Run with: aia --mcp-use github,filesystem,database adaptive_analysis
|
|
298
|
+
|
|
295
299
|
# Adaptive Project Analysis
|
|
296
300
|
|
|
297
301
|
Project type: <%= project_type %>
|
|
298
|
-
Analysis scope: <%= mcp_clients.join(', ') %>
|
|
299
302
|
|
|
300
303
|
Perform comprehensive analysis using available MCP clients to provide insights specific to this project type.
|
|
301
304
|
```
|
|
@@ -398,91 +401,45 @@ server.connect();
|
|
|
398
401
|
|
|
399
402
|
## MCP Security and Best Practices
|
|
400
403
|
|
|
401
|
-
### Security Configuration
|
|
402
|
-
```yaml
|
|
403
|
-
# Secure MCP configuration
|
|
404
|
-
mcp:
|
|
405
|
-
security:
|
|
406
|
-
sandbox_mode: true
|
|
407
|
-
allowed_operations: ["read", "list"]
|
|
408
|
-
blocked_operations: ["delete", "execute"]
|
|
409
|
-
|
|
410
|
-
resource_limits:
|
|
411
|
-
max_file_size: 10485760 # 10MB
|
|
412
|
-
max_query_results: 1000
|
|
413
|
-
timeout_seconds: 30
|
|
414
|
-
|
|
415
|
-
clients:
|
|
416
|
-
- name: filesystem
|
|
417
|
-
command: ["mcp-server-filesystem"]
|
|
418
|
-
args: ["/safe/path/only"]
|
|
419
|
-
security_context: "restricted"
|
|
420
|
-
|
|
421
|
-
- name: database
|
|
422
|
-
command: ["database-mcp-server"]
|
|
423
|
-
security_context: "read_only"
|
|
424
|
-
env:
|
|
425
|
-
DB_READ_ONLY: "true"
|
|
426
|
-
```
|
|
427
|
-
|
|
428
404
|
### Access Control
|
|
429
|
-
```ruby
|
|
430
|
-
# MCP access control in prompts
|
|
431
|
-
/ruby
|
|
432
|
-
user_role = '<%= user_role %>'
|
|
433
|
-
allowed_mcp = case user_role
|
|
434
|
-
when 'admin'
|
|
435
|
-
['github', 'filesystem', 'database']
|
|
436
|
-
when 'developer'
|
|
437
|
-
['github', 'filesystem']
|
|
438
|
-
when 'analyst'
|
|
439
|
-
['database']
|
|
440
|
-
else
|
|
441
|
-
[]
|
|
442
|
-
end
|
|
443
|
-
|
|
444
|
-
if allowed_mcp.empty?
|
|
445
|
-
puts "No MCP access for role: #{user_role}"
|
|
446
|
-
else
|
|
447
|
-
puts "/mcp #{allowed_mcp.join(',')}"
|
|
448
|
-
puts "MCP access granted: #{allowed_mcp.join(', ')}"
|
|
449
|
-
end
|
|
450
|
-
```
|
|
451
405
|
|
|
452
|
-
|
|
406
|
+
Control which MCP servers are available using CLI flags:
|
|
453
407
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
mcp
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
enabled: true
|
|
464
|
-
ttl: 3600 # 1 hour
|
|
465
|
-
max_size: 100 # Cache entries
|
|
408
|
+
```bash
|
|
409
|
+
# Allow only specific MCP servers
|
|
410
|
+
aia --mcp-use github,filesystem --chat
|
|
411
|
+
|
|
412
|
+
# Skip specific MCP servers
|
|
413
|
+
aia --mcp-skip database --chat
|
|
414
|
+
|
|
415
|
+
# Use --allowed-tools and --rejected-tools to filter MCP tools
|
|
416
|
+
aia --mcp-use github --allowed-tools "github_*" --chat
|
|
466
417
|
```
|
|
467
418
|
|
|
468
|
-
###
|
|
469
|
-
```python
|
|
470
|
-
# Async MCP server for better performance
|
|
471
|
-
import asyncio
|
|
472
|
-
import aiohttp
|
|
473
|
-
from mcp.server import Server
|
|
419
|
+
### Server Configuration Security
|
|
474
420
|
|
|
475
|
-
server
|
|
421
|
+
Limit what each MCP server can access through its own configuration:
|
|
476
422
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
423
|
+
```yaml
|
|
424
|
+
# ~/.config/aia/aia.yml
|
|
425
|
+
mcp_servers:
|
|
426
|
+
- name: filesystem
|
|
427
|
+
command: mcp-server-filesystem
|
|
428
|
+
args:
|
|
429
|
+
- /safe/path/only # Restrict to specific directories
|
|
430
|
+
|
|
431
|
+
- name: database
|
|
432
|
+
command: database-mcp-server
|
|
433
|
+
env:
|
|
434
|
+
DB_READ_ONLY: "true" # Use server-level env vars for restrictions
|
|
435
|
+
DATABASE_URL: "${DATABASE_URL}"
|
|
436
|
+
timeout: 8000
|
|
484
437
|
```
|
|
485
438
|
|
|
439
|
+
### Parallel Connections
|
|
440
|
+
|
|
441
|
+
When multiple MCP servers are configured, AIA connects to them in parallel using fiber-based concurrency (via the `simple_flow` gem) for faster startup.
|
|
442
|
+
|
|
486
443
|
## Troubleshooting MCP
|
|
487
444
|
|
|
488
445
|
### Common Issues
|
|
@@ -490,52 +447,31 @@ async def call_tool(name: str, arguments: dict):
|
|
|
490
447
|
#### Client Connection Failures
|
|
491
448
|
```bash
|
|
492
449
|
# Debug MCP client connections
|
|
493
|
-
aia --debug --mcp github test_prompt
|
|
450
|
+
aia --debug --mcp github.json test_prompt
|
|
494
451
|
|
|
495
|
-
#
|
|
496
|
-
aia --mcp-
|
|
452
|
+
# List configured servers to verify setup
|
|
453
|
+
aia --mcp-list
|
|
497
454
|
|
|
498
|
-
#
|
|
499
|
-
aia --
|
|
455
|
+
# List MCP server tools to verify connectivity
|
|
456
|
+
aia --mcp-list --list-tools
|
|
500
457
|
```
|
|
501
458
|
|
|
502
459
|
#### Protocol Errors
|
|
460
|
+
|
|
461
|
+
Enable detailed MCP logging via the logger configuration:
|
|
462
|
+
|
|
503
463
|
```yaml
|
|
504
|
-
#
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
level: debug
|
|
464
|
+
# ~/.config/aia/aia.yml
|
|
465
|
+
logger:
|
|
466
|
+
mcp:
|
|
508
467
|
file: /tmp/aia-mcp.log
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
retry_attempts: 3
|
|
512
|
-
retry_delay: 1000 # milliseconds
|
|
513
|
-
fallback_mode: graceful
|
|
468
|
+
level: debug
|
|
469
|
+
flush: true
|
|
514
470
|
```
|
|
515
471
|
|
|
516
|
-
|
|
472
|
+
Or via CLI:
|
|
517
473
|
```bash
|
|
518
|
-
#
|
|
519
|
-
aia --mcp-metrics github filesystem
|
|
520
|
-
|
|
521
|
-
# Profile MCP operations
|
|
522
|
-
aia --profile --mcp database analysis_prompt
|
|
523
|
-
```
|
|
524
|
-
|
|
525
|
-
### Debugging Tools
|
|
526
|
-
```python
|
|
527
|
-
# MCP debugging utilities
|
|
528
|
-
async def debug_mcp_call(client, tool, args):
|
|
529
|
-
start_time = time.time()
|
|
530
|
-
try:
|
|
531
|
-
result = await client.call_tool(tool, args)
|
|
532
|
-
duration = time.time() - start_time
|
|
533
|
-
print(f"MCP call successful: {tool} in {duration:.2f}s")
|
|
534
|
-
return result
|
|
535
|
-
except Exception as e:
|
|
536
|
-
duration = time.time() - start_time
|
|
537
|
-
print(f"MCP call failed: {tool} after {duration:.2f}s - {e}")
|
|
538
|
-
raise
|
|
474
|
+
aia --debug my_prompt # Sets all loggers to debug level
|
|
539
475
|
```
|
|
540
476
|
|
|
541
477
|
## MCP Examples Repository
|
|
@@ -543,7 +479,7 @@ async def debug_mcp_call(client, tool, args):
|
|
|
543
479
|
### GitHub Repository Analysis
|
|
544
480
|
```markdown
|
|
545
481
|
# ~/.prompts/mcp_examples/github_repo_health.md
|
|
546
|
-
|
|
482
|
+
# Requires MCP server "github" configured in ~/.config/aia/aia.yml
|
|
547
483
|
|
|
548
484
|
# GitHub Repository Health Check
|
|
549
485
|
|
|
@@ -580,7 +516,7 @@ Generate detailed health score with specific improvement recommendations.
|
|
|
580
516
|
### File System Audit
|
|
581
517
|
```markdown
|
|
582
518
|
# ~/.prompts/mcp_examples/filesystem_audit.md
|
|
583
|
-
|
|
519
|
+
# Requires MCP server "filesystem" configured in ~/.config/aia/aia.yml
|
|
584
520
|
|
|
585
521
|
# File System Security and Organization Audit
|
|
586
522
|
|
data/docs/prompt_management.md
CHANGED
|
@@ -8,10 +8,15 @@ AIA provides sophisticated prompt management capabilities through the PM gem, en
|
|
|
8
8
|
```
|
|
9
9
|
~/.prompts/
|
|
10
10
|
├── README.md # Documentation for your prompt collection
|
|
11
|
-
├── roles/ # Role
|
|
11
|
+
├── roles/ # Role definitions (LLM personality/persona)
|
|
12
12
|
│ ├── assistant.md
|
|
13
13
|
│ ├── code_expert.md
|
|
14
14
|
│ └── teacher.md
|
|
15
|
+
├── skills/ # Skill definitions (task instructions)
|
|
16
|
+
│ ├── code-review/
|
|
17
|
+
│ │ └── SKILL.md # YAML front matter + instruction body
|
|
18
|
+
│ └── summarizer/
|
|
19
|
+
│ └── SKILL.md
|
|
15
20
|
├── development/ # Development-related prompts
|
|
16
21
|
│ ├── code_review.md
|
|
17
22
|
│ ├── debug_help.md
|
|
@@ -292,6 +297,88 @@ Current Task:
|
|
|
292
297
|
Please provide guidance consistent with the project architecture and your role as <%= role %>.
|
|
293
298
|
```
|
|
294
299
|
|
|
300
|
+
## Skills
|
|
301
|
+
|
|
302
|
+
### Roles vs Skills
|
|
303
|
+
|
|
304
|
+
These two concepts work together but serve distinct purposes:
|
|
305
|
+
|
|
306
|
+
| Concept | Defines | Loaded from | Injected as |
|
|
307
|
+
|---------|---------|-------------|-------------|
|
|
308
|
+
| **Role** | LLM *personality* — who the model is | `~/.prompts/roles/<id>.md` | First, before skills and prompt |
|
|
309
|
+
| **Skill** | Task *instructions* — how to approach the work | `~/.prompts/skills/<name>/SKILL.md` | After role, before user prompt |
|
|
310
|
+
|
|
311
|
+
A **role** sets the persona: "You are a senior Ruby developer with deep expertise in performance optimization."
|
|
312
|
+
|
|
313
|
+
A **skill** provides procedural guidance for that persona to follow when executing the user's request: "When reviewing code, always check for: N+1 queries, missing indexes, memory leaks, and security vulnerabilities. Present findings as a prioritized list."
|
|
314
|
+
|
|
315
|
+
The assembled prompt order is:
|
|
316
|
+
|
|
317
|
+
```
|
|
318
|
+
1. Role content ← WHO the LLM is (personality)
|
|
319
|
+
2. Skill content(s) ← HOW to approach the task (instructions)
|
|
320
|
+
3. User prompt ← WHAT to do (request)
|
|
321
|
+
4. Context files ← supporting material
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### Skill File Format
|
|
325
|
+
|
|
326
|
+
Each skill lives in its own subdirectory under `~/.prompts/skills/`. The subdirectory must contain a `SKILL.md` file with YAML front matter followed by the skill instruction body:
|
|
327
|
+
|
|
328
|
+
```markdown
|
|
329
|
+
---
|
|
330
|
+
name: code-review
|
|
331
|
+
description: Thorough code review focusing on correctness, security, and maintainability.
|
|
332
|
+
user-invocable: true
|
|
333
|
+
argument-hint: ["file or topic to review"]
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
When reviewing code, systematically check:
|
|
337
|
+
|
|
338
|
+
1. **Correctness** — Does the logic match the stated intent? Are edge cases handled?
|
|
339
|
+
2. **Security** — Are there injection risks, unsafe deserialization, or exposed secrets?
|
|
340
|
+
3. **Performance** — Are there N+1 queries, unbounded loops, or unnecessary allocations?
|
|
341
|
+
4. **Maintainability** — Is the code readable? Are names clear? Is complexity justified?
|
|
342
|
+
|
|
343
|
+
Present findings as a prioritized list with file:line references where applicable.
|
|
344
|
+
Always suggest a concrete fix, not just identification of the problem.
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
The YAML front matter is metadata only. Only the body (everything after the closing `---`) is injected into the prompt.
|
|
348
|
+
|
|
349
|
+
### Using Skills
|
|
350
|
+
|
|
351
|
+
```bash
|
|
352
|
+
# Prepend a skill before the user prompt
|
|
353
|
+
aia --skill code-review review_prompt my_code.rb
|
|
354
|
+
|
|
355
|
+
# Combine role + skill for maximum context
|
|
356
|
+
aia --role ruby_expert --skill code-review review_prompt my_code.rb
|
|
357
|
+
|
|
358
|
+
# Multiple skills (applied in order)
|
|
359
|
+
aia --skill code-review --skill security-audit review_prompt my_code.rb
|
|
360
|
+
aia -s code-review,security-audit review_prompt my_code.rb
|
|
361
|
+
|
|
362
|
+
# List available skills
|
|
363
|
+
aia --list-skills
|
|
364
|
+
|
|
365
|
+
# Use a skill from within a chat session
|
|
366
|
+
/skill code-review
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### Skills in Chat Mode
|
|
370
|
+
|
|
371
|
+
In chat mode, use the `/skill` directive to inject a skill at any point in the conversation:
|
|
372
|
+
|
|
373
|
+
```
|
|
374
|
+
> /skill summarizer
|
|
375
|
+
[Skill "summarizer" instructions are injected into the next message context]
|
|
376
|
+
|
|
377
|
+
> Please summarize the discussion so far.
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
The `/skill` directive injects only the body content of `SKILL.md` — the YAML front matter is never sent to the LLM.
|
|
381
|
+
|
|
295
382
|
## Prompt Workflows and Pipelines
|
|
296
383
|
|
|
297
384
|
### Simple Workflows
|
data/docs/security.md
CHANGED
|
@@ -42,6 +42,53 @@ else
|
|
|
42
42
|
fi
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
+
## Code Execution Directives
|
|
46
|
+
|
|
47
|
+
AIA includes directives that execute code directly on your machine. Understand their security implications:
|
|
48
|
+
|
|
49
|
+
### /ruby Directive
|
|
50
|
+
|
|
51
|
+
The `/ruby` directive executes arbitrary Ruby code using `eval()` with your full user permissions. It can read files, make network calls, modify your filesystem, and execute system commands.
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
# These execute with YOUR permissions:
|
|
55
|
+
/ruby File.read('/etc/hosts')
|
|
56
|
+
/ruby system('whoami')
|
|
57
|
+
/ruby Dir.glob('**/*')
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Mitigations**:
|
|
61
|
+
- Only run prompts from trusted sources
|
|
62
|
+
- Review any prompt file before executing if it contains `/ruby` directives
|
|
63
|
+
- Be cautious with prompts shared by others or downloaded from the internet
|
|
64
|
+
|
|
65
|
+
### /shell Directive
|
|
66
|
+
|
|
67
|
+
The `/shell` directive executes system commands with your user permissions:
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
# Executes directly in your shell:
|
|
71
|
+
/shell ls -la
|
|
72
|
+
/shell cat /path/to/file
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Mitigations**:
|
|
76
|
+
- Same precautions as `/ruby` — only use with trusted prompts
|
|
77
|
+
- Consider the implications of any shell command before running it
|
|
78
|
+
|
|
79
|
+
### ERB Processing
|
|
80
|
+
|
|
81
|
+
Prompts with `.md` extension are processed through ERB, which also executes Ruby code:
|
|
82
|
+
|
|
83
|
+
```markdown
|
|
84
|
+
The current user is: <%= `whoami`.strip %>
|
|
85
|
+
Today's date is: <%= Date.today %>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Mitigations**:
|
|
89
|
+
- Review prompt files before running them, especially from untrusted sources
|
|
90
|
+
- ERB processing is always enabled and cannot be disabled per-prompt
|
|
91
|
+
|
|
45
92
|
## Prompt Security
|
|
46
93
|
|
|
47
94
|
### Input Sanitization
|
|
@@ -368,96 +415,47 @@ sanitize_environment() {
|
|
|
368
415
|
## Tool and MCP Security
|
|
369
416
|
|
|
370
417
|
### Tool Access Control
|
|
371
|
-
```yaml
|
|
372
|
-
# Secure tool configuration
|
|
373
|
-
tools:
|
|
374
|
-
security:
|
|
375
|
-
default_policy: deny
|
|
376
|
-
audit_log: /var/log/aia-tools.log
|
|
377
|
-
|
|
378
|
-
allowed_tools:
|
|
379
|
-
- name: file_reader
|
|
380
|
-
max_file_size: 1048576 # 1MB
|
|
381
|
-
allowed_extensions: [.txt, .md, .json]
|
|
382
|
-
allowed_directories: [/home/user/safe, /tmp/workspace]
|
|
383
|
-
|
|
384
|
-
- name: web_client
|
|
385
|
-
allowed_domains: [api.github.com, api.openai.com]
|
|
386
|
-
max_request_size: 1048576
|
|
387
|
-
timeout: 30
|
|
388
|
-
|
|
389
|
-
blocked_tools:
|
|
390
|
-
- system_admin
|
|
391
|
-
- file_writer
|
|
392
|
-
- shell_executor
|
|
393
|
-
```
|
|
394
418
|
|
|
395
|
-
|
|
396
|
-
```yaml
|
|
397
|
-
# Secure MCP configuration
|
|
398
|
-
mcp:
|
|
399
|
-
security:
|
|
400
|
-
sandbox_mode: true
|
|
401
|
-
network_isolation: true
|
|
402
|
-
file_system_jail: /tmp/mcp-sandbox
|
|
403
|
-
|
|
404
|
-
resource_limits:
|
|
405
|
-
max_memory: 256MB
|
|
406
|
-
max_cpu_time: 30s
|
|
407
|
-
max_file_descriptors: 100
|
|
408
|
-
|
|
409
|
-
clients:
|
|
410
|
-
- name: github
|
|
411
|
-
security_profile: network_readonly
|
|
412
|
-
allowed_operations: [read, list]
|
|
413
|
-
rate_limit: 100/hour
|
|
414
|
-
|
|
415
|
-
- name: filesystem
|
|
416
|
-
security_profile: filesystem_readonly
|
|
417
|
-
jail_directory: /home/user/safe
|
|
418
|
-
max_file_size: 10MB
|
|
419
|
-
```
|
|
419
|
+
Use CLI flags to control which tools and MCP servers are available:
|
|
420
420
|
|
|
421
|
-
|
|
421
|
+
```bash
|
|
422
|
+
# Allow only specific tools
|
|
423
|
+
aia --allowed-tools file_reader,web_client --chat
|
|
422
424
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
# ~/.aia/dev_security.yml
|
|
426
|
-
security:
|
|
427
|
-
level: relaxed
|
|
428
|
-
allow_debug: true
|
|
429
|
-
allow_local_files: true
|
|
430
|
-
allowed_models: [gpt-3.5-turbo, gpt-4]
|
|
431
|
-
log_all_requests: true
|
|
432
|
-
```
|
|
425
|
+
# Block specific tools
|
|
426
|
+
aia --rejected-tools shell_executor --chat
|
|
433
427
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
security:
|
|
438
|
-
level: strict
|
|
439
|
-
allow_debug: false
|
|
440
|
-
allow_local_files: false
|
|
441
|
-
allowed_models: [gpt-3.5-turbo] # Cost control
|
|
442
|
-
content_filtering: strict
|
|
443
|
-
audit_logging: enabled
|
|
444
|
-
network_restrictions: strict
|
|
428
|
+
# Control MCP server access
|
|
429
|
+
aia --mcp-use github,filesystem --chat
|
|
430
|
+
aia --mcp-skip database --chat
|
|
445
431
|
```
|
|
446
432
|
|
|
447
|
-
###
|
|
433
|
+
### MCP Server Configuration Security
|
|
434
|
+
|
|
435
|
+
Restrict MCP server capabilities through their configuration:
|
|
436
|
+
|
|
448
437
|
```yaml
|
|
449
|
-
# ~/.aia/
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
438
|
+
# ~/.config/aia/aia.yml
|
|
439
|
+
mcp_servers:
|
|
440
|
+
- name: filesystem
|
|
441
|
+
command: mcp-server-filesystem
|
|
442
|
+
args:
|
|
443
|
+
- /safe/path/only # Restrict to specific directories
|
|
444
|
+
|
|
445
|
+
- name: database
|
|
446
|
+
command: database-mcp-server
|
|
447
|
+
env:
|
|
448
|
+
DB_READ_ONLY: "true" # Use server-level restrictions
|
|
449
|
+
DATABASE_URL: "${DATABASE_URL}"
|
|
450
|
+
timeout: 8000
|
|
459
451
|
```
|
|
460
452
|
|
|
453
|
+
### Environment-Specific Tips
|
|
454
|
+
|
|
455
|
+
- **Development**: Use `--debug` and verbose logging to monitor tool/MCP behavior
|
|
456
|
+
- **Production scripts**: Use `--mcp-use` and `--allowed-tools` to restrict available capabilities
|
|
457
|
+
- **Shared environments**: Use environment variables for API keys; avoid storing secrets in config files
|
|
458
|
+
|
|
461
459
|
## Monitoring and Auditing
|
|
462
460
|
|
|
463
461
|
### Security Logging
|
|
@@ -8,7 +8,7 @@ This comprehensive collection showcases real-world examples of RubyLLM tools and
|
|
|
8
8
|
|
|
9
9
|
#### Advanced Log Analyzer
|
|
10
10
|
```ruby
|
|
11
|
-
# ~/.aia/tools/log_analyzer.rb
|
|
11
|
+
# ~/.config/aia/tools/log_analyzer.rb
|
|
12
12
|
require 'time'
|
|
13
13
|
require 'json'
|
|
14
14
|
|
|
@@ -177,7 +177,7 @@ end
|
|
|
177
177
|
|
|
178
178
|
#### Configuration File Manager
|
|
179
179
|
```ruby
|
|
180
|
-
# ~/.aia/tools/config_manager.rb
|
|
180
|
+
# ~/.config/aia/tools/config_manager.rb
|
|
181
181
|
require 'yaml'
|
|
182
182
|
require 'json'
|
|
183
183
|
require 'fileutils'
|
|
@@ -350,7 +350,7 @@ end
|
|
|
350
350
|
|
|
351
351
|
#### Code Quality Analyzer
|
|
352
352
|
```ruby
|
|
353
|
-
# ~/.aia/tools/code_quality.rb
|
|
353
|
+
# ~/.config/aia/tools/code_quality.rb
|
|
354
354
|
class CodeQualityAnalyzer < RubyLLM::Tool
|
|
355
355
|
description "Analyzes code quality metrics, complexity, and best practices"
|
|
356
356
|
|
|
@@ -972,7 +972,8 @@ if __name__ == "__main__":
|
|
|
972
972
|
```markdown
|
|
973
973
|
# ~/.prompts/full_stack_analysis.md
|
|
974
974
|
/tools file_analyzer.rb,code_quality.rb,config_manager.rb
|
|
975
|
-
|
|
975
|
+
# Requires MCP servers: github, filesystem, database
|
|
976
|
+
# Run with: aia --mcp-use github,filesystem,database --tools file_analyzer.rb,code_quality.rb,config_manager.rb full_stack_analysis
|
|
976
977
|
|
|
977
978
|
# Full-Stack Application Analysis
|
|
978
979
|
|
|
@@ -1031,7 +1032,8 @@ Generate comprehensive analysis with actionable insights for each identified are
|
|
|
1031
1032
|
```markdown
|
|
1032
1033
|
# ~/.prompts/devops_pipeline_analysis.md
|
|
1033
1034
|
/tools log_analyzer.rb,config_manager.rb
|
|
1034
|
-
|
|
1035
|
+
# Requires MCP servers: github, filesystem
|
|
1036
|
+
# Run with: aia --mcp-use github,filesystem --tools log_analyzer.rb,config_manager.rb devops_pipeline_analysis
|
|
1035
1037
|
|
|
1036
1038
|
# DevOps Pipeline Analysis
|
|
1037
1039
|
|
|
@@ -1081,7 +1083,7 @@ Provide implementation timeline and impact assessment for each recommendation.
|
|
|
1081
1083
|
|
|
1082
1084
|
### Multi-Environment Consistency Checker
|
|
1083
1085
|
```ruby
|
|
1084
|
-
# ~/.aia/tools/environment_checker.rb
|
|
1086
|
+
# ~/.config/aia/tools/environment_checker.rb
|
|
1085
1087
|
class EnvironmentChecker < RubyLLM::Tool
|
|
1086
1088
|
description "Compares configurations and deployments across multiple environments"
|
|
1087
1089
|
|
|
@@ -510,12 +510,8 @@ Pipeline optimized for <%= complexity %> analysis with <%= selected_pipeline.len
|
|
|
510
510
|
|
|
511
511
|
#### Workflow Interruption
|
|
512
512
|
```bash
|
|
513
|
-
#
|
|
514
|
-
|
|
515
|
-
aia --resume-workflow $WORKFLOW_ID
|
|
516
|
-
|
|
517
|
-
# Or restart from specific stage
|
|
518
|
-
aia --pipeline "failed_stage,remaining_stages" --resume-from failed_stage
|
|
513
|
+
# Restart from a specific stage by specifying the remaining pipeline
|
|
514
|
+
aia --pipeline "failed_stage,remaining_stages" input_file
|
|
519
515
|
```
|
|
520
516
|
|
|
521
517
|
#### Context Size Issues
|
data/examples/.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
output/
|