taskmonkey-cli 0.4.3 → 0.5.1
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 +6 -0
- package/package.json +1 -1
- package/src/commands/chat.js +35 -3
- package/src/commands/tasks.js +36 -0
package/bin/tm.js
CHANGED
|
@@ -8,6 +8,7 @@ import { pull } from '../src/commands/pull.js';
|
|
|
8
8
|
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
|
+
import { tasks } from '../src/commands/tasks.js';
|
|
11
12
|
import { testChat } from '../src/commands/test-chat.js';
|
|
12
13
|
import { testConversations } from '../src/commands/test-conversations.js';
|
|
13
14
|
import { optimizePrompt } from '../src/commands/optimize-prompt.js';
|
|
@@ -32,6 +33,11 @@ program
|
|
|
32
33
|
.option('--json', 'JSON output only')
|
|
33
34
|
.action(testTool);
|
|
34
35
|
|
|
36
|
+
program
|
|
37
|
+
.command('tasks')
|
|
38
|
+
.description('List available monkey tasks')
|
|
39
|
+
.action(tasks);
|
|
40
|
+
|
|
35
41
|
program
|
|
36
42
|
.command('sync')
|
|
37
43
|
.description('Upload local config files to server')
|
package/package.json
CHANGED
package/src/commands/chat.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createInterface } from 'readline';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import { loadConfig } from '../config.js';
|
|
4
|
+
import { createClient } from '../lib/api.js';
|
|
4
5
|
|
|
5
6
|
const SPINNER = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
6
7
|
|
|
@@ -13,10 +14,41 @@ export async function chat(options) {
|
|
|
13
14
|
|
|
14
15
|
const task = options.task || null;
|
|
15
16
|
const isPublic = options.public || false;
|
|
17
|
+
|
|
18
|
+
// Validate task exists and get chatId from server
|
|
16
19
|
let chatId;
|
|
17
|
-
if (task
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
if (task && !isPublic) {
|
|
21
|
+
try {
|
|
22
|
+
const client = createClient();
|
|
23
|
+
const tasksResult = await client.get('/api/tasks');
|
|
24
|
+
const tasks = tasksResult.tasks || [];
|
|
25
|
+
const found = tasks.find(t => t.slug === task);
|
|
26
|
+
if (!found) {
|
|
27
|
+
const available = tasks.filter(t => !t.is_unified).map(t => t.slug);
|
|
28
|
+
console.error(chalk.red(`Task "${task}" nicht gefunden.`));
|
|
29
|
+
if (available.length > 0) {
|
|
30
|
+
console.log(chalk.gray(`Verfügbar: ${available.join(', ')}`));
|
|
31
|
+
}
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
// Use the chatId from server (has correct userId)
|
|
35
|
+
chatId = found.chat_id;
|
|
36
|
+
} catch {
|
|
37
|
+
chatId = `task_${task}_cli_${Date.now()}`;
|
|
38
|
+
}
|
|
39
|
+
} else if (isPublic) {
|
|
40
|
+
chatId = `public_cli_${Date.now()}`;
|
|
41
|
+
} else {
|
|
42
|
+
// Unified: get chatId from server too
|
|
43
|
+
try {
|
|
44
|
+
const client = createClient();
|
|
45
|
+
const tasksResult = await client.get('/api/tasks');
|
|
46
|
+
const unified = (tasksResult.tasks || []).find(t => t.is_unified);
|
|
47
|
+
chatId = unified?.chat_id || `unified_cli_${Date.now()}`;
|
|
48
|
+
} catch {
|
|
49
|
+
chatId = `unified_cli_${Date.now()}`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
20
52
|
|
|
21
53
|
const label = task ? `(${task})` : isPublic ? '(public)' : '(unified)';
|
|
22
54
|
console.log(chalk.cyan('💬 Chat'), chalk.gray(label));
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import { createClient } from '../lib/api.js';
|
|
4
|
+
|
|
5
|
+
export async function tasks() {
|
|
6
|
+
const client = createClient();
|
|
7
|
+
const spinner = ora('Loading tasks...').start();
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
const result = await client.get('/api/tasks');
|
|
11
|
+
spinner.stop();
|
|
12
|
+
|
|
13
|
+
const taskList = result.tasks || [];
|
|
14
|
+
|
|
15
|
+
if (taskList.length === 0) {
|
|
16
|
+
console.log(chalk.yellow('Keine Tasks konfiguriert.'));
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
for (const task of taskList) {
|
|
21
|
+
const icon = task.icon || '📋';
|
|
22
|
+
const name = task.name || task.slug;
|
|
23
|
+
const slug = task.slug;
|
|
24
|
+
const desc = task.description || '';
|
|
25
|
+
const unified = task.is_unified ? chalk.gray(' (unified)') : '';
|
|
26
|
+
|
|
27
|
+
console.log(`${icon} ${chalk.white(name)}${unified} ${chalk.gray(`[${slug}]`)}`);
|
|
28
|
+
if (desc) console.log(` ${chalk.gray(desc)}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
console.log(chalk.gray(`\n${taskList.length} Tasks`));
|
|
32
|
+
} catch (err) {
|
|
33
|
+
spinner.fail(err.message);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
}
|