@dhruv2mars/offdex 0.0.6 → 0.0.8

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.
Files changed (3) hide show
  1. package/README.md +2 -1
  2. package/bin/offdex.js +105 -37
  3. package/package.json +1 -2
package/README.md CHANGED
@@ -25,9 +25,10 @@ Supported targets:
25
25
  Common usage:
26
26
 
27
27
  ```bash
28
+ offdex
29
+ offdex help
28
30
  offdex start --host 0.0.0.0 --port 42420
29
31
  offdex start --control-plane-url https://control.offdex.app
30
32
  offdex status
31
33
  offdex stop
32
- offdex --help
33
34
  ```
package/bin/offdex.js CHANGED
@@ -13,54 +13,111 @@ import {
13
13
  } from "./offdex-lib.js";
14
14
 
15
15
  const args = process.argv.slice(2);
16
- const ONBOARDING_TEXT = `Offdex
17
- Codex from your phone.
16
+ const colorEnabled =
17
+ Boolean(process.stdout.isTTY) &&
18
+ process.env.NO_COLOR !== "1" &&
19
+ process.env.NO_COLOR !== "true" &&
20
+ process.env.TERM !== "dumb";
21
+ const paint = (code, text) => colorEnabled ? `\u001b[${code}m${text}\u001b[0m` : text;
22
+ const green = (text) => paint("38;2;16;163;127", text);
23
+ const muted = (text) => paint("38;2;156;163;160", text);
24
+ const bold = (text) => paint("1", text);
25
+ const command = (text) => paint("38;2;225;229;226", text);
26
+ const link = (text) => paint("38;2;203;255;229", text);
18
27
 
19
- Get started:
20
- 1. Run offdex start
21
- 2. Open Offdex on your phone
22
- 3. Scan the QR from this terminal
28
+ function onboardingText() {
29
+ return [
30
+ bold(green("Offdex")),
31
+ muted("Codex mobile app."),
32
+ "",
33
+ "Use Codex from your phone while the real Codex session keeps running on this Mac.",
34
+ "",
35
+ green("Get started"),
36
+ ` 1. Run ${command("offdex start")}`,
37
+ " 2. Open Offdex on your phone.",
38
+ " 3. Scan the QR from this terminal.",
39
+ " 4. Send a prompt and watch Codex reply live.",
40
+ "",
41
+ green("Core commands"),
42
+ ` ${command("offdex help")} Commands, docs, GitHub, feedback.`,
43
+ ` ${command("offdex start")} Start the bridge and show the QR.`,
44
+ ` ${command("offdex status")} Show bridge, Codex, and client status.`,
45
+ ` ${command("offdex stop")} Stop the local bridge.`,
46
+ "",
47
+ `Docs: ${link("https://offdexapp.vercel.app")}`,
48
+ ].join("\n");
49
+ }
23
50
 
24
- Useful commands:
25
- offdex start Start the Mac bridge
26
- offdex status Check if Offdex is running
27
- offdex stop Stop the local bridge
28
- offdex --help Show all options
29
- `;
30
- const HELP_TEXT = `Offdex CLI
51
+ function helpText() {
52
+ return [
53
+ bold(green("Offdex help")),
54
+ muted("Codex mobile app."),
55
+ "",
56
+ green("Commands"),
57
+ ` ${command("offdex")}`,
58
+ " Open the Offdex home screen.",
59
+ "",
60
+ ` ${command("offdex help")}`,
61
+ " Show commands, docs, and support links.",
62
+ "",
63
+ ` ${command("offdex start")} ${muted("[options]")}`,
64
+ " Start the bridge and show the pairing QR.",
65
+ "",
66
+ ` ${command("offdex status")} ${muted("[options]")}`,
67
+ " Show bridge, Codex, client, and remote status.",
68
+ "",
69
+ ` ${command("offdex stop")} ${muted("[options]")}`,
70
+ " Stop the local bridge started by Offdex.",
71
+ "",
72
+ green("Start options"),
73
+ ` ${command("--host <host>")} Default: 0.0.0.0`,
74
+ ` ${command("--port <port>")} Default: 42420`,
75
+ ` ${command("--mode <codex|demo>")} Default: codex`,
76
+ ` ${command("--control-plane-url <url>")} Enable managed remote pairing.`,
77
+ "",
78
+ green("Environment fallbacks"),
79
+ ` ${command("OFFDEX_BRIDGE_HOST")}`,
80
+ ` ${command("OFFDEX_BRIDGE_PORT")}`,
81
+ ` ${command("OFFDEX_BRIDGE_MODE")}`,
82
+ ` ${command("OFFDEX_CONTROL_PLANE_URL")}`,
83
+ "",
84
+ green("Links"),
85
+ ` Docs: ${link("https://offdexapp.vercel.app")}`,
86
+ ` GitHub: ${link("https://github.com/Dhruv2mars/offdex")}`,
87
+ ` Feedback: ${link("https://github.com/Dhruv2mars/offdex/issues")}`,
88
+ ].join("\n");
89
+ }
31
90
 
32
- Usage:
33
- offdex
34
- offdex start [options]
35
- offdex status [options]
36
- offdex stop [options]
37
- offdex --help
91
+ function offlineText() {
92
+ return [
93
+ bold("Offdex is not running"),
94
+ `Start it with: ${command("offdex start")}`,
95
+ ].join("\n");
96
+ }
38
97
 
39
- Commands:
40
- start Start the Mac bridge and show the pairing QR
41
- status Check the local bridge
42
- stop Stop the local bridge started by Offdex
98
+ function commandName(argv) {
99
+ return argv[0] ?? "onboarding";
100
+ }
43
101
 
44
- Options:
45
- --host <host> Bridge host. Default: 0.0.0.0
46
- --port <port> Bridge port. Default: 42420
47
- --mode <codex|demo> Bridge runtime mode. Default: codex
48
- --control-plane-url <url> Managed remote control plane URL
49
- -h, --help Show help
102
+ function canAnswerWithoutRuntime(argv) {
103
+ const name = commandName(argv);
104
+ return (
105
+ argv.length === 0 ||
106
+ name === "help" ||
107
+ name === "--help" ||
108
+ name === "-h" ||
109
+ name === "status" ||
110
+ name === "stop"
111
+ );
112
+ }
50
113
 
51
- Environment fallbacks:
52
- OFFDEX_BRIDGE_HOST
53
- OFFDEX_BRIDGE_PORT
54
- OFFDEX_BRIDGE_MODE
55
- OFFDEX_CONTROL_PLANE_URL
56
- `;
57
114
  const installedBin = resolveInstalledBin(process.env, process.platform);
58
115
  const packageVersion = readPackageVersion();
59
116
  const currentInstalledVersion = installedVersion(process.env);
60
117
  const workspaceBridgeCli = resolveWorkspaceBridgeCli();
61
118
 
62
119
  if (!existsSync(installedBin) && args.length === 0) {
63
- console.log(ONBOARDING_TEXT);
120
+ console.log(onboardingText());
64
121
  process.exit(0);
65
122
  }
66
123
 
@@ -68,7 +125,7 @@ if (
68
125
  !existsSync(installedBin) &&
69
126
  (args[0] === "help" || args[0] === "--help" || args[0] === "-h")
70
127
  ) {
71
- console.log(HELP_TEXT);
128
+ console.log(helpText());
72
129
  process.exit(0);
73
130
  }
74
131
 
@@ -80,7 +137,18 @@ if (workspaceBridgeCli && !existsSync(installedBin)) {
80
137
  process.exit(result.status ?? 1);
81
138
  }
82
139
 
140
+ if (!existsSync(installedBin) && args[0] === "status") {
141
+ console.log(offlineText());
142
+ process.exit(1);
143
+ }
144
+
145
+ if (!existsSync(installedBin) && args[0] === "stop") {
146
+ console.log(offlineText());
147
+ process.exit(0);
148
+ }
149
+
83
150
  if (
151
+ !canAnswerWithoutRuntime(args) &&
84
152
  shouldInstallBinary({
85
153
  binExists: existsSync(installedBin),
86
154
  installedVersion: currentInstalledVersion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhruv2mars/offdex",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Codex mobile bridge CLI for Offdex",
5
5
  "type": "module",
6
6
  "bin": {
@@ -14,7 +14,6 @@
14
14
  },
15
15
  "scripts": {
16
16
  "offdex": "node bin/offdex.js",
17
- "postinstall": "node bin/install.js",
18
17
  "build": "node -e \"process.exit(0)\"",
19
18
  "check": "node --check bin/offdex.js && node --check bin/offdex-lib.js && node --check bin/install.js && node --check bin/install-lib.js && node --test test/*.test.js",
20
19
  "test": "node --test test/*.test.js"