/**
 * studiograph connector — list / remove configured MCP connectors.
 *
 * The interactive `add` subcommand was removed in cli-owner-audit Phase C6.
 * The web UI (Settings → Connectors) is the canonical surface — it handles
 * OAuth flows, per-user vs workspace credential scoping, and connection
 * health checks that the CLI never did. The CLI keeps `list` + `remove`
 * as the break-glass recovery path for when the web UI can't reach the
 * server (e.g., misconfigured connector blocking boot).
 *
 * Configs live at `~/.studiograph/connectors/<name>.json` (mode 0600) +
 * optionally `<workspace>/.studiograph/connectors/<name>.json` for the
 * sanitized git-tracked copy.
 */
import { Command } from 'commander';
import { ConnectorManager } from '../../mcp/connector-manager.js';
import { Workspace } from '../../core/workspace.js';
export const connectorCommand = new Command('connector').description('List or remove configured MCP connectors (add via the web UI: Settings → Connectors)');
// ── connector list ──────────────────────────────────────────────────────────
connectorCommand
    .command('list')
    .description('List configured connectors')
    .action(() => {
    let wsPath;
    try {
        const ws = new Workspace();
        if (ws.isWorkspace())
            wsPath = ws.getWorkspacePath();
    }
    catch { /* outside a workspace — fine, user-scoped configs only */ }
    const configs = ConnectorManager.loadConfigs(wsPath);
    if (configs.length === 0) {
        console.log('No connectors configured.');
        console.log('Add one via the web UI: Settings → Connectors.');
        return;
    }
    console.log(`Configured connectors (${configs.length}):\n`);
    for (const c of configs) {
        console.log(`  ${c.name.padEnd(16)} ${c.url}`);
        if (c.description)
            console.log(`  ${''.padEnd(16)} ${c.description}`);
        console.log();
    }
});
// ── connector remove ────────────────────────────────────────────────────────
connectorCommand
    .command('remove <name>')
    .description('Remove a connector')
    .action((name) => {
    const removed = ConnectorManager.removeConfig(name);
    if (removed) {
        console.log(`Connector "${name}" removed.`);
    }
    else {
        console.error(`No connector named "${name}" found.`);
        process.exit(1);
    }
});
//# sourceMappingURL=connector.js.map