@closedloop-ai/cli 0.2.2 → 0.2.4

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 (36) hide show
  1. package/README.md +61 -47
  2. package/docs/CLI_COMMANDS.md +78 -64
  3. package/package.json +9 -1
  4. package/packages/cli/dist/__tests__/api.test.js +151 -0
  5. package/packages/cli/dist/__tests__/api.test.js.map +1 -0
  6. package/packages/cli/dist/__tests__/errors.test.js +1 -1
  7. package/packages/cli/dist/__tests__/errors.test.js.map +1 -1
  8. package/packages/cli/dist/__tests__/performance.test.js +221 -0
  9. package/packages/cli/dist/__tests__/performance.test.js.map +1 -0
  10. package/packages/cli/dist/__tests__/setup.js +37 -7
  11. package/packages/cli/dist/__tests__/setup.js.map +1 -1
  12. package/packages/cli/dist/__tests__/team-simple.test.js +38 -0
  13. package/packages/cli/dist/__tests__/team-simple.test.js.map +1 -0
  14. package/packages/cli/dist/__tests__/test-factories.js +148 -0
  15. package/packages/cli/dist/__tests__/test-factories.js.map +1 -0
  16. package/packages/cli/dist/__tests__/validation.test.js +1 -1
  17. package/packages/cli/dist/api/feedback.js +2 -2
  18. package/packages/cli/dist/api/feedback.js.map +1 -1
  19. package/packages/cli/dist/api/ingest.js +60 -0
  20. package/packages/cli/dist/api/ingest.js.map +1 -0
  21. package/packages/cli/dist/api/team.js +14 -0
  22. package/packages/cli/dist/api/team.js.map +1 -1
  23. package/packages/cli/dist/cli.js +64 -26
  24. package/packages/cli/dist/cli.js.map +1 -1
  25. package/packages/cli/dist/commands/config.js +1 -1
  26. package/packages/cli/dist/commands/config.js.map +1 -1
  27. package/packages/cli/dist/commands/feedback.js +23 -23
  28. package/packages/cli/dist/commands/feedback.js.map +1 -1
  29. package/packages/cli/dist/commands/ingest.js +391 -0
  30. package/packages/cli/dist/commands/ingest.js.map +1 -0
  31. package/packages/cli/dist/commands/insight.js +234 -0
  32. package/packages/cli/dist/commands/insight.js.map +1 -0
  33. package/packages/cli/dist/commands/team.js +58 -20
  34. package/packages/cli/dist/commands/team.js.map +1 -1
  35. package/packages/cli/dist/config/constants.js +4 -3
  36. package/packages/cli/dist/config/constants.js.map +1 -1
package/README.md CHANGED
@@ -48,20 +48,30 @@ npm install -g @closedloop-ai/cli
48
48
  cl config set --api-key your-api-key-here
49
49
  ```
50
50
 
51
- ### Submit Your First Customer Feedback
51
+ ### Set Your Product Website (Important!)
52
+
53
+ Configure your product's website URL to help ClosedLoop understand your product context:
52
54
 
53
55
  ```bash
54
- # Submit raw customer feedback for AI analysis
55
- cl input "The new dashboard is confusing and hard to navigate. I can't find the settings menu and the layout is cluttered."
56
+ cl team website "https://yourproduct.com/feature"
57
+ ```
58
+
59
+ **Why this matters:** ClosedLoop AI uses your product URL to learn about your product features, competitors, pricing, and positioning. This enables more accurate feedback attribution and product-specific insights. For example, if you're working on iPhone, use `https://apple.com/iphone` - this helps ClosedLoop AI understand that "camera quality" feedback is about iPhone cameras, not just any camera.
60
+
61
+ ### Ingest Your First Customer Feedback
62
+
63
+ ```bash
64
+ # Ingest raw customer feedback for AI analysis
65
+ cl ingest "The new dashboard is confusing and hard to navigate. I can't find the settings menu and the layout is cluttered."
56
66
 
57
67
  # Wait for AI to analyze and generate structured insights
58
- cl input "Customer complaint about performance issues" --wait
68
+ cl ingest "Customer complaint about performance issues" --wait
59
69
 
60
70
  # View all AI-generated customer product feedback
61
- cl feedback
71
+ cl insight
62
72
 
63
73
  # Get detailed analysis of a specific insight
64
- cl feedback 2ea8f556-052b-4f5c-bf86-833780b3d00d
74
+ cl insight 2ea8f556-052b-4f5c-bf86-833780b3d00d
65
75
  ```
