myshell-tools 1.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.
- package/CHANGELOG.md +69 -0
- package/LICENSE +21 -0
- package/README.md +318 -0
- package/data/orchestrator.json +113 -0
- package/package.json +49 -0
- package/src/auth/recovery.mjs +328 -0
- package/src/auth/refresh.mjs +373 -0
- package/src/chef.mjs +348 -0
- package/src/cli/doctor.mjs +568 -0
- package/src/cli/reset.mjs +447 -0
- package/src/cli/status.mjs +379 -0
- package/src/cli.mjs +429 -0
- package/src/commands/doctor.mjs +375 -0
- package/src/commands/help.mjs +324 -0
- package/src/commands/status.mjs +331 -0
- package/src/monitor/health.mjs +486 -0
- package/src/monitor/performance.mjs +442 -0
- package/src/monitor/report.mjs +535 -0
- package/src/orchestrator/classify.mjs +391 -0
- package/src/orchestrator/confidence.mjs +151 -0
- package/src/orchestrator/handoffs.mjs +231 -0
- package/src/orchestrator/review.mjs +222 -0
- package/src/providers/balance.mjs +201 -0
- package/src/providers/claude.mjs +236 -0
- package/src/providers/codex.mjs +255 -0
- package/src/providers/detect.mjs +185 -0
- package/src/providers/errors.mjs +373 -0
- package/src/providers/select.mjs +162 -0
- package/src/repl-enhanced.mjs +417 -0
- package/src/repl.mjs +321 -0
- package/src/state/archive.mjs +366 -0
- package/src/state/atomic.mjs +116 -0
- package/src/state/cleanup.mjs +440 -0
- package/src/state/recovery.mjs +461 -0
- package/src/state/session.mjs +147 -0
- package/src/ui/errors.mjs +456 -0
- package/src/ui/formatter.mjs +327 -0
- package/src/ui/icons.mjs +318 -0
- package/src/ui/progress.mjs +468 -0
- package/templates/prompts/confidence-format.txt +14 -0
- package/templates/prompts/ic-with-feedback.txt +41 -0
- package/templates/prompts/ic.txt +13 -0
- package/templates/prompts/manager-review.txt +40 -0
- package/templates/prompts/manager.txt +14 -0
- package/templates/prompts/worker.txt +12 -0
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* status.mjs ā Live session metrics and system status display
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { getSessionSummary } from '../state/session.mjs';
|
|
6
|
+
import { detectEnvironment } from '../providers/detect.mjs';
|
|
7
|
+
import { fmt, box, separator, formatDuration, timeAgo, providerBalanceBar } from '../ui/formatter.mjs';
|
|
8
|
+
import { status, tier, session as sessionIcons, provider } from '../ui/icons.mjs';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Display comprehensive system status
|
|
12
|
+
*/
|
|
13
|
+
export function displayStatus(workingDir, options = {}) {
|
|
14
|
+
const { verbose = false } = options;
|
|
15
|
+
|
|
16
|
+
console.log(box('Cortex Status Dashboard', {
|
|
17
|
+
borderColor: fmt.blue(''),
|
|
18
|
+
padding: 1,
|
|
19
|
+
margin: 1
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
// Current Session
|
|
23
|
+
displayCurrentSession();
|
|
24
|
+
|
|
25
|
+
// System Status
|
|
26
|
+
displaySystemStatus();
|
|
27
|
+
|
|
28
|
+
// Provider Status
|
|
29
|
+
displayProviderStatus();
|
|
30
|
+
|
|
31
|
+
// Performance Metrics
|
|
32
|
+
displayPerformanceMetrics();
|
|
33
|
+
|
|
34
|
+
if (verbose) {
|
|
35
|
+
// Detailed Information
|
|
36
|
+
displayDetailedInfo(workingDir);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Quick Actions
|
|
40
|
+
displayQuickActions();
|
|
41
|
+
|
|
42
|
+
console.log('');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get quick status for minimal display
|
|
47
|
+
*/
|
|
48
|
+
export function getQuickStatus() {
|
|
49
|
+
const sessionSummary = getSessionSummary();
|
|
50
|
+
const env = detectEnvironment();
|
|
51
|
+
|
|
52
|
+
const activeSession = sessionSummary.messageCount > 0;
|
|
53
|
+
const sessionIcon = activeSession ? sessionIcons.active : sessionIcons.new;
|
|
54
|
+
const providerCount = (env.claude.authed ? 1 : 0) + (env.codex.authed ? 1 : 0);
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
session: {
|
|
58
|
+
active: activeSession,
|
|
59
|
+
messageCount: sessionSummary.messageCount,
|
|
60
|
+
duration: sessionSummary.duration || 0
|
|
61
|
+
},
|
|
62
|
+
providers: {
|
|
63
|
+
count: providerCount,
|
|
64
|
+
claude: env.claude.authed,
|
|
65
|
+
codex: env.codex.authed
|
|
66
|
+
},
|
|
67
|
+
status: providerCount > 0 ? 'ready' : 'needs_auth'
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Display current session information
|
|
73
|
+
*/
|
|
74
|
+
function displayCurrentSession() {
|
|
75
|
+
const sessionSummary = getSessionSummary();
|
|
76
|
+
|
|
77
|
+
console.log(fmt.bold('\nš¬ Current Session:'));
|
|
78
|
+
console.log(separator(50, 'ā'));
|
|
79
|
+
|
|
80
|
+
if (sessionSummary.messageCount === 0) {
|
|
81
|
+
console.log(` ${sessionIcons.new} ${fmt.dim('No active session')}`);
|
|
82
|
+
console.log(` ${status.info} Start chatting to begin a new session`);
|
|
83
|
+
} else {
|
|
84
|
+
const sessionStatus = sessionIcons.active;
|
|
85
|
+
const duration = sessionSummary.duration ? formatDuration(sessionSummary.duration) : 'Unknown';
|
|
86
|
+
const lastActivity = sessionSummary.lastMessage
|
|
87
|
+
? timeAgo(sessionSummary.lastMessage.timestamp)
|
|
88
|
+
: 'Unknown';
|
|
89
|
+
|
|
90
|
+
console.log(` ${sessionStatus} ${fmt.bold('Active Session')}`);
|
|
91
|
+
console.log(` Messages: ${fmt.cyan(sessionSummary.messageCount)} (${sessionSummary.userMessageCount} user, ${sessionSummary.assistantMessageCount} assistant)`);
|
|
92
|
+
console.log(` Duration: ${fmt.cyan(duration)}`);
|
|
93
|
+
console.log(` Last Activity: ${fmt.cyan(lastActivity)}`);
|
|
94
|
+
|
|
95
|
+
// Show recent activity
|
|
96
|
+
if (sessionSummary.lastMessage) {
|
|
97
|
+
const preview = sessionSummary.lastMessage.content.slice(0, 60);
|
|
98
|
+
const truncated = sessionSummary.lastMessage.content.length > 60 ? '...' : '';
|
|
99
|
+
console.log(` Last Message: ${fmt.dim(`"${preview}${truncated}"`)}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
console.log('');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Display system status overview
|
|
108
|
+
*/
|
|
109
|
+
function displaySystemStatus() {
|
|
110
|
+
const env = detectEnvironment();
|
|
111
|
+
const quickStatus = getQuickStatus();
|
|
112
|
+
|
|
113
|
+
console.log(fmt.bold('\nš„ System Status:'));
|
|
114
|
+
console.log(separator(50, 'ā'));
|
|
115
|
+
|
|
116
|
+
// Overall health
|
|
117
|
+
let healthIcon, healthText;
|
|
118
|
+
switch (quickStatus.status) {
|
|
119
|
+
case 'ready':
|
|
120
|
+
healthIcon = status.success;
|
|
121
|
+
healthText = fmt.green('Operational');
|
|
122
|
+
break;
|
|
123
|
+
case 'needs_auth':
|
|
124
|
+
healthIcon = status.warning;
|
|
125
|
+
healthText = fmt.yellow('Needs Authentication');
|
|
126
|
+
break;
|
|
127
|
+
default:
|
|
128
|
+
healthIcon = status.error;
|
|
129
|
+
healthText = fmt.red('Unknown');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
console.log(` ${healthIcon} Health: ${healthText}`);
|
|
133
|
+
console.log(` š Workspace: ${fmt.cyan(env.workspace)}`);
|
|
134
|
+
console.log(` š Providers: ${quickStatus.providers.count}/2 authenticated`);
|
|
135
|
+
|
|
136
|
+
console.log('');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Display provider status with details
|
|
141
|
+
*/
|
|
142
|
+
function displayProviderStatus() {
|
|
143
|
+
const env = detectEnvironment();
|
|
144
|
+
|
|
145
|
+
console.log(fmt.bold('\nš¤ Providers:'));
|
|
146
|
+
console.log(separator(50, 'ā'));
|
|
147
|
+
|
|
148
|
+
// Claude status
|
|
149
|
+
const claudeIcon = provider.claude;
|
|
150
|
+
const claudeStatus = env.claude.authed ? status.success : env.claude.installed ? status.warning : status.error;
|
|
151
|
+
const claudeText = env.claude.authed ? 'Ready' : env.claude.installed ? 'Not authenticated' : 'Not installed';
|
|
152
|
+
|
|
153
|
+
console.log(` ${claudeIcon} Claude: ${claudeStatus} ${claudeText}`);
|
|
154
|
+
|
|
155
|
+
if (env.claude.version) {
|
|
156
|
+
console.log(` Version: ${fmt.dim(env.claude.version)}`);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (env.claude.authed) {
|
|
160
|
+
console.log(` Models: ${fmt.green('Opus, Sonnet, Haiku')}`);
|
|
161
|
+
} else if (env.claude.installed) {
|
|
162
|
+
console.log(` ${status.info} Run: ${fmt.cyan('claude auth login')}`);
|
|
163
|
+
} else {
|
|
164
|
+
console.log(` ${status.info} Install: ${fmt.cyan('pip install anthropic-cli')}`);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Codex status
|
|
168
|
+
const codexIcon = provider.codex;
|
|
169
|
+
const codexStatus = env.codex.authed ? status.success : env.codex.installed ? status.warning : status.error;
|
|
170
|
+
const codexText = env.codex.authed ? 'Ready' : env.codex.installed ? 'Not authenticated' : 'Not installed';
|
|
171
|
+
|
|
172
|
+
console.log(` ${codexIcon} Codex: ${codexStatus} ${codexText}`);
|
|
173
|
+
|
|
174
|
+
if (env.codex.version) {
|
|
175
|
+
console.log(` Version: ${fmt.dim(env.codex.version)}`);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (env.codex.authed) {
|
|
179
|
+
console.log(` Models: ${fmt.green('GPT-5.5, GPT-5.4, GPT-4.1-mini')}`);
|
|
180
|
+
} else if (env.codex.installed) {
|
|
181
|
+
console.log(` ${status.info} Run: ${fmt.cyan('codex login')}`);
|
|
182
|
+
} else {
|
|
183
|
+
console.log(` ${status.info} Install: ${fmt.cyan('npm install -g @openai/codex')}`);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Usage balance
|
|
187
|
+
const balance = mockGetTodaysBalance(); // Replace with real implementation
|
|
188
|
+
if (balance.total > 0) {
|
|
189
|
+
console.log(`\n š Today's Usage Balance:`);
|
|
190
|
+
console.log(` ${providerBalanceBar(balance.claude, balance.openai)}`);
|
|
191
|
+
console.log(` ${fmt.dim(balance.label + ' ⢠' + balance.total + ' calls')}`);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
console.log('');
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Display performance metrics
|
|
199
|
+
*/
|
|
200
|
+
function displayPerformanceMetrics() {
|
|
201
|
+
console.log(fmt.bold('\nš Performance:'));
|
|
202
|
+
console.log(separator(50, 'ā'));
|
|
203
|
+
|
|
204
|
+
// Mock performance data - replace with real metrics
|
|
205
|
+
const metrics = mockGetPerformanceMetrics();
|
|
206
|
+
|
|
207
|
+
console.log(` ā” Average Response Time: ${fmt.green(metrics.avgResponseTime)}`);
|
|
208
|
+
console.log(` šÆ Success Rate: ${fmt.green(metrics.successRate)}`);
|
|
209
|
+
console.log(` š Escalation Rate: ${fmt.yellow(metrics.escalationRate)}`);
|
|
210
|
+
|
|
211
|
+
if (metrics.tokensToday > 0) {
|
|
212
|
+
console.log(` š¢ Tokens Today: ${fmt.cyan(metrics.tokensToday.toLocaleString())}`);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (metrics.costToday > 0) {
|
|
216
|
+
console.log(` š° Estimated Cost Today: ${fmt.cyan('$' + metrics.costToday.toFixed(2))}`);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
console.log('');
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Display detailed information (verbose mode)
|
|
224
|
+
*/
|
|
225
|
+
function displayDetailedInfo(workingDir) {
|
|
226
|
+
console.log(fmt.bold('\nš Detailed Information:'));
|
|
227
|
+
console.log(separator(50, 'ā'));
|
|
228
|
+
|
|
229
|
+
// Session directory details
|
|
230
|
+
const sessionPath = `${workingDir}/.cortex/sessions/`;
|
|
231
|
+
console.log(` š Session Directory: ${fmt.cyan(sessionPath)}`);
|
|
232
|
+
|
|
233
|
+
try {
|
|
234
|
+
// Mock file count - replace with real directory reading
|
|
235
|
+
const fileCount = 12; // Mock count
|
|
236
|
+
const totalSize = '2.3MB'; // Mock size
|
|
237
|
+
console.log(` Files: ${fmt.dim(fileCount)} session files`);
|
|
238
|
+
console.log(` Size: ${fmt.dim(totalSize)} total`);
|
|
239
|
+
} catch (error) {
|
|
240
|
+
console.log(` ${status.error} Error reading directory: ${error.message}`);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Configuration status
|
|
244
|
+
console.log(` āļø Configuration:`);
|
|
245
|
+
console.log(` Timeout: ${fmt.dim('120 seconds')}`);
|
|
246
|
+
console.log(` Auto-escalation: ${fmt.green('Enabled')}`);
|
|
247
|
+
console.log(` Session archiving: ${fmt.green('Enabled')}`);
|
|
248
|
+
|
|
249
|
+
// Recent activity
|
|
250
|
+
console.log(` š Recent Activity:`);
|
|
251
|
+
const recentSessions = mockGetRecentSessions(); // Replace with real data
|
|
252
|
+
|
|
253
|
+
if (recentSessions.length === 0) {
|
|
254
|
+
console.log(` ${fmt.dim('No recent sessions')}`);
|
|
255
|
+
} else {
|
|
256
|
+
recentSessions.slice(0, 3).forEach((session, index) => {
|
|
257
|
+
const timeDisplay = timeAgo(session.timestamp);
|
|
258
|
+
const preview = session.preview.slice(0, 30);
|
|
259
|
+
console.log(` ${fmt.dim(`${index + 1}.`)} ${timeDisplay} - ${fmt.dim(`"${preview}..."`)}`);
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
console.log('');
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Display available quick actions
|
|
268
|
+
*/
|
|
269
|
+
function displayQuickActions() {
|
|
270
|
+
console.log(fmt.bold('\nā” Quick Actions:'));
|
|
271
|
+
console.log(separator(50, 'ā'));
|
|
272
|
+
|
|
273
|
+
console.log(` ${fmt.cyan('cortex --doctor')} Run full health check`);
|
|
274
|
+
console.log(` ${fmt.cyan('cortex --reset')} Reset session state`);
|
|
275
|
+
console.log(` ${fmt.cyan('cortex --cleanup')} Clean up old files`);
|
|
276
|
+
console.log(` ${fmt.cyan('cortex --help')} Show all commands`);
|
|
277
|
+
|
|
278
|
+
const quickStatus = getQuickStatus();
|
|
279
|
+
if (quickStatus.status === 'needs_auth') {
|
|
280
|
+
console.log(`\n ${status.warning} ${fmt.yellow('Authentication needed to start chatting')}`);
|
|
281
|
+
} else if (!quickStatus.session.active) {
|
|
282
|
+
console.log(`\n ${status.info} ${fmt.green('Ready to start chatting!')}`);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
console.log('');
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Mock function for today's usage balance
|
|
290
|
+
*/
|
|
291
|
+
function mockGetTodaysBalance() {
|
|
292
|
+
return {
|
|
293
|
+
claude: 35,
|
|
294
|
+
openai: 65,
|
|
295
|
+
total: 18,
|
|
296
|
+
label: 'GPT-heavy ā Claude has capacity'
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Mock function for performance metrics
|
|
302
|
+
*/
|
|
303
|
+
function mockGetPerformanceMetrics() {
|
|
304
|
+
return {
|
|
305
|
+
avgResponseTime: '1.4s',
|
|
306
|
+
successRate: '94.2%',
|
|
307
|
+
escalationRate: '12.5%',
|
|
308
|
+
tokensToday: 45_230,
|
|
309
|
+
costToday: 3.42
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Mock function for recent sessions
|
|
315
|
+
*/
|
|
316
|
+
function mockGetRecentSessions() {
|
|
317
|
+
return [
|
|
318
|
+
{
|
|
319
|
+
timestamp: Date.now() - 2 * 60 * 60 * 1000, // 2 hours ago
|
|
320
|
+
preview: 'Fix the authentication bug in the login flow'
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
timestamp: Date.now() - 5 * 60 * 60 * 1000, // 5 hours ago
|
|
324
|
+
preview: 'Add error handling to the API endpoints'
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
timestamp: Date.now() - 12 * 60 * 60 * 1000, // 12 hours ago
|
|
328
|
+
preview: 'Implement user dashboard components'
|
|
329
|
+
}
|
|
330
|
+
];
|
|
331
|
+
}
|