codex-to-poke 0.1.0 → 0.1.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/README.md CHANGED
@@ -6,10 +6,11 @@ Pokedex is an independent open-source project. It is not affiliated with, endors
6
6
 
7
7
  ```bash
8
8
  codex login
9
- npx poke@latest login
10
9
  npx codex-to-poke
11
10
  ```
12
11
 
12
+ Pokedex starts the Poke login flow automatically if the tunnel needs it.
13
+
13
14
  Keep the terminal open while using Poke. When the prompt opens, type `help` to see commands.
14
15
 
15
16
  Common modes:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-to-poke",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Unofficial local Poke to Codex bridge.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -149,14 +149,59 @@ async function startStack() {
149
149
  await waitForAgent();
150
150
  statuses.agent = 'ok';
151
151
 
152
- statuses.poke = 'starting';
153
- spawnManaged('poke', npxBin(), ['poke@latest', 'tunnel', mcpHttpUrlWithToken(), '-n', 'pokedex']);
154
- await waitForPoke();
152
+ await startPokeTunnel();
155
153
  statuses.poke = 'ok';
156
- console.log("✅ Everything's fine. pokedex is ready.");
154
+ console.log("✅ Everything's fine, we're ready.\n");
155
+ console.log('Try saying "is pokedex connected?" to your Poke!\n');
157
156
  console.log('Type "help" for commands. Keep this terminal open while you use Poke.\n');
158
157
  }
159
158
 
159
+ async function startPokeTunnel() {
160
+ statuses.poke = 'starting';
161
+ spawnPokeTunnel();
162
+ try {
163
+ await waitForPoke();
164
+ } catch (error) {
165
+ if (!pokeNeedsLogin()) throw error;
166
+ await runPokeLogin();
167
+ spawnPokeTunnel();
168
+ await waitForPoke();
169
+ }
170
+ }
171
+
172
+ function spawnPokeTunnel() {
173
+ spawnManaged('poke', npxBin(), ['poke@latest', 'tunnel', mcpHttpUrlWithToken(), '-n', 'pokedex']);
174
+ }
175
+
176
+ async function runPokeLogin() {
177
+ console.log('Poke is not logged in. Starting `npx poke@latest login`...\n');
178
+ const code = await runInteractive(npxBin(), ['poke@latest', 'login']);
179
+ if (code !== 0)
180
+ throw new Error('Poke login did not complete. Run `npx poke@latest login` and retry.');
181
+ console.log('\nPoke login finished. Starting the tunnel again...\n');
182
+ }
183
+
184
+ function runInteractive(command, commandArgs) {
185
+ return new Promise((resolveRun, rejectRun) => {
186
+ const child = spawn(command, commandArgs, {
187
+ cwd: invocationCwd,
188
+ stdio: 'inherit',
189
+ env: process.env,
190
+ });
191
+ child.on('error', rejectRun);
192
+ child.on('exit', (code, signal) => {
193
+ if (signal) rejectRun(new Error(`Poke login stopped by ${signal}.`));
194
+ else resolveRun(code ?? 0);
195
+ });
196
+ });
197
+ }
198
+
199
+ function pokeNeedsLogin() {
200
+ return (serviceLogs.get('poke') ?? []).some((line) =>
201
+ /not logged in|npx poke@latest login|poke login/i.test(line)
202
+ );
203
+ }
204
+
160
205
  async function waitForRelay() {
161
206
  await waitFor(
162
207
  async () => {
@@ -439,7 +484,7 @@ function printInteractiveHelp() {
439
484
 
440
485
  setup
441
486
  codex login
442
- npx poke@latest login`);
487
+ Poke login opens automatically if needed`);
443
488
  }
444
489
 
445
490
  function spawnManaged(name, bin, binArgs) {
@@ -802,7 +847,7 @@ usage
802
847
 
803
848
  setup
804
849
  codex login
805
- npx poke@latest login
850
+ Poke login opens automatically if needed
806
851
 
807
852
  config
808
853
  ~/.pokedex/config.json