66
76
 
67
77
  ## 🎯 Perfect For
@@ -86,14 +96,14 @@ cl feedback 2ea8f556-052b-4f5c-bf86-833780b3d00d
86
96
 
87
97
  ## 📖 CLI Commands
88
98
 
89
- ### Submit Customer Feedback
99
+ ### Ingest Customer Feedback
90
100
 
91
101
  ```bash
92
- # Basic submission
93
- cl input "The app crashes when I try to upload large files"
102
+ # Basic ingestion
103
+ cl ingest "The app crashes when I try to upload large files"
94
104
 
95
105
  # With metadata for better analysis
96
- cl input "Great product, love the new features!" \
106
+ cl ingest "Great product, love the new features!" \
97
107
  --title "Positive Feedback" \
98
108
  --customer "customer-456" \
99
109
  --name "Jane Smith" \
@@ -101,33 +111,33 @@ cl input "Great product, love the new features!" \
101
111
  --url "https://support.example.com/ticket/789"
102
112
 
103
113
  # Wait for AI analysis to complete
104
- cl input "Customer complaint about performance" --wait
114
+ cl ingest "Customer complaint about performance" --wait
105
115
  ```
106
116
 
107
117
  ### View AI-Generated Customer Product Feedback
108
118
 
109
119
  ```bash
110
120
  # List all structured insights
111
- cl feedback
121
+ cl insight
112
122
 
113
123
  # View specific insight details
114
- cl feedback <insight-id>
124
+ cl insight <insight-id>
115
125
 
116
126
  # Get JSON output for scripting
117
- cl feedback --json | jq '.data[0].title'
127
+ cl insight --json | jq '.data[0].title'
118
128
  ```
119
129
 
120
130
  ### Manage Your Data
121
131
 
122
132
  ```bash
123
- # List all customer feedback submitted
124
- cl input
133
+ # List all customer feedback ingested
134
+ cl ingest
125
135
 
126
136
  # View specific feedback details
127
- cl input <feedback-id>
137
+ cl ingest <feedback-id>
128
138
 
129
139
  # Check processing status
130
- cl input <feedback-id> --status
140
+ cl ingest <feedback-id> --status
131
141
  ```
132
142
 
133
143
  ## 🔧 Configuration
@@ -140,48 +150,52 @@ The CLI stores configuration in `~/.closedloop/config.json`:
140
150
  }
141
151
  ```
142
152
 
143
- ### Environment Variables
153
+ ### Environment Variables (Advanced)
154
+
155
+ **For developers and CI/CD systems**, you can also set your API key as an environment variable instead of using the config file:
144
156
 
145
157
  ```bash
158
+ # Set the API key as an environment variable
146
159
  export CLOSEDLOOP_API_KEY="your-api-key-here"
160
+
161
+ # Now you can use the CLI without running 'cl config set'
162
+ cl input "Customer feedback here"
147
163
  ```
148
164
 
149
- ## 💡 Real-World Examples
165
+ **When to use this:**
166
+ - **CI/CD pipelines**: Set the API key in your deployment environment
167
+ - **Docker containers**: Pass the API key as an environment variable
168
+ - **Server scripts**: When running automated scripts on servers
169
+ - **Multiple users**: When different users need different API keys on the same machine
150
170
 
151
- ### Customer Success Team
152
- ```bash
153
- # Process support ticket feedback
154
- cl input "Customer can't find the export feature in the new UI" \
155
- --title "Export Feature Missing" \
156
- --customer "enterprise-123" \
157
- --source "zendesk-ticket-456"
158
-
159
- # Get AI insights on customer satisfaction trends
160
- cl feedback --severity high
161
- ```
171
+ **Note:** The CLI will automatically use the environment variable if it's set, otherwise it falls back to the config file.
162
172
 
163
- ### Product Manager
164
- ```bash
165
- # Submit user research findings
166
- cl input "Users want better mobile experience - 80% of complaints are mobile-related" \
167
- --title "Mobile UX Research" \
168
- --customer "research-participant-789"
173
+ ## 💡 Simple Workflow
169
174
 
