clawmate 1.4.1 → 1.4.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawmate",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "ClawMate - Give your AI a living body on screen",
5
5
  "main": "main/index.js",
6
6
  "bin": {
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  /**
2
3
  * "Launch pet" handler logic
3
4
  *
@@ -11,54 +12,63 @@ const path = require('path');
11
12
  const os = require('os');
12
13
  const fs = require('fs');
13
14
 
14
- module.exports = {
15
- async execute(context) {
16
- const platform = os.platform();
17
- const appRoot = path.resolve(__dirname, '..', '..');
15
+ async function launch(context) {
16
+ const log = context?.log || console.log;
17
+ const platform = os.platform();
18
+ const appRoot = path.resolve(__dirname, '..', '..');
18
19
 
19
- // Check Electron installation
20
- const nodeModulesPath = path.join(appRoot, 'node_modules');
21
- if (!fs.existsSync(nodeModulesPath)) {
22
- context.log('Installing dependencies...');
23
- try {
24
- const npmCmd = platform === 'win32' ? 'npm.cmd' : 'npm';
25
- execSync(`${npmCmd} install`, {
26
- cwd: appRoot,
27
- stdio: 'pipe',
28
- timeout: 120000,
29
- });
30
- context.log('Dependencies installed!');
31
- } catch (err) {
32
- return {
33
- success: false,
34
- message: `Dependency installation failed: ${err.message}`,
35
- };
36
- }
37
- }
38
-
39
- // Launch Electron app
20
+ // Check Electron installation
21
+ const nodeModulesPath = path.join(appRoot, 'node_modules');
22
+ if (!fs.existsSync(nodeModulesPath)) {
23
+ log('Installing dependencies...');
40
24
  try {
41
- const electronBin = platform === 'win32' ? 'npx.cmd' : 'npx';
42
- const child = spawn(electronBin, ['electron', appRoot], {
43
- detached: true,
44
- stdio: 'ignore',
25
+ const npmCmd = platform === 'win32' ? 'npm.cmd' : 'npm';
26
+ execSync(`${npmCmd} install`, {
45
27
  cwd: appRoot,
46
- env: { ...process.env },
28
+ stdio: 'inherit',
29
+ timeout: 120000,
47
30
  });
48
- child.unref();
49
-
50
- const mode = context.params?.mode || 'pet';
51
- const modeName = mode === 'pet' ? 'Clawby' : 'Claw';
52
-
53
- return {
54
- success: true,
55
- message: `ClawMate (${modeName}) has appeared on your desktop! \uD83E\uDD9E`,
56
- };
31
+ log('Dependencies installed!');
57
32
  } catch (err) {
58
33
  return {
59
34
  success: false,
60
- message: `Launch failed: ${err.message}`,
35
+ message: `Dependency installation failed: ${err.message}`,
61
36
  };
62
37
  }
63
- },
64
- };
38
+ }
39
+
40
+ // Launch Electron app
41
+ try {
42
+ const electronBin = platform === 'win32' ? 'npx.cmd' : 'npx';
43
+ const child = spawn(electronBin, ['electron', appRoot], {
44
+ detached: true,
45
+ stdio: 'ignore',
46
+ cwd: appRoot,
47
+ env: { ...process.env },
48
+ });
49
+ child.unref();
50
+
51
+ const mode = context?.params?.mode || 'pet';
52
+ const modeName = mode === 'pet' ? 'Clawby' : 'Claw';
53
+
54
+ return {
55
+ success: true,
56
+ message: `ClawMate (${modeName}) has appeared on your desktop! \uD83E\uDD9E`,
57
+ };
58
+ } catch (err) {
59
+ return {
60
+ success: false,
61
+ message: `Launch failed: ${err.message}`,
62
+ };
63
+ }
64
+ }
65
+
66
+ // CLI entry point
67
+ if (require.main === module) {
68
+ launch().then((result) => {
69
+ console.log(result.message);
70
+ if (!result.success) process.exit(1);
71
+ });
72
+ }
73
+
74
+ module.exports = { execute: launch };