myshell-tools 1.0.0 → 2.0.0-alpha.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 (150) hide show
  1. package/CHANGELOG.md +44 -69
  2. package/LICENSE +21 -21
  3. package/README.md +178 -318
  4. package/dist/cli.d.ts +8 -0
  5. package/dist/cli.js +106 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/commands/cost.d.ts +36 -0
  8. package/dist/commands/cost.js +103 -0
  9. package/dist/commands/cost.js.map +1 -0
  10. package/dist/commands/doctor.d.ts +36 -0
  11. package/dist/commands/doctor.js +115 -0
  12. package/dist/commands/doctor.js.map +1 -0
  13. package/dist/core/assess.d.ts +25 -0
  14. package/dist/core/assess.js +142 -0
  15. package/dist/core/assess.js.map +1 -0
  16. package/dist/core/classify.d.ts +19 -0
  17. package/dist/core/classify.js +80 -0
  18. package/dist/core/classify.js.map +1 -0
  19. package/dist/core/escalate.d.ts +32 -0
  20. package/dist/core/escalate.js +57 -0
  21. package/dist/core/escalate.js.map +1 -0
  22. package/dist/core/index.d.ts +13 -0
  23. package/dist/core/index.js +12 -0
  24. package/dist/core/index.js.map +1 -0
  25. package/dist/core/orchestrate.d.ts +42 -0
  26. package/dist/core/orchestrate.js +439 -0
  27. package/dist/core/orchestrate.js.map +1 -0
  28. package/dist/core/policy.d.ts +9 -0
  29. package/dist/core/policy.js +27 -0
  30. package/dist/core/policy.js.map +1 -0
  31. package/dist/core/prompt.d.ts +26 -0
  32. package/dist/core/prompt.js +125 -0
  33. package/dist/core/prompt.js.map +1 -0
  34. package/dist/core/review.d.ts +46 -0
  35. package/dist/core/review.js +148 -0
  36. package/dist/core/review.js.map +1 -0
  37. package/dist/core/route.d.ts +28 -0
  38. package/dist/core/route.js +52 -0
  39. package/dist/core/route.js.map +1 -0
  40. package/dist/core/types.d.ts +141 -0
  41. package/dist/core/types.js +14 -0
  42. package/dist/core/types.js.map +1 -0
  43. package/dist/infra/atomic.d.ts +53 -0
  44. package/dist/infra/atomic.js +171 -0
  45. package/dist/infra/atomic.js.map +1 -0
  46. package/dist/infra/clock.d.ts +9 -0
  47. package/dist/infra/clock.js +15 -0
  48. package/dist/infra/clock.js.map +1 -0
  49. package/dist/infra/index.d.ts +9 -0
  50. package/dist/infra/index.js +7 -0
  51. package/dist/infra/index.js.map +1 -0
  52. package/dist/infra/ledger.d.ts +49 -0
  53. package/dist/infra/ledger.js +90 -0
  54. package/dist/infra/ledger.js.map +1 -0
  55. package/dist/infra/paths.d.ts +28 -0
  56. package/dist/infra/paths.js +38 -0
  57. package/dist/infra/paths.js.map +1 -0
  58. package/dist/infra/pricing.d.ts +47 -0
  59. package/dist/infra/pricing.js +151 -0
  60. package/dist/infra/pricing.js.map +1 -0
  61. package/dist/infra/session.d.ts +28 -0
  62. package/dist/infra/session.js +61 -0
  63. package/dist/infra/session.js.map +1 -0
  64. package/dist/interface/render.d.ts +27 -0
  65. package/dist/interface/render.js +134 -0
  66. package/dist/interface/render.js.map +1 -0
  67. package/dist/interface/repl.d.ts +23 -0
  68. package/dist/interface/repl.js +90 -0
  69. package/dist/interface/repl.js.map +1 -0
  70. package/dist/interface/run.d.ts +20 -0
  71. package/dist/interface/run.js +31 -0
  72. package/dist/interface/run.js.map +1 -0
  73. package/dist/providers/claude-parse.d.ts +24 -0
  74. package/dist/providers/claude-parse.js +113 -0
  75. package/dist/providers/claude-parse.js.map +1 -0
  76. package/dist/providers/claude.d.ts +45 -0
  77. package/dist/providers/claude.js +122 -0
  78. package/dist/providers/claude.js.map +1 -0
  79. package/dist/providers/codex-parse.d.ts +32 -0
  80. package/dist/providers/codex-parse.js +145 -0
  81. package/dist/providers/codex-parse.js.map +1 -0
  82. package/dist/providers/codex.d.ts +44 -0
  83. package/dist/providers/codex.js +124 -0
  84. package/dist/providers/codex.js.map +1 -0
  85. package/dist/providers/detect.d.ts +49 -0
  86. package/dist/providers/detect.js +125 -0
  87. package/dist/providers/detect.js.map +1 -0
  88. package/dist/providers/errors.d.ts +49 -0
  89. package/dist/providers/errors.js +189 -0
  90. package/dist/providers/errors.js.map +1 -0
  91. package/dist/providers/index.d.ts +9 -0
  92. package/dist/providers/index.js +7 -0
  93. package/dist/providers/index.js.map +1 -0
  94. package/dist/providers/port.d.ts +74 -0
  95. package/dist/providers/port.js +16 -0
  96. package/dist/providers/port.js.map +1 -0
  97. package/dist/providers/registry.d.ts +21 -0
  98. package/dist/providers/registry.js +34 -0
  99. package/dist/providers/registry.js.map +1 -0
  100. package/dist/ui/banner.d.ts +19 -0
  101. package/dist/ui/banner.js +32 -0
  102. package/dist/ui/banner.js.map +1 -0
  103. package/dist/ui/spinner.d.ts +27 -0
  104. package/dist/ui/spinner.js +67 -0
  105. package/dist/ui/spinner.js.map +1 -0
  106. package/dist/ui/theme.d.ts +32 -0
  107. package/dist/ui/theme.js +56 -0
  108. package/dist/ui/theme.js.map +1 -0
  109. package/package.json +55 -49
  110. package/data/orchestrator.json +0 -113
  111. package/src/auth/recovery.mjs +0 -328
  112. package/src/auth/refresh.mjs +0 -373
  113. package/src/chef.mjs +0 -348
  114. package/src/cli/doctor.mjs +0 -568
  115. package/src/cli/reset.mjs +0 -447
  116. package/src/cli/status.mjs +0 -379
  117. package/src/cli.mjs +0 -429
  118. package/src/commands/doctor.mjs +0 -375
  119. package/src/commands/help.mjs +0 -324
  120. package/src/commands/status.mjs +0 -331
  121. package/src/monitor/health.mjs +0 -486
  122. package/src/monitor/performance.mjs +0 -442
  123. package/src/monitor/report.mjs +0 -535
  124. package/src/orchestrator/classify.mjs +0 -391
  125. package/src/orchestrator/confidence.mjs +0 -151
  126. package/src/orchestrator/handoffs.mjs +0 -231
  127. package/src/orchestrator/review.mjs +0 -222
  128. package/src/providers/balance.mjs +0 -201
  129. package/src/providers/claude.mjs +0 -236
  130. package/src/providers/codex.mjs +0 -255
  131. package/src/providers/detect.mjs +0 -185
  132. package/src/providers/errors.mjs +0 -373
  133. package/src/providers/select.mjs +0 -162
  134. package/src/repl-enhanced.mjs +0 -417
  135. package/src/repl.mjs +0 -321
  136. package/src/state/archive.mjs +0 -366
  137. package/src/state/atomic.mjs +0 -116
  138. package/src/state/cleanup.mjs +0 -440
  139. package/src/state/recovery.mjs +0 -461
  140. package/src/state/session.mjs +0 -147
  141. package/src/ui/errors.mjs +0 -456
  142. package/src/ui/formatter.mjs +0 -327
  143. package/src/ui/icons.mjs +0 -318
  144. package/src/ui/progress.mjs +0 -468
  145. package/templates/prompts/confidence-format.txt +0 -14
  146. package/templates/prompts/ic-with-feedback.txt +0 -41
  147. package/templates/prompts/ic.txt +0 -13
  148. package/templates/prompts/manager-review.txt +0 -40
  149. package/templates/prompts/manager.txt +0 -14
  150. package/templates/prompts/worker.txt +0 -12
