@closedloop-ai/cli 0.2.0 → 0.2.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.
Files changed (79) hide show
  1. package/CONTRIBUTING.md +437 -0
  2. package/LICENSE +21 -0
  3. package/README.md +265 -0
  4. package/docs/CLI_COMMANDS.md +508 -0
  5. package/package.json +49 -26
  6. package/packages/cli/dist/api/team.js +45 -0
  7. package/packages/cli/dist/api/team.js.map +1 -0
  8. package/{dist → packages/cli/dist}/cli.js +7 -0
  9. package/packages/cli/dist/cli.js.map +1 -0
  10. package/packages/cli/dist/commands/team.js +44 -0
  11. package/packages/cli/dist/commands/team.js.map +1 -0
  12. package/dist/cli.js.map +0 -1
  13. package/jest.config.js +0 -14
  14. package/src/__tests__/cli.test.ts +0 -44
  15. package/src/__tests__/config.test.ts +0 -38
  16. package/src/__tests__/errors.test.ts +0 -132
  17. package/src/__tests__/setup.ts +0 -21
  18. package/src/__tests__/validation.test.ts +0 -156
  19. package/src/api/auth.ts +0 -21
  20. package/src/api/feedback.ts +0 -64
  21. package/src/api/input.ts +0 -55
  22. package/src/api/usage.ts +0 -45
  23. package/src/cli.ts +0 -158
  24. package/src/commands/config.ts +0 -192
  25. package/src/commands/feedback.ts +0 -250
  26. package/src/commands/input.ts +0 -389
  27. package/src/commands/list.ts +0 -84
  28. package/src/commands/status.ts +0 -96
  29. package/src/commands/submit.ts +0 -214
  30. package/src/config/constants.ts +0 -36
  31. package/src/config/index.ts +0 -59
  32. package/src/types/index.ts +0 -119
  33. package/src/utils/errors.ts +0 -98
  34. package/src/utils/validation.ts +0 -166
  35. package/tsconfig.json +0 -25
  36. /package/{dist → packages/cli/dist}/__tests__/cli.test.js +0 -0
  37. /package/{dist → packages/cli/dist}/__tests__/cli.test.js.map +0 -0
  38. /package/{dist → packages/cli/dist}/__tests__/config.test.js +0 -0
  39. /package/{dist → packages/cli/dist}/__tests__/config.test.js.map +0 -0
  40. /package/{dist → packages/cli/dist}/__tests__/errors.test.js +0 -0
  41. /package/{dist → packages/cli/dist}/__tests__/errors.test.js.map +0 -0
  42. /package/{dist → packages/cli/dist}/__tests__/setup.js +0 -0
  43. /package/{dist → packages/cli/dist}/__tests__/setup.js.map +0 -0
  44. /package/{dist → packages/cli/dist}/__tests__/validation.test.js +0 -0
  45. /package/{dist → packages/cli/dist}/__tests__/validation.test.js.map +0 -0
  46. /package/{dist → packages/cli/dist}/api/auth.js +0 -0
  47. /package/{dist → packages/cli/dist}/api/auth.js.map +0 -0
  48. /package/{dist → packages/cli/dist}/api/feedback.js +0 -0
  49. /package/{dist → packages/cli/dist}/api/feedback.js.map +0 -0
  50. /package/{dist → packages/cli/dist}/api/input.js +0 -0
  51. /package/{dist → packages/cli/dist}/api/input.js.map +0 -0
  52. /package/{dist → packages/cli/dist}/api/usage.js +0 -0
  53. /package/{dist → packages/cli/dist}/api/usage.js.map +0 -0
  54. /package/{dist → packages/cli/dist}/commands/config.js +0 -0
  55. /package/{dist → packages/cli/dist}/commands/config.js.map +0 -0
  56. /package/{dist → packages/cli/dist}/commands/feedback.js +0 -0
  57. /package/{dist → packages/cli/dist}/commands/feedback.js.map +0 -0
  58. /package/{dist → packages/cli/dist}/commands/input.js +0 -0
  59. /package/{dist → packages/cli/dist}/commands/input.js.map +0 -0
  60. /package/{dist → packages/cli/dist}/commands/list.js +0 -0
  61. /package/{dist → packages/cli/dist}/commands/list.js.map +0 -0
  62. /package/{dist → packages/cli/dist}/commands/status.js +0 -0
  63. /package/{dist → packages/cli/dist}/commands/status.js.map +0 -0
  64. /package/{dist → packages/cli/dist}/commands/submit.js +0 -0
  65. /package/{dist → packages/cli/dist}/commands/submit.js.map +0 -0
  66. /package/{dist → packages/cli/dist}/commands/usage.js +0 -0
  67. /package/{dist → packages/cli/dist}/commands/usage.js.map +0 -0
  68. /package/{dist → packages/cli/dist}/config/constants.js +0 -0
  69. /package/{dist → packages/cli/dist}/config/constants.js.map +0 -0
  70. /package/{dist → packages/cli/dist}/config/index.js +0 -0
  71. /package/{dist → packages/cli/dist}/config/index.js.map +0 -0
  72. /package/{dist → packages/cli/dist}/types/index.js +0 -0
  73. /package/{dist → packages/cli/dist}/types/index.js.map +0 -0
  74. /package/{dist → packages/cli/dist}/utils/config.js +0 -0
  75. /package/{dist → packages/cli/dist}/utils/config.js.map +0 -0
  76. /package/{dist → packages/cli/dist}/utils/errors.js +0 -0
  77. /package/{dist → packages/cli/dist}/utils/errors.js.map +0 -0
  78. /package/{dist → packages/cli/dist}/utils/validation.js +0 -0
  79. /package/{dist → packages/cli/dist}/utils/validation.js.map +0 -0
