// `rnx get tree` — pruned structured semantic tree, default depth 5. import { formatSemanticTree, inspectTree, isSimSemanticTree } from './core' import { printJson, wantsJson } from './shared' import type { WsBridge } from '../../ws-bridge' export async function runTreeSubcommand(opts: { bridge: WsBridge args: string[] positional: string[] }): Promise { const { bridge, args, positional } = opts // --boxes keeps the deeper default expected by geometry consumers. the // semantic tree is structured in both modes. const boxes = args.includes('--boxes') const depth = positional[1] ? Number(positional[1]) : boxes ? 50 : 5 const { tree } = await inspectTree(bridge, depth) if (wantsJson(args)) { printJson({ depth, tree: tree ?? null }) return } console.log(isSimSemanticTree(tree) ? formatSemanticTree(tree) : '') }