@synergenius/flow-weaver 0.16.0 → 0.17.1

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.
@@ -12,6 +12,13 @@ import { isNonInteractive } from './init.js';
12
12
  const MCP_COMMAND = 'npx';
13
13
  const MCP_ARGS = ['@synergenius/flow-weaver@latest', 'mcp-server', '--stdio'];
14
14
  const MCP_ENTRY = { command: MCP_COMMAND, args: [...MCP_ARGS] };
15
+ /** Tools that can be spawned as interactive CLI sessions */
16
+ export const CLI_TOOL_IDS = new Set(['claude', 'codex']);
17
+ /** Binary name to spawn for each CLI tool */
18
+ export const CLI_TOOL_BINARY = {
19
+ claude: 'claude',
20
+ codex: 'codex',
21
+ };
15
22
  // ── Deps ─────────────────────────────────────────────────────────────────────
16
23
  export function defaultDeps() {
17
24
  return {
@@ -261,6 +268,58 @@ async function configureTool(tool, deps) {
261
268
  return { id: tool.id, displayName: tool.displayName, action: 'failed', detail: msg };
262
269
  }
263
270
  }
271
+ /**
272
+ * Detect and configure all AI tools without interactive prompts.
273
+ * Used by the init command after the user has already consented.
274
+ */
275
+ export async function runMcpSetupFromInit(deps) {
276
+ const d = deps ?? defaultDeps();
277
+ const detected = await detectTools(d);
278
+ const toConfig = detected.filter((t) => t.detected && !t.configured);
279
+ const configured = [];
280
+ const failed = [];
281
+ const toolMap = new Map(TOOL_REGISTRY.map((t) => [t.id, t]));
282
+ for (const t of toConfig) {
283
+ const tool = toolMap.get(t.id);
284
+ if (!tool)
285
+ continue;
286
+ const result = await configureTool(tool, d);
287
+ if (result.action === 'configured') {
288
+ configured.push(result.displayName);
289
+ }
290
+ else if (result.action === 'failed') {
291
+ failed.push(result.displayName);
292
+ }
293
+ }
294
+ // Include already-configured tools in the configured list
295
+ for (const t of detected) {
296
+ if (t.configured) {
297
+ configured.push(t.displayName);
298
+ }
299
+ }
300
+ // Classify configured/detected tools as CLI or GUI
301
+ const allConfiguredIds = detected
302
+ .filter((t) => t.detected && (t.configured || configured.includes(t.displayName)))
303
+ .map((t) => t.id);
304
+ const cliTools = allConfiguredIds.filter((id) => CLI_TOOL_IDS.has(id));
305
+ const guiTools = allConfiguredIds.filter((id) => !CLI_TOOL_IDS.has(id));
306
+ return { configured, failed, detected, cliTools, guiTools };
307
+ }
308
+ // ── Quick CLI tool detection (no config, just binary check) ──────────────────
309
+ /**
310
+ * Check which CLI agent tools are available on PATH.
311
+ * Lightweight: only runs `which` for known CLI binaries.
312
+ */
313
+ export async function detectCliTools(deps) {
314
+ const d = deps ?? defaultDeps();
315
+ const results = [];
316
+ for (const [id, binary] of Object.entries(CLI_TOOL_BINARY)) {
317
+ if (binary && await binaryExists(binary, d)) {
318
+ results.push(id);
319
+ }
320
+ }
321
+ return results;
322
+ }
264
323
  // ── Command ──────────────────────────────────────────────────────────────────
265
324
  export async function mcpSetupCommand(options, deps) {
266
325
  const d = deps ?? defaultDeps();