@@ -1,389 +0,0 @@
1
- import chalk from 'chalk';
2
- import ora from 'ora';
3
- import inquirer from 'inquirer';
4
- import { table } from 'table';
5
- import { submitFeedback } from '../api/feedback';
6
- import { listInputs as listInputsAPI, getInputDetail, getInputStatus } from '../api/input';
7
- import { CommandOptions, InputData, ListResponse } from '../types';
8
- import { CONFIG, MESSAGES } from '../config/constants';
9
- import { validateUuid, validateAndSanitizeInput, validatePagination } from '../utils/validation';
10
-
11
- // UUID regex pattern for detecting IDs
12
- const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
13
-
14
- // Main input command handler
15
- export async function handleInputCommand(content: string | undefined, options: CommandOptions) {
16
- // Check for common command mistakes
17
- if (content && ['list', 'show', 'status', 'help'].includes(content.toLowerCase())) {
18
- console.log(chalk.yellow('💡 Did you mean one of these commands?'));
19
- console.log(chalk.black(''));
20
- console.log(chalk.blue(' cl input') + chalk.black(' # List all inputs'));
21
- console.log(chalk.blue(' cl input <id>') + chalk.black(' # Show specific input details'));
22
- console.log(chalk.blue(' cl input "your content"') + chalk.black(' # Submit new input for analysis'));
23
- console.log(chalk.black(''));
24
- console.log(chalk.gray('Examples:'));
25
- console.log(chalk.gray(' cl input "Dashboard is confusing"'));
26
- console.log(chalk.gray(' cl input 74e3dd87-878f-41cf-8e5a-87527bbf7770'));
27
- return;
28
- }
29
-
30
- // If content looks like a UUID, treat it as an ID and show details
31
- if (content && validateUuid(content)) {
32
- return await showInput(content, options);
33
- }
34
-
35
- // If content provided and not a UUID, create new input
36
- if (content) {
37
- return await createInput(content, options);
38
- }
39
-
40
- // If no content provided, list inputs
41
- return await listInputs(options);
42
- }
43
-
44
- // Helper functions
45
- async function createInput(content: string, options: CommandOptions) {
46
- // Validate and sanitize input data
47
- const validatedData = validateAndSanitizeInput({
48
- content,
49
- title: options.title,
50
- source_url: options.url,
51
- customer_id: options.customer,
52
- reporter_name: options.name,
53
- reporter_email: options.email
54
- });
55
-
56
- let feedbackData: Partial<InputData> = validatedData;
57
-
58
- if (options.interactive || !content) {
59
- const answers = await inquirer.prompt([
60
- {
61
- type: 'input',
62
- name: 'content',
63
- message: 'What customer input would you like to analyze?',
64
- validate: (input) => input.length >= 10 || 'Input must be at least 10 characters',
65
- default: content
66
- },
67
- {
68
- type: 'input',
69
- name: 'title',
70
- message: 'Title for this input (optional):',
71
- default: options.title
72
- },
73
- {
74
- type: 'input',
75
- name: 'url',
76
- message: 'Source URL (optional):',
77
- default: options.url
78
- },
79
- {
80
- type: 'input',
81
- name: 'customer_id',
82
- message: 'Customer ID (optional):',
83
- default: options.customer
84
- },
85
- {
86
- type: 'input',
87
- name: 'reporter_name',
88
- message: 'Reporter name (optional):',
89
- default: options.name
90
- },
91
- {
92
- type: 'input',
93
- name: 'reporter_email',
94
- message: 'Reporter email (optional):',
95
- default: options.email
96
- }
97
- ]);
98
-
99
- feedbackData = {
100
- content: answers.content,
101
- ...(answers.title && { title: answers.title }),
102
- ...(answers.url && { source_url: answers.url }),
103
- ...(answers.customer_id && { customer_id: answers.customer_id }),
104
- ...(answers.reporter_name && { reporter_name: answers.reporter_name }),
105
- ...(answers.reporter_email && { reporter_email: answers.reporter_email })
106
- };
107
- } else {
108
- feedbackData = {
109
- content,
110
- ...(options.title && { title: options.title }),
111
- ...(options.url && { source_url: options.url }),
112
- ...(options.customer && { customer_id: options.customer }),
113
- ...(options.name && { reporter_name: options.name }),
114
- ...(options.email && { reporter_email: options.email })
115
- };
116
- }
117
-
118
- const spinner = ora('Analyzing your input...').start();
119
-
120
- const result = await submitFeedback(feedbackData);
121
- spinner.succeed('Submitted!');
122
-
123
- if (options.wait) {
124
- if (options.json) {
125
- // For JSON, we'll output the final result after waiting
126
- } else {
127
- console.log(chalk.blue(`Input ID: ${result.id}`));
128
- }
129
-
130
- const waitSpinner = ora('Processing...').start();
131
- let attempts = 0;
132
- const maxAttempts = CONFIG.MAX_RETRY_ATTEMPTS;
133
-
134
- while (attempts < maxAttempts) {
135
- await new Promise(resolve => setTimeout(resolve, CONFIG.POLL_INTERVAL_MS));
136
-
137
- try {
138
- const statusResult = await getInputStatus(result.id);
139
-
140
- if (statusResult.status === 'completed') {
141
- waitSpinner.succeed('Processing complete!');
142
-
143
- if (options.json) {
144
- console.log(JSON.stringify({ success: true, data: statusResult }, null, 2));
145
- } else {
146
- console.log(chalk.blue(`📊 Results: ${statusResult.feedback_count || 0} customer product feedback generated, ${statusResult.credits_consumed || 0} credits used`));
147
- if (statusResult.feedback_count > 0) {
148
- console.log(chalk.black('Run "cl feedback" to see generated feedback'));
149
- }
150
- }
151
- break;
152
- } else if (statusResult.status === 'failed') {
153
- waitSpinner.fail('Processing failed');
154
- if (options.json) {
155
- console.log(JSON.stringify({ success: false, error: 'Processing failed', data: statusResult }, null, 2));
156
- } else {
157
- console.log(chalk.red('\n❌ Processing failed. Check the status for more details.'));
158
- }
159
- break;
160
- } else {
161
- waitSpinner.text = `Processing... (${statusResult.status})`;
162
- }
163
- } catch (error) {
164
- waitSpinner.text = 'Processing... (checking status)';
165
- }
166
- attempts++;
167
- }
168
-
169
- if (attempts >= maxAttempts) {
170
- waitSpinner.warn('Processing is taking longer than expected');
171
- if (options.json) {
172
- console.log(JSON.stringify({ success: false, error: 'Processing timeout', data: { id: result.id, message: 'Processing is taking longer than expected' } }, null, 2));
173
- } else {
174
- console.log(chalk.yellow('\n⏳ Processing is still in progress. You can check status manually:'));
175
- console.log(chalk.black(` cl input status ${result.id}`));
176
- }
177
- }
178
- } else {
179
- spinner.succeed('Submitted!');
180
-
181
- if (options.json) {
182
- console.log(JSON.stringify({ success: true, data: result }, null, 2));
183
- } else {
184
- console.log(chalk.green('✅ Submitted!'));
185
- console.log(chalk.blue(`Input ID: ${result.id}`));
186
- console.log(chalk.black('Run "cl input status ' + result.id + '" to check progress'));
187
- console.log(chalk.black('Or use "cl input --wait" to wait for completion'));
188
- }
189
- }
190
- }
191
-
192
- async function listRecentInputs(options: any) {
193
- const result = await listInputsAPI(1, 5);
194
- const inputs = result.inputs || [];
195
-
196
- if (options.json) {
197
- console.log(JSON.stringify({ success: true, data: { inputs, pagination: result.pagination } }, null, 2));
198
- return;
199
- }
200
-
201
- if (inputs.length === 0) {
202
- console.log(chalk.yellow('No recent inputs found.'));
203
- console.log(chalk.black('Submit your first input: cl input "Your customer feedback here"'));
204
- return;
205
- }
206
-
207
- console.log(chalk.blue('\n📝 Recent Customer Inputs:'));
208
- console.log(chalk.black('─'.repeat(60)));
209
-
210
- inputs.forEach((input: any, index: number) => {
211
- const statusColor = input.status === 'completed' ? 'green' :
212
- input.status === 'processing' ? 'yellow' : 'red';
213
-
214
- console.log(chalk.blue(`${index + 1}.`), chalk.bold(input.title || 'Untitled'));
215
- console.log(chalk.black(` ID: ${input.id}`));
216
- console.log(chalk.black(` Status: ${chalk[statusColor](input.status || 'unknown')}`));
217
- console.log(chalk.black(` Content: ${input.content ? input.content.substring(0, 100) + (input.content.length > 100 ? '...' : '') : 'N/A'}`));
218
- console.log(chalk.black(` Submitted: ${input.created_at ? new Date(input.created_at).toLocaleString() : 'Unknown'}`));
219
- console.log();
220
- });
221
-
222
- console.log(chalk.black('Run "cl input list" to see all inputs'));
223
- }
224
-
225
- async function listInputs(options: CommandOptions) {
226
- const { page, limit } = validatePagination(options.page, options.limit);
227
- const status = options.status;
228
-
229
- const result = await listInputsAPI(page, limit);
230
- const inputs = result.inputs || [];
231
-
232
- if (options.json) {
233
- console.log(JSON.stringify({ success: true, data: { inputs, pagination: result.pagination } }, null, 2));
234
- return;
235
- }
236
-
237
- if (inputs.length === 0) {
238
- console.log(chalk.yellow('No inputs found.'));
239
- console.log(chalk.black('Submit your first input: cl input "Your customer feedback here"'));
240
- return;
241
- }
242
-
243
- // Create table
244
- const tableData = [
245
- [
246
- chalk.bold('ID'),
247
- chalk.bold('Title'),
248
- chalk.bold('Status'),
249
- chalk.bold('Feedback'),
250
- chalk.bold('Credits'),
251
- chalk.bold('Submitted')
252
- ]
253
- ];
254
-
255
- inputs.forEach((input: any) => {
256
- const statusColor = input.status === 'completed' ? 'green' :
257
- input.status === 'processing' ? 'yellow' : 'red';
258
-
259
- tableData.push([
260
- input.id,
261
- input.title || chalk.gray('null'),
262
- chalk[statusColor](input.status || 'unknown'),
263
- input.feedback_count || 0,
264
- input.credits_consumed || 0,
265
- input.created_at ? new Date(input.created_at).toLocaleString() : 'Unknown'
266
- ]);
267
- });
268
-
269
- console.log(chalk.blue('\n📝 Customer Inputs:'));
270
- console.log(table(tableData, {
271
- border: {
272
- topBody: '─',
273
- topJoin: '┬',
274
- topLeft: '┌',
275
- topRight: '┐',
276
- bottomBody: '─',
277
- bottomJoin: '┴',
278
- bottomLeft: '└',
279
- bottomRight: '┘',
280
- bodyLeft: '│',
281
- bodyRight: '│',
282
- bodyJoin: '│',
283
- joinBody: '─',
284
- joinLeft: '├',
285
- joinRight: '┤',
286
- joinJoin: '┼'
287
- }
288
- }));
289
-
290
- if (result.pagination) {
291
- console.log(chalk.black(`\nPage ${result.pagination.page} of ${result.pagination.pages} (${result.pagination.total} total inputs)`));
292
- if (result.pagination.page < result.pagination.pages) {
293
- console.log(chalk.gray(`💡 Use --page ${result.pagination.page + 1} to see next page`));
294
- }
295
- }
296
- }
297
-
298
- async function showInput(id: string, options: CommandOptions) {
299
- const result = await getInputDetail(id);
300
-
301
- if (options.json) {
302
- console.log(JSON.stringify({ success: true, data: result }, null, 2));
303
- return;
304
- }
305
-
306
- console.log(chalk.blue('\n📝 Input Details:'));
307
- console.log(chalk.black('─'.repeat(50)));
308
- console.log(chalk.blue('ID:'), result.id);
309
- console.log(chalk.blue('Title:'), result.title || chalk.gray('null'));
310
- console.log(chalk.blue('Status:'), result.status);
311
- console.log(chalk.blue('Content:'), result.content || 'No content');
312
- console.log(chalk.blue('Source URL:'), result.source_url || chalk.gray('null'));
313
- console.log(chalk.blue('Customer ID:'), result.customer_id || chalk.gray('null'));
314
- console.log(chalk.blue('Reporter:'), result.reporter_name || chalk.gray('null'));
315
- console.log(chalk.blue('Email:'), result.reporter_email || chalk.gray('null'));
316
- console.log(chalk.blue('AI Feedback Generated:'), result.feedback_count || 0);
317
- console.log(chalk.blue('Credits Used:'), result.credits_consumed || 0);
318
- console.log(chalk.blue('Submitted:'), result.created_at ? new Date(result.created_at).toLocaleString() : 'Unknown');
319
- console.log(chalk.blue('Updated:'), result.updated_at ? new Date(result.updated_at).toLocaleString() : 'Unknown');
320
- }
321
-
322
- async function checkInputStatus(id: string, options: CommandOptions) {
323
- const result = await getInputStatus(id);
324
-
325
- if (options.json) {
326
- console.log(JSON.stringify({ success: true, data: result }, null, 2));
327
- return;
328
- }
329
-
330
- console.log(chalk.blue('\n📊 Processing Status:'));
331
- console.log(chalk.black('─'.repeat(40)));
332
- console.log(chalk.blue('ID:'), result.id);
333
- console.log(chalk.blue('Status:'), result.status);
334
- console.log(chalk.blue('Created:'), result.created_at ? new Date(result.created_at).toLocaleString() : 'Unknown');
335
- console.log(chalk.blue('Updated:'), result.updated_at ? new Date(result.updated_at).toLocaleString() : 'Unknown');
336
- }
337
-
338
- function handleError(error: any, options: any) {
339
- if (options.json) {
340
- console.log(JSON.stringify({
341
- success: false,
342
- error: error.message,
343
- details: error.response?.data || 'Unknown error occurred'
344
- }, null, 2));
345
- } else {
346
- if (error.response?.status === 400) {
347
- const errorData = error.response.data;
348
- if (errorData?.code === 'VALIDATION_ERROR') {
349
- console.error(chalk.red('❌ Validation Error:'), errorData.error);
350
- console.log(chalk.black('\n💡 Common issues:'));
351
- console.log(chalk.black(' • Content must be at least 10 characters'));
352
- console.log(chalk.black(' • Check that all required fields are provided'));
353
- console.log(chalk.black(' • Ensure API key is valid: cl config'));
354
- } else if (errorData?.code === 'PROCESSING_ERROR') {
355
- console.error(chalk.red('❌ Processing Error:'), errorData.error);
356
- console.log(chalk.black('\n💡 This usually means:'));
357
- console.log(chalk.black(' • The content could not be processed by our AI'));
358
- console.log(chalk.black(' • Try rephrasing your input'));
359
- console.log(chalk.black(' • Make sure the content is clear and meaningful'));
360
- console.log(chalk.black(' • Check API key: cl config'));
361
- } else {
362
- console.error(chalk.red('❌ Bad Request:'), errorData?.error || 'Invalid input provided');
363
- console.log(chalk.black('\n💡 Try:'));
364
- console.log(chalk.black(' • Check your input content'));
365
- console.log(chalk.black(' • Verify API key: cl config'));
366
- console.log(chalk.black(' • Get help: cl input --help'));
367
- }
368
- } else if (error.response?.status === 401) {
369
- console.error(chalk.red('❌ Authentication Error:'), 'Invalid API key');
370
- console.log(chalk.black('\n💡 To fix:'));
371
- console.log(chalk.black(' 1. Get your free API key at: https://closedloop.sh'));
372
- console.log(chalk.black(' 2. Run: cl config set-api-key <your-key>'));
373
- } else if (error.response?.status === 429) {
374
- console.error(chalk.red('❌ Rate Limited:'), 'Too many requests');
375
- console.log(chalk.black('\n💡 Wait a moment and try again'));
376
- } else if (error.response?.status >= 500) {
377
- console.error(chalk.red('❌ Server Error:'), 'Our servers are having issues');
378
- console.log(chalk.black('\n💡 Try again in a few minutes'));
379
- } else if (error.code === 'ENOTFOUND' || error.code === 'ECONNREFUSED') {
380
- console.error(chalk.red('❌ Connection Error:'), 'Cannot connect to ClosedLoop AI servers');
381
- console.log(chalk.black('\n💡 Check your internet connection and try again'));
382
- } else {
383
- console.error(chalk.red('❌ Error:'), error.message);
384
- console.log(chalk.black('\n💡 Get help: cl --help'));
385
- }
386
- }
387
- process.exit(1);
388
- }
389
-
@@ -1,84 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { table } from 'table';
4
- import { listFeedbacks } from '../api/feedback';
5
- import { CommandOptions, FeedbackData, ListResponse } from '../types';
6
- import { CONFIG, MESSAGES } from '../config/constants';
7
-
8
- export const listCommand = new Command('list')
9
- .description('List customer inputs and generated AI feedback')
10
- .option('-p, --page <number>', 'Page number to show', '1')
11
- .option('-l, --limit <number>', 'How many items to show per page', '20')
12
- .option('-s, --status <status>', 'Show only items with this status (processing, completed, failed)')
13
- .option('--new', 'Show only inputs that are still being processed')
14
- .option('--json', 'Output in JSON format')
15
- .action(async (options: CommandOptions) => {
16
- try {
17
- const params: CommandOptions = {
18
- page: options.page || 1,
19
- limit: options.limit || CONFIG.DEFAULT_PAGE_SIZE
20
- };
21
-
22
- if (options.status) {
23
- params.status = options.status;
24
- }
25
-
26
- const result = options.new
27
- ? await listFeedbacks(params, true) // new feedbacks
28
- : await listFeedbacks(params, false); // processed feedbacks
29
-
30
- const feedbacks = result.feedbacks || result.data || [];
31
- if (feedbacks.length === 0) {
32
- if (options.json) {
33
- console.log(JSON.stringify({ success: true, data: [], pagination: result.pagination || {} }, null, 2));
34
- } else {
35
- console.log(chalk.yellow('No customer inputs found.'));
36
- }
37
- return;
38
- }
39
-
40
- if (options.json) {
41
- console.log(JSON.stringify({ success: true, data: feedbacks, pagination: result.pagination || {} }, null, 2));
42
- return;
43
- }
44
-
45
- // Create table data
46
- const tableData = [
47
- ['ID', 'Title', 'Status', 'AI Feedback', 'Credits Used', 'Submitted']
48
- ];
49
-
50
- feedbacks.forEach((item: any) => {
51
- const statusColor = item.status === 'completed' ? 'green' :
52
- item.status === 'processing' ? 'yellow' :
53
- item.status === 'pending_step2' ? 'yellow' :
54
- item.status === 'failed' ? 'red' :
55
- item.status === 'new' ? 'blue' :
56
- item.status === 'in_review' ? 'yellow' :
57
- item.status === 'addressed' ? 'green' :
58
- item.status === 'archived' ? 'gray' : 'red';
59
-
60
- tableData.push([
61
- item.id,
62
- item.title || 'Untitled',
63
- chalk[statusColor](item.status || 'unknown'),
64
- (item.feedbackCount || 0).toString(),
65
- (item.creditsConsumed || 0).toString(),
66
- item.timestamp ? new Date(item.timestamp).toLocaleString() : 'Unknown'
67
- ]);
68
- });
69
-
70
- console.log(chalk.blue('\n📋 Customer Inputs & AI Feedback:'));
71
- console.log(table(tableData));
72
-
73
- // Pagination info
74
- const pagination = result.pagination || {};
75
- if (pagination.pages > 1) {
76
- console.log(chalk.gray(`\nPage ${pagination.page} of ${pagination.pages} (${pagination.total} total items)`));
77
- console.log(chalk.gray('Use --page <number> to see more'));
78
- }
79
-
80
- } catch (error: any) {
81
- console.error(chalk.red('Error:'), error.message);
82
- process.exit(1);
83
- }
84
- });
@@ -1,96 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import ora from 'ora';
4
- import { getFeedbackStatus } from '../api/feedback';
5
- import { CommandOptions, FeedbackData } from '../types';
6
- import { CONFIG, MESSAGES } from '../config/constants';
7
-
8
- export const statusCommand = new Command('status')
9
- .description('Check processing status of a feedback submission')
10
- .argument('<id>', 'Feedback submission ID')
11
- .option('-w, --watch', 'Watch for status changes')
12
- .option('--json', 'Output in JSON format')
13
- .action(async (id, options: CommandOptions) => {
14
- try {
15
- if (options.watch) {
16
- // Watch mode - check status every few seconds
17
- const spinner = ora('Watching for status changes...').start();
18
-
19
- const checkStatus = async () => {
20
- try {
21
- const result = await getFeedbackStatus(id);
22
-
23
- if (result.status === 'completed') {
24
- spinner.succeed(chalk.green(`✅ Processing completed! Generated ${result.feedbackCount} insights`));
25
- process.exit(0);
26
- } else if (result.status === 'failed') {
27
- spinner.fail(chalk.red('❌ Processing failed'));
28
- process.exit(1);
29
- } else {
30
- spinner.text = `Processing... (${result.status})`;
31
- }
32
- } catch (error: any) {
33
- spinner.fail(chalk.red('Error checking status:') + ' ' + error.message);
34
- process.exit(1);
35
- }
36
- };
37
-
38
- // Check immediately
39
- await checkStatus();
40
-
41
- // Then check every few seconds
42
- const interval = setInterval(checkStatus, CONFIG.POLL_INTERVAL_MS);
43
-
44
- // Stop watching on Ctrl+C
45
- process.on('SIGINT', () => {
46
- clearInterval(interval);
47
- spinner.stop();
48
- console.log(chalk.yellow('\nStopped watching.'));
49
- process.exit(0);
50
- });
51
-
52
- } else {
53
- // Single check
54
- const spinner = ora('Checking status...').start();
55
-
56
- const result = await getFeedbackStatus(id);
57
-
58
- spinner.stop();
59
-
60
- if (options.json) {
61
- console.log(JSON.stringify({ success: true, data: result }, null, 2));
62
- return;
63
- }
64
-
65
- console.log(chalk.blue('\n📊 Status Information:'));
66
- console.log(chalk.gray('─'.repeat(40)));
67
- console.log(chalk.blue('ID:'), result.id);
68
- console.log(chalk.blue('Title:'), result.signal_title || result.title);
69
- console.log(chalk.blue('Status:'),
70
- result.status === 'completed' ? chalk.green(result.status) :
71
- result.status === 'processing' ? chalk.yellow(result.status) :
72
- result.status === 'pending_step2' ? chalk.yellow('pending') :
73
- result.status === 'failed' ? chalk.red(result.status) :
74
- result.status === 'new' ? chalk.blue(result.status) :
75
- result.status === 'in_review' ? chalk.yellow(result.status) :
76
- result.status === 'addressed' ? chalk.green(result.status) :
77
- result.status === 'archived' ? chalk.gray(result.status) :
78
- chalk.red(result.status)
79
- );
80
- console.log(chalk.blue('Created:'), result.created_at ? new Date(result.created_at).toLocaleString() : 'Unknown');
81
- console.log(chalk.blue('Updated:'), result.updated_at ? new Date(result.updated_at).toLocaleString() : 'Unknown');
82
- console.log(chalk.blue('Credits Used:'), result.creditsConsumed || 'Unknown');
83
- console.log(chalk.blue('AI Feedback Generated:'), result.feedbackCount || 0);
84
-
85
- if (result.status === 'completed' && (result.feedbackCount || 0) > 0) {
86
- console.log(chalk.green('\n🎯 Use "cl list" to see the generated AI feedback!'));
87
- } else if (result.status === 'processing') {
88
- console.log(chalk.yellow('\n⏳ Still processing... Use "cl status <id> --watch" to monitor'));
89
- }
90
- }
91
-
92
- } catch (error: any) {
93
- console.error(chalk.red('Error:'), error.message);
94
- process.exit(1);
95
- }
96
- });