taskmonkey-cli 0.6.0 → 0.7.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/bin/tm.js +8 -0
- package/package.json +1 -1
- package/src/commands/history.js +59 -0
package/bin/tm.js
CHANGED
|
@@ -9,6 +9,7 @@ import { watch } from '../src/commands/watch.js';
|
|
|
9
9
|
import { logs } from '../src/commands/logs.js';
|
|
10
10
|
import { chat } from '../src/commands/chat.js';
|
|
11
11
|
import { tasks } from '../src/commands/tasks.js';
|
|
12
|
+
import { history } from '../src/commands/history.js';
|
|
12
13
|
import { testChat } from '../src/commands/test-chat.js';
|
|
13
14
|
import { testConversations } from '../src/commands/test-conversations.js';
|
|
14
15
|
import { optimizePrompt } from '../src/commands/optimize-prompt.js';
|
|
@@ -54,6 +55,13 @@ program
|
|
|
54
55
|
.description('Watch for file changes and auto-sync')
|
|
55
56
|
.action(watch);
|
|
56
57
|
|
|
58
|
+
program
|
|
59
|
+
.command('history')
|
|
60
|
+
.description('Show recent chat messages for a task (for debugging)')
|
|
61
|
+
.option('-t, --task <slug>', 'Monkey task slug (default: unified)')
|
|
62
|
+
.option('-n, --last <number>', 'Number of messages', '20')
|
|
63
|
+
.action(history);
|
|
64
|
+
|
|
57
65
|
program
|
|
58
66
|
.command('logs')
|
|
59
67
|
.description('Stream server logs')
|
package/package.json
CHANGED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import { createClient } from '../lib/api.js';
|
|
4
|
+
|
|
5
|
+
export async function history(options) {
|
|
6
|
+
const client = createClient();
|
|
7
|
+
|
|
8
|
+
const spinner = ora('Loading chat history...').start();
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
const result = await client.get('/api/test/history', {
|
|
12
|
+
task: options.task || '',
|
|
13
|
+
last: options.last || '20',
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
spinner.stop();
|
|
17
|
+
|
|
18
|
+
if (result.count === 0) {
|
|
19
|
+
console.log(chalk.yellow('Keine Nachrichten gefunden.'));
|
|
20
|
+
console.log(chalk.gray(`Chat-ID: ${result.chat_id}`));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
console.log(chalk.gray(`${result.chat_id} — ${result.count} Nachrichten\n`));
|
|
25
|
+
|
|
26
|
+
for (const msg of result.messages) {
|
|
27
|
+
const time = chalk.gray(msg.created);
|
|
28
|
+
const content = (msg.content || '').replace(/\n{3,}/g, '\n').trim();
|
|
29
|
+
|
|
30
|
+
switch (msg.role) {
|
|
31
|
+
case 'user':
|
|
32
|
+
console.log(`${time} ${chalk.green('USER')} ${content}`);
|
|
33
|
+
break;
|
|
34
|
+
case 'assistant':
|
|
35
|
+
// Check for tool_use
|
|
36
|
+
if (content.includes('[tool_use:')) {
|
|
37
|
+
const tools = content.match(/\[tool_use: ([^\]]+)\]/g) || [];
|
|
38
|
+
for (const t of tools) {
|
|
39
|
+
console.log(`${time} ${chalk.yellow('TOOL')} ${t}`);
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
console.log(`${time} ${chalk.cyan('AI')} ${content.substring(0, 200)}${content.length > 200 ? '...' : ''}`);
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
case 'tool':
|
|
46
|
+
console.log(`${time} ${chalk.gray('RESULT')} ${content.substring(0, 150)}${content.length > 150 ? '...' : ''}`);
|
|
47
|
+
break;
|
|
48
|
+
case 'system':
|
|
49
|
+
console.log(`${time} ${chalk.magenta('SYS')} ${content.substring(0, 150)}`);
|
|
50
|
+
break;
|
|
51
|
+
default:
|
|
52
|
+
console.log(`${time} ${chalk.gray(msg.role.toUpperCase())} ${content.substring(0, 150)}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
} catch (err) {
|
|
56
|
+
spinner.fail(err.message);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
}
|