cost-katana-cli 2.0.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.
Files changed (148) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +343 -0
  3. package/bin/cost-katana.js +20 -0
  4. package/dist/commands/agent-inspect.d.ts +3 -0
  5. package/dist/commands/agent-inspect.d.ts.map +1 -0
  6. package/dist/commands/agent-inspect.js +630 -0
  7. package/dist/commands/agent-inspect.js.map +1 -0
  8. package/dist/commands/analytics.d.ts +3 -0
  9. package/dist/commands/analytics.d.ts.map +1 -0
  10. package/dist/commands/analytics.js +375 -0
  11. package/dist/commands/analytics.js.map +1 -0
  12. package/dist/commands/analyze.d.ts +3 -0
  13. package/dist/commands/analyze.d.ts.map +1 -0
  14. package/dist/commands/analyze.js +286 -0
  15. package/dist/commands/analyze.js.map +1 -0
  16. package/dist/commands/ask.d.ts +3 -0
  17. package/dist/commands/ask.d.ts.map +1 -0
  18. package/dist/commands/ask.js +137 -0
  19. package/dist/commands/ask.js.map +1 -0
  20. package/dist/commands/audit-firewall.d.ts +3 -0
  21. package/dist/commands/audit-firewall.d.ts.map +1 -0
  22. package/dist/commands/audit-firewall.js +737 -0
  23. package/dist/commands/audit-firewall.js.map +1 -0
  24. package/dist/commands/budget.d.ts +3 -0
  25. package/dist/commands/budget.d.ts.map +1 -0
  26. package/dist/commands/budget.js +283 -0
  27. package/dist/commands/budget.js.map +1 -0
  28. package/dist/commands/bulk-optimize.d.ts +3 -0
  29. package/dist/commands/bulk-optimize.d.ts.map +1 -0
  30. package/dist/commands/bulk-optimize.js +863 -0
  31. package/dist/commands/bulk-optimize.js.map +1 -0
  32. package/dist/commands/chat.d.ts +3 -0
  33. package/dist/commands/chat.d.ts.map +1 -0
  34. package/dist/commands/chat.js +292 -0
  35. package/dist/commands/chat.js.map +1 -0
  36. package/dist/commands/check-cache.d.ts +3 -0
  37. package/dist/commands/check-cache.d.ts.map +1 -0
  38. package/dist/commands/check-cache.js +267 -0
  39. package/dist/commands/check-cache.js.map +1 -0
  40. package/dist/commands/compare.d.ts +3 -0
  41. package/dist/commands/compare.d.ts.map +1 -0
  42. package/dist/commands/compare.js +131 -0
  43. package/dist/commands/compare.js.map +1 -0
  44. package/dist/commands/config.d.ts +3 -0
  45. package/dist/commands/config.d.ts.map +1 -0
  46. package/dist/commands/config.js +421 -0
  47. package/dist/commands/config.js.map +1 -0
  48. package/dist/commands/craft-workflow.d.ts +3 -0
  49. package/dist/commands/craft-workflow.d.ts.map +1 -0
  50. package/dist/commands/craft-workflow.js +844 -0
  51. package/dist/commands/craft-workflow.js.map +1 -0
  52. package/dist/commands/debug-prompt.d.ts +3 -0
  53. package/dist/commands/debug-prompt.d.ts.map +1 -0
  54. package/dist/commands/debug-prompt.js +614 -0
  55. package/dist/commands/debug-prompt.js.map +1 -0
  56. package/dist/commands/diff-prompts.d.ts +3 -0
  57. package/dist/commands/diff-prompts.d.ts.map +1 -0
  58. package/dist/commands/diff-prompts.js +553 -0
  59. package/dist/commands/diff-prompts.js.map +1 -0
  60. package/dist/commands/high-cost-prompts.d.ts +3 -0
  61. package/dist/commands/high-cost-prompts.d.ts.map +1 -0
  62. package/dist/commands/high-cost-prompts.js +719 -0
  63. package/dist/commands/high-cost-prompts.js.map +1 -0
  64. package/dist/commands/init.d.ts +3 -0
  65. package/dist/commands/init.d.ts.map +1 -0
  66. package/dist/commands/init.js +325 -0
  67. package/dist/commands/init.js.map +1 -0
  68. package/dist/commands/key.d.ts +3 -0
  69. package/dist/commands/key.d.ts.map +1 -0
  70. package/dist/commands/key.js +574 -0
  71. package/dist/commands/key.js.map +1 -0
  72. package/dist/commands/list-models.d.ts +3 -0
  73. package/dist/commands/list-models.d.ts.map +1 -0
  74. package/dist/commands/list-models.js +154 -0
  75. package/dist/commands/list-models.js.map +1 -0
  76. package/dist/commands/models.d.ts +3 -0
  77. package/dist/commands/models.d.ts.map +1 -0
  78. package/dist/commands/models.js +107 -0
  79. package/dist/commands/models.js.map +1 -0
  80. package/dist/commands/optimize.d.ts +3 -0
  81. package/dist/commands/optimize.d.ts.map +1 -0
  82. package/dist/commands/optimize.js +345 -0
  83. package/dist/commands/optimize.js.map +1 -0
  84. package/dist/commands/project.d.ts +3 -0
  85. package/dist/commands/project.d.ts.map +1 -0
  86. package/dist/commands/project.js +475 -0
  87. package/dist/commands/project.js.map +1 -0
  88. package/dist/commands/prompt-metrics.d.ts +3 -0
  89. package/dist/commands/prompt-metrics.d.ts.map +1 -0
  90. package/dist/commands/prompt-metrics.js +665 -0
  91. package/dist/commands/prompt-metrics.js.map +1 -0
  92. package/dist/commands/replay-session.d.ts +3 -0
  93. package/dist/commands/replay-session.d.ts.map +1 -0
  94. package/dist/commands/replay-session.js +615 -0
  95. package/dist/commands/replay-session.js.map +1 -0
  96. package/dist/commands/retry-log.d.ts +3 -0
  97. package/dist/commands/retry-log.d.ts.map +1 -0
  98. package/dist/commands/retry-log.js +686 -0
  99. package/dist/commands/retry-log.js.map +1 -0
  100. package/dist/commands/rewrite-prompt.d.ts +3 -0
  101. package/dist/commands/rewrite-prompt.d.ts.map +1 -0
  102. package/dist/commands/rewrite-prompt.js +802 -0
  103. package/dist/commands/rewrite-prompt.js.map +1 -0
  104. package/dist/commands/set-budget.d.ts +3 -0
  105. package/dist/commands/set-budget.d.ts.map +1 -0
  106. package/dist/commands/set-budget.js +909 -0
  107. package/dist/commands/set-budget.js.map +1 -0
  108. package/dist/commands/simulate-cost.d.ts +3 -0
  109. package/dist/commands/simulate-cost.d.ts.map +1 -0
  110. package/dist/commands/simulate-cost.js +873 -0
  111. package/dist/commands/simulate-cost.js.map +1 -0
  112. package/dist/commands/suggest-models.d.ts +3 -0
  113. package/dist/commands/suggest-models.d.ts.map +1 -0
  114. package/dist/commands/suggest-models.js +674 -0
  115. package/dist/commands/suggest-models.js.map +1 -0
  116. package/dist/commands/test.d.ts +3 -0
  117. package/dist/commands/test.d.ts.map +1 -0
  118. package/dist/commands/test.js +187 -0
  119. package/dist/commands/test.js.map +1 -0
  120. package/dist/commands/trace-workflow.d.ts +3 -0
  121. package/dist/commands/trace-workflow.d.ts.map +1 -0
  122. package/dist/commands/trace-workflow.js +651 -0
  123. package/dist/commands/trace-workflow.js.map +1 -0
  124. package/dist/commands/trace.d.ts +3 -0
  125. package/dist/commands/trace.d.ts.map +1 -0
  126. package/dist/commands/trace.js +468 -0
  127. package/dist/commands/trace.js.map +1 -0
  128. package/dist/commands/track.d.ts +3 -0
  129. package/dist/commands/track.d.ts.map +1 -0
  130. package/dist/commands/track.js +404 -0
  131. package/dist/commands/track.js.map +1 -0
  132. package/dist/index.d.ts +4 -0
  133. package/dist/index.d.ts.map +1 -0
  134. package/dist/index.js +169 -0
  135. package/dist/index.js.map +1 -0
  136. package/dist/utils/config.d.ts +46 -0
  137. package/dist/utils/config.d.ts.map +1 -0
  138. package/dist/utils/config.js +321 -0
  139. package/dist/utils/config.js.map +1 -0
  140. package/dist/utils/logger.d.ts +21 -0
  141. package/dist/utils/logger.d.ts.map +1 -0
  142. package/dist/utils/logger.js +101 -0
  143. package/dist/utils/logger.js.map +1 -0
  144. package/dist/utils/models.d.ts +22 -0
  145. package/dist/utils/models.d.ts.map +1 -0
  146. package/dist/utils/models.js +2251 -0
  147. package/dist/utils/models.js.map +1 -0
  148. package/package.json +107 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Abdul Sagheer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,343 @@