170
- # Analyze feature request patterns
171
- cl feedback --category "feature-request"
172
- ```
175
+ Here's how to get started with ClosedLoop AI CLI:
173
176
 
174
- ### Business Analyst
175
177
  ```bash
176
- # Process survey responses
177
- cl input "NPS score dropped 15 points this quarter due to performance issues" \
178
- --title "Q3 NPS Analysis" \
179
- --customer "survey-respondent-101"
178
+ # 1. Set your API key
179
+ cl config set --api-key your-api-key-here
180
+
181
+ # 2. Set your product website (helps AI understand your product)
182
+ cl team website "https://yourproduct.com/feature"
180
183
 
181
- # Get strategic insights for leadership
182
- cl feedback --priority high
184
+ # 3. Ingest customer feedback
185
+ cl ingest "The new dashboard is confusing and hard to navigate"
186
+
187
+ # 4. Check what feedback you've ingested
188
+ cl ingest
189
+
190
+ # 5. View AI analysis of your feedback
191
+ cl insight
192
+
193
+ # 6. Get details on specific feedback
194
+ cl insight <insight-id>
183
195
  ```
184
196
 
197
+ That's it! ClosedLoop AI will automatically analyze your feedback and provide actionable insights.
198
+
185
199
  ## 📚 Documentation
186
200
 
187
201
  - **[Complete CLI Commands Reference](docs/CLI_COMMANDS.md)** - All commands, parameters, and examples
@@ -9,6 +9,7 @@ Complete reference for all CLI commands, parameters, and user experience.
9
9
  - [How to Use API Keys](#how-to-use-api-keys)
10
10
  - [Input Commands](#input-commands)
11
11
  - [Feedback Commands](#feedback-commands)
12
+ - [Team Commands](#team-commands)
12
13
  - [General Commands](#general-commands)
13
14
  - [Error Handling](#error-handling)
14
15
  - [Examples](#examples)
@@ -69,18 +70,18 @@ export CLOSEDLOOP_API_KEY="your-api-key-here"
69
70
  cl config # Will use environment variable
70
71
  ```
71
72
 
72
- ## Input Commands
73
+ ## Ingest Commands
73
74
 
74
- ### Submit Customer Product Feedback
75
+ ### Ingest Customer Product Feedback
75
76
 
76
- #### Basic Submission
77
+ #### Basic Ingestion
77
78
  ```bash
78
- cl input "Your customer product feedback here"
79
+ cl ingest "Your customer product feedback here"
79
80
  ```
80
81
 
81
82
  #### With Metadata
82
83
  ```bash
83
- cl input "The dashboard is confusing and hard to navigate" \
84
+ cl ingest "The dashboard is confusing and hard to navigate" \
84
85
  --title "Dashboard UX Issues" \
85
86
  --customer "customer-123" \
86
87
  --name "John Doe" \
@@ -90,51 +91,51 @@ cl input "The dashboard is confusing and hard to navigate" \
90
91
 
91
92
  #### Wait for Processing
92
93
  ```bash
93
- cl input "Customer complaint about performance" --wait
94
+ cl ingest "Customer complaint about performance" --wait
94
95
  # Shows real-time processing status
95
96
  ```
96
97
 
97
98
  #### JSON Output
98
99
  ```bash
99
- cl input "Great product, love the new features!" --json
100
+ cl ingest "Great product, love the new features!" --json
100
101
  # Output: {"id":"74e3dd87-878f-41cf-8e5a-87527bbf7770","status":"submitted"}
101
102
  ```
102
103
 
103
- ### List Customer Inputs
104
+ ### List Ingested Feedback
104
105
 
105
106
  #### Basic List
106
107
  ```bash
107
- cl input
108
- # Shows table of recent inputs
108
+ cl ingest
109
+ # Shows table of recent ingests
109
110
  ```
110
111
 
111
112
  #### With Pagination
112
113
  ```bash
113
- cl input --page 2 --limit 10
114
+ cl ingest --page 2 --limit 10
114
115
  # Shows page 2 with 10 items per page
115
116
  ```
116
117
 
117
118
  #### JSON Output
118
119
  ```bash
