@codemieai/code 0.0.36 → 0.0.37
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/README.md +33 -0
- package/dist/agents/codemie-code/tools/assistant-invocation.d.ts.map +1 -1
- package/dist/agents/codemie-code/tools/assistant-invocation.js +2 -2
- package/dist/agents/codemie-code/tools/assistant-invocation.js.map +1 -1
- package/dist/agents/core/extension/BaseExtensionInstaller.d.ts.map +1 -1
- package/dist/agents/core/extension/BaseExtensionInstaller.js +11 -4
- package/dist/agents/core/extension/BaseExtensionInstaller.js.map +1 -1
- package/dist/agents/core/session/BaseProcessor.d.ts +22 -1
- package/dist/agents/core/session/BaseProcessor.d.ts.map +1 -1
- package/dist/agents/plugins/claude/claude-acp.plugin.d.ts +5 -0
- package/dist/agents/plugins/claude/claude-acp.plugin.d.ts.map +1 -1
- package/dist/agents/plugins/claude/claude-acp.plugin.js +12 -2
- package/dist/agents/plugins/claude/claude-acp.plugin.js.map +1 -1
- package/dist/agents/plugins/claude/claude.plugin.d.ts.map +1 -1
- package/dist/agents/plugins/claude/claude.plugin.js +4 -0
- package/dist/agents/plugins/claude/claude.plugin.js.map +1 -1
- package/dist/agents/plugins/claude/claude.session.d.ts +5 -0
- package/dist/agents/plugins/claude/claude.session.d.ts.map +1 -1
- package/dist/agents/plugins/claude/claude.session.js +101 -2
- package/dist/agents/plugins/claude/claude.session.js.map +1 -1
- package/dist/agents/plugins/claude/plugin/.claude-plugin/plugin.json +1 -1
- package/dist/agents/plugins/claude/session/processors/claude.conversations-processor.d.ts +0 -1
- package/dist/agents/plugins/claude/session/processors/claude.conversations-processor.d.ts.map +1 -1
- package/dist/agents/plugins/claude/session/processors/claude.conversations-processor.js +13 -19
- package/dist/agents/plugins/claude/session/processors/claude.conversations-processor.js.map +1 -1
- package/dist/agents/plugins/claude/session/processors/claude.metrics-processor.d.ts.map +1 -1
- package/dist/agents/plugins/claude/session/processors/claude.metrics-processor.js +29 -4
- package/dist/agents/plugins/claude/session/processors/claude.metrics-processor.js.map +1 -1
- package/dist/cli/commands/assistants/chat.js +9 -6
- package/dist/cli/commands/assistants/chat.js.map +1 -1
- package/dist/cli/commands/assistants/constants.d.ts +2 -6
- package/dist/cli/commands/assistants/constants.d.ts.map +1 -1
- package/dist/cli/commands/assistants/constants.js +2 -5
- package/dist/cli/commands/assistants/constants.js.map +1 -1
- package/dist/cli/commands/assistants/index.d.ts.map +1 -1
- package/dist/cli/commands/assistants/index.js +1 -11
- package/dist/cli/commands/assistants/index.js.map +1 -1
- package/dist/cli/commands/assistants/setup/configuration/actions.d.ts +30 -0
- package/dist/cli/commands/assistants/setup/configuration/actions.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/configuration/actions.js +63 -0
- package/dist/cli/commands/assistants/setup/configuration/actions.js.map +1 -0
- package/dist/cli/commands/assistants/setup/configuration/constants.d.ts +49 -0
- package/dist/cli/commands/assistants/setup/configuration/constants.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/configuration/constants.js +56 -0
- package/dist/cli/commands/assistants/setup/configuration/constants.js.map +1 -0
- package/dist/cli/commands/assistants/setup/configuration/index.d.ts +9 -0
- package/dist/cli/commands/assistants/setup/configuration/index.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/configuration/index.js +8 -0
- package/dist/cli/commands/assistants/setup/configuration/index.js.map +1 -0
- package/dist/cli/commands/assistants/setup/configuration/selection.d.ts +12 -0
- package/dist/cli/commands/assistants/setup/configuration/selection.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/configuration/selection.js +94 -0
- package/dist/cli/commands/assistants/setup/configuration/selection.js.map +1 -0
- package/dist/cli/commands/assistants/setup/configuration/types.d.ts +22 -0
- package/dist/cli/commands/assistants/setup/configuration/types.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/configuration/types.js +2 -0
- package/dist/cli/commands/assistants/setup/configuration/types.js.map +1 -0
- package/dist/cli/commands/assistants/setup/configuration/ui.d.ts +9 -0
- package/dist/cli/commands/assistants/setup/configuration/ui.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/configuration/ui.js +86 -0
- package/dist/cli/commands/assistants/setup/configuration/ui.js.map +1 -0
- package/dist/cli/commands/assistants/setup/constants.d.ts +26 -0
- package/dist/cli/commands/assistants/setup/constants.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/constants.js +21 -0
- package/dist/cli/commands/assistants/setup/constants.js.map +1 -0
- package/dist/cli/commands/assistants/setup/data.d.ts +30 -0
- package/dist/cli/commands/assistants/setup/data.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/data.js +125 -0
- package/dist/cli/commands/assistants/setup/data.js.map +1 -0
- package/dist/cli/commands/assistants/setup/generators/claude-agent-generator.d.ts.map +1 -0
- package/dist/cli/commands/assistants/{generators → setup/generators}/claude-agent-generator.js +6 -2
- package/dist/cli/commands/assistants/setup/generators/claude-agent-generator.js.map +1 -0
- package/dist/cli/commands/assistants/setup/generators/claude-skill-generator.d.ts +12 -0
- package/dist/cli/commands/assistants/setup/generators/claude-skill-generator.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/generators/claude-skill-generator.js +94 -0
- package/dist/cli/commands/assistants/setup/generators/claude-skill-generator.js.map +1 -0
- package/dist/cli/commands/assistants/setup/helpers.d.ts +27 -0
- package/dist/cli/commands/assistants/setup/helpers.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/helpers.js +94 -0
- package/dist/cli/commands/assistants/setup/helpers.js.map +1 -0
- package/dist/cli/commands/assistants/setup/index.d.ts +17 -0
- package/dist/cli/commands/assistants/setup/index.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/index.js +193 -0
- package/dist/cli/commands/assistants/setup/index.js.map +1 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/actions.d.ts +47 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/actions.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/actions.js +140 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/actions.js.map +1 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/constants.d.ts +56 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/constants.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/constants.js +61 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/constants.js.map +1 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/index.d.ts +12 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/index.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/index.js +48 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/index.js.map +1 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/interactive-prompt.d.ts +6 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/interactive-prompt.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/interactive-prompt.js +90 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/interactive-prompt.js.map +1 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/types.d.ts +37 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/types.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/types.js +2 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/types.js.map +1 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/ui.d.ts +6 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/ui.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/ui.js +103 -0
- package/dist/cli/commands/assistants/setup/manualConfiguration/ui.js.map +1 -0
- package/dist/cli/commands/assistants/setup/selection/actions.d.ts +31 -0
- package/dist/cli/commands/assistants/setup/selection/actions.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/selection/actions.js +321 -0
- package/dist/cli/commands/assistants/setup/selection/actions.js.map +1 -0
- package/dist/cli/commands/assistants/setup/selection/constants.d.ts +79 -0
- package/dist/cli/commands/assistants/setup/selection/constants.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/selection/constants.js +90 -0
- package/dist/cli/commands/assistants/setup/selection/constants.js.map +1 -0
- package/dist/cli/commands/assistants/setup/selection/index.d.ts +25 -0
- package/dist/cli/commands/assistants/setup/selection/index.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/selection/index.js +127 -0
- package/dist/cli/commands/assistants/setup/selection/index.js.map +1 -0
- package/dist/cli/commands/assistants/setup/selection/interactive-prompt.d.ts +20 -0
- package/dist/cli/commands/assistants/setup/selection/interactive-prompt.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/selection/interactive-prompt.js +328 -0
- package/dist/cli/commands/assistants/setup/selection/interactive-prompt.js.map +1 -0
- package/dist/cli/commands/assistants/setup/selection/types.d.ts +27 -0
- package/dist/cli/commands/assistants/setup/selection/types.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/selection/types.js +2 -0
- package/dist/cli/commands/assistants/setup/selection/types.js.map +1 -0
- package/dist/cli/commands/assistants/setup/selection/ui.d.ts +11 -0
- package/dist/cli/commands/assistants/setup/selection/ui.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/selection/ui.js +189 -0
- package/dist/cli/commands/assistants/setup/selection/ui.js.map +1 -0
- package/dist/cli/commands/assistants/setup/selection/utils.d.ts +36 -0
- package/dist/cli/commands/assistants/setup/selection/utils.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/selection/utils.js +55 -0
- package/dist/cli/commands/assistants/setup/selection/utils.js.map +1 -0
- package/dist/cli/commands/assistants/setup/summary/index.d.ts +16 -0
- package/dist/cli/commands/assistants/setup/summary/index.d.ts.map +1 -0
- package/dist/cli/commands/assistants/setup/summary/index.js +48 -0
- package/dist/cli/commands/assistants/setup/summary/index.js.map +1 -0
- package/dist/cli/commands/log/cleaner.d.ts +33 -0
- package/dist/cli/commands/log/cleaner.d.ts.map +1 -0
- package/dist/cli/commands/log/cleaner.js +214 -0
- package/dist/cli/commands/log/cleaner.js.map +1 -0
- package/dist/cli/commands/log/filter.d.ts +55 -0
- package/dist/cli/commands/log/filter.d.ts.map +1 -0
- package/dist/cli/commands/log/filter.js +128 -0
- package/dist/cli/commands/log/filter.js.map +1 -0
- package/dist/cli/commands/log/follower.d.ts +36 -0
- package/dist/cli/commands/log/follower.d.ts.map +1 -0
- package/dist/cli/commands/log/follower.js +151 -0
- package/dist/cli/commands/log/follower.js.map +1 -0
- package/dist/cli/commands/log/formatter.d.ts +76 -0
- package/dist/cli/commands/log/formatter.d.ts.map +1 -0
- package/dist/cli/commands/log/formatter.js +261 -0
- package/dist/cli/commands/log/formatter.js.map +1 -0
- package/dist/cli/commands/log/index.d.ts +6 -0
- package/dist/cli/commands/log/index.d.ts.map +1 -0
- package/dist/cli/commands/log/index.js +398 -0
- package/dist/cli/commands/log/index.js.map +1 -0
- package/dist/cli/commands/log/parser.d.ts +20 -0
- package/dist/cli/commands/log/parser.d.ts.map +1 -0
- package/dist/cli/commands/log/parser.js +111 -0
- package/dist/cli/commands/log/parser.js.map +1 -0
- package/dist/cli/commands/log/reader.d.ts +61 -0
- package/dist/cli/commands/log/reader.d.ts.map +1 -0
- package/dist/cli/commands/log/reader.js +327 -0
- package/dist/cli/commands/log/reader.js.map +1 -0
- package/dist/cli/commands/log/types.d.ts +100 -0
- package/dist/cli/commands/log/types.d.ts.map +1 -0
- package/dist/cli/commands/log/types.js +5 -0
- package/dist/cli/commands/log/types.js.map +1 -0
- package/dist/cli/commands/setup.d.ts.map +1 -1
- package/dist/cli/commands/setup.js +2 -0
- package/dist/cli/commands/setup.js.map +1 -1
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/env/types.d.ts +1 -0
- package/dist/env/types.d.ts.map +1 -1
- package/dist/env/types.js.map +1 -1
- package/dist/providers/plugins/sso/session/SessionSyncer.d.ts +5 -0
- package/dist/providers/plugins/sso/session/SessionSyncer.d.ts.map +1 -1
- package/dist/providers/plugins/sso/session/SessionSyncer.js +102 -3
- package/dist/providers/plugins/sso/session/SessionSyncer.js.map +1 -1
- package/dist/providers/plugins/sso/session/processors/conversations/conversation-sync-processor.d.ts +0 -1
- package/dist/providers/plugins/sso/session/processors/conversations/conversation-sync-processor.d.ts.map +1 -1
- package/dist/providers/plugins/sso/session/processors/conversations/conversation-sync-processor.js +25 -48
- package/dist/providers/plugins/sso/session/processors/conversations/conversation-sync-processor.js.map +1 -1
- package/dist/providers/plugins/sso/session/processors/metrics/metrics-sync-processor.d.ts.map +1 -1
- package/dist/providers/plugins/sso/session/processors/metrics/metrics-sync-processor.js +8 -34
- package/dist/providers/plugins/sso/session/processors/metrics/metrics-sync-processor.js.map +1 -1
- package/dist/utils/native-installer.d.ts +1 -0
- package/dist/utils/native-installer.d.ts.map +1 -1
- package/dist/utils/native-installer.js +21 -7
- package/dist/utils/native-installer.js.map +1 -1
- package/package.json +2 -2
- package/dist/cli/commands/assistants/generators/claude-agent-generator.d.ts.map +0 -1
- package/dist/cli/commands/assistants/generators/claude-agent-generator.js.map +0 -1
- package/dist/cli/commands/assistants/list.d.ts +0 -11
- package/dist/cli/commands/assistants/list.d.ts.map +0 -1
- package/dist/cli/commands/assistants/list.js +0 -323
- package/dist/cli/commands/assistants/list.js.map +0 -1
- /package/dist/cli/commands/assistants/{generators → setup/generators}/claude-agent-generator.d.ts +0 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Log formatter - Output formatting for logs and sessions
|
|
3
|
+
*/
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
/**
|
|
6
|
+
* Format log entries for console output
|
|
7
|
+
*/
|
|
8
|
+
export class LogFormatter {
|
|
9
|
+
format;
|
|
10
|
+
constructor(format) {
|
|
11
|
+
this.format = {
|
|
12
|
+
format: format?.format || 'text',
|
|
13
|
+
colorize: format?.colorize ?? true,
|
|
14
|
+
verbose: format?.verbose ?? false
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Format log entries as text
|
|
19
|
+
*/
|
|
20
|
+
formatText(entries) {
|
|
21
|
+
if (entries.length === 0) {
|
|
22
|
+
return this.colorize(chalk.yellow('\nNo logs found matching the specified criteria.\n'));
|
|
23
|
+
}
|
|
24
|
+
const lines = [];
|
|
25
|
+
for (const entry of entries) {
|
|
26
|
+
lines.push(this.formatLogEntry(entry));
|
|
27
|
+
}
|
|
28
|
+
return lines.join('\n');
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Format a single log entry
|
|
32
|
+
*/
|
|
33
|
+
formatLogEntry(entry) {
|
|
34
|
+
const timestamp = this.formatTimestamp(entry.timestamp);
|
|
35
|
+
const level = this.formatLevel(entry.level);
|
|
36
|
+
const agent = this.colorize(chalk.cyan(`[${entry.agent}]`));
|
|
37
|
+
if (this.format.verbose) {
|
|
38
|
+
// Verbose format includes session ID and profile
|
|
39
|
+
const sessionId = entry.sessionId.substring(0, 8);
|
|
40
|
+
const profile = entry.profile ? this.colorize(chalk.magenta(`[${entry.profile}]`)) : '';
|
|
41
|
+
return `${timestamp} ${level} ${agent} ${this.colorize(chalk.dim(`[${sessionId}]`))} ${profile} ${entry.message}`.trim();
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// Compact format
|
|
45
|
+
return `${timestamp} ${level} ${agent} ${entry.message}`;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Format timestamp
|
|
50
|
+
*/
|
|
51
|
+
formatTimestamp(date) {
|
|
52
|
+
const timeStr = date.toISOString();
|
|
53
|
+
return this.colorize(chalk.dim(timeStr));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Format log level with color
|
|
57
|
+
*/
|
|
58
|
+
formatLevel(level) {
|
|
59
|
+
const levelUpper = level.toUpperCase().padEnd(5);
|
|
60
|
+
switch (level) {
|
|
61
|
+
case 'error':
|
|
62
|
+
return this.colorize(chalk.red(levelUpper));
|
|
63
|
+
case 'warn':
|
|
64
|
+
return this.colorize(chalk.yellow(levelUpper));
|
|
65
|
+
case 'info':
|
|
66
|
+
return this.colorize(chalk.green(levelUpper));
|
|
67
|
+
case 'debug':
|
|
68
|
+
default:
|
|
69
|
+
return this.colorize(chalk.blue(levelUpper));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Format log entries as JSON
|
|
74
|
+
*/
|
|
75
|
+
formatJSON(entries) {
|
|
76
|
+
const formatted = entries.map(entry => ({
|
|
77
|
+
timestamp: entry.timestamp.toISOString(),
|
|
78
|
+
level: entry.level,
|
|
79
|
+
agent: entry.agent,
|
|
80
|
+
sessionId: entry.sessionId,
|
|
81
|
+
profile: entry.profile,
|
|
82
|
+
message: entry.message
|
|
83
|
+
}));
|
|
84
|
+
return JSON.stringify(formatted, null, 2);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Format log entries as JSONL
|
|
88
|
+
*/
|
|
89
|
+
formatJSONL(entries) {
|
|
90
|
+
const lines = entries.map(entry => {
|
|
91
|
+
const obj = {
|
|
92
|
+
timestamp: entry.timestamp.toISOString(),
|
|
93
|
+
level: entry.level,
|
|
94
|
+
agent: entry.agent,
|
|
95
|
+
sessionId: entry.sessionId,
|
|
96
|
+
profile: entry.profile,
|
|
97
|
+
message: entry.message
|
|
98
|
+
};
|
|
99
|
+
return JSON.stringify(obj);
|
|
100
|
+
});
|
|
101
|
+
return lines.join('\n');
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Format session metadata for display
|
|
105
|
+
*/
|
|
106
|
+
formatSession(session, conversation) {
|
|
107
|
+
const lines = [];
|
|
108
|
+
lines.push(this.colorize(chalk.bold.cyan('\nSession Details\n')));
|
|
109
|
+
lines.push(this.formatKeyValue('Session ID', session.sessionId));
|
|
110
|
+
lines.push(this.formatKeyValue('Agent', session.agentName));
|
|
111
|
+
lines.push(this.formatKeyValue('Provider', session.provider));
|
|
112
|
+
lines.push(this.formatKeyValue('Status', this.formatStatus(session.status)));
|
|
113
|
+
lines.push(this.formatKeyValue('Working Directory', session.workingDirectory));
|
|
114
|
+
if (session.gitBranch) {
|
|
115
|
+
lines.push(this.formatKeyValue('Git Branch', session.gitBranch));
|
|
116
|
+
}
|
|
117
|
+
lines.push(this.formatKeyValue('Start Time', new Date(session.startTime).toISOString()));
|
|
118
|
+
if (session.endTime) {
|
|
119
|
+
lines.push(this.formatKeyValue('End Time', new Date(session.endTime).toISOString()));
|
|
120
|
+
const duration = this.formatDuration(session.endTime - session.startTime);
|
|
121
|
+
lines.push(this.formatKeyValue('Duration', duration));
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
lines.push(this.formatKeyValue('Duration', 'In progress'));
|
|
125
|
+
}
|
|
126
|
+
if (conversation && conversation.length > 0) {
|
|
127
|
+
lines.push('');
|
|
128
|
+
lines.push(this.colorize(chalk.bold.cyan('Conversation Summary\n')));
|
|
129
|
+
lines.push(this.formatKeyValue('Total Turns', conversation.length.toString()));
|
|
130
|
+
}
|
|
131
|
+
return lines.join('\n') + '\n';
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Format session list as table
|
|
135
|
+
*/
|
|
136
|
+
formatSessionList(sessions) {
|
|
137
|
+
if (sessions.length === 0) {
|
|
138
|
+
return this.colorize(chalk.yellow('\nNo sessions found.\n'));
|
|
139
|
+
}
|
|
140
|
+
const lines = [];
|
|
141
|
+
lines.push(this.colorize(chalk.bold.cyan('\nSessions\n')));
|
|
142
|
+
// Table header
|
|
143
|
+
const header = this.colorize(chalk.bold('SESSION ID AGENT START TIME DURATION STATUS DIRECTORY'));
|
|
144
|
+
lines.push(header);
|
|
145
|
+
lines.push(this.colorize(chalk.dim('─'.repeat(120))));
|
|
146
|
+
// Table rows
|
|
147
|
+
for (const session of sessions) {
|
|
148
|
+
const id = session.sessionId.substring(0, 16).padEnd(16);
|
|
149
|
+
const agent = session.agentName.padEnd(11);
|
|
150
|
+
const startTime = session.startTime.toISOString().padEnd(21);
|
|
151
|
+
const duration = session.duration
|
|
152
|
+
? this.formatDuration(session.duration).padEnd(11)
|
|
153
|
+
: 'in progress'.padEnd(11);
|
|
154
|
+
const status = this.formatStatus(session.status).padEnd(11);
|
|
155
|
+
const dir = this.truncatePath(session.workingDirectory, 40);
|
|
156
|
+
lines.push(`${id} ${agent} ${startTime} ${duration} ${status} ${dir}`);
|
|
157
|
+
}
|
|
158
|
+
lines.push('');
|
|
159
|
+
lines.push(this.colorize(chalk.dim(`Total: ${sessions.length} session(s)`)));
|
|
160
|
+
lines.push('');
|
|
161
|
+
return lines.join('\n');
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Format cleanup statistics
|
|
165
|
+
*/
|
|
166
|
+
formatCleanupStats(stats, isDryRun) {
|
|
167
|
+
const lines = [];
|
|
168
|
+
const title = isDryRun
|
|
169
|
+
? this.colorize(chalk.bold.yellow('\nCleanup Preview (Dry Run)\n'))
|
|
170
|
+
: this.colorize(chalk.bold.green('\nCleanup Complete\n'));
|
|
171
|
+
lines.push(title);
|
|
172
|
+
lines.push(this.formatKeyValue('Debug Logs Deleted', stats.debugLogsDeleted.toString()));
|
|
173
|
+
lines.push(this.formatKeyValue('Sessions Deleted', stats.sessionsDeleted.toString()));
|
|
174
|
+
lines.push(this.formatKeyValue('Space Freed', this.formatBytes(stats.bytesFreed)));
|
|
175
|
+
if (stats.oldestFileDate) {
|
|
176
|
+
lines.push(this.formatKeyValue('Oldest File Date', stats.oldestFileDate.toISOString().split('T')[0]));
|
|
177
|
+
}
|
|
178
|
+
if (stats.newestFileDate) {
|
|
179
|
+
lines.push(this.formatKeyValue('Newest File Date', stats.newestFileDate.toISOString().split('T')[0]));
|
|
180
|
+
}
|
|
181
|
+
if (isDryRun) {
|
|
182
|
+
lines.push('');
|
|
183
|
+
lines.push(this.colorize(chalk.yellow('Run without --dry-run to perform actual cleanup.')));
|
|
184
|
+
}
|
|
185
|
+
lines.push('');
|
|
186
|
+
return lines.join('\n');
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Format key-value pair
|
|
190
|
+
*/
|
|
191
|
+
formatKeyValue(key, value) {
|
|
192
|
+
const keyFormatted = this.colorize(chalk.bold(key.padEnd(20)));
|
|
193
|
+
return `${keyFormatted}: ${value}`;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Format status with color
|
|
197
|
+
*/
|
|
198
|
+
formatStatus(status) {
|
|
199
|
+
switch (status) {
|
|
200
|
+
case 'completed':
|
|
201
|
+
return this.colorize(chalk.green(status));
|
|
202
|
+
case 'failed':
|
|
203
|
+
return this.colorize(chalk.red(status));
|
|
204
|
+
case 'active':
|
|
205
|
+
return this.colorize(chalk.yellow(status));
|
|
206
|
+
default:
|
|
207
|
+
return status;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Format duration in milliseconds to human-readable string
|
|
212
|
+
*/
|
|
213
|
+
formatDuration(ms) {
|
|
214
|
+
const seconds = Math.floor(ms / 1000);
|
|
215
|
+
const minutes = Math.floor(seconds / 60);
|
|
216
|
+
const hours = Math.floor(minutes / 60);
|
|
217
|
+
if (hours > 0) {
|
|
218
|
+
return `${hours}h ${minutes % 60}m`;
|
|
219
|
+
}
|
|
220
|
+
else if (minutes > 0) {
|
|
221
|
+
return `${minutes}m ${seconds % 60}s`;
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
return `${seconds}s`;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Format bytes to human-readable string
|
|
229
|
+
*/
|
|
230
|
+
formatBytes(bytes) {
|
|
231
|
+
if (bytes < 1024)
|
|
232
|
+
return `${bytes} B`;
|
|
233
|
+
if (bytes < 1024 * 1024)
|
|
234
|
+
return `${(bytes / 1024).toFixed(2)} KB`;
|
|
235
|
+
if (bytes < 1024 * 1024 * 1024)
|
|
236
|
+
return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
|
|
237
|
+
return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Truncate path to max length
|
|
241
|
+
*/
|
|
242
|
+
truncatePath(path, maxLength) {
|
|
243
|
+
if (path.length <= maxLength)
|
|
244
|
+
return path;
|
|
245
|
+
return '...' + path.substring(path.length - maxLength + 3);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Apply colorization conditionally
|
|
249
|
+
*/
|
|
250
|
+
colorize(text) {
|
|
251
|
+
return this.format.colorize ? text : this.stripAnsi(text);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Strip ANSI color codes
|
|
255
|
+
*/
|
|
256
|
+
stripAnsi(text) {
|
|
257
|
+
// eslint-disable-next-line no-control-regex
|
|
258
|
+
return text.replace(/\u001b\[\d+m/g, '');
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
//# sourceMappingURL=formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../../../src/cli/commands/log/formatter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B;;GAEG;AACH,MAAM,OAAO,YAAY;IACf,MAAM,CAAe;IAE7B,YAAY,MAA8B;QACxC,IAAI,CAAC,MAAM,GAAG;YACZ,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,MAAM;YAChC,QAAQ,EAAE,MAAM,EAAE,QAAQ,IAAI,IAAI;YAClC,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,KAAK;SAClC,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,OAAmB;QAC5B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,oDAAoD,CAAC,CAAC,CAAC;QAC3F,CAAC;QAED,MAAM,KAAK,GA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,CAAC,CAAC,KAAK,CAAC;QAClE,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI;YAAE,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;QAClF,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAC3D,CAAC;IAED;;OAEG;IACK,YAAY,CAAC,IAAY,EAAE,SAAiB;QAClD,IAAI,IAAI,CAAC,MAAM,IAAI,SAAS;YAAE,OAAO,IAAI,CAAC;QAC1C,OAAO,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED;;OAEG;IACK,QAAQ,CAAC,IAAY;QAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACK,SAAS,CAAC,IAAY;QAC5B,4CAA4C;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IAC3C,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/log/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,wBAAgB,gBAAgB,IAAI,OAAO,CA+I1C"}
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Log command - View and manage logs and sessions
|
|
3
|
+
*/
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import { writeFileSync } from 'fs';
|
|
7
|
+
import { LogReader, SessionReader } from './reader.js';
|
|
8
|
+
import { LogFormatter } from './formatter.js';
|
|
9
|
+
import { LogFollower } from './follower.js';
|
|
10
|
+
import { LogCleaner } from './cleaner.js';
|
|
11
|
+
import { logger } from '../../../utils/logger.js';
|
|
12
|
+
export function createLogCommand() {
|
|
13
|
+
const command = new Command('log');
|
|
14
|
+
command
|
|
15
|
+
.description('View and manage debug logs and sessions')
|
|
16
|
+
.option('--session <id>', 'Filter by session ID')
|
|
17
|
+
.option('--agent <name>', 'Filter by agent (claude, gemini, etc.)')
|
|
18
|
+
.option('--profile <name>', 'Filter by profile name')
|
|
19
|
+
.option('--level <level>', 'Filter by log level (debug, info, warn, error)')
|
|
20
|
+
.option('--from <date>', 'Filter from date (YYYY-MM-DD)')
|
|
21
|
+
.option('--to <date>', 'Filter to date (YYYY-MM-DD)')
|
|
22
|
+
.option('--last <duration>', 'Filter last duration (e.g., 7d, 24h, 30m)')
|
|
23
|
+
.option('--grep <pattern>', 'Search pattern (supports regex)')
|
|
24
|
+
.option('-n, --lines <number>', 'Number of lines to show (default: 50)', '50')
|
|
25
|
+
.option('-v, --verbose', 'Show full details including session IDs and profiles')
|
|
26
|
+
.option('--format <format>', 'Output format (text, json, jsonl)', 'text')
|
|
27
|
+
.option('--no-color', 'Disable color output')
|
|
28
|
+
.option('-o, --output <path>', 'Write to file instead of stdout')
|
|
29
|
+
.action(async (options) => {
|
|
30
|
+
try {
|
|
31
|
+
await viewDebugLogs(options);
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
logger.error('Log command failed:', error);
|
|
35
|
+
console.error(chalk.red(`\n✗ Failed: ${error instanceof Error ? error.message : String(error)}\n`));
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
// Subcommand: debug (alias for default behavior)
|
|
40
|
+
const debugCommand = new Command('debug');
|
|
41
|
+
debugCommand
|
|
42
|
+
.description('View debug logs (same as default log command)')
|
|
43
|
+
.option('--session <id>', 'Filter by session ID')
|
|
44
|
+
.option('--agent <name>', 'Filter by agent')
|
|
45
|
+
.option('--profile <name>', 'Filter by profile')
|
|
46
|
+
.option('--level <level>', 'Filter by log level')
|
|
47
|
+
.option('--from <date>', 'Filter from date')
|
|
48
|
+
.option('--to <date>', 'Filter to date')
|
|
49
|
+
.option('--last <duration>', 'Filter last duration')
|
|
50
|
+
.option('--grep <pattern>', 'Search pattern')
|
|
51
|
+
.option('-n, --lines <number>', 'Number of lines', '50')
|
|
52
|
+
.option('-v, --verbose', 'Show full details')
|
|
53
|
+
.option('--format <format>', 'Output format', 'text')
|
|
54
|
+
.option('--no-color', 'Disable color')
|
|
55
|
+
.option('-o, --output <path>', 'Output file')
|
|
56
|
+
.action(async (options) => {
|
|
57
|
+
try {
|
|
58
|
+
await viewDebugLogs(options);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
logger.error('Debug log command failed:', error);
|
|
62
|
+
console.error(chalk.red(`\n✗ Failed: ${error instanceof Error ? error.message : String(error)}\n`));
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
command.addCommand(debugCommand);
|
|
67
|
+
// Subcommand: session <id>
|
|
68
|
+
const sessionCommand = new Command('session');
|
|
69
|
+
sessionCommand
|
|
70
|
+
.description('View specific session details')
|
|
71
|
+
.argument('<id>', 'Session ID')
|
|
72
|
+
.option('-v, --verbose', 'Show conversation details')
|
|
73
|
+
.option('--format <format>', 'Output format (text, json)', 'text')
|
|
74
|
+
.option('--no-color', 'Disable color')
|
|
75
|
+
.action(async (sessionId, options) => {
|
|
76
|
+
try {
|
|
77
|
+
await viewSession(sessionId, options);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
logger.error('Session view failed:', error);
|
|
81
|
+
console.error(chalk.red(`\n✗ Failed: ${error instanceof Error ? error.message : String(error)}\n`));
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
command.addCommand(sessionCommand);
|
|
86
|
+
// Subcommand: list-sessions
|
|
87
|
+
const listSessionsCommand = new Command('list-sessions');
|
|
88
|
+
listSessionsCommand
|
|
89
|
+
.description('List all sessions')
|
|
90
|
+
.option('--agent <name>', 'Filter by agent')
|
|
91
|
+
.option('--from <date>', 'Filter from date')
|
|
92
|
+
.option('--to <date>', 'Filter to date')
|
|
93
|
+
.option('--last <duration>', 'Filter last duration')
|
|
94
|
+
.option('--sort <field>', 'Sort by field (time, duration, agent)', 'time')
|
|
95
|
+
.option('--reverse', 'Reverse sort order')
|
|
96
|
+
.option('--format <format>', 'Output format (text, json)', 'text')
|
|
97
|
+
.option('--no-color', 'Disable color')
|
|
98
|
+
.action(async (options) => {
|
|
99
|
+
try {
|
|
100
|
+
await listSessions(options);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
logger.error('List sessions failed:', error);
|
|
104
|
+
console.error(chalk.red(`\n✗ Failed: ${error instanceof Error ? error.message : String(error)}\n`));
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
command.addCommand(listSessionsCommand);
|
|
109
|
+
// Subcommand: follow
|
|
110
|
+
const followCommand = new Command('follow');
|
|
111
|
+
followCommand
|
|
112
|
+
.description('Follow logs in real-time (tail -f style)')
|
|
113
|
+
.option('--agent <name>', 'Filter by agent')
|
|
114
|
+
.option('--level <level>', 'Filter by log level')
|
|
115
|
+
.option('--grep <pattern>', 'Search pattern')
|
|
116
|
+
.option('-v, --verbose', 'Show full details')
|
|
117
|
+
.option('--no-color', 'Disable color')
|
|
118
|
+
.action(async (options) => {
|
|
119
|
+
try {
|
|
120
|
+
await followLogs(options);
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
logger.error('Follow logs failed:', error);
|
|
124
|
+
console.error(chalk.red(`\n✗ Failed: ${error instanceof Error ? error.message : String(error)}\n`));
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
command.addCommand(followCommand);
|
|
129
|
+
// Subcommand: clean
|
|
130
|
+
const cleanCommand = new Command('clean');
|
|
131
|
+
cleanCommand
|
|
132
|
+
.description('Clean up old logs and sessions')
|
|
133
|
+
.option('--days <number>', 'Retention period in days (default: 5)', '5')
|
|
134
|
+
.option('--sessions', 'Also delete old sessions (not just debug logs)')
|
|
135
|
+
.option('--dry-run', 'Preview what would be deleted without actually deleting')
|
|
136
|
+
.option('--yes', 'Skip confirmation prompt')
|
|
137
|
+
.action(async (options) => {
|
|
138
|
+
try {
|
|
139
|
+
await cleanLogs(options);
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
logger.error('Clean logs failed:', error);
|
|
143
|
+
console.error(chalk.red(`\n✗ Failed: ${error instanceof Error ? error.message : String(error)}\n`));
|
|
144
|
+
process.exit(1);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
command.addCommand(cleanCommand);
|
|
148
|
+
return command;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* View debug logs
|
|
152
|
+
*/
|
|
153
|
+
async function viewDebugLogs(options) {
|
|
154
|
+
const filter = parseFilterOptions(options);
|
|
155
|
+
const maxLines = parseInt(String(options.lines || '50'), 10);
|
|
156
|
+
// Read logs
|
|
157
|
+
const reader = new LogReader();
|
|
158
|
+
const entries = await reader.readLogs(filter, maxLines);
|
|
159
|
+
// Format output
|
|
160
|
+
const formatter = new LogFormatter({
|
|
161
|
+
format: options.format || 'text',
|
|
162
|
+
colorize: options.noColor !== true,
|
|
163
|
+
verbose: options.verbose || false
|
|
164
|
+
});
|
|
165
|
+
let output;
|
|
166
|
+
switch (options.format) {
|
|
167
|
+
case 'json':
|
|
168
|
+
output = formatter.formatJSON(entries);
|
|
169
|
+
break;
|
|
170
|
+
case 'jsonl':
|
|
171
|
+
output = formatter.formatJSONL(entries);
|
|
172
|
+
break;
|
|
173
|
+
default:
|
|
174
|
+
output = formatter.formatText(entries);
|
|
175
|
+
}
|
|
176
|
+
// Output to file or stdout
|
|
177
|
+
if (options.output) {
|
|
178
|
+
writeFileSync(options.output, output);
|
|
179
|
+
console.log(chalk.green(`\n✓ Logs written to ${options.output}\n`));
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
console.log(output);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* View specific session details
|
|
187
|
+
*/
|
|
188
|
+
async function viewSession(sessionId, options) {
|
|
189
|
+
const reader = new SessionReader();
|
|
190
|
+
// Read session metadata
|
|
191
|
+
const session = reader.readSession(sessionId);
|
|
192
|
+
if (!session) {
|
|
193
|
+
console.error(chalk.red(`\n✗ Session not found: ${sessionId}\n`));
|
|
194
|
+
process.exit(1);
|
|
195
|
+
}
|
|
196
|
+
// Read conversation if verbose
|
|
197
|
+
const conversation = options.verbose ? reader.readSessionConversation(sessionId) : undefined;
|
|
198
|
+
// Format output
|
|
199
|
+
const formatter = new LogFormatter({
|
|
200
|
+
format: options.format || 'text',
|
|
201
|
+
colorize: options.noColor !== true,
|
|
202
|
+
verbose: options.verbose || false
|
|
203
|
+
});
|
|
204
|
+
if (options.format === 'json') {
|
|
205
|
+
const output = JSON.stringify({ session, conversation }, null, 2);
|
|
206
|
+
console.log(output);
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
const output = formatter.formatSession(session, conversation);
|
|
210
|
+
console.log(output);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* List all sessions
|
|
215
|
+
*/
|
|
216
|
+
async function listSessions(options) {
|
|
217
|
+
const filter = parseFilterOptions(options);
|
|
218
|
+
const reader = new SessionReader();
|
|
219
|
+
// Read sessions
|
|
220
|
+
let sessions = reader.listSessions(filter);
|
|
221
|
+
// Convert to list entries
|
|
222
|
+
const entries = sessions.map(s => ({
|
|
223
|
+
sessionId: s.sessionId,
|
|
224
|
+
agentName: s.agentName,
|
|
225
|
+
startTime: new Date(s.startTime),
|
|
226
|
+
duration: s.endTime ? s.endTime - s.startTime : undefined,
|
|
227
|
+
status: s.status,
|
|
228
|
+
workingDirectory: s.workingDirectory,
|
|
229
|
+
gitBranch: s.gitBranch
|
|
230
|
+
}));
|
|
231
|
+
// Sort
|
|
232
|
+
const sortField = options.sort || 'time';
|
|
233
|
+
entries.sort((a, b) => {
|
|
234
|
+
let comparison = 0;
|
|
235
|
+
switch (sortField) {
|
|
236
|
+
case 'duration':
|
|
237
|
+
comparison = (a.duration || 0) - (b.duration || 0);
|
|
238
|
+
break;
|
|
239
|
+
case 'agent':
|
|
240
|
+
comparison = a.agentName.localeCompare(b.agentName);
|
|
241
|
+
break;
|
|
242
|
+
case 'time':
|
|
243
|
+
default:
|
|
244
|
+
comparison = a.startTime.getTime() - b.startTime.getTime();
|
|
245
|
+
}
|
|
246
|
+
return options.reverse ? -comparison : comparison;
|
|
247
|
+
});
|
|
248
|
+
// Format output
|
|
249
|
+
const formatter = new LogFormatter({
|
|
250
|
+
format: options.format || 'text',
|
|
251
|
+
colorize: options.noColor !== true,
|
|
252
|
+
verbose: false
|
|
253
|
+
});
|
|
254
|
+
if (options.format === 'json') {
|
|
255
|
+
console.log(JSON.stringify(entries, null, 2));
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
const output = formatter.formatSessionList(entries);
|
|
259
|
+
console.log(output);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Follow logs in real-time
|
|
264
|
+
*/
|
|
265
|
+
async function followLogs(options) {
|
|
266
|
+
const filter = parseFilterOptions(options);
|
|
267
|
+
const reader = new LogReader();
|
|
268
|
+
const logFile = reader.getMostRecentLogFile();
|
|
269
|
+
if (!logFile) {
|
|
270
|
+
console.error(chalk.red('\n✗ No log file found for today\n'));
|
|
271
|
+
console.error(chalk.dim('Debug logs are created when agents run.\n'));
|
|
272
|
+
process.exit(1);
|
|
273
|
+
}
|
|
274
|
+
const formatter = new LogFormatter({
|
|
275
|
+
format: 'text',
|
|
276
|
+
colorize: options.noColor !== true,
|
|
277
|
+
verbose: options.verbose || false
|
|
278
|
+
});
|
|
279
|
+
console.log(chalk.cyan(`\nFollowing logs: ${logFile}`));
|
|
280
|
+
console.log(chalk.dim('Press Ctrl+C to stop\n'));
|
|
281
|
+
const follower = new LogFollower(formatter, filter);
|
|
282
|
+
await follower.follow(logFile);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Clean old logs
|
|
286
|
+
*/
|
|
287
|
+
async function cleanLogs(options) {
|
|
288
|
+
const retentionDays = parseInt(String(options.days || '5'), 10);
|
|
289
|
+
const includeSessions = options.sessions || false;
|
|
290
|
+
const dryRun = options.dryRun || false;
|
|
291
|
+
// Confirmation prompt (unless --yes or --dry-run)
|
|
292
|
+
if (!dryRun && !options.yes) {
|
|
293
|
+
console.log(chalk.yellow('\n⚠️ Warning: This will permanently delete files.\n'));
|
|
294
|
+
console.log(` Retention period: ${retentionDays} days`);
|
|
295
|
+
console.log(` Debug logs: Will be deleted`);
|
|
296
|
+
console.log(` Sessions: ${includeSessions ? 'Will be deleted' : 'Will NOT be deleted'}\n`);
|
|
297
|
+
console.log(chalk.dim('Run with --dry-run to preview what would be deleted.\n'));
|
|
298
|
+
console.log(chalk.dim('Run with --yes to skip this confirmation.\n'));
|
|
299
|
+
process.exit(1);
|
|
300
|
+
}
|
|
301
|
+
// Perform cleanup
|
|
302
|
+
const cleaner = new LogCleaner();
|
|
303
|
+
const stats = cleaner.clean(retentionDays, includeSessions, dryRun);
|
|
304
|
+
// Format output
|
|
305
|
+
const formatter = new LogFormatter({ colorize: options.noColor !== true, format: 'text', verbose: false });
|
|
306
|
+
const output = formatter.formatCleanupStats(stats, dryRun);
|
|
307
|
+
console.log(output);
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Parse filter options from command line arguments
|
|
311
|
+
*/
|
|
312
|
+
function parseFilterOptions(options) {
|
|
313
|
+
const filter = {};
|
|
314
|
+
if (options.session) {
|
|
315
|
+
filter.sessionId = options.session;
|
|
316
|
+
}
|
|
317
|
+
if (options.agent) {
|
|
318
|
+
filter.agent = options.agent;
|
|
319
|
+
}
|
|
320
|
+
if (options.profile) {
|
|
321
|
+
filter.profile = options.profile;
|
|
322
|
+
}
|
|
323
|
+
if (options.level) {
|
|
324
|
+
filter.level = options.level;
|
|
325
|
+
}
|
|
326
|
+
// Parse date filters
|
|
327
|
+
if (options.from) {
|
|
328
|
+
const fromDate = parseDate(options.from);
|
|
329
|
+
if (!fromDate) {
|
|
330
|
+
console.warn(chalk.yellow(`Warning: Invalid --from date "${options.from}", ignoring filter`));
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
filter.fromDate = fromDate;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
if (options.to) {
|
|
337
|
+
const toDate = parseDate(options.to);
|
|
338
|
+
if (!toDate) {
|
|
339
|
+
console.warn(chalk.yellow(`Warning: Invalid --to date "${options.to}", ignoring filter`));
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
filter.toDate = toDate;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
// Parse --last duration
|
|
346
|
+
if (options.last) {
|
|
347
|
+
const duration = parseDuration(options.last);
|
|
348
|
+
if (!duration) {
|
|
349
|
+
console.warn(chalk.yellow(`Warning: Invalid --last duration "${options.last}", ignoring filter`));
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
filter.fromDate = new Date(Date.now() - duration);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
// Parse --grep pattern
|
|
356
|
+
if (options.grep) {
|
|
357
|
+
filter.pattern = options.grep;
|
|
358
|
+
filter.isRegex = false; // Simple string search for now
|
|
359
|
+
}
|
|
360
|
+
return filter;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Parse date string (YYYY-MM-DD) to Date object
|
|
364
|
+
*/
|
|
365
|
+
function parseDate(dateStr) {
|
|
366
|
+
try {
|
|
367
|
+
const date = new Date(dateStr);
|
|
368
|
+
if (isNaN(date.getTime())) {
|
|
369
|
+
return null;
|
|
370
|
+
}
|
|
371
|
+
return date;
|
|
372
|
+
}
|
|
373
|
+
catch {
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Parse duration string (e.g., "7d", "24h", "30m") to milliseconds
|
|
379
|
+
*/
|
|
380
|
+
function parseDuration(durationStr) {
|
|
381
|
+
const match = durationStr.match(/^(\d+)([dhm])$/);
|
|
382
|
+
if (!match) {
|
|
383
|
+
return null;
|
|
384
|
+
}
|
|
385
|
+
const value = parseInt(match[1], 10);
|
|
386
|
+
const unit = match[2];
|
|
387
|
+
switch (unit) {
|
|
388
|
+
case 'd':
|
|
389
|
+
return value * 24 * 60 * 60 * 1000;
|
|
390
|
+
case 'h':
|
|
391
|
+
return value * 60 * 60 * 1000;
|
|
392
|
+
case 'm':
|
|
393
|
+
return value * 60 * 1000;
|
|
394
|
+
default:
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
//# sourceMappingURL=index.js.map
|