@mindexec/cli 0.2.0 → 0.2.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/README.md CHANGED
@@ -18,6 +18,14 @@ By default the CLI opens the MindCanvas app in your default browser after the
18
18
  bridge is ready. Use `mindexec --no-open` or `MINDEXEC_NO_OPEN=1` when you only
19
19
  want to start the listener.
20
20
 
21
+ For npx and global installs, the default workspace is the directory where you
22
+ run the command. Run it from the folder that contains your `.mindexec` data, or
23
+ pass the workspace explicitly:
24
+
25
+ ```bash
26
+ npx @mindexec/cli --workspace /path/to/workspace
27
+ ```
28
+
21
29
  For local frontend development, keep LocalBridge running and refresh the
22
30
  packaged app bundle after code changes:
23
31
 
@@ -47,6 +55,7 @@ mindexec
47
55
  湲곕낯 ?ㅽ뻾 二쇱냼??`http://127.0.0.1:5147`?낅땲?? `WORKSPACE_PATH`媛€ 鍮꾩뼱 ?덉쑝硫??ㅼ튂???⑦궎吏€??遺€紐??대뜑瑜?湲곕낯 ?묒뾽 怨듦컙?쇰줈 ?ъ슜?⑸땲??
48
56
 
49
57
  ```bash
58
+ mindexec --workspace /custom/path
50
59
  BRIDGE_PORT=8080 WORKSPACE_PATH=/custom/path mindexec
51
60
  ```
52
61
 
package/launch-bridge.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const path = require('path');
4
+ const fs = require('fs');
4
5
  const { spawn } = require('child_process');
5
6
  const packageInfo = require('./package.json');
6
7
  const { normalizePort, releaseBridgePort } = require('./port-guard.cjs');
@@ -8,23 +9,94 @@ const { normalizePort, releaseBridgePort } = require('./port-guard.cjs');
8
9
  const bridgeRoot = __dirname;
9
10
  const serverPath = path.resolve(bridgeRoot, 'server.js');
10
11
  const inheritedWorkspacePath = String(process.env.WORKSPACE_PATH || '').trim();
11
- const workspacePath = inheritedWorkspacePath || path.resolve(bridgeRoot, '..');
12
12
  const rawArgs = process.argv.slice(2);
13
+ const parsedArgs = extractWorkspaceArg(rawArgs);
14
+ const cliArgs = parsedArgs.args;
15
+ const workspacePath = path.resolve(
16
+ parsedArgs.workspacePath || inheritedWorkspacePath || getDefaultWorkspacePath()
17
+ );
13
18
  const appUrl = `http://localhost:${normalizePort(process.env.BRIDGE_PORT)}/mindcanvas`;
14
19
  const statusUrl = `http://127.0.0.1:${normalizePort(process.env.BRIDGE_PORT)}/api/status`;
15
20
 
21
+ function isSamePath(left, right) {
22
+ return path.resolve(left).toLowerCase() === path.resolve(right).toLowerCase();
23
+ }
24
+
25
+ function pathExists(...segments) {
26
+ return fs.existsSync(path.join(...segments));
27
+ }
28
+
29
+ function looksLikeWorkspaceRoot(candidate) {
30
+ return pathExists(candidate, '.mindexec')
31
+ || pathExists(candidate, 'MindExecution.Web')
32
+ || pathExists(candidate, 'MindExecution.Shared')
33
+ || pathExists(candidate, 'LocalBridge');
34
+ }
35
+
36
+ function getDefaultWorkspacePath() {
37
+ const cwd = process.cwd();
38
+ const bridgeParent = path.resolve(bridgeRoot, '..');
39
+
40
+ if (isSamePath(cwd, bridgeRoot) && looksLikeWorkspaceRoot(bridgeParent)) {
41
+ return bridgeParent;
42
+ }
43
+
44
+ return cwd;
45
+ }
46
+
47
+ function extractWorkspaceArg(args) {
48
+ const filteredArgs = [];
49
+ let workspacePath = '';
50
+
51
+ for (let index = 0; index < args.length; index += 1) {
52
+ const arg = args[index];
53
+ if (arg === '--workspace' || arg === '--workspace-path') {
54
+ workspacePath = String(args[index + 1] || '').trim();
55
+ if (!workspacePath) {
56
+ console.error(`[MindExec CLI] ${arg} requires a path.`);
57
+ process.exit(1);
58
+ }
59
+
60
+ index += 1;
61
+ continue;
62
+ }
63
+
64
+ if (arg.startsWith('--workspace=')) {
65
+ workspacePath = arg.slice('--workspace='.length).trim();
66
+ continue;
67
+ }
68
+
69
+ if (arg.startsWith('--workspace-path=')) {
70
+ workspacePath = arg.slice('--workspace-path='.length).trim();
71
+ continue;
72
+ }
73
+
74
+ filteredArgs.push(arg);
75
+ }
76
+
77
+ return {
78
+ args: filteredArgs,
79
+ workspacePath
80
+ };
81
+ }
82
+
16
83
  function printHelp() {
17
84
  console.log(`MindExec CLI ${packageInfo.version}
18
85
 
19
86
  Usage:
20
- mindexec [start] [node-options]
21
- npx @mindexec/cli
87
+ mindexec [start] [options] [node-options]
88
+ npx @mindexec/cli [options]
22
89
 
23
90
  Runs the MindExec local app and bridge on http://localhost:5147/mindcanvas by default.
24
91
 
92
+ Options:
93
+ --workspace <path>
94
+ Workspace root. Defaults to the current directory for npx/global runs
95
+ --no-open Do not open the local app in the default browser
96
+
25
97
  Environment:
26
98
  BRIDGE_PORT Local bridge port. Default: 5147
27
- WORKSPACE_PATH Workspace root. Default: parent of the installed package
99
+ WORKSPACE_PATH Workspace root. Overridden by --workspace when both are set
28
100
  BRIDGE_TOKEN Fixed token for protected REST APIs
29
101
  MINDEXEC_WEB_ROOT Published MindCanvas wwwroot override. Default: package wwwroot
30
102
  MINDEXEC_NO_OPEN=1
@@ -37,25 +109,27 @@ Environment:
37
109
  Examples:
38
110
  mindexec
39
111
  mindexec --no-open
112
+ mindexec --workspace /path/to/work
113
+ npx @mindexec/cli --workspace /path/to/work
40
114
  BRIDGE_PORT=8080 WORKSPACE_PATH=/path/to/work mindexec
41
115
  mindexec --watch
42
116
  `);
43
117
  }