119
- cl input --json
120
+ cl ingest --json
120
121
  # Output: {"data":[...],"pagination":{...}}
121
122
  ```
122
123
 
123
- ### View Specific Input
124
+ ### View Specific Ingest
124
125
 
125
126
  #### By ID
126
127
  ```bash
127
- cl input 74e3dd87-878f-41cf-8e5a-87527bbf7770
128
- # Shows detailed input information
128
+ cl ingest 74e3dd87-878f-41cf-8e5a-87527bbf7770
129
+ # Shows detailed ingest information
129
130
  ```
130
131
 
131
132
  #### JSON Output
132
133
  ```bash
133
- cl input 74e3dd87-878f-41cf-8e5a-87527bbf7770 --json
134
+ cl ingest 74e3dd87-878f-41cf-8e5a-87527bbf7770 --json
134
135
  # Output: {"id":"...","content":"...","status":"..."}
135
136
  ```
136
137
 
137
- ### Input Parameters
138
+ ### Ingest Parameters
138
139
 
139
140
  | Parameter | Type | Required | Description | Example |
140
141
  |-----------|------|----------|-------------|---------|
@@ -149,25 +150,25 @@ cl input 74e3dd87-878f-41cf-8e5a-87527bbf7770 --json
149
150
  | `--page` | number | No | Page number for listing | `--page 2` |
150
151
  | `--limit` | number | No | Items per page (max 100) | `--limit 20` |
151
152
 
152
- ## Feedback Commands
153
+ ## Insight Commands
153
154
 
154
155
  ### List AI-Generated Insights
155
156
 
156
157
  #### Basic List
157
158
  ```bash
158
- cl feedback
159
+ cl insight
159
160
  # Shows table of AI-generated insights
160
161
  ```
161
162
 
162
163
  #### With Pagination
163
164
  ```bash
164
- cl feedback --page 2 --limit 5
165
+ cl insight --page 2 --limit 5
165
166
  # Shows page 2 with 5 items per page
166
167
  ```
167
168
 
168
169
  #### JSON Output
169
170
  ```bash
170
- cl feedback --json
171
+ cl insight --json
171
172
  # Output: {"data":[...],"pagination":{...}}
172
173
  ```
173
174
 
@@ -175,17 +176,17 @@ cl feedback --json
175
176
 
176
177
  #### By ID
177
178
  ```bash
178
- cl feedback 2ea8f556-052b-4f5c-bf86-833780b3d00d
179
+ cl insight 2ea8f556-052b-4f5c-bf86-833780b3d00d
179
180
  # Shows detailed insight information
180
181
  ```
181
182
 
182
183
  #### JSON Output
183
184
  ```bash
184
- cl feedback 2ea8f556-052b-4f5c-bf86-833780b3d00d --json
185
+ cl insight 2ea8f556-052b-4f5c-bf86-833780b3d00d --json
185
186
  # Output: {"id":"...","title":"...","content":"..."}
186
187
  ```
187
188
 
188
- ### Feedback Parameters
189
+ ### Insight Parameters
189
190
 
190
191
  | Parameter | Type | Required | Description | Example |
191
192
  |-----------|------|----------|-------------|---------|
@@ -198,24 +199,36 @@ cl feedback 2ea8f556-052b-4f5c-bf86-833780b3d00d --json
198
199
 
199
200
  ## Team Commands
200
201
 
201
- ### Update Team Website
202
+ ### Team Website Management
202
203
 
203
- #### Basic Update
204
+ **Why set your product website?** ClosedLoop AI uses your product URL to learn about your product features, competitors, pricing, and positioning. This enables more accurate feedback attribution and product-specific insights. For example, if you're working on iPhone, use `https://apple.com/iphone` - this helps ClosedLoop AI understand that "camera quality" feedback is about iPhone cameras, not just any camera.
205
+
206
+ #### Show Current Website
204
207
  ```bash
205
- cl team website update "https://example.com"
206
- # Output: Team website updated successfully
207
- # Website: https://example.com
208
+ cl team website
209
+ # Output: Website: https://example.com
208
210
  # Updated: 2024-01-15T10:30:00Z
209
211
  ```
210
212
 
