@memberjunction/ai-cli 3.4.0 → 4.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.
- package/README.md +154 -333
- package/bin/run.js +3 -3
- package/dist/commands/actions/list.js +17 -46
- package/dist/commands/actions/list.js.map +1 -1
- package/dist/commands/actions/run.d.ts +1 -1
- package/dist/commands/actions/run.js +32 -61
- package/dist/commands/actions/run.js.map +1 -1
- package/dist/commands/agents/list.js +17 -46
- package/dist/commands/agents/list.js.map +1 -1
- package/dist/commands/agents/run.d.ts +2 -2
- package/dist/commands/agents/run.js +34 -63
- package/dist/commands/agents/run.js.map +1 -1
- package/dist/commands/prompts/list.js +15 -21
- package/dist/commands/prompts/list.js.map +1 -1
- package/dist/commands/prompts/run.d.ts +5 -5
- package/dist/commands/prompts/run.js +22 -28
- package/dist/commands/prompts/run.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -24
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +13 -13
- package/dist/index.js +13 -32
- package/dist/index.js.map +1 -1
- package/dist/lib/audit-analyzer.js +1 -5
- package/dist/lib/audit-analyzer.js.map +1 -1
- package/dist/lib/audit-formatter.d.ts +1 -1
- package/dist/lib/audit-formatter.js +78 -85
- package/dist/lib/audit-formatter.js.map +1 -1
- package/dist/lib/console-manager.js +3 -7
- package/dist/lib/console-manager.js.map +1 -1
- package/dist/lib/execution-logger.js +13 -25
- package/dist/lib/execution-logger.js.map +1 -1
- package/dist/lib/mj-provider.js +20 -29
- package/dist/lib/mj-provider.js.map +1 -1
- package/dist/lib/output-formatter.js +61 -69
- package/dist/lib/output-formatter.js.map +1 -1
- package/dist/lib/text-formatter.js +13 -20
- package/dist/lib/text-formatter.js.map +1 -1
- package/dist/services/ActionService.d.ts +1 -1
- package/dist/services/ActionService.js +14 -40
- package/dist/services/ActionService.js.map +1 -1
- package/dist/services/AgentAuditService.d.ts +1 -1
- package/dist/services/AgentAuditService.js +14 -44
- package/dist/services/AgentAuditService.js.map +1 -1
- package/dist/services/AgentService.d.ts +1 -1
- package/dist/services/AgentService.js +19 -49
- package/dist/services/AgentService.js.map +1 -1
- package/dist/services/ConversationService.js +31 -60
- package/dist/services/ConversationService.js.map +1 -1
- package/dist/services/PromptService.d.ts +1 -1
- package/dist/services/PromptService.js +12 -39
- package/dist/services/PromptService.js.map +1 -1
- package/dist/services/ValidationService.js +1 -5
- package/dist/services/ValidationService.js.map +1 -1
- package/oclif.manifest.json +7 -7
- package/package.json +31 -30
package/README.md
CHANGED
|
@@ -1,379 +1,200 @@
|
|
|
1
1
|
# @memberjunction/ai-cli
|
|
2
2
|
|
|
3
|
-
MemberJunction AI
|
|
3
|
+
Command-line interface for executing MemberJunction AI agents, prompts, and actions. Built on the oclif framework, it provides both one-shot and interactive modes with rich terminal output, conversation history management, audit logging, and direct database integration.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
[](https://github.com/MemberJunction/MJ)
|
|
5
|
+
> **Note**: The standalone `mj-ai` binary is deprecated. All AI functionality has been integrated into the main MemberJunction CLI. Use `mj ai` commands instead.
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
## Overview
|
|
11
|
-
|
|
12
|
-
A fully functional command-line interface for executing MemberJunction AI agents, actions, and direct prompts. The CLI provides seamless integration with the MJ infrastructure, supporting both interactive and programmatic execution of AI workflows.
|
|
7
|
+
## Architecture
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
```mermaid
|
|
10
|
+
graph TD
|
|
11
|
+
subgraph "@memberjunction/ai-cli"
|
|
12
|
+
CLI["oclif CLI Framework<br/>mj-ai binary"]
|
|
13
|
+
style CLI fill:#2d8659,stroke:#1a5c3a,color:#fff
|
|
14
|
+
|
|
15
|
+
subgraph "Commands"
|
|
16
|
+
AL["agents list"]
|
|
17
|
+
style AL fill:#7c5295,stroke:#563a6b,color:#fff
|
|
18
|
+
AR["agents run"]
|
|
19
|
+
style AR fill:#7c5295,stroke:#563a6b,color:#fff
|
|
20
|
+
PL["prompts list"]
|
|
21
|
+
style PL fill:#7c5295,stroke:#563a6b,color:#fff
|
|
22
|
+
PRR["prompts run"]
|
|
23
|
+
style PRR fill:#7c5295,stroke:#563a6b,color:#fff
|
|
24
|
+
ACL["actions list"]
|
|
25
|
+
style ACL fill:#7c5295,stroke:#563a6b,color:#fff
|
|
26
|
+
ACR["actions run"]
|
|
27
|
+
style ACR fill:#7c5295,stroke:#563a6b,color:#fff
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
subgraph "Services"
|
|
31
|
+
AS["AgentService"]
|
|
32
|
+
style AS fill:#b8762f,stroke:#8a5722,color:#fff
|
|
33
|
+
PS["PromptService"]
|
|
34
|
+
style PS fill:#b8762f,stroke:#8a5722,color:#fff
|
|
35
|
+
ACS["ActionService"]
|
|
36
|
+
style ACS fill:#b8762f,stroke:#8a5722,color:#fff
|
|
37
|
+
CS["ConversationService"]
|
|
38
|
+
style CS fill:#b8762f,stroke:#8a5722,color:#fff
|
|
39
|
+
VS["ValidationService"]
|
|
40
|
+
style VS fill:#b8762f,stroke:#8a5722,color:#fff
|
|
41
|
+
AAS["AgentAuditService"]
|
|
42
|
+
style AAS fill:#b8762f,stroke:#8a5722,color:#fff
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
subgraph "Utilities"
|
|
46
|
+
OF["OutputFormatter"]
|
|
47
|
+
style OF fill:#2d6a9f,stroke:#1a4971,color:#fff
|
|
48
|
+
TF["TextFormatter"]
|
|
49
|
+
style TF fill:#2d6a9f,stroke:#1a4971,color:#fff
|
|
50
|
+
CM["ConsoleManager"]
|
|
51
|
+
style CM fill:#2d6a9f,stroke:#1a4971,color:#fff
|
|
52
|
+
EL["ExecutionLogger"]
|
|
53
|
+
style EL fill:#2d6a9f,stroke:#1a4971,color:#fff
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
CLI --> AL
|
|
58
|
+
CLI --> AR
|
|
59
|
+
CLI --> PL
|
|
60
|
+
CLI --> PRR
|
|
61
|
+
CLI --> ACL
|
|
62
|
+
CLI --> ACR
|
|
63
|
+
|
|
64
|
+
AR --> AS
|
|
65
|
+
PRR --> PS
|
|
66
|
+
ACR --> ACS
|
|
67
|
+
AS --> CS
|
|
68
|
+
AS --> AAS
|
|
69
|
+
```
|
|
26
70
|
|
|
27
71
|
## Installation
|
|
28
72
|
|
|
29
|
-
This package is part of the MemberJunction workspace. Install dependencies from the repository root:
|
|
30
|
-
|
|
31
73
|
```bash
|
|
32
|
-
npm install
|
|
74
|
+
npm install -g @memberjunction/ai-cli
|
|
33
75
|
```
|
|
34
76
|
|
|
35
|
-
##
|
|
36
|
-
|
|
37
|
-
The CLI provides commands for executing AI agents, actions, and direct prompts:
|
|
77
|
+
## Commands
|
|
38
78
|
|
|
39
79
|
### Agent Commands
|
|
40
80
|
|
|
41
|
-
Execute AI agents with natural language prompts:
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
# List available agents (20+ agents ready)
|
|
45
|
-
./packages/AI/AICLI/bin/run agents:list --output=compact
|
|
46
|
-
|
|
47
|
-
# Execute an agent with a prompt
|
|
48
|
-
./packages/AI/AICLI/bin/run agents:run -a "Skip: Requirements Expert" -p "Create a dashboard for sales metrics"
|
|
49
|
-
|
|
50
|
-
# Start interactive chat with an agent
|
|
51
|
-
./packages/AI/AICLI/bin/run agents:run -a "Child Component Generator Sub-agent" --chat
|
|
52
|
-
|
|
53
|
-
# Execute with verbose output and custom timeout
|
|
54
|
-
./packages/AI/AICLI/bin/run agents:run -a "Skip: Technical Design Expert" -p "Build a React component" --verbose --timeout=600000
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
### Action Commands
|
|
58
|
-
|
|
59
|
-
Execute individual actions with parameters:
|
|
60
|
-
|
|
61
81
|
```bash
|
|
62
|
-
# List available
|
|
63
|
-
|
|
82
|
+
# List all available agents
|
|
83
|
+
mj-ai agents list
|
|
64
84
|
|
|
65
|
-
#
|
|
66
|
-
|
|
85
|
+
# List agents with filtering
|
|
86
|
+
mj-ai agents list --filter "sales"
|
|
67
87
|
|
|
68
|
-
#
|
|
69
|
-
|
|
88
|
+
# Run an agent interactively (chat mode)
|
|
89
|
+
mj-ai agents run --name "Sales Assistant"
|
|
70
90
|
|
|
71
|
-
#
|
|
72
|
-
|
|
73
|
-
--param "To=user@example.com" \
|
|
74
|
-
--param "Subject=Test Message" \
|
|
75
|
-
--param "Body=Hello from MJ CLI" \
|
|
76
|
-
--param "MessageType=Email" \
|
|
77
|
-
--param "Provider=SendGrid"
|
|
91
|
+
# Run an agent with a single message
|
|
92
|
+
mj-ai agents run --name "Data Analyzer" --message "Show Q3 revenue by region"
|
|
78
93
|
|
|
79
|
-
#
|
|
80
|
-
|
|
94
|
+
# Run an agent by ID
|
|
95
|
+
mj-ai agents run --id "agent-uuid"
|
|
81
96
|
```
|
|
82
97
|
|
|
83
98
|
### Prompt Commands
|
|
84
99
|
|
|
85
|
-
Execute direct prompts with any available AI model:
|
|
86
|
-
|
|
87
100
|
```bash
|
|
88
|
-
# List available
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
# Execute a direct prompt
|
|
92
|
-
./packages/AI/AICLI/bin/run prompts:run -p "Explain machine learning in simple terms"
|
|
101
|
+
# List all available prompts
|
|
102
|
+
mj-ai prompts list
|
|
93
103
|
|
|
94
|
-
#
|
|
95
|
-
|
|
104
|
+
# Run a prompt with data
|
|
105
|
+
mj-ai prompts run --name "Summarize Content" --data '{"content": "Long text..."}'
|
|
96
106
|
|
|
97
|
-
#
|
|
98
|
-
|
|
99
|
-
--system "You are a poet" \
|
|
100
|
-
--temperature 0.3 \
|
|
101
|
-
--max-tokens 100
|
|
107
|
+
# Run a prompt with a file
|
|
108
|
+
mj-ai prompts run --name "Analyze Document" --file ./report.txt
|
|
102
109
|
```
|
|
103
110
|
|
|
104
|
-
###
|
|
105
|
-
|
|
106
|
-
All commands support multiple output formats:
|
|
111
|
+
### Action Commands
|
|
107
112
|
|
|
108
113
|
```bash
|
|
109
|
-
#
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
# Table output - structured tabular format
|
|
113
|
-
./packages/AI/AICLI/bin/run agents:list --output=table
|
|
114
|
+
# List all available actions
|
|
115
|
+
mj-ai actions list
|
|
114
116
|
|
|
115
|
-
#
|
|
116
|
-
|
|
117
|
+
# Run an action with parameters
|
|
118
|
+
mj-ai actions run --name "Send Email" --params '{"to": "user@example.com", "subject": "Test"}'
|
|
117
119
|
```
|
|
118
120
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
- `--verbose, -v`: Show detailed execution information including timing and IDs
|
|
122
|
-
- `--timeout <ms>`: Override default timeout (default: 300000ms / 5 minutes)
|
|
123
|
-
- `--dry-run`: Validate configuration and parameters without executing
|
|
124
|
-
- `--output <format>`: Output format (compact, json, table)
|
|
125
|
-
- `--help`: Show command-specific help and examples
|
|
126
|
-
|
|
127
|
-
## Features
|
|
128
|
-
|
|
129
|
-
### Progress Tracking
|
|
130
|
-
|
|
131
|
-
The CLI provides real-time progress updates during agent execution:
|
|
132
|
-
|
|
133
|
-
**Non-verbose mode**: Compact progress indicators on a single line
|
|
134
|
-
```
|
|
135
|
-
🚀 [ 0%] initialization: Initializing agent...
|
|
136
|
-
✓ [ 10%] validation: Validating agent configuration
|
|
137
|
-
💭 [ 30%] prompt execution: Running agent's initial prompt...
|
|
138
|
-
🧠 [ 70%] decision processing: Analyzing response
|
|
139
|
-
✨ [ 95%] finalization: Finalizing agent execution
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
**Verbose mode**: Detailed progress with metadata
|
|
143
|
-
```
|
|
144
|
-
🚀 [ 0%] initialization - Initializing Demo Loop Agent agent and preparing execution environment
|
|
145
|
-
{"agentRun":null}
|
|
146
|
-
|
|
147
|
-
✓ [ 10%] validation - Validating agent configuration and loading prompts
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
### Text Formatting
|
|
151
|
-
|
|
152
|
-
Long agent responses are automatically formatted for better readability:
|
|
153
|
-
- **Word wrapping** at console width (default 80 characters)
|
|
154
|
-
- **Paragraph preservation** maintains original structure
|
|
155
|
-
- **List formatting** with proper indentation for bullets and numbered lists
|
|
156
|
-
- **Code highlighting** in gray for code blocks
|
|
157
|
-
- **JSON formatting** with syntax highlighting for structured data
|
|
121
|
+
## Key Features
|
|
158
122
|
|
|
159
123
|
### Interactive Chat Mode
|
|
160
124
|
|
|
161
|
-
|
|
162
|
-
-
|
|
163
|
-
-
|
|
164
|
-
-
|
|
165
|
-
-
|
|
166
|
-
|
|
167
|
-
### Agent Run Auditing
|
|
168
|
-
|
|
169
|
-
The AgentAuditService provides comprehensive debugging and performance analysis tools for AI agent executions. This service is exposed through the MJCLI `mj ai audit agent-run` command.
|
|
170
|
-
|
|
171
|
-
**Key Features:**
|
|
172
|
-
- **List Recent Runs**: Filter by agent name, status, and date range
|
|
173
|
-
- **Run Summaries**: High-level overview with step list and identifiable IDs
|
|
174
|
-
- **Step Detail Analysis**: Deep dive into specific step inputs/outputs with smart truncation
|
|
175
|
-
- **Error Analysis**: Automatic error pattern detection with suggested fixes
|
|
176
|
-
- **Multiple Output Formats**: Compact, JSON, table, markdown
|
|
177
|
-
- **Token Management**: Smart truncation prevents overwhelming large payloads (configurable with `--max-tokens`)
|
|
178
|
-
- **Export Capabilities**: Full data export to JSON files for offline analysis
|
|
179
|
-
|
|
180
|
-
**Smart Truncation:**
|
|
181
|
-
The audit system automatically truncates large input/output payloads to prevent token overflow, showing the first 70% and last 30% of content with a truncation indicator. This is especially useful for Skip-Brain agents that generate large component payloads.
|
|
182
|
-
|
|
183
|
-
**Performance Optimization:**
|
|
184
|
-
All audit queries use `ResultType: 'simple'` for optimal read-only performance, avoiding unnecessary entity object instantiation overhead.
|
|
185
|
-
|
|
186
|
-
## Architecture
|
|
187
|
-
|
|
188
|
-
The CLI follows the MetadataSync pattern with:
|
|
189
|
-
|
|
190
|
-
- **Service Layer**: AgentService, ActionService, ValidationService, AgentAuditService
|
|
191
|
-
- **Infrastructure**: MJ Provider with database integration
|
|
192
|
-
- **Logging**: Comprehensive execution tracking with file output
|
|
193
|
-
- **Error Handling**: User-friendly error messages with next steps
|
|
194
|
-
- **Configuration**: Automatic mj.config.cjs detection and loading
|
|
195
|
-
- **Text Formatting**: Advanced console output formatting with TextFormatter
|
|
196
|
-
- **Progress Tracking**: Real-time execution status with visual indicators
|
|
197
|
-
- **Audit & Analysis**: AgentAuditService for debugging and performance analysis
|
|
198
|
-
|
|
199
|
-
### Design Decisions
|
|
200
|
-
|
|
201
|
-
**Why No oclif Init Hooks:**
|
|
202
|
-
The CLI intentionally does not use oclif init hooks for database initialization. Init hooks have significant limitations:
|
|
203
|
-
- Don't run during help/version commands
|
|
204
|
-
- Early database failures would break even `--help`
|
|
205
|
-
- More restrictive error handling
|
|
206
|
-
- Commands are imported before hooks run
|
|
207
|
-
|
|
208
|
-
Instead, we use **service-based initialization** which provides:
|
|
209
|
-
- Better error isolation and debugging
|
|
210
|
-
- Lazy initialization (only when needed)
|
|
211
|
-
- Reliable help/version commands
|
|
212
|
-
- Comprehensive error messages with actionable steps
|
|
213
|
-
|
|
214
|
-
**Future Enhancement Option:**
|
|
215
|
-
A Base Command Pattern could reduce code duplication while maintaining current benefits:
|
|
216
|
-
```typescript
|
|
217
|
-
export abstract class BaseCommand extends Command {
|
|
218
|
-
protected async initMJ(): Promise<void> {
|
|
219
|
-
// Shared initialization logic
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
```
|
|
223
|
-
This would be a better alternative than init hooks for shared functionality.
|
|
224
|
-
|
|
225
|
-
## Configuration
|
|
226
|
-
|
|
227
|
-
The CLI uses the standard MemberJunction configuration from `mj.config.cjs` in the repository root.
|
|
228
|
-
|
|
229
|
-
**✅ Currently Working With:**
|
|
230
|
-
- SQL Server database connection
|
|
231
|
-
- User authentication and context
|
|
232
|
-
- AI model and provider settings
|
|
233
|
-
- Metadata caching and performance optimization
|
|
234
|
-
|
|
235
|
-
**Required Configuration in mj.config.cjs:**
|
|
236
|
-
- Database connection settings (host, port, database, user, password)
|
|
237
|
-
- AI model configuration for agent execution
|
|
238
|
-
- User authentication setup
|
|
125
|
+
When running an agent without `--message`, the CLI enters interactive chat mode with:
|
|
126
|
+
- Multi-line input support
|
|
127
|
+
- Conversation history across turns
|
|
128
|
+
- Real-time progress indicators (spinners)
|
|
129
|
+
- Formatted markdown output
|
|
130
|
+
- Color-coded output for different message types
|
|
239
131
|
|
|
240
|
-
|
|
132
|
+
### Conversation Management
|
|
241
133
|
|
|
242
|
-
|
|
134
|
+
The `ConversationService` manages conversation state:
|
|
135
|
+
- Creates and tracks MJ Conversation entities
|
|
136
|
+
- Maintains message history across agent turns
|
|
137
|
+
- Supports conversation resumption
|
|
243
138
|
|
|
244
|
-
|
|
245
|
-
cd packages/AI/AICLI
|
|
246
|
-
npm run build
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
### Running in Development
|
|
250
|
-
|
|
251
|
-
```bash
|
|
252
|
-
# From repository root (recommended)
|
|
253
|
-
./packages/AI/AICLI/bin/run agents:list
|
|
254
|
-
|
|
255
|
-
# Or from package directory
|
|
256
|
-
cd packages/AI/AICLI
|
|
257
|
-
./bin/run agents:list
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
### Testing Commands
|
|
261
|
-
|
|
262
|
-
```bash
|
|
263
|
-
# Test help system
|
|
264
|
-
./packages/AI/AICLI/bin/run --help
|
|
265
|
-
./packages/AI/AICLI/bin/run agents:run --help
|
|
266
|
-
|
|
267
|
-
# Test basic connectivity
|
|
268
|
-
./packages/AI/AICLI/bin/run agents:list --output=json | jq length
|
|
269
|
-
|
|
270
|
-
# Test validation without execution
|
|
271
|
-
./packages/AI/AICLI/bin/run actions:run -n "Calculate Expression" --param "Expression=1+1" --dry-run
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
## Performance
|
|
275
|
-
|
|
276
|
-
Current performance benchmarks:
|
|
277
|
-
- **Metadata Loading**: ~700ms (includes full entity and relationship mapping)
|
|
278
|
-
- **Agent Listing**: Instant after metadata load
|
|
279
|
-
- **Action Discovery**: Instant after metadata load
|
|
280
|
-
- **Database Connection**: <100ms on subsequent calls
|
|
281
|
-
|
|
282
|
-
## Logging
|
|
283
|
-
|
|
284
|
-
Execution logs are stored in `.mj-ai/logs/` directory with comprehensive tracking:
|
|
285
|
-
|
|
286
|
-
**What's Logged:**
|
|
287
|
-
- Execution steps and timing
|
|
288
|
-
- Agent/action responses and parameters
|
|
289
|
-
- Error details and stack traces
|
|
290
|
-
- Performance metrics and database query times
|
|
291
|
-
- User context and configuration details
|
|
139
|
+
### Audit Logging
|
|
292
140
|
|
|
293
|
-
|
|
294
|
-
-
|
|
295
|
-
-
|
|
141
|
+
The `AgentAuditService` provides detailed execution audit trails:
|
|
142
|
+
- Token usage tracking per turn
|
|
143
|
+
- Cost estimation
|
|
144
|
+
- Execution time tracking
|
|
145
|
+
- Action execution logging
|
|
146
|
+
- Error recording
|
|
296
147
|
|
|
297
|
-
|
|
298
|
-
```
|
|
299
|
-
.mj-ai/logs/2025-06-21_18-36-13_ftwxjeywx_execution.log
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
## Troubleshooting
|
|
148
|
+
### Output Formatting
|
|
303
149
|
|
|
304
|
-
|
|
150
|
+
Rich terminal output with:
|
|
151
|
+
- Markdown rendering via `TextFormatter`
|
|
152
|
+
- Tabular data display via `table` package
|
|
153
|
+
- Color-coded status messages via `chalk`
|
|
154
|
+
- Spinner animations via `ora-classic`
|
|
155
|
+
- Structured JSON output option
|
|
305
156
|
|
|
306
|
-
|
|
307
|
-
- Ensure you're running from the MJ repository root
|
|
308
|
-
- Verify mj.config.cjs exists and has database settings
|
|
157
|
+
### Database Integration
|
|
309
158
|
|
|
310
|
-
|
|
311
|
-
-
|
|
312
|
-
-
|
|
313
|
-
-
|
|
159
|
+
Direct SQL Server connection for:
|
|
160
|
+
- Loading agent, prompt, and action metadata
|
|
161
|
+
- Storing conversation history
|
|
162
|
+
- Recording execution logs
|
|
163
|
+
- User context resolution
|
|
314
164
|
|
|
315
|
-
|
|
316
|
-
- Verify user has execute permissions on ./bin/run
|
|
317
|
-
- Check database user permissions for metadata access
|
|
318
|
-
|
|
319
|
-
### Getting Help
|
|
320
|
-
|
|
321
|
-
```bash
|
|
322
|
-
# Command-specific help
|
|
323
|
-
./packages/AI/AICLI/bin/run agents:run --help
|
|
324
|
-
./packages/AI/AICLI/bin/run actions:run --help
|
|
325
|
-
|
|
326
|
-
# Global help
|
|
327
|
-
./packages/AI/AICLI/bin/run --help
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
## Migration Guide
|
|
331
|
-
|
|
332
|
-
The AI CLI functionality has been integrated into the main MemberJunction CLI. To migrate:
|
|
333
|
-
|
|
334
|
-
### Command Changes
|
|
335
|
-
|
|
336
|
-
| Old Command (mj-ai) | New Command (mj) |
|
|
337
|
-
|---------------------|------------------|
|
|
338
|
-
| `mj-ai agents:list` | `mj ai agents list` |
|
|
339
|
-
| `mj-ai agents:run` | `mj ai agents run` |
|
|
340
|
-
| `mj-ai actions:list` | `mj ai actions list` |
|
|
341
|
-
| `mj-ai actions:run` | `mj ai actions run` |
|
|
342
|
-
| `mj-ai prompts:list` | `mj ai prompts list` |
|
|
343
|
-
| `mj-ai prompts:run` | `mj ai prompts run` |
|
|
344
|
-
|
|
345
|
-
### Examples
|
|
346
|
-
|
|
347
|
-
```bash
|
|
348
|
-
# Old way
|
|
349
|
-
mj-ai agents:run -a "Skip: Requirements Expert" -p "Create a dashboard"
|
|
350
|
-
|
|
351
|
-
# New way
|
|
352
|
-
mj ai agents run -a "Skip: Requirements Expert" -p "Create a dashboard"
|
|
353
|
-
|
|
354
|
-
# Old way
|
|
355
|
-
mj-ai actions:run -n "Get Weather" --param "Location=Boston"
|
|
356
|
-
|
|
357
|
-
# New way
|
|
358
|
-
mj ai actions run -n "Get Weather" --param "Location=Boston"
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
### Installation
|
|
362
|
-
|
|
363
|
-
Instead of using this package directly, install the main MJ CLI:
|
|
364
|
-
|
|
365
|
-
```bash
|
|
366
|
-
npm install -g @memberjunction/cli
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
### Configuration
|
|
370
|
-
|
|
371
|
-
No changes needed - both CLIs use the same `mj.config.cjs` file.
|
|
372
|
-
|
|
373
|
-
### Support Timeline
|
|
374
|
-
|
|
375
|
-
- **Now**: Both `mj-ai` and `mj ai` commands work
|
|
376
|
-
- **3 months**: `mj-ai` will show deprecation warnings
|
|
377
|
-
- **6 months**: `mj-ai` package will be archived
|
|
165
|
+
## Configuration
|
|
378
166
|
|
|
379
|
-
|
|
167
|
+
Configure via `mj.config.cjs`, `.mjrc`, or environment variables:
|
|
168
|
+
|
|
169
|
+
```javascript
|
|
170
|
+
module.exports = {
|
|
171
|
+
databaseSettings: {
|
|
172
|
+
host: 'localhost',
|
|
173
|
+
port: 1433,
|
|
174
|
+
database: 'MemberJunction',
|
|
175
|
+
username: 'sa',
|
|
176
|
+
password: 'password'
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Required environment variables:
|
|
182
|
+
- `DB_HOST`, `DB_PORT`, `DB_DATABASE`, `DB_USERNAME`, `DB_PASSWORD` -- Database connection
|
|
183
|
+
- `AI_VENDOR_API_KEY__OPENAILLM` -- OpenAI API key (or other provider keys)
|
|
184
|
+
|
|
185
|
+
## Dependencies
|
|
186
|
+
|
|
187
|
+
- `@oclif/core` -- CLI framework
|
|
188
|
+
- `@memberjunction/ai-agents` -- AgentRunner for agent execution
|
|
189
|
+
- `@memberjunction/ai-prompts` -- AIPromptRunner for prompt execution
|
|
190
|
+
- `@memberjunction/ai-core-plus` -- Shared types
|
|
191
|
+
- `@memberjunction/ai` -- Core AI abstractions
|
|
192
|
+
- `@memberjunction/actions` -- Action execution
|
|
193
|
+
- `@memberjunction/core` / `@memberjunction/core-entities` -- MJ framework
|
|
194
|
+
- `@memberjunction/sqlserver-dataprovider` -- SQL Server data access
|
|
195
|
+
- `@memberjunction/core-entities-server` -- Server-side entity extensions
|
|
196
|
+
- `@inquirer/prompts` -- Interactive prompts
|
|
197
|
+
- `chalk` -- Terminal colors
|
|
198
|
+
- `ora-classic` -- Terminal spinners
|
|
199
|
+
- `table` -- Tabular output
|
|
200
|
+
- `cosmiconfig` -- Configuration loading
|
package/bin/run.js
CHANGED
|
@@ -1,62 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const core_1 = require("@oclif/core");
|
|
30
|
-
const ora_classic_1 = __importDefault(require("ora-classic"));
|
|
31
|
-
const ActionService_1 = require("../../services/ActionService");
|
|
32
|
-
const output_formatter_1 = require("../../lib/output-formatter");
|
|
33
|
-
const ValidationService_1 = require("../../services/ValidationService");
|
|
34
|
-
class ActionsList extends core_1.Command {
|
|
35
|
-
static description = 'List available actions';
|
|
36
|
-
static examples = [
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import ora from 'ora-classic';
|
|
3
|
+
import { ActionService } from '../../services/ActionService.js';
|
|
4
|
+
import { OutputFormatter } from '../../lib/output-formatter.js';
|
|
5
|
+
import { ValidationService } from '../../services/ValidationService.js';
|
|
6
|
+
export default class ActionsList extends Command {
|
|
7
|
+
static { this.description = 'List available actions'; }
|
|
8
|
+
static { this.examples = [
|
|
37
9
|
'<%= config.bin %> <%= command.id %>',
|
|
38
10
|
'<%= config.bin %> <%= command.id %> --output=json',
|
|
39
11
|
'<%= config.bin %> <%= command.id %> --output=table',
|
|
40
|
-
];
|
|
41
|
-
static flags = {
|
|
42
|
-
output:
|
|
12
|
+
]; }
|
|
13
|
+
static { this.flags = {
|
|
14
|
+
output: Flags.string({
|
|
43
15
|
description: 'Output format',
|
|
44
16
|
options: ['compact', 'json', 'table'],
|
|
45
17
|
default: 'table'
|
|
46
18
|
})
|
|
47
|
-
};
|
|
19
|
+
}; }
|
|
48
20
|
async run() {
|
|
49
21
|
const { flags } = await this.parse(ActionsList);
|
|
50
|
-
const spinner = (
|
|
22
|
+
const spinner = ora('Loading available actions...');
|
|
51
23
|
try {
|
|
52
|
-
const validator = new
|
|
24
|
+
const validator = new ValidationService();
|
|
53
25
|
const outputFormat = validator.validateOutputFormat(flags.output);
|
|
54
26
|
spinner.start();
|
|
55
|
-
const actionService = new
|
|
27
|
+
const actionService = new ActionService();
|
|
56
28
|
await actionService.initialize();
|
|
57
29
|
const actions = await actionService.listActions();
|
|
58
30
|
spinner.stop();
|
|
59
|
-
const formatter = new
|
|
31
|
+
const formatter = new OutputFormatter(outputFormat);
|
|
60
32
|
this.log(formatter.formatActionList(actions));
|
|
61
33
|
// Clean up resources
|
|
62
34
|
await this.cleanup();
|
|
@@ -79,7 +51,7 @@ class ActionsList extends core_1.Command {
|
|
|
79
51
|
}
|
|
80
52
|
async cleanup() {
|
|
81
53
|
try {
|
|
82
|
-
const { closeMJProvider } = await
|
|
54
|
+
const { closeMJProvider } = await import('../../lib/mj-provider.js');
|
|
83
55
|
await closeMJProvider();
|
|
84
56
|
}
|
|
85
57
|
catch (error) {
|
|
@@ -87,5 +59,4 @@ class ActionsList extends core_1.Command {
|
|
|
87
59
|
}
|
|
88
60
|
}
|
|
89
61
|
}
|
|
90
|
-
exports.default = ActionsList;
|
|
91
62
|
//# sourceMappingURL=list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/actions/list.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/actions/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,GAAG,MAAM,aAAa,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,OAAO;aACvC,gBAAW,GAAG,wBAAwB,CAAC;aAEvC,aAAQ,GAAG;QAChB,qCAAqC;QACrC,mDAAmD;QACnD,oDAAoD;KACrD,CAAC;aAEK,UAAK,GAAG;QACb,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;YACnB,WAAW,EAAE,eAAe;YAC5B,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC;YACrC,OAAO,EAAE,OAAO;SACjB,CAAC;KACH,CAAC;IAEF,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAChD,MAAM,OAAO,GAAG,GAAG,CAAC,8BAA8B,CAAC,CAAC;QAEpD,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,IAAI,iBAAiB,EAAE,CAAC;YAC1C,MAAM,YAAY,GAAG,SAAS,CAAC,oBAAoB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAElE,OAAO,CAAC,KAAK,EAAE,CAAC;YAEhB,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;YAC1C,MAAM,aAAa,CAAC,UAAU,EAAE,CAAC;YAEjC,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,WAAW,EAAE,CAAC;YAElD,OAAO,CAAC,IAAI,EAAE,CAAC;YAEf,MAAM,SAAS,GAAG,IAAI,eAAe,CAAC,YAAY,CAAC,CAAC;YACpD,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;YAE9C,qBAAqB;YACrB,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;YAErB,yCAAyC;YACzC,YAAY,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAEtC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBACvB,OAAO,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;YACzC,CAAC;YAED,qDAAqD;YACrD,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBAClC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACxB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACf,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,OAAO;QACnB,IAAI,CAAC;YACH,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAC;YAClE,MAAM,eAAe,EAAE,CAAC;QAC1B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,6DAA6D;QAC/D,CAAC;IACH,CAAC"}
|
|
@@ -3,7 +3,7 @@ export default class ActionsRun extends Command {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
-
name: import("@oclif/core/lib/interfaces").OptionFlag<string
|
|
6
|
+
name: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
7
|
param: import("@oclif/core/lib/interfaces").OptionFlag<string[], import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
8
|
verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
9
9
|
timeout: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|