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.
- package/CHANGELOG.md +44 -69
- package/LICENSE +21 -21
- package/README.md +178 -318
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +106 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/cost.d.ts +36 -0
- package/dist/commands/cost.js +103 -0
- package/dist/commands/cost.js.map +1 -0
- package/dist/commands/doctor.d.ts +36 -0
- package/dist/commands/doctor.js +115 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/core/assess.d.ts +25 -0
- package/dist/core/assess.js +142 -0
- package/dist/core/assess.js.map +1 -0
- package/dist/core/classify.d.ts +19 -0
- package/dist/core/classify.js +80 -0
- package/dist/core/classify.js.map +1 -0
- package/dist/core/escalate.d.ts +32 -0
- package/dist/core/escalate.js +57 -0
- package/dist/core/escalate.js.map +1 -0
- package/dist/core/index.d.ts +13 -0
- package/dist/core/index.js +12 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/orchestrate.d.ts +42 -0
- package/dist/core/orchestrate.js +439 -0
- package/dist/core/orchestrate.js.map +1 -0
- package/dist/core/policy.d.ts +9 -0
- package/dist/core/policy.js +27 -0
- package/dist/core/policy.js.map +1 -0
- package/dist/core/prompt.d.ts +26 -0
- package/dist/core/prompt.js +125 -0
- package/dist/core/prompt.js.map +1 -0
- package/dist/core/review.d.ts +46 -0
- package/dist/core/review.js +148 -0
- package/dist/core/review.js.map +1 -0
- package/dist/core/route.d.ts +28 -0
- package/dist/core/route.js +52 -0
- package/dist/core/route.js.map +1 -0
- package/dist/core/types.d.ts +141 -0
- package/dist/core/types.js +14 -0
- package/dist/core/types.js.map +1 -0
- package/dist/infra/atomic.d.ts +53 -0
- package/dist/infra/atomic.js +171 -0
- package/dist/infra/atomic.js.map +1 -0
- package/dist/infra/clock.d.ts +9 -0
- package/dist/infra/clock.js +15 -0
- package/dist/infra/clock.js.map +1 -0
- package/dist/infra/index.d.ts +9 -0
- package/dist/infra/index.js +7 -0
- package/dist/infra/index.js.map +1 -0
- package/dist/infra/ledger.d.ts +49 -0
- package/dist/infra/ledger.js +90 -0
- package/dist/infra/ledger.js.map +1 -0
- package/dist/infra/paths.d.ts +28 -0
- package/dist/infra/paths.js +38 -0
- package/dist/infra/paths.js.map +1 -0
- package/dist/infra/pricing.d.ts +47 -0
- package/dist/infra/pricing.js +151 -0
- package/dist/infra/pricing.js.map +1 -0
- package/dist/infra/session.d.ts +28 -0
- package/dist/infra/session.js +61 -0
- package/dist/infra/session.js.map +1 -0
- package/dist/interface/render.d.ts +27 -0
- package/dist/interface/render.js +134 -0
- package/dist/interface/render.js.map +1 -0
- package/dist/interface/repl.d.ts +23 -0
- package/dist/interface/repl.js +90 -0
- package/dist/interface/repl.js.map +1 -0
- package/dist/interface/run.d.ts +20 -0
- package/dist/interface/run.js +31 -0
- package/dist/interface/run.js.map +1 -0
- package/dist/providers/claude-parse.d.ts +24 -0
- package/dist/providers/claude-parse.js +113 -0
- package/dist/providers/claude-parse.js.map +1 -0
- package/dist/providers/claude.d.ts +45 -0
- package/dist/providers/claude.js +122 -0
- package/dist/providers/claude.js.map +1 -0
- package/dist/providers/codex-parse.d.ts +32 -0
- package/dist/providers/codex-parse.js +145 -0
- package/dist/providers/codex-parse.js.map +1 -0
- package/dist/providers/codex.d.ts +44 -0
- package/dist/providers/codex.js +124 -0
- package/dist/providers/codex.js.map +1 -0
- package/dist/providers/detect.d.ts +49 -0
- package/dist/providers/detect.js +125 -0
- package/dist/providers/detect.js.map +1 -0
- package/dist/providers/errors.d.ts +49 -0
- package/dist/providers/errors.js +189 -0
- package/dist/providers/errors.js.map +1 -0
- package/dist/providers/index.d.ts +9 -0
- package/dist/providers/index.js +7 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/port.d.ts +74 -0
- package/dist/providers/port.js +16 -0
- package/dist/providers/port.js.map +1 -0
- package/dist/providers/registry.d.ts +21 -0
- package/dist/providers/registry.js +34 -0
- package/dist/providers/registry.js.map +1 -0
- package/dist/ui/banner.d.ts +19 -0
- package/dist/ui/banner.js +32 -0
- package/dist/ui/banner.js.map +1 -0
- package/dist/ui/spinner.d.ts +27 -0
- package/dist/ui/spinner.js +67 -0
- package/dist/ui/spinner.js.map +1 -0
- package/dist/ui/theme.d.ts +32 -0
- package/dist/ui/theme.js +56 -0
- package/dist/ui/theme.js.map +1 -0
- package/package.json +55 -49
- package/data/orchestrator.json +0 -113
- package/src/auth/recovery.mjs +0 -328
- package/src/auth/refresh.mjs +0 -373
- package/src/chef.mjs +0 -348
- package/src/cli/doctor.mjs +0 -568
- package/src/cli/reset.mjs +0 -447
- package/src/cli/status.mjs +0 -379
- package/src/cli.mjs +0 -429
- package/src/commands/doctor.mjs +0 -375
- package/src/commands/help.mjs +0 -324
- package/src/commands/status.mjs +0 -331
- package/src/monitor/health.mjs +0 -486
- package/src/monitor/performance.mjs +0 -442
- package/src/monitor/report.mjs +0 -535
- package/src/orchestrator/classify.mjs +0 -391
- package/src/orchestrator/confidence.mjs +0 -151
- package/src/orchestrator/handoffs.mjs +0 -231
- package/src/orchestrator/review.mjs +0 -222
- package/src/providers/balance.mjs +0 -201
- package/src/providers/claude.mjs +0 -236
- package/src/providers/codex.mjs +0 -255
- package/src/providers/detect.mjs +0 -185
- package/src/providers/errors.mjs +0 -373
- package/src/providers/select.mjs +0 -162
- package/src/repl-enhanced.mjs +0 -417
- package/src/repl.mjs +0 -321
- package/src/state/archive.mjs +0 -366
- package/src/state/atomic.mjs +0 -116
- package/src/state/cleanup.mjs +0 -440
- package/src/state/recovery.mjs +0 -461
- package/src/state/session.mjs +0 -147
- package/src/ui/errors.mjs +0 -456
- package/src/ui/formatter.mjs +0 -327
- package/src/ui/icons.mjs +0 -318
- package/src/ui/progress.mjs +0 -468
- package/templates/prompts/confidence-format.txt +0 -14
- package/templates/prompts/ic-with-feedback.txt +0 -41
- package/templates/prompts/ic.txt +0 -13
- package/templates/prompts/manager-review.txt +0 -40
- package/templates/prompts/manager.txt +0 -14
- package/templates/prompts/worker.txt +0 -12
package/src/commands/doctor.mjs
DELETED
|
@@ -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
|
-
}
|
package/src/commands/help.mjs
DELETED
|
@@ -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
|
-
}
|