clawflowbang 1.0.0 → 1.0.2

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.
@@ -1,10 +1,11 @@
1
- /**
2
- * Cron commands - จัดการ cronjobs
3
- */
4
-
1
+ /**
2
+ * Cron commands - จัดการ cronjobs
3
+ */
4
+
5
5
  const chalk = require('chalk');
6
6
  const ClawFlow = require('../index');
7
7
  const { normalizeCronExpression } = require('../core/CronFormat');
8
+ const YAML = require('yaml');
8
9
 
9
10
  function parseJsonParams(params) {
10
11
  if (params === undefined || params === null || params === '') {
@@ -15,7 +16,41 @@ function parseJsonParams(params) {
15
16
  return params;
16
17
  }
17
18
 
18
- return JSON.parse(params);
19
+ const raw = String(params).trim();
20
+ const unquoted =
21
+ (raw.startsWith("'") && raw.endsWith("'")) || (raw.startsWith('"') && raw.endsWith('"'))
22
+ ? raw.slice(1, -1).trim()
23
+ : raw;
24
+
25
+ const candidates = [raw, unquoted];
26
+
27
+ for (const candidate of candidates) {
28
+ if (!candidate) continue;
29
+ try {
30
+ const parsed = JSON.parse(candidate);
31
+ if (parsed && typeof parsed === 'object') {
32
+ return parsed;
33
+ }
34
+ } catch (_error) {
35
+ // Continue to YAML fallback
36
+ }
37
+ }
38
+
39
+ for (const candidate of candidates) {
40
+ if (!candidate) continue;
41
+ try {
42
+ const parsed = YAML.parse(candidate);
43
+ if (parsed && typeof parsed === 'object') {
44
+ return parsed;
45
+ }
46
+ } catch (_error) {
47
+ // Continue
48
+ }
49
+ }
50
+
51
+ throw new Error(
52
+ 'รูปแบบ --params ไม่ถูกต้อง (ใช้ JSON object เช่น {"message":"hello"} หรือ YAML object เช่น message: hello)',
53
+ );
19
54
  }
20
55
 
21
56
  function resolveScheduleInput(options) {
@@ -29,27 +64,27 @@ function resolveScheduleInput(options) {
29
64
  module.exports = {
30
65
  async list() {
31
66
  const hub = new ClawFlow();
32
-
67
+
33
68
  try {
34
- console.log(chalk.cyan.bold('\n⏰ Cronjobs ที่ตั้งไว้:\n'));
69
+ console.log(chalk.cyan.bold('\n⏰ Configured Cronjobs:\n'));
35
70
 
36
71
  const crons = await hub.listCrons();
37
72
 
38
73
  if (crons.length === 0) {
39
- console.log(chalk.gray(' ไม่มี cronjobs'));
40
- } else {
74
+ console.log(chalk.gray(' No cronjobs configured'));
75
+ } else {
41
76
  crons.forEach((job) => {
42
77
  const status = job.enabled !== false ? chalk.green('●') : chalk.gray('○');
43
78
  console.log(` ${status} ${chalk.bold(job.skill || job.name)}`);
44
79
  console.log(` ${chalk.blue('Schedule:')} ${job.schedule}`);
45
- console.log(` ${chalk.blue('Description:')} ${job.description || '-'}`);
46
- console.log();
47
- });
48
- }
49
- } catch (error) {
50
- console.error(chalk.red(`\n❌ Error: ${error.message}`));
51
- process.exit(1);
52
- }
80
+ console.log(` ${chalk.blue('Description:')} ${job.description || '-'}`);
81
+ console.log();
82
+ });
83
+ }
84
+ } catch (error) {
85
+ console.error(chalk.red(`\n❌ Error: ${error.message}`));
86
+ process.exit(1);
87
+ }
53
88
  },
54
89
 
