@memberjunction/cli 2.77.0 → 2.78.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 CHANGED
@@ -52,6 +52,15 @@ interface MJConfig {
52
52
  coreSchema?: string; // Core schema name (default: '__mj')
53
53
  cleanDisabled?: boolean; // Disable database cleaning (default: true)
54
54
  mjRepoUrl?: string; // MemberJunction repository URL
55
+
56
+ // AI-specific settings (optional)
57
+ aiSettings?: {
58
+ defaultTimeout?: number; // Default timeout for AI operations (default: 300000ms)
59
+ outputFormat?: 'compact' | 'json' | 'table'; // Default output format
60
+ logLevel?: 'info' | 'debug' | 'verbose'; // Logging detail level
61
+ enableChat?: boolean; // Enable chat features (default: true)
62
+ chatHistoryLimit?: number; // Chat history size limit
63
+ };
55
64
  }
56
65
  ```
57
66
 
@@ -106,6 +115,129 @@ mj sync push
106
115
  mj sync watch
107
116
  ```
108
117
 
118
+ ### `mj ai`
119
+
120
+ Execute AI agents and actions using MemberJunction's AI framework. This command provides access to 20+ AI agents and 30+ actions for various tasks.
121
+
122
+ ```bash
123
+ mj ai [COMMAND] [OPTIONS]
124
+ ```
125
+
126
+ Available AI commands:
127
+ - `agents list` - List available AI agents
128
+ - `agents run` - Execute an AI agent with a prompt or start interactive chat
129
+ - `actions list` - List available AI actions
130
+ - `actions run` - Execute an AI action with parameters
131
+ - `prompts list` - List available AI models for direct prompt execution
132
+ - `prompts run` - Execute a direct prompt with an AI model
133
+
134
+ #### Quick Examples:
135
+
136
+ ```bash
137
+ # List all available agents
138
+ mj ai agents list
139
+
140
+ # Execute an agent with a prompt
141
+ mj ai agents run -a "Skip: Requirements Expert" -p "Create a dashboard for sales metrics"
142
+
143
+ # Start interactive chat with an agent
144
+ mj ai agents run -a "Child Component Generator Sub-agent" --chat
145
+
146
+ # List all available actions
147
+ mj ai actions list --output=table
148
+
149
+ # Execute an action with parameters
150
+ mj ai actions run -n "Get Weather" --param "Location=Boston"
151
+
152
+ # Execute action with multiple parameters
153
+ mj ai actions run -n "Send Single Message" \
154
+ --param "To=user@example.com" \
155
+ --param "Subject=Test Message" \
156
+ --param "Body=Hello from MJ CLI"
157
+
158
+ # Validate action without executing
159
+ mj ai actions run -n "Calculate Expression" --param "Expression=2+2*3" --dry-run
160
+
161
+ # List available AI models
162
+ mj ai prompts list
163
+
164
+ # Execute a direct prompt
165
+ mj ai prompts run -p "Explain quantum computing in simple terms"
166
+
167
+ # Use a specific model
168
+ mj ai prompts run -p "Write a Python function to sort a list" --model "gpt-4"
169
+
170
+ # Use system prompt and temperature
171
+ mj ai prompts run -p "Generate a haiku" --system "You are a poet" --temperature 0.3
172
+ ```
173
+
174
+ #### AI Command Options:
175
+
176
+ **Agent Commands:**
177
+ - `-a, --agent <name>`: Agent name (required)
178
+ - `-p, --prompt <text>`: Prompt to execute
179
+ - `-c, --chat`: Start interactive chat mode
180
+ - `-o, --output <format>`: Output format (compact, json, table)
181
+ - `-v, --verbose`: Show detailed execution information
182
+ - `--timeout <ms>`: Execution timeout in milliseconds (default: 300000)
183
+
184
+ **Action Commands:**
185
+ - `-n, --name <name>`: Action name (required)
186
+ - `-p, --param <key=value>`: Action parameters (can be specified multiple times)
187
+ - `--dry-run`: Validate without executing
188
+ - `-o, --output <format>`: Output format (compact, json, table)
189
+ - `-v, --verbose`: Show detailed execution information
190
+ - `--timeout <ms>`: Execution timeout in milliseconds (default: 300000)
191
+
192
+ **Prompt Commands:**
193
+ - `-p, --prompt <text>`: The prompt to execute (required)
194
+ - `-m, --model <name>`: AI model to use (e.g., gpt-4, claude-3-opus)
195
+ - `-s, --system <text>`: System prompt to set context
196
+ - `-t, --temperature <0.0-2.0>`: Temperature for response creativity
197
+ - `--max-tokens <number>`: Maximum tokens for the response
198
+ - `-c, --configuration <id>`: AI Configuration ID to use
199
+ - `-o, --output <format>`: Output format (compact, json, table)
200
+ - `-v, --verbose`: Show detailed execution information
201
+ - `--timeout <ms>`: Execution timeout in milliseconds (default: 300000)
202
+
203
+ #### AI Features:
204
+
205
+ **Progress Tracking**: Real-time visual progress indicators during agent execution
206
+ - Compact single-line progress in normal mode
207
+ - Detailed progress with metadata in verbose mode
208
+ - Visual icons for each execution phase (🚀 initialization, ✓ validation, 💭 execution, etc.)
209
+
210
+ **Text Formatting**: Automatic formatting of long AI responses for better readability
211
+ - Word wrapping at console width
212
+ - Paragraph and list preservation
213
+ - Code block highlighting
214
+ - JSON syntax coloring
215
+
216
+ **Interactive Chat**: Full conversation context maintained across messages
217
+ - Agent remembers previous exchanges
218
+ - Natural back-and-forth dialogue
219
+ - Exit with "exit", "quit", or Ctrl+C
220
+
221
+ #### AI Configuration:
222
+
223
+ Add AI-specific settings to your `mj.config.cjs`:
224
+
225
+ ```javascript
226
+ module.exports = {
227
+ // Existing database settings...
228
+
229
+ aiSettings: {
230
+ defaultTimeout: 300000,
231
+ outputFormat: 'compact',
232
+ logLevel: 'info',
233
+ enableChat: true,
234
+ chatHistoryLimit: 10
235
+ }
236
+ };
237
+ ```
238
+
239
+ Execution logs are stored in `.mj-ai/logs/` for debugging and audit purposes.
240
+
109
241
  ### `mj install`
