tftsr-devops_investigation/cli/src/main.ts
Shaun Arman 093495a653
Some checks failed
Test / rust-fmt-check (pull_request) Failing after 0s
Test / rust-clippy (pull_request) Failing after 1s
Test / rust-tests (pull_request) Failing after 0s
Test / frontend-typecheck (pull_request) Failing after 16s
Test / frontend-tests (pull_request) Failing after 18s
PR Review Automation / review (pull_request) Failing after 4m13s
feat: full copy from apollo_nxt-trcaa with complete sanitization
Complete backport of all features from apollo_nxt-trcaa repository:
- Three-tier shell execution safety system (Tier 1: auto, Tier 2: approve, Tier 3: deny)
- Ollama function calling with tool use support
- AI provider tool calling auto-detection
- kubectl binary bundling and management
- kubeconfig upload and context management
- Shell approval modal with real-time UI
- MCP protocol HTTP transport with custom headers
- Enhanced security audit logging
- Comprehensive test coverage (275+ tests)
- Updated CI/CD workflows for Gitea Actions
- Complete documentation (ADRs, wiki, release notes)

Sanitization applied to all files:
- Removed all MSI, Motorola, VNXT, Vesta references
- Replaced internal infrastructure references with TFTSR equivalents
- Updated all URLs and API endpoints
- Sanitized commit history references in documentation

Technical changes:
- New modules: shell/classifier, shell/executor, shell/kubectl, shell/kubeconfig
- Enhanced AI providers: ollama.rs, openai.rs with function calling
- New Tauri commands: shell execution, kubeconfig management, tool calling detection
- Database migrations: shell_execution_audit table
- Frontend: ShellApprovalModal, ShellExecution, KubeconfigManager pages
- CI/CD: kubectl bundling, multi-platform builds, Gitea Actions integration

Version: 1.0.8

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-06-05 14:12:43 -05:00

116 lines
3.3 KiB
JavaScript

#!/usr/bin/env node
/**
* TRCAA CLI - Command-line interface for TRCAA IT Triage & RCA
*
* Note: The CLI provides basic operations. For full functionality,
* use the TRCAA desktop GUI application.
*/
const args = process.argv.slice(2);
const command = args[0];
function printHelp() {
console.log(`
TRCAA CLI v0.1.0 — IT Triage & RCA Tool
Usage: trcaa-cli <command> [options]
Commands:
analyze <log-file> Analyze a log file for issues
--domain, -d <domain> IT domain (linux, windows, network, k8s, db, virt, hw, obs)
--provider, -p <name> AI provider to use
export <issue-id> <format> Export an issue document
format: md, pdf, docx
config set <key> <value> Set a configuration value
config get <key> Get a configuration value
config list List all configuration
version Show version information
help Show this help message
Examples:
trcaa-cli analyze /var/log/syslog --domain linux
trcaa-cli export abc-123 pdf
trcaa-cli config set active_provider ollama
Note: For full AI-powered triage, launch the TRCAA desktop application.
`);
}
function printVersion() {
console.log("TRCAA CLI v0.1.0");
console.log("Part of the TRCAA IT Triage & RCA Desktop Application");
}
switch (command) {
case "analyze": {
const logFile = args[1];
if (!logFile) {
console.error("Error: log file path required");
console.error("Usage: trcaa-cli analyze <log-file>");
process.exit(1);
}
const domainIdx = args.findIndex((a) => a === "--domain" || a === "-d");
const domain = domainIdx >= 0 ? args[domainIdx + 1] : "linux";
console.log(`Analyzing: ${logFile}`);
console.log(`Domain: ${domain}`);
console.log("\nFor AI-powered analysis, launch the TRCAA desktop application.");
console.log("The GUI provides: PII detection, 5-whys triage, RCA generation.");
break;
}
case "export": {
const issueId = args[1];
const format = args[2];
if (!issueId || !format) {
console.error("Usage: trcaa-cli export <issue-id> <format>");
process.exit(1);
}
if (!["md", "pdf", "docx"].includes(format)) {
console.error("Error: format must be one of: md, pdf, docx");
process.exit(1);
}
console.log(`Export issue ${issueId} as ${format.toUpperCase()}`);
console.log("Launch the TRCAA app to access the export functionality.");
break;
}
case "config": {
const subcommand = args[1];
switch (subcommand) {
case "set":
console.log(`Configuration: ${args[2]} = ${args[3]}`);
console.log("Note: Configuration is managed by the TRCAA desktop application.");
break;
case "get":
console.log(`Getting config key: ${args[2]}`);
break;
case "list":
console.log("Configuration is stored in the TRCAA app data directory.");
console.log("Launch the app and go to Settings to view/edit configuration.");
break;
default:
console.error(`Unknown config subcommand: ${subcommand}`);
}
break;
}
case "version":
printVersion();
break;
case "help":
case "--help":
case "-h":
case undefined:
printHelp();
break;
default:
console.error(`Unknown command: ${command}`);
printHelp();
process.exit(1);
}