flowviant 0.38.0 → 0.40.0

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.
@@ -7,6 +7,7 @@
7
7
  import { execFileSync } from 'node:child_process';
8
8
  import { ok, warn, info, c } from './ui.mjs';
9
9
  import { addLocalBinToPath, promptYesNo, installClaude, installGh } from './install.mjs';
10
+ import { RUNTIMES, detectRuntimes, mediatedSafeGap } from './runtimes.mjs';
10
11
 
11
12
  function present(cmd) {
12
13
  try {
@@ -28,28 +29,66 @@ function ghAuthed() {
28
29
 
29
30
  /** Prints a checklist and, when a missing prereq is auto-installable, OFFERS to
30
31
  * install it (consent-based, never silent). Returns false only if a *fatal*
31
- * prereq (claude, or git when worktrees are used) is still missing after. */
32
+ * prereq (SOME drivable runtime, or git when worktrees are used) is still
33
+ * missing after. */
32
34
  export async function preflight({ needGit = true } = {}) {
33
35
  addLocalBinToPath(); // find a gh/cloudflared we bundled on a previous run
34
- let claude = present('claude');
35
36
  let gh = present('gh');
36
37
  const node18 = Number(process.versions.node.split('.')[0]) >= 18;
37
38
  const git = needGit ? present('git') : true;
38
39
 
39
40
  info('checking your setup (this tool drives these — it never sees their logins):');
40
41
 
41
- // claude — fatal. Offer the official npm install (no-default: it's bigger and
42
- // account-coupled, so we don't push it).
43
- if (claude) {
44
- ok(`claude installed ${c.dim('· must be signed in run `claude` once if you haven’t')}`);
45
- } else {
46
- warn('claude NOT found Claude Code is required.');
47
- if (await promptYesNo('Install Claude Code now?', false)) {
48
- if (installClaude((m) => info(m))) claude = present('claude');
42
+ // THE RUNTIMES. This used to test one binary — `present('claude')` and treat
43
+ // its absence as fatal, which stopped being right the moment a second CLI could
44
+ // build a task: a machine with Codex and no Claude Code is a working machine,
45
+ // and it was refused at startup. What is fatal is having NOTHING to build with.
46
+ //
47
+ // Reported per runtime rather than as a single verdict, because the three
48
+ // states a user can be in need three different sentences: not installed
49
+ // (install it), installed but this daemon cannot drive it here (the live-mode
50
+ // note, or the registry's own `blocked` reason), and ready.
51
+ let detected = detectRuntimes({ refresh: true });
52
+ const shown = detected.filter((r) => r.installed || r.id === 'claude');
53
+ for (const r of shown) {
54
+ const rt = RUNTIMES[r.id];
55
+ if (r.dispatchable) {
56
+ ok(
57
+ `${rt.bin} installed ${c.dim(`· ${rt.label} · must be signed in — run \`${rt.login}\` once if you haven’t`)}`
58
+ );
59
+ } else if (r.installed) {
60
+ warn(`${rt.bin} installed but not usable here ${c.dim(`· ${r.blocked ?? 'unsupported'}`)}`);
61
+ } else if (r.id === 'claude') {
62
+ // Only Claude gets an install offer: it is the one whose installer we
63
+ // control and can verify. The others are named, not fetched.
64
+ warn('claude NOT found.');
65
+ if (await promptYesNo('Install Claude Code now?', false)) {
66
+ if (installClaude((m) => info(m))) detected = detectRuntimes({ refresh: true });
67
+ }
68
+ if (!detected.find((d) => d.id === 'claude')?.installed) {
69
+ warn('install Claude Code manually: https://claude.com/claude-code');
70
+ }
71
+ }
72
+ }
73
+ const drivable = detected.filter((r) => r.dispatchable);
74
+ // SAFE mode narrows what an agent may do — except on a runtime whose only
75
+ // permission control is all-or-nothing. Say so at startup rather than letting
76
+ // an operator believe a setting is in force that isn't.
77
+ for (const r of drivable) {
78
+ if (mediatedSafeGap(RUNTIMES[r.id])) {
79
+ warn(
80
+ `${RUNTIMES[r.id].bin}: FLOWVIANT_SAFE cannot narrow this runtime — it has no per-invocation permission control, so its builds run unrestricted`
81
+ );
82
+ }
83
+ }
84
+ // Name the alternatives once, and only when there is nothing to build with —
85
+ // a working machine does not need a catalogue of the CLIs it is not using.
86
+ if (drivable.length === 0) {
87
+ for (const rt of Object.values(RUNTIMES)) {
88
+ if (!detected.find((d) => d.id === rt.id)?.installed) {
89
+ info(`${c.dim(`or ${rt.label}: ${rt.install}`)}`);
90
+ }
49
91
  }
50
- claude
51
- ? ok('claude installed — run `claude` once to sign in')
52
- : warn('install Claude Code manually: https://claude.com/claude-code');
53
92
  }
54
93
 
55
94
  // gh — needed to open PRs. Offer to fetch the isolated binary (yes-default:
@@ -72,6 +111,8 @@ export async function preflight({ needGit = true } = {}) {
72
111
  node18 ? ok(`node ${process.versions.node}`) : warn(`node ${process.versions.node} — need 18+`);
73
112
  console.log('');
74
113
 
75
- if (!claude) warn('Without `claude` nothing can run — install + sign in, then restart.');
76
- return claude && git;
114
+ if (drivable.length === 0) {
115
+ warn('No usable coding CLI — install and sign in to one of the above, then restart.');
116
+ }
117
+ return drivable.length > 0 && git;
77
118
  }