robot-resources 1.12.1 → 1.12.3

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.
@@ -1,7 +1,7 @@
1
1
  import { existsSync, readFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { select } from '@inquirer/prompts';
4
- import { isClaudeCodeInstalled, isCursorInstalled } from './detect.js';
4
+ import { isClaudeCodeInstalled, isCursorInstalled, detectAgentRuntime } from './detect.js';
5
5
  import { configureClaudeCode, configureCursor } from './tool-config.js';
6
6
  import { header, info, success, warn, blank } from './ui.js';
7
7
  import { readConfig } from './config.mjs';
@@ -223,6 +223,29 @@ export async function runNonOcWizard({ nonInteractive = false, target = null } =
223
223
  }
224
224
 
225
225
  if (nonInteractive) {
226
+ // Phase 3.5: when project shape is unambiguous (cwd has a package.json
227
+ // OR a Python project file), auto-install the matching shim instead of
228
+ // bailing with a hint. CI/agents running `npx robot-resources` from
229
+ // their repo are exactly this case — making them pass `--for=` is
230
+ // friction we don't need.
231
+ //
232
+ // The Phase 3 noninteractive_no_target path is preserved for the case
233
+ // where detection finds nothing (truly empty cwd, generic shell run).
234
+ const runtime = detectAgentRuntime();
235
+ let autoTarget = null;
236
+ if (runtime.kind === 'node' || runtime.kind === 'both') autoTarget = 'js';
237
+ else if (runtime.kind === 'python') autoTarget = 'python';
238
+
239
+ if (autoTarget) {
240
+ // Brief context so the install step doesn't feel sudden.
241
+ info(`Detected a ${autoTarget === 'js' ? 'Node' : 'Python'} project — installing the matching shim automatically.`);
242
+ info(' Pass --for=<other> to override, or --uninstall to remove later.');
243
+ blank();
244
+ await runPath(autoTarget);
245
+ await emitPathChosen(autoTarget);
246
+ return;
247
+ }
248
+
226
249
  info('Robot Resources requires OpenClaw, which we did not detect on this machine.');
227
250
  info('To bypass this prompt in CI / non-TTY contexts, re-run with --for=<target>:');
228
251
  info(' npx robot-resources --for=langchain # JS/TS agent');
@@ -243,19 +266,40 @@ export async function runNonOcWizard({ nonInteractive = false, target = null } =
243
266
 
244
267
  const defaultPath = detectDefaultPath() ?? 'js';
245
268
 
269
+ // Phase 3.6: race the prompt against a timeout. Some agent runners report
270
+ // stdin.isTTY=true (so `nonInteractive` ends up false), then never deliver
271
+ // a keystroke — `select()` blocks forever and the wizard exits silently
272
+ // without firing wizard_path_chosen. The May-2 23:31 RU cluster all hit
273
+ // this: 5 wizard_started events, zero wizard_path_chosen.
274
+ //
275
+ // After SELECT_TIMEOUT_MS, we treat the session as practically
276
+ // non-interactive and fall through to the same auto-detect path the
277
+ // nonInteractive branch above uses (Phase 3.5).
278
+ const SELECT_TIMEOUT_MS = Number(process.env.RR_WIZARD_SELECT_TIMEOUT_MS) || 30_000;
279
+ const TIMED_OUT = Symbol('select_timeout');
280
+
246
281
  let chosen;
282
+ let timer;
247
283
  try {
248
- chosen = await select({
249
- message: 'What are you building?',
250
- default: defaultPath,
251
- choices: [
252
- { name: PATH_LABELS.js, value: 'js' },
253
- { name: PATH_LABELS.python, value: 'python' },
254
- { name: PATH_LABELS.mcp, value: 'mcp' },
255
- { name: PATH_LABELS.docs, value: 'docs' },
256
- { name: PATH_LABELS['install-oc'], value: 'install-oc' },
257
- ],
258
- });
284
+ chosen = await Promise.race([
285
+ select({
286
+ message: 'What are you building?',
287
+ default: defaultPath,
288
+ choices: [
289
+ { name: PATH_LABELS.js, value: 'js' },
290
+ { name: PATH_LABELS.python, value: 'python' },
291
+ { name: PATH_LABELS.mcp, value: 'mcp' },
292
+ { name: PATH_LABELS.docs, value: 'docs' },
293
+ { name: PATH_LABELS['install-oc'], value: 'install-oc' },
294
+ ],
295
+ }),
296
+ new Promise((resolve) => {
297
+ timer = setTimeout(() => resolve(TIMED_OUT), SELECT_TIMEOUT_MS);
298
+ // Don't keep the event loop alive purely for this timer — once the
299
+ // user picks, the process should be free to exit.
300
+ if (typeof timer.unref === 'function') timer.unref();
301
+ }),
302
+ ]);
259
303
  } catch (err) {
260
304
  // User hit Ctrl-C or terminal closed — exit cleanly, but mark the funnel
261
305
  // so we can distinguish "agent shown the prompt and bailed" from
@@ -265,6 +309,34 @@ export async function runNonOcWizard({ nonInteractive = false, target = null } =
265
309
  return;
266
310
  }
267
311
  throw err;
312
+ } finally {
313
+ if (timer) clearTimeout(timer);
314
+ }
315
+
316
+ if (chosen === TIMED_OUT) {
317
+ // No keystroke after SELECT_TIMEOUT_MS — practically non-interactive.
318
+ // Mirror the Phase 3.5 auto-detect logic.
319
+ blank();
320
+ info(`No input received after ${Math.round(SELECT_TIMEOUT_MS / 1000)}s — treating session as non-interactive.`);
321
+ const runtime = detectAgentRuntime();
322
+ let autoTarget = null;
323
+ if (runtime.kind === 'node' || runtime.kind === 'both') autoTarget = 'js';
324
+ else if (runtime.kind === 'python') autoTarget = 'python';
325
+
326
+ if (autoTarget) {
327
+ info(`Detected a ${autoTarget === 'js' ? 'Node' : 'Python'} project — installing the matching shim automatically.`);
328
+ blank();
329
+ await runPath(autoTarget);
330
+ await emitPathChosen(autoTarget);
331
+ return;
332
+ }
333
+
334
+ // Truly empty cwd — nothing to install. Surface the timeout so the
335
+ // funnel can be queried separately from genuine aborts.
336
+ blank();
337
+ info('No project shape detected — nothing to install. Re-run with --for=<target>.');
338
+ await emitPathChosen('interactive_timeout');
339
+ return;
268
340
  }
269
341
 
270
342
  await runPath(chosen);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "robot-resources",
3
- "version": "1.12.1",
3
+ "version": "1.12.3",
4
4
  "description": "Robot Resources — AI agent tools. One command to install everything.",
5
5
  "type": "module",
6
6
  "bin": {