211
- #### With Validation
213
+ #### Set Team Website
212
214
  ```bash
213
- cl team website update "https://mycompany.com"
215
+ cl team website "https://example.com"
214
216
  # Output: Team website updated successfully
215
- # Website: https://mycompany.com
217
+ # Website: https://example.com
216
218
  # Updated: 2024-01-15T10:30:00Z
217
219
  ```
218
220
 
221
+ #### JSON Output
222
+ ```bash
223
+ # Show website in JSON format
224
+ cl team website --json
225
+ # Output: {"success": true, "data": {"website": "https://example.com", "updated_at": "2024-01-15T10:30:00Z"}}
226
+
227
+ # Set website in JSON format
228
+ cl team website "https://example.com" --json
229
+ # Output: {"success": true, "data": {"website": "https://example.com", "updated_at": "2024-01-15T10:30:00Z"}}
230
+ ```
231
+
219
232
  ### Team Management
220
233
  ```bash
221
234
  cl team
@@ -226,19 +239,20 @@ cl team
226
239
 
227
240
  | Parameter | Type | Required | Description | Example |
228
241
  |-----------|------|----------|-------------|---------|
229
- | `website` | string | Yes | Team website URL (must include http:// or https://) | `"https://example.com"` |
242
+ | `website` | string | No | Team website URL (must include http:// or https://) | `"https://example.com"` |
243
+ | `--json` | flag | No | Output in JSON format | `--json` |
230
244
 
231
245
  ### Team Error Handling
232
246
 
233
247
  #### Invalid Website URL
234
248
  ```bash
235
- cl team website update "invalid-url"
249
+ cl team website "invalid-url"
236
250
  # Error: Invalid website URL format. Must include protocol (http:// or https://) and domain
237
251
  ```
238
252
 
239
253
  #### Missing API Key
240
254
  ```bash
241
- cl team website update "https://example.com"
255
+ cl team website "https://example.com"
242
256
  # Error: API key not configured. Run: cl config set --api-key <key>
243
257
  ```
244
258
 
@@ -327,52 +341,52 @@ cl input "Test feedback"
327
341
  # 1. Configure API key
328
342
  cl config set --api-key your-api-key-here
329
343
 
330
- # 2. Submit customer product feedback
331
- cl input "The new dashboard is confusing and hard to navigate"
344
+ # 2. Ingest customer product feedback
345
+ cl ingest "The new dashboard is confusing and hard to navigate"
332
346
 
333
347
  # 3. Wait for AI analysis
334
- cl input "Customer complaint about performance" --wait
348
+ cl ingest "Customer complaint about performance" --wait
335
349
 
336
350
  # 4. View AI-generated insights
337
- cl feedback
351
+ cl insight
338
352
 
339
353
  # 5. Get detailed insight
340
- cl feedback 2ea8f556-052b-4f5c-bf86-833780b3d00d
354
+ cl insight 2ea8f556-052b-4f5c-bf86-833780b3d00d
341
355
  ```
342
356
 
343
357
  ### Advanced Workflow
344
358
  ```bash
345
- # 1. Submit with full metadata
346
- cl input "Great product, love the new features!" \
359
+ # 1. Ingest with full metadata
360
+ cl ingest "Great product, love the new features!" \
347
361
  --title "Positive Feedback" \
348
362
  --customer "enterprise-123" \
349
363
  --name "Jane Smith" \
350
364
  --email "jane@example.com" \
351
365
  --url "https://support.example.com/ticket/789"
352
366
 
353
- # 2. List all inputs with pagination
354
- cl input --page 1 --limit 20
367
+ # 2. List all ingests with pagination
368
+ cl ingest --page 1 --limit 20
355
369
 
356
370
  # 3. Get JSON output for scripting
357
- cl feedback --json | jq '.data[0].title'
371
+ cl insight --json | jq '.data[0].title'
358
372
 
359
- # 4. View specific input details
360
- cl input 74e3dd87-878f-41cf-8e5a-87527bbf7770 --json
373
+ # 4. View specific ingest details
374
+ cl ingest 74e3dd87-878f-41cf-8e5a-87527bbf7770 --json
361
375
  ```
362
376
 
363
377
  ### Scripting Examples