44
118
 
45
- if (rawArgs.includes('--help') || rawArgs.includes('-h')) {
119
+ if (cliArgs.includes('--help') || cliArgs.includes('-h')) {
46
120
  printHelp();
47
121
  process.exit(0);
48
122
  }
49
123
 
50
- if (rawArgs.includes('--version') || rawArgs.includes('-v')) {
124
+ if (cliArgs.includes('--version') || cliArgs.includes('-v')) {
51
125
  console.log(packageInfo.version);
52
126
  process.exit(0);
53
127
  }
54
128
 
55
- const command = rawArgs[0];
129
+ const command = cliArgs[0];
56
130
  const commandArgs = command === 'start' || command === 'bridge'
57
- ? rawArgs.slice(1)
58
- : rawArgs;
131
+ ? cliArgs.slice(1)
132
+ : cliArgs;
59
133
  const shouldOpenApp = !commandArgs.some(arg => arg === '--no-open' || arg === '--no-browser')
60
134
  && !/^(1|true|yes|on)$/i.test(String(process.env.MINDEXEC_NO_OPEN || '').trim())
61
135
  && !/^(0|false|no|off)$/i.test(String(process.env.MINDEXEC_OPEN_APP || '').trim());
package/package.json CHANGED
@@ -1,25 +1,25 @@
1
1
  {
2
2
  "name": "@mindexec/cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "MindExec local runtime and bridge CLI",
5
5
  "main": "server.js",
6
6
  "type": "module",
7
- "files": [
8
- "start-bridge.bat",
9
- "start-bridge.sh",
10
- "launch-bridge.cjs",
11
- "server.js",
12
- "codex-runtime.js",
13
- "port-guard.cjs",
14
- "wwwroot/",
15
- "scripts/",
7
+ "files": [
8
+ "start-bridge.bat",
9
+ "start-bridge.sh",
10
+ "launch-bridge.cjs",
11
+ "server.js",
12
+ "codex-runtime.js",
13
+ "port-guard.cjs",
14
+ "wwwroot/",
15
+ "scripts/",
16
16
  "tree-sitter-grammars/",
17
17
  "README.md"
18
18
  ],
19
19
  "scripts": {
20
20
  "start": "node launch-bridge.cjs",
21
21
  "dev": "node launch-bridge.cjs --watch",
22
- "test:syntax": "node --check server.js && node --check codex-runtime.js && node --check launch-bridge.cjs && node --check port-guard.cjs && node --check scripts/setup-tree-sitter-grammars.mjs",
22
+ "test:syntax": "node --check server.js && node --check codex-runtime.js && node --check launch-bridge.cjs && node --check port-guard.cjs && node --check scripts/setup-tree-sitter-grammars.mjs",
23
23
  "pack:dry": "npm pack --dry-run",
24
24
  "setup:grammars": "node scripts/setup-tree-sitter-grammars.mjs",
25
25
  "postinstall": "npm run setup:grammars"