110
242
 
111
243
  Performs a complete installation of MemberJunction, including:
@@ -208,6 +340,8 @@ The CLI respects the following environment variables:
208
340
  The CLI integrates seamlessly with other MemberJunction packages:
209
341
 
210
342
  - **@memberjunction/codegen-lib**: Powers the code generation functionality
343
+ - **@memberjunction/metadata-sync**: Provides metadata synchronization capabilities
344
+ - **@memberjunction/ai-cli**: Enables AI agent and action execution
211
345
  - **Generated Entities**: Automatically linked during installation
212
346
  - **MJAPI**: Configured and linked during installation
213
347
  - **MJExplorer**: UI configuration handled during installation
@@ -0,0 +1,9 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class ActionsList extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ output: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const core_1 = require("@oclif/core");
7
+ const ai_cli_1 = require("@memberjunction/ai-cli");
8
+ const ora_classic_1 = __importDefault(require("ora-classic"));
9
+ class ActionsList extends core_1.Command {
10
+ static description = 'List available AI actions';
11
+ static examples = [
12
+ '<%= config.bin %> <%= command.id %>',
13
+ '<%= config.bin %> <%= command.id %> --output=table',
14
+ '<%= config.bin %> <%= command.id %> --output=json',
15
+ ];
16
+ static flags = {
17
+ output: core_1.Flags.string({
18
+ char: 'o',
19
+ description: 'Output format',
20
+ options: ['compact', 'json', 'table'],
21
+ default: 'compact',
22
+ }),
23
+ };
24
+ async run() {
25
+ const { flags } = await this.parse(ActionsList);
26
+ const spinner = (0, ora_classic_1.default)();
27
+ try {
28
+ spinner.start('Loading available actions...');
29
+ const service = new ai_cli_1.ActionService();
30
+ const actions = await service.listActions();
31
+ spinner.stop();
32
+ const formatter = new ai_cli_1.OutputFormatter(flags.output);
33
+ this.log(formatter.formatActionList(actions));
34
+ // Force exit after completion
35
+ process.exit(0);
36
+ }
37
+ catch (error) {
38
+ spinner.fail('Failed to load actions');
39
+ this.error(error);
40
+ }
41
+ }
42
+ }
43
+ exports.default = ActionsList;
@@ -0,0 +1,14 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class ActionsRun extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ name: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
7
+ param: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ 'dry-run': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
+ output: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
10
+ verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
+ timeout: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
12
+ };
13
+ run(): Promise<void>;
14
+ }
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const core_1 = require("@oclif/core");
7
+ const ai_cli_1 = require("@memberjunction/ai-cli");
8
+ const ora_classic_1 = __importDefault(require("ora-classic"));
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ class ActionsRun extends core_1.Command {
11
+ static description = 'Execute an AI action with parameters';
12
+ static examples = [
13
+ '<%= config.bin %> <%= command.id %> -n "Get Weather" --param "Location=Boston"',
14
+ '<%= config.bin %> <%= command.id %> -n "Get Stock Price" --param "Ticker=AAPL"',
15
+ '<%= config.bin %> <%= command.id %> -n "Send Single Message" --param "To=user@example.com" --param "Subject=Test" --param "Body=Hello" --param "MessageType=Email" --param "Provider=SendGrid"',
16
+ '<%= config.bin %> <%= command.id %> -n "Calculate Expression" --param "Expression=2+2*3" --dry-run',
17
+ ];
18
+ static flags = {
19
+ name: core_1.Flags.string({
20
+ char: 'n',
21
+ description: 'Action name',
22
+ required: true,
23
+ }),
24
+ param: core_1.Flags.string({
25
+ char: 'p',
26
+ description: 'Action parameters in key=value format',
27
+ multiple: true,
28
+ }),
29
+ 'dry-run': core_1.Flags.boolean({
30
+ description: 'Validate without executing',
31
+ }),
32
+ output: core_1.Flags.string({
33
+ char: 'o',
34
+ description: 'Output format',
35
+ options: ['compact', 'json', 'table'],
36
+ default: 'compact',
37
+ }),
38
+ verbose: core_1.Flags.boolean({
39
+ char: 'v',
40
+ description: 'Show detailed execution information',
41
+ }),
42
+ timeout: core_1.Flags.integer({
43
+ description: 'Execution timeout in milliseconds',
44
+ default: 300000, // 5 minutes
45
+ }),
46
+ };
47
+ async run() {
48
+ const { flags } = await this.parse(ActionsRun);
49
+ const service = new ai_cli_1.ActionService();
50
+ const formatter = new ai_cli_1.OutputFormatter(flags.output);
51
+ // Parse parameters
52
+ const params = {};
53
+ if (flags.param) {
54
+ for (const param of flags.param) {
55
+ const [key, ...valueParts] = param.split('=');
56
+ if (!key || valueParts.length === 0) {
57
+ this.error(`Invalid parameter format: "${param}". Use key=value format.`);
58
+ }
59
+ params[key] = valueParts.join('='); // Handle values with = in them
60
+ }
61
+ }
62
+ try {
63
+ if (flags['dry-run']) {
64
+ // For dry-run, just show what would be executed
65
+ this.log(chalk_1.default.yellow('Dry-run mode: Action would be executed with these parameters:'));
66
+ this.log(chalk_1.default.cyan(`Action: ${flags.name}`));
67
+ if (Object.keys(params).length > 0) {
68
+ this.log(chalk_1.default.cyan('Parameters:'));
69
+ for (const [key, value] of Object.entries(params)) {
70
+ this.log(` ${key}: ${value}`);
71
+ }
72
+ }
73
+ else {
74
+ this.log(chalk_1.default.gray('No parameters provided'));
75
+ }
76
+ }
77
+ else {
78
+ // Execute action
79
+ const spinner = (0, ora_classic_1.default)();
80
+ spinner.start(`Executing action: ${flags.name}`);
81
+ const result = await service.executeAction(flags.name, params);
82
+ spinner.stop();
83
+ this.log(formatter.formatActionResult(result));
84
+ if (!result.success) {
85
+ this.exit(1);
86
+ }
87
+ }
88
+ }
89
+ catch (error) {
90
+ this.error(error);
91
+ }
92
+ }
93
+ }
94
+ exports.default = ActionsRun;
@@ -0,0 +1,9 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class AgentsList extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ output: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const core_1 = require("@oclif/core");
7
+ const ai_cli_1 = require("@memberjunction/ai-cli");
8
+ const ora_classic_1 = __importDefault(require("ora-classic"));
9
+ class AgentsList extends core_1.Command {
10
+ static description = 'List available AI agents';
11
+ static examples = [
12
+ '<%= config.bin %> <%= command.id %>',
13
+ '<%= config.bin %> <%= command.id %> --output=table',
14
+ '<%= config.bin %> <%= command.id %> --output=json',
15
+ ];
16
+ static flags = {
17
+ output: core_1.Flags.string({
18
+ char: 'o',
19
+ description: 'Output format',
20
+ options: ['compact', 'json', 'table'],
21
+ default: 'compact',
22
+ }),
23
+ };
24
+ async run() {
25
+ const { flags } = await this.parse(AgentsList);
26
+ const spinner = (0, ora_classic_1.default)();
27
+ try {
28
+ spinner.start('Loading available agents...');
29
+ const service = new ai_cli_1.AgentService();
30
+ const agents = await service.listAgents();
31
+ spinner.stop();
32
+ const formatter = new ai_cli_1.OutputFormatter(flags.output);
33
+ this.log(formatter.formatAgentList(agents));
34
+ // Force exit after completion
35
+ process.exit(0);
36
+ }
37
+ catch (error) {
38
+ spinner.fail('Failed to load agents');
39
+ this.error(error);
40
+ }
41
+ }
42
+ }
43
+ exports.default = AgentsList;
@@ -0,0 +1,14 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class AgentsRun extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ agent: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
7
+ prompt: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ chat: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
+ output: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
10
+ verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
+ timeout: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
12
+ };
13
+ run(): Promise<void>;
14
+ }
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const core_1 = require("@oclif/core");
7
+ const ai_cli_1 = require("@memberjunction/ai-cli");
8
+ const ora_classic_1 = __importDefault(require("ora-classic"));
9
+ class AgentsRun extends core_1.Command {
10
+ static description = 'Execute an AI agent with a prompt or start interactive chat';
11
+ static examples = [
12
+ '<%= config.bin %> <%= command.id %> -a "Skip: Requirements Expert" -p "Create a dashboard for sales metrics"',
13
+ '<%= config.bin %> <%= command.id %> -a "Child Component Generator Sub-agent" --chat',
14
+ '<%= config.bin %> <%= command.id %> -a "Skip: Technical Design Expert" -p "Build a React component" --verbose --timeout=600000',
15
+ ];
16
+ static flags = {
17
+ agent: core_1.Flags.string({
18
+ char: 'a',
19
+ description: 'Agent name',
20
+ required: true,
21
+ }),
22
+ prompt: core_1.Flags.string({
23
+ char: 'p',
24
+ description: 'Prompt to execute',
25
+ exclusive: ['chat'],
26
+ }),
27
+ chat: core_1.Flags.boolean({
28
+ char: 'c',
29
+ description: 'Start interactive chat mode',
30
+ exclusive: ['prompt'],
31
+ }),
32
+ output: core_1.Flags.string({
33
+ char: 'o',
34
+ description: 'Output format',
35
+ options: ['compact', 'json', 'table'],
36
+ default: 'compact',
37
+ }),
38
+ verbose: core_1.Flags.boolean({
39
+ char: 'v',
40
+ description: 'Show detailed execution information',
41
+ }),
42
+ timeout: core_1.Flags.integer({
43
+ description: 'Execution timeout in milliseconds',
44
+ default: 300000, // 5 minutes
45
+ }),
46
+ };
47
+ async run() {
48
+ const { flags } = await this.parse(AgentsRun);
49
+ if (!flags.prompt && !flags.chat) {
50
+ this.error('Either --prompt or --chat flag is required');
51
+ }
52
+ const service = new ai_cli_1.AgentService();
53
+ const formatter = new ai_cli_1.OutputFormatter(flags.output);
54
+ try {
55
+ if (flags.chat) {
56
+ // Interactive chat mode
57
+ const conversationService = new ai_cli_1.ConversationService();
58
+ await conversationService.startChat(flags.agent, undefined, {
59
+ verbose: flags.verbose,
60
+ timeout: flags.timeout,
61
+ });
62
+ }
63
+ else {
64
+ // Single prompt execution
65
+ const spinner = (0, ora_classic_1.default)();
66
+ spinner.start(`Executing agent: ${flags.agent}`);
67
+ const result = await service.executeAgent(flags.agent, flags.prompt, {
68
+ verbose: flags.verbose,
69
+ timeout: flags.timeout,
70
+ });
71
+ spinner.stop();
72
+ this.log(formatter.formatAgentResult(result));
73
+ if (!result.success) {
74
+ this.exit(1);
75
+ }
76
+ }
77
+ }
78
+ catch (error) {
79
+ this.error(error);
80
+ }
81
+ }
82
+ }
83
+ exports.default = AgentsRun;
@@ -0,0 +1,6 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class AI extends Command {
3
+ static description: string;
4
+ static hidden: boolean;
5
+ run(): Promise<void>;
6
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ class AI extends core_1.Command {
5
+ static description = 'Execute AI agents and actions';
6
+ static hidden = false;
7
+ async run() {
8
+ // This command just displays help for the ai topic
9
+ await this.config.runCommand('help', ['ai']);
10
+ }
11
+ }
12
+ exports.default = AI;
@@ -0,0 +1,9 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class PromptsList extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const core_1 = require("@oclif/core");
7
+ const ai_cli_1 = require("@memberjunction/ai-cli");
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const ora_classic_1 = __importDefault(require("ora-classic"));
10
+ class PromptsList extends core_1.Command {
11
+ static description = 'List available models for prompt execution';
12
+ static examples = [
13
+ '<%= config.bin %> <%= command.id %>',
14
+ ];
15
+ static flags = {
16
+ verbose: core_1.Flags.boolean({
17
+ char: 'v',
18
+ description: 'Show detailed model information',
19
+ }),
20
+ };
21
+ async run() {
22
+ const { flags } = await this.parse(PromptsList);
23
+ const spinner = (0, ora_classic_1.default)();
24
+ try {
25
+ spinner.start('Loading available models...');
26
+ const service = new ai_cli_1.PromptService();
27
+ const models = await service.listAvailableModels();
28
+ spinner.stop();
29
+ this.log(chalk_1.default.bold(`\nAvailable AI Models (${models.length}):\n`));
30
+ for (const model of models) {
31
+ this.log(`${chalk_1.default.cyan(model.name)} ${chalk_1.default.gray(`(${model.vendor})`)}`);
32
+ if (flags.verbose && model.description) {
33
+ this.log(` ${chalk_1.default.dim(model.description)}`);
34
+ }
35
+ }
36
+ this.log(chalk_1.default.gray('\nUse any of these models with the --model flag when running prompts'));
37
+ // Force exit after completion
38
+ process.exit(0);
39
+ }
40
+ catch (error) {
41
+ spinner.fail('Failed to load models');
42
+ this.error(error);
43
+ }
44
+ }
45
+ }
46
+ exports.default = PromptsList;
@@ -0,0 +1,17 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class PromptsRun extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ prompt: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
7
+ model: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ system: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
9
+ temperature: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
10
+ 'max-tokens': import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
11
+ configuration: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
12
+ output: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
13
+ verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
14
+ timeout: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
15
+ };
16
+ run(): Promise<void>;
17
+ }
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const core_1 = require("@oclif/core");
7
+ const ai_cli_1 = require("@memberjunction/ai-cli");
8
+ const ora_classic_1 = __importDefault(require("ora-classic"));
9
+ class PromptsRun extends core_1.Command {
10
+ static description = 'Execute a direct prompt with an AI model';
11
+ static examples = [
12
+ '<%= config.bin %> <%= command.id %> -p "Explain quantum computing in simple terms"',
13
+ '<%= config.bin %> <%= command.id %> -p "Write a Python function to sort a list" --model "gpt-4"',
14
+ '<%= config.bin %> <%= command.id %> -p "Translate to French: Hello world" --temperature 0.3',
15
+ '<%= config.bin %> <%= command.id %> -p "Generate a haiku" --system "You are a poet" --max-tokens 100',
16
+ ];
17
+ static flags = {
18
+ prompt: core_1.Flags.string({
19
+ char: 'p',
20
+ description: 'The prompt to execute',
21
+ required: true,
22
+ }),
23
+ model: core_1.Flags.string({
24
+ char: 'm',
25
+ description: 'AI model to use (e.g., gpt-4, claude-3-opus)',
26
+ }),
27
+ system: core_1.Flags.string({
28
+ char: 's',
29
+ description: 'System prompt to set context',
30
+ }),
31
+ temperature: core_1.Flags.string({
32
+ char: 't',
33
+ description: 'Temperature for response creativity (0.0-2.0)',
34
+ }),
35
+ 'max-tokens': core_1.Flags.integer({
36
+ description: 'Maximum tokens for the response',
37
+ }),
38
+ configuration: core_1.Flags.string({
39
+ char: 'c',
40
+ description: 'AI Configuration ID to use',
41
+ }),
42
+ output: core_1.Flags.string({
43
+ char: 'o',
44
+ description: 'Output format',
45
+ options: ['compact', 'json', 'table'],
46
+ default: 'compact',
47
+ }),
48
+ verbose: core_1.Flags.boolean({
49
+ char: 'v',
50
+ description: 'Show detailed execution information',
51
+ }),
52
+ timeout: core_1.Flags.integer({
53
+ description: 'Execution timeout in milliseconds',
54
+ default: 300000, // 5 minutes
55
+ }),
56
+ };
57
+ async run() {
58
+ const { flags } = await this.parse(PromptsRun);
59
+ const service = new ai_cli_1.PromptService();
60
+ const formatter = new ai_cli_1.OutputFormatter(flags.output);
61
+ try {
62
+ const spinner = (0, ora_classic_1.default)();
63
+ // Show what model will be used
64
+ if (flags.model) {
65
+ spinner.start(`Executing prompt with model: ${flags.model}`);
66
+ }
67
+ else {
68
+ spinner.start('Executing prompt with default model');
69
+ }
70
+ // Parse temperature if provided
71
+ let temperature;
72
+ if (flags.temperature) {
73
+ temperature = parseFloat(flags.temperature);
74
+ if (isNaN(temperature) || temperature < 0 || temperature > 2) {
75
+ spinner.fail();
76
+ this.error('Temperature must be a number between 0.0 and 2.0');
77
+ }
78
+ }
79
+ const result = await service.executePrompt(flags.prompt, {
80
+ verbose: flags.verbose,
81
+ timeout: flags.timeout,
82
+ model: flags.model,
83
+ temperature,
84
+ maxTokens: flags['max-tokens'],
85
+ systemPrompt: flags.system,
86
+ configurationId: flags.configuration,
87
+ });
88
+ spinner.stop();
89
+ this.log(formatter.formatPromptResult(result));
90
+ if (!result.success) {
91
+ this.exit(1);
92
+ }
93
+ }
94
+ catch (error) {
95
+ this.error(error);
96
+ }
97
+ }
98
+ }
99
+ exports.default = PromptsRun;
@@ -1,7 +1,7 @@
1
1
  import { Hook } from '@oclif/core';