@@ -1,375 +0,0 @@
1
- /**
2
- * doctor.mjs — Enhanced system health check with visual dashboard
3
- */
4
-
5
- import { detectEnvironment, getAvailableModels } from '../providers/detect.mjs';
6
- import { fmt, box, separator, providerBalanceBar } from '../ui/formatter.mjs';
7
- import { status, provider, tier, health } from '../ui/icons.mjs';
8
-
9
- /**
10
- * Run comprehensive system health check
11
- */
12
- export async function runDoctorCheck() {
13
- console.log(box('🩺 Cortex System Health Check', {
14
- borderColor: fmt.blue(''),
15
- textColor: fmt.bold(''),
16
- padding: 1,
17
- margin: 1
18
- }));
19
-
20
- const env = detectEnvironment();
21
- const models = getAvailableModels(env);
22
-
23
- // Provider Status Section
24
- console.log(fmt.bold('\nšŸ“‹ Provider Status:'));
25
- console.log(separator(50, '─'));
26
-
27
- checkProviderStatus('Claude', env.claude);
28
- checkProviderStatus('Codex', env.codex);
29
-
30
- // Model Availability Section
31
- console.log(fmt.bold('\nšŸ¤– Model Availability:'));
32
- console.log(separator(50, '─'));
33
-
34
- checkModelTiers(models);
35
-
36
- // Environment Section
37
- console.log(fmt.bold('\nšŸŒ Environment:'));
38
- console.log(separator(50, '─'));
39
-
40
- checkEnvironment(env);
41
-
42
- // Performance Section
43
- console.log(fmt.bold('\nšŸ“Š Performance:'));
44
- console.log(separator(50, '─'));
45
-
46
- await checkPerformance(env);
47
-
48
- // Overall Health Assessment with visual summary
49
- console.log(fmt.bold('\nšŸ„ Health Summary:'));
50
- console.log(separator(50, '─'));
51
-
52
- const healthStatus = assessOverallHealth(env, models);
53
- displayHealthSummary(healthStatus);
54
-
55
- // Quick action summary
56
- console.log(fmt.bold('\nšŸš€ Quick Actions:'));
57
- console.log(separator(50, '─'));
58
- displayQuickActions(healthStatus);
59
-
60
- // Recommendations
61
- if (healthStatus.issues.length > 0) {
62
- console.log(fmt.bold('\nšŸ’” Recommendations:'));
63
- console.log(separator(50, '─'));
64
- displayRecommendations(healthStatus.issues);
65
- }
66
-
67
- console.log('');
68
- }
69
-
70
- /**
71
- * Check individual provider status
72
- */
73
- function checkProviderStatus(name, providerInfo) {
74
- const icon = provider[name.toLowerCase()] || 'ā—‹';
75
- const installIcon = providerInfo.installed ? status.success : status.error;
76
- const authIcon = providerInfo.authed ? status.success : status.warning;
77
-
78
- console.log(` ${icon} ${fmt.bold(name)} Provider:`);
79
- console.log(` Installation: ${installIcon} ${providerInfo.installed ? 'Found' : 'Missing'}`);
80
-
81
- if (providerInfo.version) {
82
- console.log(` Version: ${fmt.dim(providerInfo.version)}`);
83
- }
84
-
85
- console.log(` Authentication: ${authIcon} ${providerInfo.authed ? 'Valid' : 'Invalid'}`);
86
-
87
- if (!providerInfo.installed) {
88
- displayInstallGuidance(name);
89
- } else if (!providerInfo.authed) {
90
- displayAuthGuidance(name);
91
- }
92
-
93
- console.log('');
94
- }
95
-
96
- /**
97
- * Check model tier availability
98
- */
99
- function checkModelTiers(models) {
100
- const tiers = [
101
- { name: 'Manager', key: 'manager', icon: tier.manager, description: 'Complex decisions, architecture, reviews' },
102
- { name: 'IC', key: 'ic', icon: tier.ic, description: 'Implementation, coding, main workload' },
103
- { name: 'Worker', key: 'worker', icon: tier.worker, description: 'Simple tasks, lookups, grep operations' }
104
- ];
105
-
106
- for (const tierInfo of tiers) {
107
- const tierModels = models[tierInfo.key] || [];
108
- const count = tierModels.length;
109
- const healthIcon = count > 0 ? health.healthy : health.critical;
110
-
111
- console.log(` ${tierInfo.icon} ${fmt.bold(tierInfo.name)} Tier: ${healthIcon} ${count} model(s) available`);
112
- console.log(` ${fmt.dim(tierInfo.description)}`);
113
-
114
- if (count > 0) {
115
- for (const model of tierModels.slice(0, 3)) { // Show first 3 models
116
- const modelDisplay = `${model.provider}/${model.model}`;
117
- console.log(` ${fmt.dim('ā”œā”€')} ${fmt.green(modelDisplay)}`);
118
- }
119
- if (tierModels.length > 3) {
120
- console.log(` ${fmt.dim('└─')} ${fmt.dim(`... and ${tierModels.length - 3} more`)}`);
121
- }
122
- } else {
123
- console.log(` ${fmt.red('└─ No models available for this tier')}`);
124
- }
125
-
126
- console.log('');
127
- }
128
- }
129
-
130
- /**
131
- * Check environment details
132
- */
133
- function checkEnvironment(env) {
134
- console.log(` šŸ“ Workspace: ${fmt.cyan(env.workspace)}`);
135
- console.log(` šŸ“Š Sessions: ${fmt.cyan(env.workspace + '/.cortex/sessions/')}`);
136
-
137
- const hasProviders = env.hasProviders;
138
- const providerIcon = hasProviders ? status.success : status.error;
139
- console.log(` šŸ”Œ Providers: ${providerIcon} ${hasProviders ? 'Ready' : 'None authenticated'}`);
140
-
141
- // Check session directory
142
- try {
143
- const sessionPath = env.workspace + '/.cortex/sessions/';
144
- console.log(` šŸ’¾ Session Storage: ${status.success} Accessible`);
145
- } catch (error) {
146
- console.log(` šŸ’¾ Session Storage: ${status.error} Error - ${error.message}`);
147
- }
148
-
149
- console.log('');
150
- }
151
-
152
- /**
153
- * Check performance metrics
154
- */
155
- async function checkPerformance(env) {
156
- // Mock performance check - in a real implementation this would test actual response times
157
- console.log(` ⚔ Claude Response Time: ${fmt.green('~1.2s')} ${fmt.dim('(excellent)')}`);
158
- console.log(` ⚔ Codex Response Time: ${fmt.green('~0.8s')} ${fmt.dim('(excellent)')}`);
159
-
160
- // Show today's usage balance
161
- const balance = mockGetUsageBalance();
162
- console.log(` šŸ“Š Today's Usage Balance:`);
163
- console.log(` ${providerBalanceBar(balance.claude, balance.openai)}`);
164
- console.log(` ${fmt.dim(balance.label)}`);
165
-
166
- console.log('');
167
- }
168
-
169
- /**
170
- * Assess overall health
171
- */
172
- function assessOverallHealth(env, models) {
173
- const issues = [];
174
- let status = 'healthy';
175
-
176
- // Check critical issues
177
- if (!env.hasProviders) {
178
- issues.push({
179
- level: 'critical',
180
- message: 'No authenticated providers found',
181
- action: 'Authenticate at least one provider to use Cortex'
182
- });
183
- status = 'critical';
184
- }
185
-
186
- if (models.manager.length === 0 && models.ic.length === 0) {
187
- issues.push({
188
- level: 'critical',
189
- message: 'No models available for work execution',
190
- action: 'Check provider authentication and model availability'
191
- });
192
- status = 'critical';
193
- }
194
-
195
- // Check warnings
196
- if (models.manager.length === 0) {
197
- issues.push({
198
- level: 'warning',
199
- message: 'No Manager tier models available',
200
- action: 'Complex tasks may not escalate properly'
201
- });
202
- if (status === 'healthy') status = 'warning';
203
- }
204
-
205
- if (!env.claude.authed && env.claude.installed) {
206
- issues.push({
207
- level: 'warning',
208
- message: 'Claude CLI installed but not authenticated',
209
- action: 'Run: claude auth login'
210
- });
211
- if (status === 'healthy') status = 'warning';
212
- }
213
-
214
- if (!env.codex.authed && env.codex.installed) {
215
- issues.push({
216
- level: 'warning',
217
- message: 'Codex CLI installed but not authenticated',
218
- action: 'Run: codex login'
219
- });
220
- if (status === 'healthy') status = 'warning';
221
- }
222
-
223
- return { status, issues, env, models };
224
- }
225
-
226
- /**
227
- * Display health summary
228
- */
229
- function displayHealthSummary(healthStatus) {
230
- const { status: healthState, issues, models } = healthStatus;
231
-
232
- let summaryIcon, summaryText, summaryColor;
233
- switch (healthState) {
234
- case 'healthy':
235
- summaryIcon = health.healthy;
236
- summaryText = 'System is healthy and ready for AI orchestration';
237
- summaryColor = fmt.green;
238
- break;
239
- case 'warning':
240
- summaryIcon = health.warning;
241
- summaryText = 'System is functional but has some issues';
242
- summaryColor = fmt.yellow;
243
- break;
244
- case 'critical':
245
- summaryIcon = health.critical;
246
- summaryText = 'System has critical issues that prevent operation';
247
- summaryColor = fmt.red;
248
- break;
249
- default:
250
- summaryIcon = health.unknown;
251
- summaryText = 'Health status unknown';
252
- summaryColor = fmt.dim;
253
- }
254
-
255
- console.log(` ${summaryIcon} ${summaryColor(fmt.bold('Overall Health:'))} ${summaryColor(summaryText)}`);
256
-
257
- // Show capability summary
258
- const capabilities = [];
259
- if (models.manager.length > 0) capabilities.push('Complex reasoning');
260
- if (models.ic.length > 0) capabilities.push('Code implementation');
261
- if (models.worker.length > 0) capabilities.push('Simple tasks');
262
-
263
- if (capabilities.length > 0) {
264
- console.log(` ${status.info} ${fmt.bold('Available Capabilities:')} ${capabilities.join(', ')}`);
265
- }
266
-
267
- console.log(` ${tier.worker} ${fmt.bold('Ready for:')} ${issues.length === 0 ? 'All operations' : 'Limited operations'}`);
268
- console.log('');
269
- }
270
-
271
- /**
272
- * Display actionable recommendations
273
- */
274
- function displayRecommendations(issues) {
275
- for (let i = 0; i < issues.length; i++) {
276
- const issue = issues[i];
277
- const levelIcon = issue.level === 'critical' ? status.error : status.warning;
278
- const levelColor = issue.level === 'critical' ? fmt.red : fmt.yellow;
279
-
280
- console.log(` ${levelIcon} ${levelColor(fmt.bold(issue.message))}`);
281
- console.log(` ${status.info} ${issue.action}`);
282
-
283
- if (i < issues.length - 1) {
284
- console.log('');
285
- }
286
- }
287
- console.log('');
288
- }
289
-
290
- /**
291
- * Display installation guidance
292
- */
293
- function displayInstallGuidance(providerName) {
294
- const guides = {
295
- Claude: {
296
- command: 'pip install anthropic-cli',
297
- docs: 'https://claude.ai/cli'
298
- },
299
- Codex: {
300
- command: 'npm install -g @openai/codex',
301
- docs: 'https://openai.com/codex'
302
- }
303
- };
304
-
305
- const guide = guides[providerName];
306
- if (guide) {
307
- console.log(` ${status.info} Install: ${fmt.cyan(guide.command)}`);
308
- console.log(` ${status.docs} Guide: ${fmt.cyan(guide.docs)}`);
309
- }
310
- }
311
-
312
- /**
313
- * Display authentication guidance
314
- */
315
- function displayAuthGuidance(providerName) {
316
- const commands = {
317
- Claude: 'claude auth login',
318
- Codex: 'codex login'
319
- };
320
-
321
- const command = commands[providerName];
322
- if (command) {
323
- console.log(` ${status.info} Authenticate: ${fmt.cyan(command)}`);
324
- }
325
- }
326
-
327
- /**
328
- * Mock function to get usage balance (replace with real implementation)
329
- */
330
- function mockGetUsageBalance() {
331
- // This would read from actual usage logs
332
- return {
333
- claude: 45,
334
- openai: 55,
335
- total: 23,
336
- label: 'Well balanced across providers'
337
- };
338
- }
339
-
340
- /**
341
- * Display quick actions based on health status
342
- */
343
- function displayQuickActions(healthStatus) {
344
- const { status: healthState, env } = healthStatus;
345
-
346
- if (healthState === 'healthy') {
347
- console.log(` ${status.success} ${fmt.green('System is ready!')} Run ${fmt.cyan('cortex')} to start`);
348
- } else {
349
- const actions = [];
350
-
351
- if (!env.claude.authed && env.claude.installed) {
352
- actions.push(`Run: ${fmt.cyan('claude auth login')}`);
353
- }
354
- if (!env.claude.installed) {
355
- actions.push(`Install: ${fmt.cyan('pip install anthropic-cli')}`);
356
- }
357
- if (!env.codex.authed && env.codex.installed) {
358
- actions.push(`Run: ${fmt.cyan('codex login')}`);
359
- }
360
- if (!env.codex.installed) {
361
- actions.push(`Install: ${fmt.cyan('npm install -g @openai/codex')}`);
362
- }
363
-
364
- for (let i = 0; i < actions.length; i++) {
365
- const action = actions[i];
366
- console.log(` ${i + 1}. ${action}`);
367
- }
368
-
369
- if (actions.length === 0) {
370
- console.log(` ${status.info} Run ${fmt.cyan('cortex')} to continue`);
371
- }
372
- }
373
-
374
- console.log('');
375
- }
@@ -1,324 +0,0 @@
1
- /**
2
- * help.mjs — Rich help system with examples and visual formatting
3
- */
4
-
5
- import { fmt, box, separator, createTree } from '../ui/formatter.mjs';
6
- import { status, tier, actions } from '../ui/icons.mjs';
7
-
8
- const VERSION = '1.0.0';
9
-
10
- /**
11
- * Display comprehensive help information
12
- */
13
- export function displayHelp() {
14
- // Header
15
- console.log(box(`Cortex v${VERSION} — AI Org Chart Orchestration`, {
16
- borderColor: fmt.brightBlue(''),
17
- textColor: fmt.bold(''),
18
- padding: 1,
19
- margin: 1
20
- }));
21
-
22
- // Quick Start
23
- displayQuickStart();
24
-
25
- // Commands
26
- displayCommands();
27
-
28
- // Hierarchy
29
- displayHierarchy();
30
-
31
- // Examples
32
- displayExamples();
33
-
34
- // Advanced Usage
35
- displayAdvancedUsage();
36
-
37
- console.log('');
38
- }
39
-
40
- /**
41
- * Display quick start section
42
- */
43
- function displayQuickStart() {
44
- console.log(fmt.bold('\nšŸš€ Quick Start:'));
45
- console.log(separator(60, '─'));
46
-
47
- const quickSteps = [
48
- {
49
- text: fmt.green('cortex --doctor') + ' — Check system health',
50
- children: [
51
- { text: fmt.dim('Verify providers are installed and authenticated') }
52
- ]
53
- },
54
- {
55
- text: fmt.green('cortex') + ' — Start interactive chat',
56
- children: [
57
- { text: fmt.dim('Begin AI-powered development workflow') }
58
- ]
59
- },
60
- {
61
- text: fmt.dim('Type your request and press Enter'),
62
- children: [
63
- { text: fmt.dim('AI will route to appropriate tier automatically') }
64
- ]
65
- }
66
- ];
67
-
68
- const tree = createTree(quickSteps);
69
- tree.forEach(line => console.log(' ' + line));
70
-
71
- console.log('');
72
- }
73
-
74
- /**
75
- * Display all available commands
76
- */
77
- function displayCommands() {
78
- console.log(fmt.bold('\nšŸ“‹ Commands:'));
79
- console.log(separator(60, '─'));
80
-
81
- const commands = [
82
- {
83
- category: 'Main Usage',
84
- items: [
85
- { cmd: 'cortex', desc: 'Start interactive chat with AI hierarchy' },
86
- { cmd: 'cortex --help', desc: 'Show this help information' },
87
- { cmd: 'cortex --version', desc: 'Show version information' }
88
- ]
89
- },
90
- {
91
- category: 'System Health',
92
- items: [
93
- { cmd: 'cortex --doctor', desc: 'Run comprehensive health check' },
94
- { cmd: 'cortex --status', desc: 'Show current session and system status' }
95
- ]
96
- },
97
- {
98
- category: 'Session Management',
99
- items: [
100
- { cmd: 'cortex --reset [level]', desc: 'Reset state (sessions, state, all, nuclear)' },
101
- { cmd: 'cortex --cleanup', desc: 'Clean up old files and optimize storage' },
102
- { cmd: 'cortex --resume [plan-id]', desc: 'Resume interrupted work' },
103
- { cmd: 'cortex --recovery', desc: 'Show recovery options for interrupted work' }
104
- ]
105
- },
106
- {
107
- category: 'Analytics & Reporting',
108
- items: [
109
- { cmd: 'cortex --report', desc: 'Generate comprehensive session report' },
110
- { cmd: 'cortex --trends [days]', desc: 'Show performance trends (default: 7 days)' }
111
- ]
112
- }
113
- ];
114
-
115
- for (const category of commands) {
116
- console.log(`\n ${fmt.bold(category.category)}:`);
117
-
118
- for (const item of category.items) {
119
- console.log(` ${fmt.cyan(item.cmd.padEnd(25))} ${fmt.dim('—')} ${item.desc}`);
120
- }
121
- }
122
-
123
- console.log('');
124
- }
125
-
126
- /**
127
- * Display AI hierarchy information
128
- */
129
- function displayHierarchy() {
130
- console.log(fmt.bold('\nšŸ¢ AI Org Chart Hierarchy:'));
131
- console.log(separator(60, '─'));
132
-
133
- const hierarchyLevels = [
134
- {
135
- name: 'MANAGER',
136
- icon: tier.manager,
137
- color: fmt.red,
138
- description: 'Complex decisions, architecture, code review, escalations',
139
- models: 'Claude Opus, GPT-5.5',
140
- when: 'High complexity, architecture decisions, final reviews'
141
- },
142
- {
143
- name: 'IC (Individual Contributor)',
144
- icon: tier.ic,
145
- color: fmt.yellow,
146
- description: 'Main workhorses for implementation and coding tasks',
147
- models: 'Claude Sonnet, GPT-5.4',
148
- when: 'Implementation, bug fixes, feature development'
149
- },
150
- {
151
- name: 'WORKER',
152
- icon: tier.worker,
153
- color: fmt.blue,
154
- description: 'Fast, cheap models for simple tasks',
155
- models: 'Claude Haiku, GPT-4.1-mini',
156
- when: 'File search, grep, simple lookups, documentation'
157
- }
158
- ];
159
-
160
- for (const level of hierarchyLevels) {
161
- console.log(` ${level.icon} ${level.color(fmt.bold(level.name))}`);
162
- console.log(` ${fmt.dim('Description:')} ${level.description}`);
163
- console.log(` ${fmt.dim('Models:')} ${fmt.green(level.models)}`);
164
- console.log(` ${fmt.dim('Best for:')} ${level.when}`);
165
- console.log('');
166
- }
167
-
168
- console.log(fmt.bold('šŸ“ˆ How Escalation Works:'));
169
- console.log(` 1. Tasks start at appropriate tier (usually ${fmt.yellow('IC')})`);
170
- console.log(` 2. Models escalate ${fmt.red('UP')} when they need help or hit complexity`);
171
- console.log(` 3. Managers can delegate ${fmt.blue('DOWN')} to workers for simple subtasks`);
172
- console.log(` 4. Everything is transparent — you see the org chart in action`);
173
-
174
- console.log('');
175
- }
176
-
177
- /**
178
- * Display usage examples
179
- */
180
- function displayExamples() {
181
- console.log(fmt.bold('\nšŸ’” Usage Examples:'));
182
- console.log(separator(60, '─'));
183
-
184
- const examples = [
185
- {
186
- category: 'Development Tasks',
187
- examples: [
188
- {
189
- input: 'Fix the authentication bug in login.ts',
190
- flow: 'IC → implements fix → Manager review if complex'
191
- },
192
- {
193
- input: 'Find all files that import React hooks',
194
- flow: 'Worker → searches codebase → returns file list'
195
- },
196
- {
197
- input: 'Design a new microservices architecture',
198
- flow: 'Manager → architectural planning → delegates implementation'
199
- }
200
- ]
201
- },
202
- {
203
- category: 'Code Analysis',
204
- examples: [
205
- {
206
- input: 'Explain how the authentication system works',
207
- flow: 'Worker → reads files → IC → explains patterns'
208
- },
209
- {
210
- input: 'Review this pull request for security issues',
211
- flow: 'Manager → comprehensive security review'
212
- },
213
- {
214
- input: 'What are the performance bottlenecks?',
215
- flow: 'IC → analyzes code → Manager → strategic recommendations'
216
- }
217
- ]
218
- },
219
- {
220
- category: 'Documentation',
221
- examples: [
222
- {
223
- input: 'Write API documentation for the user service',
224
- flow: 'Worker → reads code → IC → writes documentation'
225
- },
226
- {
227
- input: 'Create a deployment guide',
228
- flow: 'Manager → strategic overview → Worker → detailed steps'
229
- }
230
- ]
231
- }
232
- ];
233
-
234
- for (const category of examples) {
235
- console.log(`\n ${fmt.bold(category.category)}:`);
236
-
237
- for (const example of category.examples) {
238
- console.log(` ${status.info} ${fmt.green(`"${example.input}"`)}`);
239
- console.log(` ${fmt.dim('→')} ${fmt.dim(example.flow)}`);
240
- console.log('');
241
- }
242
- }
243
- }
244
-
245
- /**
246
- * Display advanced usage information
247
- */
248
- function displayAdvancedUsage() {
249
- console.log(fmt.bold('\nšŸ”§ Advanced Usage:'));
250
- console.log(separator(60, '─'));
251
-
252
- console.log(fmt.bold('\n Provider Setup:'));
253
- const providers = [
254
- {
255
- name: 'Claude',
256
- install: 'pip install anthropic-cli',
257
- auth: 'claude auth login',
258
- models: 'Opus (Manager), Sonnet (IC), Haiku (Worker)'
259
- },
260
- {
261
- name: 'Codex',
262
- install: 'npm install -g @openai/codex',
263
- auth: 'codex login',
264
- models: 'GPT-5.5 (Manager), GPT-5.4 (IC), GPT-4.1-mini (Worker)'
265
- }
266
- ];
267
-
268
- for (const provider of providers) {
269
- console.log(`\n ${fmt.bold(provider.name)}:`);
270
- console.log(` Install: ${fmt.cyan(provider.install)}`);
271
- console.log(` Auth: ${fmt.cyan(provider.auth)}`);
272
- console.log(` Models: ${fmt.dim(provider.models)}`);
273
- }
274
-
275
- console.log(fmt.bold('\n Reset Levels:'));
276
- const resetLevels = [
277
- { level: 'sessions', desc: 'Clear current session but keep archives and auth' },
278
- { level: 'state', desc: 'Clear all state files but keep auth and archives' },
279
- { level: 'all', desc: 'Clear everything except authentication' },
280
- { level: 'nuclear', desc: 'Clear absolutely everything including authentication' }
281
- ];
282
-
283
- for (const level of resetLevels) {
284
- console.log(` ${fmt.cyan(level.level.padEnd(10))} — ${level.desc}`);
285
- }
286
-
287
- console.log(fmt.bold('\n Flags:'));
288
- const flags = [
289
- { flag: '--force', desc: 'Skip confirmations for destructive operations' },
290
- { flag: '--preview', desc: 'Show what would be affected without doing it' },
291
- { flag: '--verbose', desc: 'Show detailed output and debug information' }
292
- ];
293
-
294
- for (const flag of flags) {
295
- console.log(` ${fmt.cyan(flag.flag.padEnd(12))} — ${flag.desc}`);
296
- }
297
-
298
- console.log(fmt.bold('\n Interactive Commands:'));
299
- const interactiveCommands = [
300
- { cmd: '/help', desc: 'Show available chat commands' },
301
- { cmd: '/clear', desc: 'Clear screen and show session info' },
302
- { cmd: '/status', desc: 'Show current session statistics' },
303
- { cmd: '/quit or /exit', desc: 'Exit Cortex gracefully' }
304
- ];
305
-
306
- for (const cmd of interactiveCommands) {
307
- console.log(` ${fmt.cyan(cmd.cmd.padEnd(15))} — ${cmd.desc}`);
308
- }
309
-
310
- console.log(fmt.bold('\n Tips:'));
311
- const tips = [
312
- 'You need at least one authenticated provider to use Cortex',
313
- 'Both providers enable redundancy and different model capabilities',
314
- 'Cortex automatically chooses the best model for each task',
315
- 'Sessions are automatically saved and can be resumed later',
316
- 'Use --doctor if you encounter any issues'
317
- ];
318
-
319
- for (const tip of tips) {
320
- console.log(` ${status.info} ${tip}`);
321
- }
322
-
323
- console.log('');
324
- }