364
378
  ```bash
365
379
  #!/bin/bash
366
- # submit-feedback.sh
380
+ # ingest-feedback.sh
367
381
 
368
- # Submit feedback and get ID
369
- ID=$(cl input "$1" --json | jq -r '.id')
382
+ # Ingest feedback and get ID
383
+ ID=$(cl ingest "$1" --json | jq -r '.id')
370
384
 
371
385
  # Wait for processing
372
- cl input "$ID" --wait
386
+ cl ingest "$ID" --wait
373
387
 
374
388
  # Show results
375
- cl feedback
389
+ cl insight
376
390
  ```
377
391
 
378
392
  ```bash
@@ -380,7 +394,7 @@ cl feedback
380
394
  # get-insights.sh
381
395
 
382
396
  # Get all insights in JSON format
383
- cl feedback --json | jq '.data[] | {id: .id, title: .title, status: .status}'
397
+ cl insight --json | jq '.data[] | {id: .id, title: .title, status: .status}'
384
398
  ```
385
399
 
386
400
  ## Output Formats
@@ -421,35 +435,35 @@ cl feedback --json | jq '.data[] | {id: .id, title: .title, status: .status}'
421
435
  ### 1. Use Descriptive Titles
422
436
  ```bash
423
437
  # Good
424
- cl input "The app crashes when uploading files" --title "File Upload Crash"
438
+ cl ingest "The app crashes when uploading files" --title "File Upload Crash"
425
439
 
426
440
  # Bad
427
- cl input "App broken" --title "Issue"
441
+ cl ingest "App broken" --title "Issue"
428
442
  ```
429
443
 
430
444
  ### 2. Include Customer Context
431
445
  ```bash
432
446
  # Good
433
- cl input "Feature request" --customer "enterprise-123" --name "John Doe"
447
+ cl ingest "Feature request" --customer "enterprise-123" --name "John Doe"
434
448
 
435
449
  # Bad
436
- cl input "Feature request"
450
+ cl ingest "Feature request"
437
451
  ```
438
452
 
439
453
  ### 3. Use JSON for Scripting
440
454
  ```bash
441
455
  # Good
442
- cl feedback --json | jq '.data[0].title'
456
+ cl insight --json | jq '.data[0].title'
443
457
 
444
458
  # Bad
445
- cl feedback | grep "Title"
459
+ cl insight | grep "Title"
446
460
  ```
447
461
 
448
462
  ### 4. Handle Errors Gracefully
449
463
  ```bash
450
464
  #!/bin/bash
451
- if ! cl input "$1" --wait; then
452
- echo "Failed to submit feedback"
465
+ if ! cl ingest "$1" --wait; then
466
+ echo "Failed to ingest feedback"
453
467
  exit 1
454
468
  fi
455
469
  ```
@@ -457,13 +471,13 @@ fi
457
471
  ### 5. Use Pagination for Large Datasets
458
472
  ```bash
459
473
  # Good - increase limit for larger datasets
460
- cl input --page 1 --limit 50
474
+ cl ingest --page 1 --limit 50
461
475
 
462
476
  # Also good - use default pagination
463
- cl input --page 2 # Shows 20 items per page (default)
477
+ cl ingest --page 2 # Shows 20 items per page (default)
464
478
 
465
479
  # Bad - trying to show too many at once
466
- cl input --limit 200 # Will be capped at 100 (max limit)
480
+ cl ingest --limit 200 # Will be capped at 100 (max limit)
467
481
  ```
468
482
 
469
483
  ## Troubleshooting
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@closedloop-ai/cli",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "ClosedLoop AI CLI - AI-powered customer product feedback analysis tool",
5
5
  "bin": {
6
6
  "cl": "./packages/cli/dist/cli.js"
@@ -45,6 +45,14 @@
45
45
  "workspaces": [
46
46
  "packages/cli"
47
47
  ],
48
+ "dependencies": {
49
+ "commander": "^11.0.0",
50
+ "axios": "^1.6.0",
51
+ "chalk": "^4.1.2",
52
+ "ora": "^5.4.1",
53
+ "inquirer": "^8.2.6",
54
+ "table": "^6.8.1"
55
+ },
48
56
  "devDependencies": {
49
57
  "@types/node": "^20.0.0",
50
58
  "typescript": "^5.0.0",