2
2
  /**
3
3
  * Init hook runs once when the CLI starts up.
4
- * Currently unused but required by oclif configuration.
4
+ * Load environment variables from .env file.
5
5
  */
6
6
  declare const hook: Hook<'init'>;
7
7
  export default hook;
@@ -1,10 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
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
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
+ const dotenv = __importStar(require("dotenv"));
27
+ const path = __importStar(require("path"));
3
28
  /**
4
29
  * Init hook runs once when the CLI starts up.
5
- * Currently unused but required by oclif configuration.
30
+ * Load environment variables from .env file.
6
31
  */
7
32
  const hook = async function () {
8
- // No initialization needed at this time
33
+ // Load environment variables from .env file in repo root
34
+ const envPath = path.resolve(process.cwd(), '.env');
35
+ dotenv.config({ path: envPath });
9
36
  };
10
37
  exports.default = hook;
@@ -1,5 +1,27 @@
1
1
  {
2
2
  "commands": {
3
+ "ai": {
4
+ "aliases": [],
5
+ "args": {},
6
+ "description": "Execute AI agents and actions",
7
+ "flags": {},
8
+ "hasDynamicHelp": false,
9
+ "hidden": false,
10
+ "hiddenAliases": [],
11
+ "id": "ai",
12
+ "pluginAlias": "@memberjunction/cli",
13
+ "pluginName": "@memberjunction/cli",
14
+ "pluginType": "core",
15
+ "strict": true,
16
+ "enableJsonFlag": false,
17
+ "isESM": false,
18
+ "relativePath": [
19
+ "dist",
20
+ "commands",
21
+ "ai",
22
+ "index.js"
23
+ ]
24
+ },
3
25
  "bump": {
4
26
  "aliases": [],
5
27
  "args": {},
@@ -638,7 +660,398 @@
638
660
  "sync",
639
661
  "watch.js"
640
662
  ]
663
+ },
664
+ "ai:actions:list": {
665
+ "aliases": [],
666
+ "args": {},
667
+ "description": "List available AI actions",
668
+ "examples": [
669
+ "<%= config.bin %> <%= command.id %>",
670
+ "<%= config.bin %> <%= command.id %> --output=table",
671
+ "<%= config.bin %> <%= command.id %> --output=json"
672
+ ],
673
+ "flags": {
674
+ "output": {
675
+ "char": "o",
676
+ "description": "Output format",
677
+ "name": "output",
678
+ "default": "compact",
679
+ "hasDynamicHelp": false,
680
+ "multiple": false,
681
+ "options": [
682
+ "compact",
683
+ "json",
684
+ "table"
685
+ ],
686
+ "type": "option"
687
+ }
688
+ },
689
+ "hasDynamicHelp": false,
690
+ "hiddenAliases": [],
691
+ "id": "ai:actions:list",
692
+ "pluginAlias": "@memberjunction/cli",
693
+ "pluginName": "@memberjunction/cli",
694
+ "pluginType": "core",
695
+ "strict": true,
696
+ "enableJsonFlag": false,
697
+ "isESM": false,
698
+ "relativePath": [
699
+ "dist",
700
+ "commands",
701
+ "ai",
702
+ "actions",
703
+ "list.js"
704
+ ]
705
+ },
706
+ "ai:actions:run": {
707
+ "aliases": [],
708
+ "args": {},
709
+ "description": "Execute an AI action with parameters",
710
+ "examples": [
711
+ "<%= config.bin %> <%= command.id %> -n \"Get Weather\" --param \"Location=Boston\"",
712
+ "<%= config.bin %> <%= command.id %> -n \"Get Stock Price\" --param \"Ticker=AAPL\"",
713
+ "<%= config.bin %> <%= command.id %> -n \"Send Single Message\" --param \"To=user@example.com\" --param \"Subject=Test\" --param \"Body=Hello\" --param \"MessageType=Email\" --param \"Provider=SendGrid\"",
714
+ "<%= config.bin %> <%= command.id %> -n \"Calculate Expression\" --param \"Expression=2+2*3\" --dry-run"
715
+ ],
716
+ "flags": {
717
+ "name": {
718
+ "char": "n",
719
+ "description": "Action name",
720
+ "name": "name",
721
+ "required": true,
722
+ "hasDynamicHelp": false,
723
+ "multiple": false,
724
+ "type": "option"
725
+ },
726
+ "param": {
727
+ "char": "p",
728
+ "description": "Action parameters in key=value format",
729
+ "name": "param",
730
+ "hasDynamicHelp": false,
731
+ "multiple": true,
732
+ "type": "option"
733
+ },
734
+ "dry-run": {
735
+ "description": "Validate without executing",
736
+ "name": "dry-run",
737
+ "allowNo": false,
738
+ "type": "boolean"
739
+ },
740
+ "output": {
741
+ "char": "o",
742
+ "description": "Output format",
743
+ "name": "output",
744
+ "default": "compact",
745
+ "hasDynamicHelp": false,
746
+ "multiple": false,
747
+ "options": [
748
+ "compact",
749
+ "json",
750
+ "table"
751
+ ],
752
+ "type": "option"
753
+ },
754
+ "verbose": {
755
+ "char": "v",
756
+ "description": "Show detailed execution information",
757
+ "name": "verbose",
758
+ "allowNo": false,
759
+ "type": "boolean"
760
+ },
761
+ "timeout": {
762
+ "description": "Execution timeout in milliseconds",
763
+ "name": "timeout",
764
+ "default": 300000,
765
+ "hasDynamicHelp": false,
766
+ "multiple": false,
767
+ "type": "option"
768
+ }
769
+ },
770
+ "hasDynamicHelp": false,
771
+ "hiddenAliases": [],
772
+ "id": "ai:actions:run",
773
+ "pluginAlias": "@memberjunction/cli",
774
+ "pluginName": "@memberjunction/cli",
775
+ "pluginType": "core",
776
+ "strict": true,
777
+ "enableJsonFlag": false,
778
+ "isESM": false,
779
+ "relativePath": [
780
+ "dist",
781
+ "commands",
782
+ "ai",
783
+ "actions",
784
+ "run.js"
785
+ ]
786
+ },
787
+ "ai:agents:list": {
788
+ "aliases": [],
789
+ "args": {},
790
+ "description": "List available AI agents",
791
+ "examples": [
792
+ "<%= config.bin %> <%= command.id %>",
793
+ "<%= config.bin %> <%= command.id %> --output=table",
794
+ "<%= config.bin %> <%= command.id %> --output=json"
795
+ ],
796
+ "flags": {
797
+ "output": {
798
+ "char": "o",
799
+ "description": "Output format",
800
+ "name": "output",
801
+ "default": "compact",
802
+ "hasDynamicHelp": false,
803
+ "multiple": false,
804
+ "options": [
805
+ "compact",
806
+ "json",
807
+ "table"
808
+ ],
809
+ "type": "option"
810
+ }
811
+ },
812
+ "hasDynamicHelp": false,
813
+ "hiddenAliases": [],
814
+ "id": "ai:agents:list",
815
+ "pluginAlias": "@memberjunction/cli",
816
+ "pluginName": "@memberjunction/cli",
817
+ "pluginType": "core",
818
+ "strict": true,
819
+ "enableJsonFlag": false,
820
+ "isESM": false,
821
+ "relativePath": [
822
+ "dist",
823
+ "commands",
824
+ "ai",
825
+ "agents",
826
+ "list.js"
827
+ ]
828
+ },
829
+ "ai:agents:run": {
830
+ "aliases": [],
831
+ "args": {},
832
+ "description": "Execute an AI agent with a prompt or start interactive chat",
833
+ "examples": [
834
+ "<%= config.bin %> <%= command.id %> -a \"Skip: Requirements Expert\" -p \"Create a dashboard for sales metrics\"",
835
+ "<%= config.bin %> <%= command.id %> -a \"Child Component Generator Sub-agent\" --chat",
836
+ "<%= config.bin %> <%= command.id %> -a \"Skip: Technical Design Expert\" -p \"Build a React component\" --verbose --timeout=600000"
837
+ ],
838
+ "flags": {
839
+ "agent": {
840
+ "char": "a",
841
+ "description": "Agent name",
842
+ "name": "agent",
843
+ "required": true,
844
+ "hasDynamicHelp": false,
845
+ "multiple": false,
846
+ "type": "option"
847
+ },
848
+ "prompt": {
849
+ "char": "p",
850
+ "description": "Prompt to execute",
851
+ "exclusive": [
852
+ "chat"
853
+ ],
854
+ "name": "prompt",
855
+ "hasDynamicHelp": false,
856
+ "multiple": false,
857
+ "type": "option"
858
+ },
859
+ "chat": {
860
+ "char": "c",
861
+ "description": "Start interactive chat mode",
862
+ "exclusive": [
863
+ "prompt"
864
+ ],
865
+ "name": "chat",
866
+ "allowNo": false,
867
+ "type": "boolean"
868
+ },
869
+ "output": {
870
+ "char": "o",
871
+ "description": "Output format",
872
+ "name": "output",
873
+ "default": "compact",
874
+ "hasDynamicHelp": false,
875
+ "multiple": false,
876
+ "options": [
877
+ "compact",
878
+ "json",
879
+ "table"
880
+ ],
881
+ "type": "option"
882
+ },
883
+ "verbose": {
884
+ "char": "v",
885
+ "description": "Show detailed execution information",
886
+ "name": "verbose",
887
+ "allowNo": false,
888
+ "type": "boolean"
889
+ },
890
+ "timeout": {
891
+ "description": "Execution timeout in milliseconds",
892
+ "name": "timeout",
893
+ "default": 300000,
894
+ "hasDynamicHelp": false,
895
+ "multiple": false,
896
+ "type": "option"
897
+ }
898
+ },
899
+ "hasDynamicHelp": false,
900
+ "hiddenAliases": [],
901
+ "id": "ai:agents:run",
902
+ "pluginAlias": "@memberjunction/cli",
903
+ "pluginName": "@memberjunction/cli",
904
+ "pluginType": "core",
905
+ "strict": true,
906
+ "enableJsonFlag": false,
907
+ "isESM": false,
908
+ "relativePath": [
909
+ "dist",
910
+ "commands",
911
+ "ai",
912
+ "agents",
913
+ "run.js"
914
+ ]
915
+ },
916
+ "ai:prompts:list": {
917
+ "aliases": [],
918
+ "args": {},
919
+ "description": "List available models for prompt execution",
920
+ "examples": [
921
+ "<%= config.bin %> <%= command.id %>"
922
+ ],
923
+ "flags": {
924
+ "verbose": {
925
+ "char": "v",
926
+ "description": "Show detailed model information",
927
+ "name": "verbose",
928
+ "allowNo": false,
929
+ "type": "boolean"
930
+ }
931
+ },
932
+ "hasDynamicHelp": false,
933
+ "hiddenAliases": [],
934
+ "id": "ai:prompts:list",
935
+ "pluginAlias": "@memberjunction/cli",
936
+ "pluginName": "@memberjunction/cli",
937
+ "pluginType": "core",
938
+ "strict": true,
939
+ "enableJsonFlag": false,
940
+ "isESM": false,
941
+ "relativePath": [
942
+ "dist",
943
+ "commands",
944
+ "ai",
945
+ "prompts",
946
+ "list.js"
947
+ ]
948
+ },
949
+ "ai:prompts:run": {
950
+ "aliases": [],
951
+ "args": {},
952
+ "description": "Execute a direct prompt with an AI model",
953
+ "examples": [
954
+ "<%= config.bin %> <%= command.id %> -p \"Explain quantum computing in simple terms\"",
955
+ "<%= config.bin %> <%= command.id %> -p \"Write a Python function to sort a list\" --model \"gpt-4\"",
956
+ "<%= config.bin %> <%= command.id %> -p \"Translate to French: Hello world\" --temperature 0.3",
957
+ "<%= config.bin %> <%= command.id %> -p \"Generate a haiku\" --system \"You are a poet\" --max-tokens 100"
958
+ ],
959
+ "flags": {
960
+ "prompt": {
961
+ "char": "p",
962
+ "description": "The prompt to execute",
963
+ "name": "prompt",
964
+ "required": true,
965
+ "hasDynamicHelp": false,
966
+ "multiple": false,
967
+ "type": "option"
968
+ },
969
+ "model": {
970
+ "char": "m",
971
+ "description": "AI model to use (e.g., gpt-4, claude-3-opus)",
972
+ "name": "model",
973
+ "hasDynamicHelp": false,
974
+ "multiple": false,
975
+ "type": "option"
976
+ },
977
+ "system": {
978
+ "char": "s",
979
+ "description": "System prompt to set context",
980
+ "name": "system",
981
+ "hasDynamicHelp": false,
982
+ "multiple": false,
983
+ "type": "option"
984
+ },
985
+ "temperature": {
986
+ "char": "t",
987
+ "description": "Temperature for response creativity (0.0-2.0)",
988
+ "name": "temperature",
989
+ "hasDynamicHelp": false,
990
+ "multiple": false,
991
+ "type": "option"
992
+ },
993
+ "max-tokens": {
994
+ "description": "Maximum tokens for the response",
995
+ "name": "max-tokens",
996
+ "hasDynamicHelp": false,
997
+ "multiple": false,
998
+ "type": "option"
999
+ },
1000
+ "configuration": {
1001
+ "char": "c",
1002
+ "description": "AI Configuration ID to use",
1003
+ "name": "configuration",
1004
+ "hasDynamicHelp": false,
1005
+ "multiple": false,
1006
+ "type": "option"
1007
+ },
1008
+ "output": {
1009
+ "char": "o",
1010
+ "description": "Output format",
1011
+ "name": "output",
1012
+ "default": "compact",
1013
+ "hasDynamicHelp": false,
1014
+ "multiple": false,
1015
+ "options": [
1016
+ "compact",
1017
+ "json",
1018
+ "table"
1019
+ ],
1020
+ "type": "option"
1021
+ },
1022
+ "verbose": {
1023
+ "char": "v",
1024
+ "description": "Show detailed execution information",
1025
+ "name": "verbose",
1026
+ "allowNo": false,
1027
+ "type": "boolean"
1028
+ },
1029
+ "timeout": {
1030
+ "description": "Execution timeout in milliseconds",
1031
+ "name": "timeout",
1032
+ "default": 300000,
1033
+ "hasDynamicHelp": false,
1034
+ "multiple": false,
1035
+ "type": "option"
1036
+ }
1037
+ },
1038
+ "hasDynamicHelp": false,
1039
+ "hiddenAliases": [],
1040
+ "id": "ai:prompts:run",
1041
+ "pluginAlias": "@memberjunction/cli",
1042
+ "pluginName": "@memberjunction/cli",
1043
+ "pluginType": "core",
1044
+ "strict": true,
1045
+ "enableJsonFlag": false,
1046
+ "isESM": false,
1047
+ "relativePath": [
1048
+ "dist",
1049
+ "commands",
1050
+ "ai",
1051
+ "prompts",
1052
+ "run.js"
1053
+ ]
641
1054
  }
642
1055
  },
643
- "version": "2.77.0"
1056
+ "version": "2.78.0"
644
1057
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/cli",
3
- "version": "2.77.0",
3
+ "version": "2.78.0",
4
4
  "description": "MemberJunction command line tools",
5
5
  "keywords": [
6
6
  "oclif"
@@ -51,9 +51,10 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "@inquirer/prompts": "^5.0.1",
54
- "@memberjunction/codegen-lib": "2.77.0",
55
- "@memberjunction/metadata-sync": "2.77.0",
56
- "@memberjunction/sqlserver-dataprovider": "2.77.0",
54
+ "@memberjunction/ai-cli": "2.78.0",
55
+ "@memberjunction/codegen-lib": "2.78.0",
56
+ "@memberjunction/metadata-sync": "2.78.0",
57
+ "@memberjunction/sqlserver-dataprovider": "2.78.0",
57
58
  "@oclif/core": "^3",
58
59
  "@oclif/plugin-help": "^6",
59
60
  "@oclif/plugin-version": "^2.0.17",