55
90
  async add(skillName, options) {
@@ -61,29 +96,29 @@ module.exports = {
61
96
  const parsedParams = parseJsonParams(params);
62
97
  const schedule = resolveScheduleInput(options);
63
98
 
64
- console.log(chalk.cyan(`\n➕ กำลังเพิ่ม cronjob สำหรับ ${chalk.bold(skillName)}...\n`));
99
+ console.log(chalk.cyan(`\n➕ Adding cronjob for ${chalk.bold(skillName)}...\n`));
65
100
 
66
101
  const job = await hub.cronManager.add(skillName, schedule, parsedParams, description);
67
102
 
68
- console.log(chalk.green(`\n✓ เพิ่ม cronjob สำเร็จ`));
103
+ console.log(chalk.green(`\n✓ Cronjob added successfully`));
69
104
  console.log(` ID: ${job.id}`);
70
105
  console.log(` Schedule: ${job.schedule}`);
71
- } catch (error) {
72
- console.error(chalk.red(`\n❌ Error: ${error.message}`));
73
- process.exit(1);
74
- }
75
- },
76
-
106
+ } catch (error) {
107
+ console.error(chalk.red(`\n❌ Error: ${error.message}`));
108
+ process.exit(1);
109
+ }
110
+ },
111
+
77
112
  async remove(jobId) {
78
- const hub = new ClawFlow();
79
-
80
- try {
81
- console.log(chalk.cyan(`\n🗑️ กำลังลบ cronjob ${chalk.bold(jobId)}...\n`));
82
-
83
- await hub.cronManager.remove(jobId);
84
-
85
- console.log(chalk.green(`\n✓ ลบ cronjob สำเร็จ`));
86
- } catch (error) {
113
+ const hub = new ClawFlow();
114
+
115
+ try {
116
+ console.log(chalk.cyan(`\n🗑️ Removing cronjob ${chalk.bold(jobId)}...\n`));
117
+
118
+ await hub.cronManager.remove(jobId);
119
+
120
+ console.log(chalk.green(`\n✓ Cronjob removed successfully`));
121
+ } catch (error) {
87
122
  console.error(chalk.red(`\n❌ Error: ${error.message}`));
88
123
  process.exit(1);
89
124
  }
@@ -105,12 +140,12 @@ module.exports = {
105
140
  }
106
141
 
107
142
  if (Object.keys(updates).length === 0) {
108
- throw new Error('ไม่มีข้อมูลสำหรับแก้ไข (ใช้ --schedule/--every/--description/--params)');
143
+ throw new Error('No update data provided (use --schedule/--every/--description/--params)');
109
144
  }
110
145
 
111
146
  const updated = await hub.cronManager.edit(jobId, updates);
112
147
 
113
- console.log(chalk.green(`\n✓ แก้ไข cronjob สำเร็จ`));
148
+ console.log(chalk.green(`\n✓ Cronjob updated successfully`));
114
149
  console.log(` ID: ${updated.id || jobId}`);
115
150
  if (updated.schedule) {
116
151
  console.log(` Schedule: ${updated.schedule}`);
@@ -1,11 +1,11 @@
1
1
  /**
2
- * Init command - เริ่มต้นใช้งาน ClawFlow
2
+ * Init command - Initialize ClawFlow
3
3
  */
4
4
 
5
- const chalk = require('chalk');
6
- const fs = require('fs-extra');
7
- const path = require('path');
8
- const inquirer = require('inquirer');
5
+ const chalk = require('chalk');
6
+ const fs = require('fs-extra');
7
+ const path = require('path');
8
+ const inquirer = require('inquirer');
9
9
 
10
10
  module.exports = async function initCommand(options) {
11
11
  const { force = false } = options;
@@ -14,22 +14,22 @@ module.exports = async function initCommand(options) {
14
14
  const configDir = path.join(cwd, '.clawflowhub');
15
15
  const configFile = path.join(configDir, 'config.json');
16
16
 
17
- console.log(chalk.cyan.bold('\n🚀 เริ่มต้นใช้งาน ClawFlow\n'));
17
+ console.log(chalk.cyan.bold('\n🚀 Initialize ClawFlow\n'));
18
18
 
19
19
  // ตรวจสอบว่ามี config อยู่แล้วหรือไม่
20
20
  if (fs.existsSync(configFile) && !force) {
21
- console.log(chalk.yellow('⚠️ พบการตั้งค่าเดิมในโฟลเดอร์นี้'));
21
+ console.log(chalk.yellow('⚠️ Existing configuration found in this folder'));
22
22
  const { overwrite } = await inquirer.prompt([
23
23
  {
24
24
  type: 'confirm',
25
25
  name: 'overwrite',
26
- message: 'ต้องการเขียนทับการตั้งค่าเดิมหรือไม่?',
26
+ message: 'Do you want to overwrite the existing configuration?',
27
27
  default: false,
28
28
  },
29
29
  ]);
30
30
 
31
31
  if (!overwrite) {
32
- console.log(chalk.gray(' ยกเลิกการดำเนินการ'));
32
+ console.log(chalk.gray(' Operation cancelled'));
33
33
  return;
34
34
  }
35
35
  }
@@ -39,25 +39,25 @@ module.exports = async function initCommand(options) {
39
39
  {
40
40
  type: 'input',
41
41
  name: 'skillsPath',
42
- message: 'โฟลเดอร์สำหรับเก็บ skills:',
42
+ message: 'Folder for storing skills:',
43
43
  default: './skills',
44
44
  },
45
45
  {
46
46
  type: 'input',
47
47
  name: 'openclawBin',
48
- message: 'Path ของ openclaw CLI:',
48
+ message: 'Path to openclaw CLI:',
49
49
  default: 'openclaw',
50
50
  },
51
51
  {
52
52
  type: 'input',
53
53
  name: 'clawhubBin',
54
- message: 'Path ของ clawhub CLI:',
54
+ message: 'Path to clawhub CLI:',
55
55
  default: 'clawhub',
56
56
  },
57
57
  {
58
58
  type: 'confirm',
59
59
  name: 'enableNpmRegistry',
60
- message: 'เปิดใช้งาน NPM Registry (ค้นหา packages จาก npm)?',
60
+ message: 'Enable NPM Registry (search packages from npm)?',
61
61
  default: true,
62
62
  },
63
63
  ]);
@@ -65,9 +65,9 @@ module.exports = async function initCommand(options) {
65
65
  // สร้าง config
66
66
  const config = {
67
67
  version: '1.0.0',
68
- openclaw: {
69
- baseUrl: 'http://localhost:3000',
70
- apiKey: null,
68
+ openclaw: {
69
+ baseUrl: 'http://localhost:18789',
70
+ apiKey: null,
71
71
  cliBin: answers.openclawBin,
72
72
  clawhubBin: answers.clawhubBin,
73
73
  workspacePath: path.join(cwd, '.openclaw'),
@@ -100,13 +100,13 @@ module.exports = async function initCommand(options) {
100
100
  fs.writeFileSync(gitignorePath, 'npm-cache/\nlogs/\n*.log\n');
101
101
  }
102
102
 
103
- console.log(chalk.green('\n✓ สร้างการตั้งค่าเสร็จสิ้น'));
103
+ console.log(chalk.green('\n✓ Configuration created successfully'));
104
104
  console.log(chalk.gray(` Config: ${configFile}`));
105
105
  console.log(chalk.gray(` Skills: ${config.openclaw.skillsPath}`));
106
106
  console.log();
107
- console.log(chalk.cyan('คำสั่งที่ใช้ได้:'));
108
- console.log(' clawflow install <package> - ติดตั้ง package');
109
- console.log(' clawflow list - แสดงรายการ packages');
110
- console.log(' clawflow search <query> - ค้นหา packages');
111
- console.log();
112
- };
107
+ console.log(chalk.cyan('Available commands:'));
108
+ console.log(' clawflow install <package> - Install a package');
109
+ console.log(' clawflow list - Show packages');
110
+ console.log(' clawflow search <query> - Search packages');
111
+ console.log();
112
+ };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Install Command - ติดตั้ง package พร้อม skills และ cronjobs
2
+ * Install Command - Install a package including skills and cronjobs
3
3
  */
4
4
 
5
5
  const chalk = require('chalk');
@@ -7,13 +7,13 @@ const ClawFlow = require('../index');
7
7
 
8
8
  module.exports = async function installCommand(packageName, options) {
9
9
  try {
10
- const cfh = new ClawFlow({
11
- configPath: options.config,
12
- skillsPath: options.skillsPath,
13
- cronJobsFile: options.cronJobs,
14
- openclawBin: options.openclawBin,
15
- clawhubBin: options.clawhubBin,
16
- });
10
+ const cfh = new ClawFlow({
11
+ configPath: options.config,
12
+ skillsPath: options.skillsPath,
13
+ cronJobsFile: options.cronJobs,
14
+ openclawBin: options.openclawBin,
15
+ clawhubBin: options.clawhubBin,
16
+ });
17
17
 
18
18
  const result = await cfh.install(packageName, {
19
19
  global: options.global,
@@ -22,17 +22,17 @@ module.exports = async function installCommand(packageName, options) {
22
22
  });
23
23
 
24
24
  if (result.success) {
25
- console.log(chalk.green('\n🎉 ติดตั้งสำเร็จ!'));
26
-
27
- if (!result.dryRun) {
28
- console.log(chalk.gray('\nใช้คำสั่งต่อไปนี้เพื่อดูรายละเอียด:'));
29
- console.log(chalk.cyan(` clawflow status`));
30
- console.log(chalk.cyan(` clawflow cron-list`));
31
- }
32
- }
25
+ console.log(chalk.green('\n🎉 Installation successful!'));
26
+
27
+ if (!result.dryRun) {
28
+ console.log(chalk.gray('\nRun the following commands to view details:'));
29
+ console.log(chalk.cyan(` clawflow status`));
30
+ console.log(chalk.cyan(` clawflow cron-list`));
31
+ }
32
+ }
33
33
 
34
34
  } catch (error) {
35
- console.error(chalk.red('\n❌ ติดตั้งไม่สำเร็จ:'), error.message);
35
+ console.error(chalk.red('\n❌ Installation failed:'), error.message);
36
36
  process.exit(1);
37
37
  }
38
38
  };
@@ -1,9 +1,9 @@
1
1
  /**
2
- * List command - แสดงรายการ packages
2
+ * List command - Show packages
3
3
  */
4
4
 
5
- const chalk = require('chalk');
6
5
  const ClawFlow = require('../index');
6
+ const TUI = require('../core/TerminalUI');
7
7
 
8
8
  module.exports = async function listCommand(options) {
9
9
  const { available = false, npm = false } = options;
@@ -12,66 +12,68 @@ module.exports = async function listCommand(options) {
12
12
 
13
13
  try {
14
14
  if (available || npm) {
15
- // แสดง packages ที่พร้อมติดตั้ง
16
- console.log(chalk.cyan.bold('\n📦 Packages ที่พร้อมติดตั้ง:\n'));
15
+ // Show available packages
16
+ TUI.printSection('Available Packages');
17
17
 
18
18
  const packages = await hub.registry.getAvailablePackages({
19
19
  includeNpm: npm || true,
20
20
  });
21
21
 
22
22
  if (packages.length === 0) {
23
- console.log(chalk.gray(' ไม่พบ packages'));
23
+ TUI.printInfo('No packages found');
24
24
  } else {
25
25
  // แยกตาม source
26
26
  const builtins = packages.filter((p) => p.source === 'builtin');
27
27
  const npms = packages.filter((p) => p.source === 'npm');
28
28
 
29
29
  if (builtins.length > 0) {
30
- console.log(chalk.yellow(' Built-in Packages:'));
30
+ console.log();
31
+ console.log(TUI.neonGlow('Built-in Packages:', TUI.colors.warning));
31
32
  builtins.forEach((pkg) => {
32
- console.log(` ${chalk.green('●')} ${chalk.bold(pkg.name)}@${pkg.version}`);
33
- console.log(` ${chalk.gray(pkg.description || 'ไม่มีคำอธิบาย')}`);
34
- console.log(` ${chalk.blue('Skills:')} ${pkg.skills} | ${chalk.blue('Crons:')} ${pkg.crons}`);
35
33
  console.log();
34
+ console.log(TUI.neonGlow(' ● ' + pkg.name, TUI.colors.success) + ' ' + pkg.version);
35
+ console.log(' ' + TUI.colors.info + (pkg.description || 'No description'));
36
+ console.log(' ' + TUI.colors.secondary + 'Skills: ' + TUI.colors.info + pkg.skills + ' | ' + TUI.colors.secondary + 'Crons: ' + TUI.colors.info + pkg.crons);
36
37
  });
37
38
  }
38
39
 
39
40
  if (npms.length > 0) {
40
- console.log(chalk.yellow(' NPM Packages:'));
41
+ console.log();
42
+ console.log(TUI.neonGlow('NPM Packages:', TUI.colors.warning));
41
43
  npms.forEach((pkg) => {
42
- console.log(` ${chalk.green('◆')} ${chalk.bold(pkg.name)}@${pkg.version}`);
43
- console.log(` ${chalk.gray(pkg.description || 'ไม่มีคำอธิบาย')}`);
44
- console.log(` ${chalk.blue('Author:')} ${pkg.author}`);
45
44
  console.log();
45
+ console.log(TUI.neonGlow(' ◆ ' + pkg.name, TUI.colors.secondary) + ' ' + pkg.version);
46
+ console.log(' ' + TUI.colors.info + (pkg.description || 'No description'));
47
+ console.log(' ' + TUI.colors.secondary + 'Author: ' + TUI.colors.info + pkg.author);
46
48
  });
47
49
  }
48
50
  }
49
51
  } else {
50
- // แสดง packages ที่ติดตั้งแล้ว
51
- console.log(chalk.cyan.bold('\n📦 Packages ที่ติดตั้งแล้ว:\n'));
52
+ // Show installed packages
53
+ TUI.printSection('Installed Packages');
52
54
 
53
55
  const installed = await hub.registry.getInstalledPackages();
54
56
  const entries = Object.entries(installed);
55
57
 
56
- if (entries.length === 0) {
57
- console.log(chalk.gray(' ยังไม่มี packages ที่ติดตั้ง'));
58
- console.log(chalk.gray(' ใช้ "clawflow install <package>" เพื่อติดตั้ง'));
59
- } else {
58
+ if (entries.length === 0) {
59
+ TUI.printInfo('No packages installed yet');
60
+ TUI.printInfo('Use "clawflow install <package>" to install');
61
+ } else {
60
62
  entries.forEach(([name, info]) => {
61
- console.log(` ${chalk.green('✓')} ${chalk.bold(name)}@${info.version}`);
62
- console.log(` ${chalk.blue('ติดตั้งเมื่อ:')} ${new Date(info.installedAt).toLocaleString()}`);
63
+ console.log();
64
+ console.log(TUI.neonGlow('' + name, TUI.colors.success) + ' ' + info.version);
65
+ console.log(' ' + TUI.colors.secondary + 'Installed at: ' + TUI.colors.info + new Date(info.installedAt).toLocaleString());
63
66
  if (info.skills?.length > 0) {
64
- console.log(` ${chalk.blue('Skills:')} ${info.skills.join(', ')}`);
67
+ console.log(' ' + TUI.colors.secondary + 'Skills: ' + TUI.colors.info + info.skills.join(', '));
65
68
  }
66
69
  if (info.crons?.length > 0) {
67
- console.log(` ${chalk.blue('Cronjobs:')} ${info.crons.length} รายการ`);
70
+ console.log(' ' + TUI.colors.secondary + 'Cronjobs: ' + TUI.colors.info + info.crons.length + ' entries');
68
71
  }
69
- console.log();
70
72
  });
71
73
  }
72
74
  }
73
75
  } catch (error) {
74
- console.error(chalk.red(`\n❌ Error: ${error.message}`));
76
+ TUI.printError(error.message);
75
77
  process.exit(1);
76
78
  }
77
79
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Remove command - ถอนการติดตั้ง package
2
+ * Remove command - Uninstall a package
3
3
  */
4
4
 
5
5
  const chalk = require('chalk');
@@ -11,14 +11,14 @@ module.exports = async function removeCommand(packageName, options) {
11
11
  const hub = new ClawFlow();
12
12
 
13
13
  try {
14
- console.log(chalk.cyan(`\n🗑️ กำลังถอนการติดตั้ง ${chalk.bold(packageName)}...\n`));
14
+ console.log(chalk.cyan(`\n🗑️ Uninstalling ${chalk.bold(packageName)}...\n`));
15
15
 
16
16
  const result = await hub.remove(packageName, { global, keepConfig });
17
17
 
18
18
  if (result.success) {
19
- console.log(chalk.green(`\n✓ ถอนการติดตั้ง ${packageName} สำเร็จ`));
19
+ console.log(chalk.green(`\n✓ Uninstalled ${packageName} successfully`));
20
20
  } else {
21
- console.log(chalk.yellow(`\n⚠️ ${result.reason || 'ไม่สามารถถอนการติดตั้งได้'}`));
21
+ console.log(chalk.yellow(`\n⚠️ ${result.reason || 'Unable to uninstall'}`));
22
22
  }
23
23
  } catch (error) {
24
24
  console.error(chalk.red(`\n❌ Error: ${error.message}`));
@@ -1,23 +1,25 @@
1
1
  /**
2
- * Search command - ค้นหา packages
2
+ * Search command - Search packages
3
3
  */
4
4
 
5
- const chalk = require('chalk');
6
5
  const ClawFlow = require('../index');
6
+ const TUI = require('../core/TerminalUI');
7
7
 
8
8
  module.exports = async function searchCommand(query, options) {
9
9
  const { npm = true } = options;
10
10
 
11
- if (!query) {
12
- console.log(chalk.yellow('⚠️ กรุณาระบุคำค้นหา'));
13
- console.log(chalk.gray(' ตัวอย่าง: clawflow search trading'));
14
- process.exit(1);
15
- }
11
+ if (!query) {
12
+ TUI.printWarning('Please specify a search query');
13
+ console.log(' ' + TUI.colors.info + 'Example: clawflow search trading');
14
+ process.exit(1);
15
+ }
16
16
 
17
17
  const hub = new ClawFlow();
18
18
 
19
19
  try {
20
- console.log(chalk.cyan(`\n🔍 กำลังค้นหา "${query}"...\n`));
20
+ console.log();
21
+ TUI.printInfo('Searching for "' + query + '"...');
22
+ console.log();
21
23
 
22
24
  const results = await hub.registry.searchPackages(query, {
23
25
  includeNpm: npm,
@@ -25,37 +27,38 @@ module.exports = async function searchCommand(query, options) {
25
27
  });
26
28
 
27
29
  if (results.length === 0) {
28
- console.log(chalk.yellow(' ไม่พบ packages ที่ตรงกับคำค้นหา'));
29
- console.log(chalk.gray(' ลองใช้คำค้นหาอื่น หรือตรวจสอบการเชื่อมต่ออินเทอร์เน็ต'));
30
+ TUI.printWarning('No packages match your search');
31
+ TUI.printInfo('Try a different query or check your internet connection');
30
32
  } else {
31
- console.log(chalk.green(` พบ ${results.length} packages:\n`));
33
+ TUI.printSuccess('Found ' + results.length + ' packages');
34
+ console.log();
32
35
 
33
36
  results.forEach((pkg) => {
34
37
  const icon = pkg.source === 'builtin' ? '●' : '◆';
35
- const sourceLabel = pkg.source === 'builtin' ? chalk.gray('[built-in]') : chalk.blue('[npm]');
38
+ const sourceLabel = pkg.source === 'builtin' ? TUI.colors.info + '[built-in]' : TUI.colors.secondary + '[npm]';
36
39
 
37
- console.log(` ${chalk.green(icon)} ${chalk.bold(pkg.name)}@${pkg.version} ${sourceLabel}`);
38
- console.log(` ${chalk.gray(pkg.description || 'ไม่มีคำอธิบาย')}`);
40
+ console.log(TUI.neonGlow(' ' + icon + ' ', TUI.colors.success) + TUI.neonGlow(pkg.name, TUI.colors.secondary) + ' ' + pkg.version + ' ' + sourceLabel);
41
+ console.log(' ' + TUI.colors.info + (pkg.description || 'No description'));
39
42
 
40
43
  if (pkg.skills?.length > 0) {
41
- console.log(` ${chalk.blue('Skills:')} ${pkg.skills.map((s) => s.name || s).join(', ')}`);
44
+ console.log(' ' + TUI.colors.secondary + 'Skills: ' + TUI.colors.info + pkg.skills.map((s) => s.name || s).join(', '));
42
45
  }
43
46
 
44
47
  if (pkg.crons?.length > 0) {
45
- console.log(` ${chalk.blue('Cronjobs:')} ${pkg.crons.length} รายการ`);
48
+ console.log(' ' + TUI.colors.secondary + 'Cronjobs: ' + TUI.colors.info + pkg.crons.length + ' entries');
46
49
  }
47
50
 
48
51
  if (pkg.source === 'npm' && pkg.author) {
49
- console.log(` ${chalk.blue('Author:')} ${pkg.author}`);
52
+ console.log(' ' + TUI.colors.secondary + 'Author: ' + TUI.colors.info + pkg.author);
50
53
  }
51
54
 
52
55
  console.log();
53
56
  });
54
57
 
55
- console.log(chalk.gray(' ใช้ "clawflow install <package-name>" เพื่อติดตั้ง'));
56
- }
58
+ TUI.printInfo('Use "clawflow install <package-name>" to install');
59
+ }
57
60
  } catch (error) {
58
- console.error(chalk.red(`\n❌ Error: ${error.message}`));
61
+ TUI.printError(error.message);
59
62
  process.exit(1);
60
63
  }
61
64
  };
@@ -1,68 +1,62 @@
1
1
  /**
2
- * Status command - แสดงสถานะระบบ
2
+ * Status command - Show system status
3
3
  */
4
4
 
5
- const chalk = require('chalk');
6
5
  const os = require('os');
7
6
  const ClawFlow = require('../index');
8
7
  const OpenClawCLI = require('../core/OpenClawCLI');
8
+ const TUI = require('../core/TerminalUI');
9
9
 
10
10
  module.exports = async function statusCommand() {
11
11
  const hub = new ClawFlow();
12
12
  const openclawCLI = new OpenClawCLI(hub.config);
13
13
 
14
- console.log(chalk.cyan.bold('\n📊 สถานะระบบ ClawFlow\n'));
14
+ TUI.printSection('ClawFlow System Status');
15
15
 
16
16
  // System Info
17
- console.log(chalk.yellow('System:'));
18
- console.log(` Node.js: ${process.version}`);
19
- console.log(` Platform: ${process.platform} (${os.arch()})`);
20
- console.log(` Home: ${os.homedir()}`);
17
+ TUI.printKeyValue('Node.js', process.version);
18
+ TUI.printKeyValue('Platform', `${process.platform} (${os.arch()})`);
19
+ TUI.printKeyValue('Home', os.homedir());
21
20
  console.log();
22
21
 
23
22
  // ClawFlow Config
24
- console.log(chalk.yellow('ClawFlow:'));
25
- console.log(` Config Path: ${hub.config.getConfigPath()}`);
26
- console.log(` Skills Path: ${hub.config.getSkillsPath()}`);
27
- console.log(` Cron Jobs File: ${hub.config.getCronJobsFilePath()}`);
23
+ TUI.printKeyValue('Config Path', hub.config.getConfigPath());
24
+ TUI.printKeyValue('Skills Path', hub.config.getSkillsPath());
25
+ TUI.printKeyValue('Cron Jobs File', hub.config.getCronJobsFilePath());
28
26
  console.log();
29
27
 
30
28
  // OpenClaw Integration
31
- console.log(chalk.yellow('OpenClaw Integration:'));
32
29
  const hasOpenClaw = openclawCLI.hasOpenClaw();
33
30
  const hasClawhub = openclawCLI.hasClawhub();
34
31
 
35
- console.log(` openclaw CLI: ${hasOpenClaw ? chalk.green('✓ พบ') : chalk.red('✗ ไม่พบ')}`);
36
- console.log(` clawhub CLI: ${hasClawhub ? chalk.green('✓ พบ') : chalk.red('✗ ไม่พบ')}`);
32
+ TUI.printKeyValue('openclaw CLI', hasOpenClaw ? '✓ Found' : '✗ Not found');
33
+ TUI.printKeyValue('clawhub CLI', hasClawhub ? '✓ Found' : '✗ Not found');
37
34
  console.log();
38
35
 
39
36
  // Installed Packages
40
37
  const installed = await hub.listInstalled();
41
38
  const installedCount = Object.keys(installed).length;
42
39
 
43
- console.log(chalk.yellow('Packages:'));
44
- console.log(` Installed: ${installedCount} packages`);
40
+ TUI.printKeyValue('Installed Packages', `${installedCount} packages`);
45
41
 
46
42
  if (installedCount > 0) {
47
43
  Object.entries(installed).forEach(([name, info]) => {
48
- console.log(` - ${name}@${info.version}`);
44
+ TUI.printListItem(`${name}@${info.version}`, 4);
49
45
  });
50
46
  }
51
47
  console.log();
52
48
 
53
49
  // Cron Jobs
54
- const crons = await hub.listCrons();
55
- console.log(chalk.yellow('Cron Jobs:'));
56
- console.log(` Total: ${crons.length} jobs`);
57
- console.log(` Enabled: ${crons.filter((c) => c.enabled !== false).length} jobs`);
50
+ const crons = await hub.listCrons();
51
+ TUI.printKeyValue('Total Cron Jobs', `${crons.length} jobs`);
52
+ TUI.printKeyValue('Enabled Jobs', `${crons.filter((c) => c.enabled !== false).length} jobs`);
58
53
  console.log();
59
54
 
60
55
  // NPM Registry
61
- console.log(chalk.yellow('NPM Registry:'));
62
- console.log(` URL: https://registry.npmjs.org`);
63
- console.log(` Cache: Enabled (5 minutes)`);
56
+ TUI.printKeyValue('Registry URL', 'https://registry.npmjs.org');
57
+ TUI.printKeyValue('Cache', 'Enabled (5 minutes)');
64
58
  console.log();
65
59
 
66
- console.log(chalk.green(' ระบบพร้อมใช้งาน'));
60
+ TUI.printSuccess('System is operational');
67
61
  console.log();
68
62
  };