prompt-forge-studio-cli 1.0.0 → 1.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prompt-forge-studio-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Professional terminal-native prompt engineering studio",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -20,6 +20,7 @@
20
20
  "figlet": "^1.10.0",
21
21
  "gradient-string": "^3.0.0",
22
22
  "inquirer": "^8.2.7",
23
- "ora": "^5.4.1"
23
+ "ora": "^5.4.1",
24
+ "prompt-forge-studio-cli": "^1.0.0"
24
25
  }
25
26
  }
package/src/api.js CHANGED
@@ -3,36 +3,67 @@ const { getHealthStatus } = require('./health');
3
3
  const { requireAuth } = require('./auth');
4
4
  const chalk = require('chalk');
5
5
 
6
- // Simulated AI responses based on prompt input
6
+ // Real AI responses based on prompt input using Prompt Forge API
7
7
  async function generateResponse(prompt, model) {
8
- const spinner = ora(`Generating response with ${chalk.cyan(model)}...`).start();
8
+ const spinner = ora(`Generating response with ${chalk.cyan(model)} via Prompt Forge...`).start();
9
9
 
10
- // Simulate network latency
11
- const latency = Math.floor(Math.random() * 500) + 500;
12
- await new Promise(resolve => setTimeout(resolve, latency));
10
+ try {
11
+ const auth = await requireAuth();
12
+ const apiKey = auth.promptforge;
13
13
 
14
- // Simulated failure logic: pretend gemini is currently having issues occasionally
15
- if (model === 'gemini' && Math.random() > 0.5) {
16
- spinner.fail(`Failed to get response from ${chalk.cyan(model)}`);
17
- throw new Error('Provider connection timeout');
18
- }
14
+ if (!apiKey) {
15
+ throw new Error('Prompt Forge API Key is missing. Run `:key` to set it.');
16
+ }
19
17
 
20
- spinner.succeed(`Received response from ${chalk.cyan(model)} in ${latency}ms`);
18
+ // Send request to your local or deployed Prompt Forge instance
19
+ // Assuming user runs local for now, but usually they'd specify a host.
20
+ // We'll default to localhost:3000 but let config override it later.
21
+ const { getConfig } = require('./config');
22
+ const config = getConfig() || {};
23
+ const baseUrl = config.host || 'http://localhost:3000';
21
24
 
22
- let responseText;
23
- if (prompt.toLowerCase().includes('hello') || prompt.toLowerCase().includes('hi')) {
24
- responseText = `Hello! I am the ${model} model. How can I help you in Forge Studio today?`;
25
- } else {
26
- responseText = `This is a generated response from ${model} for your prompt: "${prompt}".\n\n- Point 1: Simulated insight\n- Point 2: Prompt engineering tip\n- Point 3: Evaluation matrix.`;
27
- }
25
+ const payload = { prompt };
26
+ if (model) {
27
+ payload.model = model;
28
+ }
29
+
30
+ const response = await fetch(`${baseUrl}/api/v1/cli`, {
31
+ method: 'POST',
32
+ headers: {
33
+ 'Content-Type': 'application/json',
34
+ 'x-api-key': apiKey
35
+ },
36
+ body: JSON.stringify(payload)
37
+ });
28
38
 
29
- return {
30
- text: responseText,
31
- metadata: {
32
- model,
33
- latency
39
+ if (!response.ok) {
40
+ const errData = await response.json().catch(() => ({}));
41
+ throw new Error(errData.error || errData.message || `API Error: ${response.status}`);
34
42
  }
35
- };
43
+
44
+ const data = await response.json();
45
+
46
+ if (!data.success) {
47
+ throw new Error(data.error || 'Failed to generate content');
48
+ }
49
+
50
+ spinner.succeed(`Received response from ${chalk.cyan(data.meta?.model || model)} using Prompt Forge API in ${data.meta?.latency_ms || '?'}ms`);
51
+
52
+ return {
53
+ text: data.data,
54
+ metadata: {
55
+ model: data.meta?.model || model,
56
+ latency: data.meta?.latency_ms,
57
+ tokensInput: data.meta?.tokens_input,
58
+ tokensOutput: data.meta?.tokens_output,
59
+ costMicroUsd: data.meta?.cost_micro_usd
60
+ }
61
+ };
62
+
63
+ } catch (error) {
64
+ spinner.fail(`Failed to get response`);
65
+ throw error;
66
+ }
36
67
  }
37
68
 
38
69
  async function executeWithFailover(prompt, primaryModel, autoFailover) {
package/src/auth.js CHANGED
@@ -25,38 +25,29 @@ function getAuth() {
25
25
  }
26
26
  }
27
27
 
28
- function setAuth(provider, key) {
28
+ function setAuth(key) {
29
29
  ensureForgeHomeDir();
30
30
  const currentAuth = getAuth();
31
- currentAuth[provider] = key;
31
+ currentAuth['promptforge'] = key;
32
32
  fs.writeFileSync(AUTH_FILE, JSON.stringify(currentAuth, null, 2), { mode: 0o600 });
33
33
  }
34
34
 
35
35
  async function requireAuth() {
36
36
  const auth = getAuth();
37
- if (Object.keys(auth).length === 0) {
38
- console.log(chalk.yellow('\nNo API keys found. Let\'s set up your primary provider.'));
39
-
40
- const { provider } = await inquirer.prompt([
41
- {
42
- type: 'list',
43
- name: 'provider',
44
- message: 'Select an AI provider to configure:',
45
- choices: ['openai', 'anthropic', 'gemini']
46
- }
47
- ]);
37
+ if (!auth.promptforge) {
38
+ console.log(chalk.yellow('\nNo Prompt Forge API key found. Let\'s get you authenticated.'));
48
39
 
49
40
  const { key } = await inquirer.prompt([
50
41
  {
51
42
  type: 'password',
52
43
  name: 'key',
53
- message: `Enter your ${provider.toUpperCase()} API Key:`,
44
+ message: `Enter your Prompt Forge API Key:`,
54
45
  mask: '*'
55
46
  }
56
47
  ]);
57
48
 
58
- setAuth(provider, key);
59
- console.log(chalk.green('\n✔ API key saved securely locally.'));
49
+ setAuth(key);
50
+ console.log(chalk.green('\n✔ Prompt Forge API key saved securely locally.'));
60
51
  return getAuth();
61
52
  }
62
53
  return auth;
package/src/studio.js CHANGED
@@ -81,20 +81,14 @@ async function handleCommand(input) {
81
81
  break;
82
82
 
83
83
  case ':key':
84
- const { provider } = await inquirer.prompt([{
85
- type: 'list',
86
- name: 'provider',
87
- message: 'Which provider to configure?',
88
- choices: AVAILABLE_MODELS.map(m => m === 'gpt-4o' ? 'openai' : (m === 'claude' ? 'anthropic' : 'gemini'))
89
- }]);
90
84
  const { key } = await inquirer.prompt([{
91
85
  type: 'password',
92
86
  name: 'key',
93
- message: `Enter new API key for ${provider}:`,
87
+ message: `Enter new Prompt Forge API Key:`,
94
88
  mask: '*'
95
89
  }]);
96
- setAuth(provider, key);
97
- showInfoBox(`Key updated for ${provider}`);
90
+ setAuth(key);
91
+ showInfoBox(`Prompt Forge API Key updated.`);
98
92
  break;
99
93
 
100
94
  default:
@@ -1,9 +0,0 @@
1
- # test-project
2
-
3
- A Prompt Forge Studio project.
4
-
5
- ## Directory Structure
6
- - `/prompts` - Your prompt templates
7
- - `/sessions` - Saved studio sessions
8
- - `/logs` - Execution logs
9
- - `/.forge` - Local project cache (git-ignored)
@@ -1,6 +0,0 @@
1
- {
2
- "project": "test-project",
3
- "version": "1.0.0",
4
- "defaultModel": "gpt-4o",
5
- "autoFailover": true
6
- }