@dhruv2mars/offdex 0.0.7 → 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 (2) hide show
  1. package/bin/offdex.js +106 -52
  2. package/package.json +1 -2
package/bin/offdex.js CHANGED
@@ -13,68 +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 mobile app.
18
-
19
- Use Codex from your phone while the real Codex session keeps running on this Mac.
20
-
21
- Get started:
22
- 1. Run: offdex start
23
- 2. Open Offdex on your phone.
24
- 3. Scan the QR from this terminal.
25
- 4. Send a prompt and watch Codex reply live.
26
-
27
- Core commands:
28
- offdex help Commands, docs, GitHub, feedback.
29
- offdex start Start the bridge and show the QR.
30
- offdex status Show bridge, Codex, and client status.
31
- offdex stop Stop the local bridge.
32
-
33
- Docs: https://offdexapp.vercel.app
34
- `;
35
- const HELP_TEXT = `Offdex help
36
- Codex mobile app.
37
-
38
- Commands:
39
- offdex
40
- Open the Offdex home screen.
41
-
42
- offdex help
43
- Show commands, docs, and support links.
44
-
45
- offdex start [options]
46
- Start the bridge and show the pairing QR.
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);
27
+
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
+ }
47
50
 
48
- offdex status [options]
49
- Show bridge, Codex, client, and remote status.
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
+ }
50
90
 
51
- offdex stop [options]
52
- Stop the local bridge started by Offdex.
91
+ function offlineText() {
92
+ return [
93
+ bold("Offdex is not running"),
94
+ `Start it with: ${command("offdex start")}`,
95
+ ].join("\n");
96
+ }
53
97
 
54
- Start options:
55
- --host <host> Default: 0.0.0.0
56
- --port <port> Default: 42420
57
- --mode <codex|demo> Default: codex
58
- --control-plane-url <url> Enable managed remote pairing.
98
+ function commandName(argv) {
99
+ return argv[0] ?? "onboarding";
100
+ }
59
101
 
60
- Environment fallbacks:
61
- OFFDEX_BRIDGE_HOST
62
- OFFDEX_BRIDGE_PORT
63
- OFFDEX_BRIDGE_MODE
64
- OFFDEX_CONTROL_PLANE_URL
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
+ }
65
113
 
66
- Links:
67
- Docs: https://offdexapp.vercel.app
68
- GitHub: https://github.com/Dhruv2mars/offdex
69
- Feedback: https://github.com/Dhruv2mars/offdex/issues
70
- `;
71
114
  const installedBin = resolveInstalledBin(process.env, process.platform);
72
115
  const packageVersion = readPackageVersion();
73
116
  const currentInstalledVersion = installedVersion(process.env);
74
117
  const workspaceBridgeCli = resolveWorkspaceBridgeCli();
75
118
 
76
119
  if (!existsSync(installedBin) && args.length === 0) {
77
- console.log(ONBOARDING_TEXT);
120
+ console.log(onboardingText());
78
121
  process.exit(0);
79
122
  }
80
123
 
@@ -82,7 +125,7 @@ if (
82
125
  !existsSync(installedBin) &&
83
126
  (args[0] === "help" || args[0] === "--help" || args[0] === "-h")
84
127
  ) {
85
- console.log(HELP_TEXT);
128
+ console.log(helpText());
86
129
  process.exit(0);
87
130
  }
88
131
 
@@ -94,7 +137,18 @@ if (workspaceBridgeCli && !existsSync(installedBin)) {
94
137
  process.exit(result.status ?? 1);
95
138
  }
96
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
+
97
150
  if (
151
+ !canAnswerWithoutRuntime(args) &&
98
152
  shouldInstallBinary({
99
153
  binExists: existsSync(installedBin),
100
154
  installedVersion: currentInstalledVersion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhruv2mars/offdex",
3
- "version": "0.0.7",
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"