intentiai 0.1.0 → 0.1.2

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.
@@ -4,13 +4,13 @@ const api = require('../lib/api');
4
4
  const config = require('../lib/config');
5
5
 
6
6
  function requireProject() {
7
- const projectKey = config.getCurrentProject();
8
- if (!projectKey) {
7
+ const currentProject = config.getCurrentProject();
8
+ if (!currentProject || !currentProject.id) {
9
9
  console.error(chalk.red('No project selected'));
10
- console.log(chalk.gray('Select a project with:'), chalk.cyan('gatellm project select'));
10
+ console.log(chalk.gray('Select a project with:'), chalk.cyan('intentiai project select'));
11
11
  process.exit(1);
12
12
  }
13
- return projectKey;
13
+ return currentProject;
14
14
  }
15
15
 
16
16
  module.exports = (program) => {
@@ -19,13 +19,14 @@ module.exports = (program) => {
19
19
  .command('deploy')
20
20
  .description('Deploy your chatbot (show integration info)')
21
21
  .action(async () => {
22
- const projectKey = requireProject();
22
+ const currentProject = requireProject();
23
23
 
24
24
  try {
25
25
  const spinner = ora('Fetching project details...').start();
26
26
 
27
- const project = await api.getProject(projectKey);
27
+ const project = await api.getProject(currentProject.id);
28
28
  const apiUrl = config.getApiUrl();
29
+ const projectKey = project.project_key;
29
30
 
30
31
  spinner.stop();
31
32
 
@@ -113,9 +114,9 @@ print(response.choices[0].message.content)
113
114
 
114
115
  console.log(chalk.cyan('\n=== Next Steps ===\n'));
115
116
  console.log(chalk.gray('1. Test your deployment:'));
116
- console.log(chalk.white(` gatellm test "Hello, how are you?"\n`));
117
+ console.log(chalk.white(` intentiai test "Hello, how are you?"\n`));
117
118
  console.log(chalk.gray('2. View project details:'));
118
- console.log(chalk.white(` gatellm project current\n`));
119
+ console.log(chalk.white(` intentiai project current\n`));
119
120
  console.log(chalk.gray('3. Monitor in production:'));
120
121
  console.log(chalk.white(` Check logs at: ${apiUrl}/logs (coming soon)\n`));
121
122
 
@@ -6,13 +6,13 @@ const api = require('../lib/api');
6
6
  const config = require('../lib/config');
7
7
 
8
8
  function requireProject() {
9
- const projectKey = config.getCurrentProject();
10
- if (!projectKey) {
9
+ const currentProject = config.getCurrentProject();
10
+ if (!currentProject || !currentProject.id) {
11
11
  console.error(chalk.red('No project selected'));
12
- console.log(chalk.gray('Select a project with:'), chalk.cyan('gatellm project select'));
12
+ console.log(chalk.gray('Select a project with:'), chalk.cyan('intentiai project select'));
13
13
  process.exit(1);
14
14
  }
15
- return projectKey;
15
+ return currentProject;
16
16
  }
17
17
 
18
18
  module.exports = (program) => {
@@ -26,6 +26,7 @@ module.exports = (program) => {
26
26
  .option('-e, --examples <examples...>', 'Example queries (comma-separated or multiple -e flags)')
27
27
  .action(async (name, options) => {
28
28
  requireProject();
29
+ let spinner;
29
30
 
30
31
  try {
31
32
  let { description, examples } = options;
@@ -46,7 +47,7 @@ module.exports = (program) => {
46
47
  // Parse examples
47
48
  const examplesList = examples || [];
48
49
 
49
- const spinner = ora('Creating intent...').start();
50
+ spinner = ora('Creating intent...').start();
50
51
 
51
52
  await api.createIntent(name, description, examplesList);
52
53
 
@@ -58,10 +59,10 @@ module.exports = (program) => {
58
59
  }
59
60
 
60
61
  console.log('\n' + chalk.yellow('Next steps:'));
61
- console.log(chalk.gray(' 1. Add routing rule:'), chalk.cyan(`gatellm route add --intent "${name}"`));
62
- console.log(chalk.gray(' 2. Set system prompt:'), chalk.cyan(`gatellm prompt set --intent "${name}"`));
62
+ console.log(chalk.gray(' 1. Add routing rule:'), chalk.cyan(`intentiai route add --intent "${name}"`));
63
+ console.log(chalk.gray(' 2. Set system prompt:'), chalk.cyan(`intentiai prompt set --intent "${name}"`));
63
64
  } catch (error) {
64
- spinner.fail(chalk.red('Failed to create intent'));
65
+ if (spinner) spinner.fail(chalk.red('Failed to create intent'));
65
66
  console.error(chalk.red('Error:'), error.message);
66
67
  process.exit(1);
67
68
  }
@@ -78,7 +79,7 @@ module.exports = (program) => {
78
79
  try {
79
80
  const spinner = ora('Fetching intents...').start();
80
81
 
81
- const intents = await api.listIntents();
82
+ const intents = await api.listCurrentProjectIntents();
82
83
 
83
84
  spinner.stop();
84
85
 
@@ -166,7 +167,7 @@ module.exports = (program) => {
166
167
  }
167
168
 
168
169
  const spinner = ora('Deleting intent...').start();
169
- await api.deleteIntent(name);
170
+ await api.deleteIntentByName(name);
170
171
  spinner.succeed(chalk.green('Intent deleted successfully'));
171
172
  } catch (error) {
172
173
  console.error(chalk.red('Failed to delete intent:'), error.message);
@@ -20,10 +20,11 @@ module.exports = (program) => {
20
20
  const response = await api.createProject(name, options.description || '');
21
21
 
22
22
  // Auto-select the new project
23
- config.setCurrentProject(response.project_key);
23
+ config.setCurrentProject(response.id, response.name);
24
24
 
25
25
  spinner.succeed(chalk.green('Project created successfully!'));
26
- console.log(chalk.gray('Name:'), name);
26
+ console.log(chalk.gray('Name:'), response.name);
27
+ console.log(chalk.gray('Project ID:'), chalk.cyan(response.id));
27
28
  console.log(chalk.gray('Project Key:'), chalk.cyan(response.project_key));
28
29
  console.log(chalk.gray('Status:'), chalk.green('Active (selected)'));
29
30
 
@@ -54,20 +55,20 @@ module.exports = (program) => {
54
55
 
55
56
  if (projects.length === 0) {
56
57
  console.log(chalk.yellow('No projects found'));
57
- console.log(chalk.gray('Create one with:'), chalk.cyan('gatellm project create <name>'));
58
+ console.log(chalk.gray('Create one with:'), chalk.cyan('intentiai project create <name>'));
58
59
  return;
59
60
  }
60
61
 
61
62
  const table = new Table({
62
- head: [chalk.cyan('Name'), chalk.cyan('Project Key'), chalk.cyan('Description'), chalk.cyan('Status')],
63
- colWidths: [25, 40, 35, 10]
63
+ head: [chalk.cyan('ID'), chalk.cyan('Name'), chalk.cyan('Description'), chalk.cyan('Status')],
64
+ colWidths: [8, 25, 40, 12]
64
65
  });
65
66
 
66
67
  projects.forEach(proj => {
67
- const isActive = proj.project_key === currentProject;
68
+ const isActive = currentProject && proj.id === currentProject.id;
68
69
  table.push([
70
+ proj.id,
69
71
  isActive ? chalk.green(`${proj.name} *`) : proj.name,
70
- proj.project_key,
71
72
  proj.description || chalk.gray('(no description)'),
72
73
  isActive ? chalk.green('Active') : chalk.gray('---')
73
74
  ]);
@@ -83,11 +84,11 @@ module.exports = (program) => {
83
84
 
84
85
  // Select project
85
86
  project
86
- .command('select [projectKey]')
87
+ .command('select [projectId]')
87
88
  .description('Select a project to work with')
88
- .action(async (projectKey) => {
89
+ .action(async (projectId) => {
89
90
  try {
90
- if (!projectKey) {
91
+ if (!projectId) {
91
92
  // Show interactive selection
92
93
  const projects = await api.listProjects();
93
94
 
@@ -99,25 +100,25 @@ module.exports = (program) => {
99
100
  const answers = await inquirer.prompt([
100
101
  {
101
102
  type: 'list',
102
- name: 'projectKey',
103
+ name: 'projectId',
103
104
  message: 'Select a project:',
104
105
  choices: projects.map(p => ({
105
- name: `${p.name} (${p.project_key})`,
106
- value: p.project_key
106
+ name: `${p.name} (ID: ${p.id})`,
107
+ value: p.id
107
108
  }))
108
109
  }
109
110
  ]);
110
111
 
111
- projectKey = answers.projectKey;
112
+ projectId = answers.projectId;
112
113
  }
113
114
 
114
115
  // Verify project exists
115
- const project = await api.getProject(projectKey);
116
+ const project = await api.getProject(projectId);
116
117
 
117
- config.setCurrentProject(projectKey);
118
+ config.setCurrentProject(project.id, project.name);
118
119
 
119
120
  console.log(chalk.green('Project selected:'), project.name);
120
- console.log(chalk.gray('Project Key:'), chalk.cyan(projectKey));
121
+ console.log(chalk.gray('Project ID:'), chalk.cyan(project.id));
121
122
  } catch (error) {
122
123
  console.error(chalk.red('Failed to select project:'), error.message);
123
124
  process.exit(1);
@@ -129,21 +130,22 @@ module.exports = (program) => {
129
130
  .command('current')
130
131
  .description('Show currently selected project')
131
132
  .action(async () => {
132
- const projectKey = config.getCurrentProject();
133
+ const currentProject = config.getCurrentProject();
133
134
 
134
- if (!projectKey) {
135
+ if (!currentProject || !currentProject.id) {
135
136
  console.log(chalk.yellow('No project selected'));
136
- console.log(chalk.gray('Select one with:'), chalk.cyan('gatellm project select'));
137
+ console.log(chalk.gray('Select one with:'), chalk.cyan('intentiai project select'));
137
138
  return;
138
139
  }
139
140
 
140
141
  try {
141
142
  const spinner = ora('Fetching project details...').start();
142
- const project = await api.getProject(projectKey);
143
+ const project = await api.getProject(currentProject.id);
143
144
  spinner.stop();
144
145
 
145
146
  console.log(chalk.green('Current Project:'));
146
147
  console.log(chalk.gray(' Name:'), project.name);
148
+ console.log(chalk.gray(' Project ID:'), chalk.cyan(project.id));
147
149
  console.log(chalk.gray(' Project Key:'), chalk.cyan(project.project_key));
148
150
  console.log(chalk.gray(' Description:'), project.description || chalk.gray('(no description)'));
149
151
  console.log(chalk.gray(' Created:'), new Date(project.created_at).toLocaleString());
@@ -155,17 +157,17 @@ module.exports = (program) => {
155
157
 
156
158
  // Delete project
157
159
  project
158
- .command('delete <projectKey>')
160
+ .command('delete <projectId>')
159
161
  .description('Delete a project')
160
162
  .option('-y, --yes', 'Skip confirmation')
161
- .action(async (projectKey, options) => {
163
+ .action(async (projectId, options) => {
162
164
  try {
163
165
  if (!options.yes) {
164
166
  const answers = await inquirer.prompt([
165
167
  {
166
168
  type: 'confirm',
167
169
  name: 'confirm',
168
- message: `Are you sure you want to delete project ${projectKey}?`,
170
+ message: `Are you sure you want to delete project ${projectId}?`,
169
171
  default: false
170
172
  }
171
173
  ]);
@@ -177,11 +179,12 @@ module.exports = (program) => {
177
179
  }
178
180
 
179
181
  const spinner = ora('Deleting project...').start();
180
- await api.deleteProject(projectKey);
182
+ await api.deleteProject(projectId);
181
183
 
182
184
  // Clear current project if it's the one being deleted
183
- if (config.getCurrentProject() === projectKey) {
184
- config.setCurrentProject(null);
185
+ const currentProject = config.getCurrentProject();
186
+ if (currentProject && currentProject.id == projectId) {
187
+ config.clearCurrentProject();
185
188
  }
186
189
 
187
190
  spinner.succeed(chalk.green('Project deleted successfully'));
@@ -8,13 +8,13 @@ const api = require('../lib/api');
8
8
  const config = require('../lib/config');
9
9
 
10
10
  function requireProject() {
11
- const projectKey = config.getCurrentProject();
12
- if (!projectKey) {
11
+ const currentProject = config.getCurrentProject();
12
+ if (!currentProject || !currentProject.id) {
13
13
  console.error(chalk.red('No project selected'));
14
- console.log(chalk.gray('Select a project with:'), chalk.cyan('gatellm project select'));
14
+ console.log(chalk.gray('Select a project with:'), chalk.cyan('intentiai project select'));
15
15
  process.exit(1);
16
16
  }
17
- return projectKey;
17
+ return currentProject;
18
18
  }
19
19
 
20
20
  module.exports = (program) => {
@@ -29,17 +29,17 @@ module.exports = (program) => {
29
29
  .option('-f, --file <file>', 'Load system message from file')
30
30
  .option('-m, --modifier <modifier>', 'High difficulty modifier')
31
31
  .action(async (options) => {
32
- requireProject();
32
+ const project = requireProject();
33
33
 
34
34
  try {
35
35
  let { intent, system, file, modifier } = options;
36
36
 
37
37
  // Get intents
38
- const intents = await api.listIntents();
38
+ const intents = await api.listCurrentProjectIntents();
39
39
 
40
40
  if (intents.length === 0) {
41
41
  console.error(chalk.red('No intents found'));
42
- console.log(chalk.gray('Create an intent first:'), chalk.cyan('gatellm intent add <name>'));
42
+ console.log(chalk.gray('Create an intent first:'), chalk.cyan('intentiai intent add <name>'));
43
43
  process.exit(1);
44
44
  }
45
45
 
@@ -81,7 +81,7 @@ module.exports = (program) => {
81
81
 
82
82
  const spinner = ora('Setting prompt...').start();
83
83
 
84
- await api.setPrompt(intent, system, modifier);
84
+ await api.setPromptByIntentName(intent, system, modifier);
85
85
 
86
86
  spinner.succeed(chalk.green('Prompt set successfully!'));
87
87
  console.log(chalk.gray('Intent:'), intent);
@@ -104,7 +104,7 @@ module.exports = (program) => {
104
104
 
105
105
  try {
106
106
  const spinner = ora('Fetching prompt...').start();
107
- const promptData = await api.getPrompt(intent);
107
+ const promptData = await api.getPromptByIntentName(intent);
108
108
  spinner.stop();
109
109
 
110
110
  console.log(chalk.green('System Prompt:'));
@@ -132,12 +132,12 @@ module.exports = (program) => {
132
132
 
133
133
  try {
134
134
  const spinner = ora('Fetching prompts...').start();
135
- const prompts = await api.listPrompts();
135
+ const prompts = await api.listAllPrompts();
136
136
  spinner.stop();
137
137
 
138
138
  if (prompts.length === 0) {
139
139
  console.log(chalk.yellow('No prompts configured'));
140
- console.log(chalk.gray('Set one with:'), chalk.cyan('gatellm prompt set'));
140
+ console.log(chalk.gray('Set one with:'), chalk.cyan('intentiai prompt set'));
141
141
  return;
142
142
  }
143
143
 
package/commands/route.js CHANGED
@@ -6,16 +6,16 @@ const api = require('../lib/api');
6
6
  const config = require('../lib/config');
7
7
 
8
8
  function requireProject() {
9
- const projectKey = config.getCurrentProject();
10
- if (!projectKey) {
9
+ const currentProject = config.getCurrentProject();
10
+ if (!currentProject || !currentProject.id) {
11
11
  console.error(chalk.red('No project selected'));
12
- console.log(chalk.gray('Select a project with:'), chalk.cyan('gatellm project select'));
12
+ console.log(chalk.gray('Select a project with:'), chalk.cyan('intentiai project select'));
13
13
  process.exit(1);
14
14
  }
15
- return projectKey;
15
+ return currentProject;
16
16
  }
17
17
 
18
- const DIFFICULTY_LEVELS = ['easy', 'medium', 'hard'];
18
+ const DIFFICULTY_LEVELS = ['easy', 'medium', 'hard']; // Maps to API: low, medium, high
19
19
  const PROVIDERS = {
20
20
  openai: ['gpt-4o', 'gpt-4o-mini', 'gpt-4-turbo', 'gpt-3.5-turbo'],
21
21
  groq: ['llama-3.1-8b-instant', 'llama-3.3-70b-versatile', 'mixtral-8x7b-32768'],
@@ -35,17 +35,17 @@ module.exports = (program) => {
35
35
  .option('-m, --model <model>', 'Model name')
36
36
  .option('-p, --provider <provider>', 'Provider (openai/groq/anthropic/gemini)')
37
37
  .action(async (options) => {
38
- requireProject();
38
+ const project = requireProject();
39
39
 
40
40
  try {
41
41
  let { intent, difficulty, model, provider } = options;
42
42
 
43
43
  // Interactive prompts for missing options
44
- const intents = await api.listIntents();
44
+ const intents = await api.listCurrentProjectIntents();
45
45
 
46
46
  if (intents.length === 0) {
47
47
  console.error(chalk.red('No intents found'));
48
- console.log(chalk.gray('Create an intent first:'), chalk.cyan('gatellm intent add <name>'));
48
+ console.log(chalk.gray('Create an intent first:'), chalk.cyan('intentiai intent add <name>'));
49
49
  process.exit(1);
50
50
  }
51
51
 
@@ -89,7 +89,7 @@ module.exports = (program) => {
89
89
 
90
90
  const spinner = ora('Creating routing rule...').start();
91
91
 
92
- await api.createRoute(intent, difficulty, model, provider);
92
+ await api.addRoute(project.id, intent, difficulty, provider, model);
93
93
 
94
94
  spinner.succeed(chalk.green('Routing rule created successfully!'));
95
95
  console.log(chalk.gray('Intent:'), intent);
@@ -107,18 +107,18 @@ module.exports = (program) => {
107
107
  .alias('ls')
108
108
  .description('List all routing rules')
109
109
  .action(async () => {
110
- requireProject();
110
+ const project = requireProject();
111
111
 
112
112
  try {
113
113
  const spinner = ora('Fetching routes...').start();
114
114
 
115
- const routes = await api.listRoutes();
115
+ const routes = await api.listRoutes(project.id);
116
116
 
117
117
  spinner.stop();
118
118
 
119
119
  if (routes.length === 0) {
120
120
  console.log(chalk.yellow('No routing rules found'));
121
- console.log(chalk.gray('Create one with:'), chalk.cyan('gatellm route add'));
121
+ console.log(chalk.gray('Create one with:'), chalk.cyan('intentiai route add'));
122
122
  return;
123
123
  }
124
124
 
package/commands/test.js CHANGED
@@ -4,13 +4,13 @@ const api = require('../lib/api');
4
4
  const config = require('../lib/config');
5
5
 
6
6
  function requireProject() {
7
- const projectKey = config.getCurrentProject();
8
- if (!projectKey) {
7
+ const currentProject = config.getCurrentProject();
8
+ if (!currentProject || !currentProject.id) {
9
9
  console.error(chalk.red('No project selected'));
10
- console.log(chalk.gray('Select a project with:'), chalk.cyan('gatellm project select'));
10
+ console.log(chalk.gray('Select a project with:'), chalk.cyan('intentiai project select'));
11
11
  process.exit(1);
12
12
  }
13
- return projectKey;
13
+ return currentProject;
14
14
  }
15
15
 
16
16
  module.exports = (program) => {
@@ -20,12 +20,14 @@ module.exports = (program) => {
20
20
  .description('Test a query against your chatbot')
21
21
  .option('-s, --stream', 'Stream the response')
22
22
  .action(async (query, options) => {
23
- requireProject();
23
+ const project = requireProject();
24
24
 
25
25
  try {
26
26
  const spinner = ora('Processing query...').start();
27
27
 
28
- const response = await api.testQuery(query, options.stream);
28
+ // Get project details to get the project key
29
+ const projectDetails = await api.getProject(project.id);
30
+ const response = await api.testQuery(projectDetails.project_key, query);
29
31
 
30
32
  spinner.stop();
31
33
 
package/commands/train.js CHANGED
@@ -5,13 +5,13 @@ const api = require('../lib/api');
5
5
  const config = require('../lib/config');
6
6
 
7
7
  function requireProject() {
8
- const projectKey = config.getCurrentProject();
9
- if (!projectKey) {
8
+ const currentProject = config.getCurrentProject();
9
+ if (!currentProject || !currentProject.id) {
10
10
  console.error(chalk.red('No project selected'));
11
- console.log(chalk.gray('Select a project with:'), chalk.cyan('gatellm project select'));
11
+ console.log(chalk.gray('Select a project with:'), chalk.cyan('intentiai project select'));
12
12
  process.exit(1);
13
13
  }
14
- return projectKey;
14
+ return currentProject;
15
15
  }
16
16
 
17
17
  async function sleep(ms) {
@@ -29,14 +29,14 @@ module.exports = (program) => {
29
29
  .option('-n, --samples <number>', 'Number of samples per intent', '100')
30
30
  .option('-w, --watch', 'Watch training progress')
31
31
  .action(async (options) => {
32
- requireProject();
32
+ const project = requireProject();
33
33
 
34
34
  try {
35
35
  const numSamples = parseInt(options.samples);
36
36
 
37
37
  const spinner = ora('Starting training...').start();
38
38
 
39
- const response = await api.startTraining(options.intents, numSamples);
39
+ const response = await api.startTraining(project.id, numSamples);
40
40
 
41
41
  spinner.succeed(chalk.green('Training started!'));
42
42
  console.log(chalk.gray('Task ID:'), chalk.cyan(response.task_id));
@@ -83,7 +83,7 @@ module.exports = (program) => {
83
83
  }
84
84
  } else {
85
85
  console.log(chalk.gray('\nCheck training status with:'));
86
- console.log(chalk.cyan(` gatellm train status ${response.task_id}`));
86
+ console.log(chalk.cyan(` intentiai train status ${response.task_id}`));
87
87
  }
88
88
  } catch (error) {
89
89
  console.error(chalk.red('Failed to start training:'), error.message);
package/lib/api.js CHANGED
@@ -23,15 +23,9 @@ function createClient() {
23
23
  }
24
24
 
25
25
  // Auth endpoints
26
- async function login(username, password) {
26
+ async function login(email, password) {
27
27
  const client = createClient();
28
- const formData = new URLSearchParams();
29
- formData.append('username', username);
30
- formData.append('password', password);
31
-
32
- const response = await client.post('/auth/login', formData, {
33
- headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
34
- });
28
+ const response = await client.post('/auth/login', { email, password });
35
29
  return response.data;
36
30
  }
37
31
 
@@ -55,7 +49,8 @@ async function createProject(name, description = '') {
55
49
  async function listProjects() {
56
50
  const client = createClient();
57
51
  const response = await client.get('/projects');
58
- return response.data;
52
+ // Backend returns {projects: [...]}
53
+ return response.data.projects || response.data;
59
54
  }
60
55
 
61
56
  async function getProject(projectId) {
@@ -84,6 +79,71 @@ async function addIntent(projectId, name, description, examples = []) {
84
79
  async function listIntents(projectId) {
85
80
  const client = createClient();
86
81
  const response = await client.get(`/projects/${projectId}/intents`);
82
+ // Backend returns {intents: [...]}
83
+ return response.data.intents || response.data;
84
+ }
85
+
86
+ // Alias for CLI compatibility - creates intent using current project from config
87
+ async function createIntent(name, description, examples = []) {
88
+ const config = require('./config');
89
+ const project = config.getCurrentProject();
90
+ if (!project || !project.id) {
91
+ throw new Error('No project selected');
92
+ }
93
+ return addIntent(project.id, name, description, examples);
94
+ }
95
+
96
+ // Get intent by name
97
+ async function getIntent(name) {
98
+ const config = require('./config');
99
+ const project = config.getCurrentProject();
100
+ if (!project || !project.id) {
101
+ throw new Error('No project selected');
102
+ }
103
+ const intents = await listIntents(project.id);
104
+ const intent = intents.find(i => i.name === name);
105
+ if (!intent) {
106
+ throw new Error(`Intent "${name}" not found`);
107
+ }
108
+ return intent;
109
+ }
110
+
111
+ // Delete intent by name (for CLI)
112
+ async function deleteIntentByName(name) {
113
+ const config = require('./config');
114
+ const project = config.getCurrentProject();
115
+ if (!project || !project.id) {
116
+ throw new Error('No project selected');
117
+ }
118
+ const intents = await listIntents(project.id);
119
+ const intent = intents.find(i => i.name === name);
120
+ if (!intent) {
121
+ throw new Error(`Intent "${name}" not found`);
122
+ }
123
+ return deleteIntent(project.id, intent.id);
124
+ }
125
+
126
+ // List intents for current project (for CLI)
127
+ async function listCurrentProjectIntents() {
128
+ const config = require('./config');
129
+ const project = config.getCurrentProject();
130
+ if (!project || !project.id) {
131
+ throw new Error('No project selected');
132
+ }
133
+ return listIntents(project.id);
134
+ }
135
+
136
+ // Batch create intents
137
+ async function batchCreateIntents(intents) {
138
+ const config = require('./config');
139
+ const project = config.getCurrentProject();
140
+ if (!project || !project.id) {
141
+ throw new Error('No project selected');
142
+ }
143
+ const client = createClient();
144
+ const response = await client.post(`/projects/${project.id}/intents/batch`, {
145
+ intents: intents.map(i => ({ name: i.name, description: i.description }))
146
+ });
87
147
  return response.data;
88
148
  }
89
149
 
@@ -96,11 +156,20 @@ async function deleteIntent(projectId, intentId) {
96
156
  // Routing endpoints
97
157
  async function addRoute(projectId, intentName, difficulty, provider, model) {
98
158
  const client = createClient();
159
+
160
+ // Map CLI difficulty (easy/medium/hard) to API difficulty (low/medium/high)
161
+ const difficultyMap = {
162
+ 'easy': 'low',
163
+ 'medium': 'medium',
164
+ 'hard': 'high'
165
+ };
166
+
99
167
  const response = await client.post(`/projects/${projectId}/routing-rules`, {
100
- intent_name: intentName,
101
- difficulty,
102
- provider,
103
- model
168
+ name: `${intentName}_${difficulty}_rule`,
169
+ intent_condition: intentName,
170
+ difficulty_condition: difficultyMap[difficulty] || difficulty,
171
+ target_model_provider: provider,
172
+ target_model_name: model
104
173
  });
105
174
  return response.data;
106
175
  }
@@ -108,7 +177,8 @@ async function addRoute(projectId, intentName, difficulty, provider, model) {
108
177
  async function listRoutes(projectId) {
109
178
  const client = createClient();
110
179
  const response = await client.get(`/projects/${projectId}/routing-rules`);
111
- return response.data;
180
+ // Backend returns {rules: [...]}
181
+ return response.data.rules || response.data;
112
182
  }
113
183
 
114
184
  async function deleteRoute(routeId) {
@@ -118,11 +188,14 @@ async function deleteRoute(routeId) {
118
188
  }
119
189
 
120
190
  // Prompt endpoints
121
- async function setPrompt(projectId, intentId, systemPrompt, difficulty = null) {
191
+ async function setPrompt(projectId, intentId, systemMessage, name = null) {
122
192
  const client = createClient();
123
193
  const response = await client.post(`/projects/${projectId}/intents/${intentId}/prompts`, {
124
- system_prompt: systemPrompt,
125
- difficulty
194
+ name: name || 'default',
195
+ system_message: systemMessage,
196
+ model_provider: 'gemini',
197
+ model_name: 'gemini-1.5-flash',
198
+ is_default: true
126
199
  });
127
200
  return response.data;
128
201
  }
@@ -133,6 +206,46 @@ async function getPrompts(projectId, intentId) {
133
206
  return response.data;
134
207
  }
135
208
 
209
+ // CLI-compatible prompt methods
210
+ async function setPromptByIntentName(intentName, systemMessage, modifier = null) {
211
+ const config = require('./config');
212
+ const project = config.getCurrentProject();
213
+ if (!project || !project.id) {
214
+ throw new Error('No project selected');
215
+ }
216
+ const intents = await listIntents(project.id);
217
+ const intent = intents.find(i => i.name === intentName);
218
+ if (!intent) {
219
+ throw new Error(`Intent "${intentName}" not found`);
220
+ }
221
+ return setPrompt(project.id, intent.id, systemMessage, modifier);
222
+ }
223
+
224
+ async function getPromptByIntentName(intentName) {
225
+ const config = require('./config');
226
+ const project = config.getCurrentProject();
227
+ if (!project || !project.id) {
228
+ throw new Error('No project selected');
229
+ }
230
+ const intents = await listIntents(project.id);
231
+ const intent = intents.find(i => i.name === intentName);
232
+ if (!intent) {
233
+ throw new Error(`Intent "${intentName}" not found`);
234
+ }
235
+ return getPrompts(project.id, intent.id);
236
+ }
237
+
238
+ async function listAllPrompts() {
239
+ const config = require('./config');
240
+ const project = config.getCurrentProject();
241
+ if (!project || !project.id) {
242
+ throw new Error('No project selected');
243
+ }
244
+ const client = createClient();
245
+ const response = await client.get(`/projects/${project.id}/prompts`);
246
+ return response.data.prompts || response.data;
247
+ }
248
+
136
249
  // Document endpoints
137
250
  async function uploadDocument(projectId, filePath) {
138
251
  const client = createClient();
@@ -158,9 +271,11 @@ async function deleteDocument(documentId) {
158
271
  }
159
272
 
160
273
  // Training endpoints
161
- async function startTraining(projectId) {
274
+ async function startTraining(projectId, numSamples = 100) {
162
275
  const client = createClient();
163
- const response = await client.post(`/projects/${projectId}/train`);
276
+ const response = await client.post(`/projects/${projectId}/train`, {
277
+ num_samples: numSamples
278
+ });
164
279
  return response.data;
165
280
  }
166
281
 
@@ -189,6 +304,13 @@ async function getProjectKey(projectId) {
189
304
  return response.data.project_key;
190
305
  }
191
306
 
307
+ // Health check
308
+ async function health() {
309
+ const client = createClient();
310
+ const response = await client.get('/health');
311
+ return response.data;
312
+ }
313
+
192
314
  // Device auth endpoints (for browser-based login)
193
315
  async function checkDeviceAuth(deviceCode) {
194
316
  const client = createClient();
@@ -214,13 +336,21 @@ module.exports = {
214
336
  getProject,
215
337
  deleteProject,
216
338
  addIntent,
339
+ createIntent,
217
340
  listIntents,
341
+ listCurrentProjectIntents,
342
+ getIntent,
218
343
  deleteIntent,
344
+ deleteIntentByName,
345
+ batchCreateIntents,
219
346
  addRoute,
220
347
  listRoutes,
221
348
  deleteRoute,
222
349
  setPrompt,
350
+ setPromptByIntentName,
223
351
  getPrompts,
352
+ getPromptByIntentName,
353
+ listAllPrompts,
224
354
  uploadDocument,
225
355
  listDocuments,
226
356
  deleteDocument,
@@ -228,6 +358,7 @@ module.exports = {
228
358
  getTrainingStatus,
229
359
  testQuery,
230
360
  getProjectKey,
361
+ health,
231
362
  checkDeviceAuth,
232
363
  completeDeviceAuth
233
364
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intentiai",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "IntentiAI CLI - Intent-aware LLM routing that saves 60-90% on API costs",
5
5
  "main": "index.js",
6
6
  "bin": {