run method
Runs the command with parsed args.
Implementation
@override
Future<void> run(LocalCommandContext context, List<String> args) async {
final runFullScreen = context.runFullScreen;
if (runFullScreen == null) {
context.writeLine(':ide requires an interactive terminal.');
return;
}
if (context.client == null) {
context.writeLine(':ide requires a connected session.');
return;
}
if (args.length > 1) {
context.writeLine('usage: :ide [path]');
return;
}
final arg = args.isEmpty ? null : args.first;
final root = resolveRemoteIdeRoot(arg, context.currentRemoteCwd?.call());
if (root == null) {
context.writeLine(
':ide: remote working directory unknown yet — run a command first, '
'or pass an absolute path.',
);
return;
}
final workspace = RemoteWorkspace(
client: context.requireClient,
nodeId: context.node.id.value,
rootPath: root,
shellFamily: context.shellFamily,
);
// Wire the AI agent panel through the Hub (same precedence as `:ai`); a null
// provider makes the panel show setup help. The run_command tool is gated by
// the same shield the CLI builds (default detectors + knowledge risk).
final wiring = await resolveAiWiring(
settings: _settings,
service: _service,
);
final aiProvider = wiring == null
? null
: providerFor(wiring.config, wiring.httpClient);
final shield = CommandShield(
analyzer: Analyzer(
securityAnalyzer: SecurityAnalyzer(
detectors: [
...SecurityAnalyzer.defaultDetectors,
KnowledgeRiskDetector(),
],
),
),
);
await runFullScreen((input) async {
final driver = XtermTerminalDriver(
term: _term,
input: input,
resizeEvents: _resizeEvents,
);
final app = IdeApp(
workspace: workspace,
terminal: driver,
aiProvider: aiProvider,
aiModel: wiring?.config.model,
shield: shield,
commandSyntax: ideCommandSyntaxFor(context.shellFamily),
);
await app.run();
});
}