1
+ # Cost Katana CLI 🥷
2
+
3
+ **Chat with AI from your terminal. Track costs automatically.**
4
+
5
+ ```bash
6
+ $ cost-katana chat
7
+
8
+ You: Hello!
9
+ AI: Hi! How can I help you today?
10
+ 💰 Cost: $0.0001
11
+
12
+ You: Write me a Python function
13
+ AI: Here's a Python function...
14
+ 💰 Session: $0.0023
15
+ ```
16
+
17
+ Simple. Powerful. Cost-aware.
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ npm install -g cost-katana-cli
23
+ ```
24
+
25
+ ## Quick Start
26
+
27
+ ### 1. Setup (One-time)
28
+
29
+ ```bash
30
+ cost-katana init
31
+ ```
32
+
33
+ Answer 2 questions:
34
+ 1. Your API key (from [costkatana.com](https://costkatana.com))
35
+ 2. Your default AI model
36
+
37
+ Done! ✅
38
+
39
+ ### 2. Start Chatting
40
+
41
+ ```bash
42
+ cost-katana chat
43
+ ```
44
+
45
+ That's it!
46
+
47
+ ## Essential Commands
48
+
49
+ ### Chat with AI
50
+
51
+ ```bash
52
+ # Start interactive chat
53
+ cost-katana chat
54
+
55
+ # Use specific model
56
+ cost-katana chat --model claude-3-sonnet
57
+
58
+ # With system prompt
59
+ cost-katana chat --system "You are a coding expert"
60
+ ```
61
+
62
+ ### Quick Question (No chat mode)
63
+
64
+ ```bash
65
+ # Ask a single question
66
+ cost-katana ask "What is the capital of France?"
67
+
68
+ # Save answer to file
69
+ cost-katana ask "Explain Python" --output answer.txt
70
+
71
+ # Use different model
72
+ cost-katana ask "Write a poem" --model gpt-4
73
+ ```
74
+
75
+ ### Analyze Costs
76
+
77
+ ```bash
78
+ # See your spending
79
+ cost-katana analyze
80
+
81
+ # Last 7 days
82
+ cost-katana analyze --days 7
83
+
84
+ # Export to CSV
85
+ cost-katana analyze --export costs.csv
86
+ ```
87
+
88
+ ### List Models
89
+
90
+ ```bash
91
+ # See available models
92
+ cost-katana models
93
+
94
+ # Filter by provider
95
+ cost-katana models --provider openai
96
+
97
+ # Show with prices
98
+ cost-katana models --prices
99
+ ```
100
+
101
+ ## Chat Session Commands
102
+
103
+ While in a chat session, you can use:
104
+
105
+ - `help` - Show commands
106
+ - `cost` - Show session cost
107
+ - `models` - Switch model
108
+ - `clear` - Clear history
109
+ - `save` - Save conversation
110
+ - `quit` - Exit
111
+
112
+ ## Advanced Features
113
+
114
+ ### Cost Optimization
115
+
116
+ ```bash
117
+ # Enable Cortex (70-95% savings)
118
+ cost-katana chat --cortex
119
+
120
+ # Enable caching
121
+ cost-katana chat --cache
122
+ ```
123
+
124
+ ### Compare Models
125
+
126
+ ```bash
127
+ # Compare costs across models
128
+ cost-katana compare "Explain AI" --models gpt-4,claude-3-sonnet,gemini-pro
129
+ ```
130
+
131
+ ### Budget Tracking
132
+
133
+ ```bash
134
+ # Set daily budget
135
+ cost-katana budget set --daily 10
136
+
137
+ # Check budget status
138
+ cost-katana budget status
139
+
140
+ # Get alerts
141
+ cost-katana budget alerts
142
+ ```
143
+
144
+ ## Configuration
145
+
146
+ ### View Config
147
+
148
+ ```bash
149
+ cost-katana config
150
+ ```
151
+
152
+ ### Update Settings
153
+
154
+ ```bash
155
+ # Change default model
156
+ cost-katana config set model gpt-4
157
+
158
+ # Set temperature
159
+ cost-katana config set temperature 0.7
160
+
161
+ # Set daily limit
162
+ cost-katana config set daily-limit 5
163
+ ```
164
+
165
+ ### Environment Variables
166
+
167
+ ```bash
168
+ # Alternative to init command
169
+ export COST_KATANA_KEY="dak_your_key"
170
+ export COST_KATANA_MODEL="gpt-4"
171
+ ```
172
+
173
+ ## Real-World Examples
174
+
175
+ ### Code Assistant
176
+
177
+ ```bash
178
+ $ cost-katana chat --system "You are a senior developer. Be concise."
179
+
180
+ You: Review this code: [paste code]
181
+ AI: Here are the issues...
182
+ 💰 Cost: $0.0045
183
+
184
+ You: How do I fix issue #2?
185
+ AI: Here's how to fix it...
186
+ 💰 Session: $0.0067
187
+ ```
188
+
189
+ ### Content Writer
190
+
191
+ ```bash
192
+ $ cost-katana chat --model gpt-4 --cortex
193
+
194
+ You: Write a blog post about AI
195
+ AI: [Generates comprehensive post with 70% cost savings]
196
+ 💰 Cost: $0.0123 (saved $0.041 with Cortex!)
197
+ ```
198
+
199
+ ### Quick Answers
200
+
201
+ ```bash
202
+ # Get quick answers without entering chat mode
203
+ $ cost-katana ask "What's the weather API for Node.js?"
204
+ > Use the 'axios' library to call weather APIs like OpenWeatherMap...
205
+ 💰 Cost: $0.0002
206
+
207
+ $ cost-katana ask "Python sort list by date" --output answer.md
208
+ ✅ Saved to answer.md
209
+ 💰 Cost: $0.0003
210
+ ```
211
+
212
+ ## Tips
213
+
214
+ ### Save Money
215
+
216
+ ```bash
217
+ # Use cheaper models for simple tasks
218
+ cost-katana chat --model gpt-3.5-turbo # 10x cheaper
219
+
220
+ # Enable optimization for long content
221
+ cost-katana chat --cortex # 70-95% savings
222
+
223
+ # Cache repeated queries
224
+ cost-katana chat --cache # Free repeated answers
225
+ ```
226
+
227
+ ### Productivity
228
+
229
+ ```bash
230
+ # Save conversations
231
+ cost-katana chat --output session.json
232
+
233
+ # Load previous conversation
234
+ cost-katana chat --file session.json
235
+
236
+ # Pipe output
237
+ cost-katana ask "List of AI models" | grep gpt
238
+ ```
239
+
240
+ ## Comparison
241
+
242
+ ### Traditional AI CLIs
243
+
244
+ ```bash
245
+ # Complex setup
246
+ export OPENAI_API_KEY="sk-..."
247
+ export ANTHROPIC_API_KEY="sk-ant-..."
248
+
249
+ # Different commands for each provider
250
+ openai chat
251
+ anthropic messages create
252
+ ```
253
+
254
+ ### Cost Katana CLI
255
+
256
+ ```bash
257
+ # Simple setup
258
+ cost-katana init
259
+
260
+ # One command for all providers
261
+ cost-katana chat
262
+
263
+ # Automatic cost tracking!
264
+ ```
265
+
266
+ ## Troubleshooting
267
+
268
+ ### "API key not found"
269
+
270
+ ```bash
271
+ # Run init again
272
+ cost-katana init
273
+
274
+ # Or set environment variable
275
+ export COST_KATANA_KEY="dak_your_key"
276
+ ```
277
+
278
+ ### "Model not available"
279
+
280
+ ```bash
281
+ # See available models
282
+ cost-katana models
283
+
284
+ # Try a different model
285
+ cost-katana chat --model gpt-3.5-turbo
286
+ ```
287
+
288
+ ### "Rate limit exceeded"
289
+
290
+ ```bash
291
+ # CLI automatically retries
292
+ # If persistent, try different model:
293
+ cost-katana chat --model claude-3-haiku
294
+ ```
295
+
296
+ ## Dashboard Integration
297
+
298
+ All your CLI usage is tracked at [costkatana.com/dashboard](https://costkatana.com/dashboard):
299
+
300
+ - Real-time cost tracking
301
+ - Usage by model
302
+ - Daily/weekly/monthly stats
303
+ - Budget alerts
304
+ - Optimization tips
305
+
306
+ ```bash
307
+ # Every command is tracked
308
+ cost-katana chat
309
+ cost-katana ask "Hello"
310
+
311
+ # View at: https://costkatana.com/dashboard
312
+ ```
313
+
314
+ ## Why Cost Katana CLI?
315
+
316
+ ✅ **Simple**: 2-step setup, then just `cost-katana chat`
317
+ ✅ **Universal**: Works with all AI providers
318
+ ✅ **Cost-Aware**: See costs in real-time
319
+ ✅ **Optimized**: Built-in 70-95% cost reduction
320
+ ✅ **Tracked**: Everything logged to dashboard
321
+ ✅ **Beautiful**: Clean, colorful terminal UI
322
+
323
+ ## Support
324
+
325
+ - **Documentation**: https://docs.costkatana.com/cli
326
+ - **Dashboard**: https://costkatana.com
327
+ - **GitHub**: https://github.com/Hypothesize-Tech/costkatana-cli
328
+ - **Discord**: https://discord.gg/Wcwzw8wM
329
+ - **Email**: support@costkatana.com
330
+
331
+ ## License
332
+
333
+ MIT © Cost Katana
334
+
335
+ ---
336
+
337
+ **Start chatting with AI in your terminal!**
338
+
339
+ ```bash
340
+ npm install -g cost-katana-cli
341
+ cost-katana init
342
+ cost-katana chat
343
+ ```
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+
3
+ // This file is the entry point for the CLI tool
4
+ // It will be compiled from TypeScript and placed in the bin directory
5
+
6
+ try {
7
+ // Try to load the compiled JavaScript
8
+ require('../dist/index.js');
9
+ } catch (error) {
10
+ // If compiled version doesn't exist, try to run TypeScript directly
11
+ try {
12
+ require('ts-node/register');
13
+ require('../src/index.ts');
14
+ } catch (tsError) {
15
+ console.error('Error: Could not start Cost Katana CLI');
16
+ console.error('Please run "npm run build" to compile the TypeScript code');
17
+ console.error('Or install ts-node: npm install -g ts-node');
18
+ process.exit(1);
19
+ }
20
+ }
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function agentInspectCommand(program: Command): void;
3
+ //# sourceMappingURL=agent-inspect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-inspect.d.ts","sourceRoot":"","sources":["../../src/commands/agent-inspect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,QA8FnD"}