Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions bin/recs-tui.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env bun
/**
* CLI entry point for the RecordStream TUI pipeline builder.
*
* Usage:
* recs tui [inputfile] Open TUI with optional input file
* recs tui --session <id> Resume a saved session
* recs tui --list List saved sessions
* recs tui --clean Remove sessions older than 7 days
* recs tui --pipeline "..." Start with an initial pipeline command
*/

import { launchTui, type TuiOptions } from "../src/tui/index.tsx";

const args = process.argv.slice(2);

// Handle --list
if (args.includes("--list")) {
// TODO: implement session listing (Phase 3)
console.log("No saved sessions. (Session persistence coming in Phase 3)");
process.exit(0);
}

// Handle --clean
if (args.includes("--clean")) {
// TODO: implement session cleanup (Phase 3)
console.log("Session cleanup not yet implemented. (Phase 3)");
process.exit(0);
}

// Parse options
const options: TuiOptions = {};

for (let i = 0; i < args.length; i++) {
const arg = args[i]!;

if (arg === "--session" || arg === "-s") {
options.sessionId = args[i + 1];
i++; // skip value
} else if (arg === "--pipeline" || arg === "-p") {
options.pipeline = args[i + 1];
i++; // skip value
} else if (arg === "--help" || arg === "-h") {
console.log(`Usage: recs tui [options] [inputfile]

Options:
--session, -s <id> Resume a saved session
--pipeline, -p <cmd> Start with an initial pipeline command
--list List saved sessions
--clean Remove sessions older than 7 days
--help, -h Show this help message

Examples:
recs tui data.jsonl
recs tui access.log --pipeline "fromre '^(\\S+)' | grep status=200"
recs tui --session abc123
recs tui`);
process.exit(0);
} else if (!arg.startsWith("-")) {
// Positional arg = input file
options.inputFile = arg;
}
}

await launchTui(options);
15 changes: 15 additions & 0 deletions bin/recs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@ if (command === "story") {
process.exit(0);
}

// Handle TUI subcommand
if (command === "tui") {
const tuiArgs = args.slice(1);
// Re-exec via recs-tui.ts with remaining args
const { join } = await import("node:path");
const tuiEntry = join(import.meta.dir, "recs-tui.ts");
const proc = Bun.spawn(["bun", "run", tuiEntry, ...tuiArgs], {
stdin: "inherit",
stdout: "inherit",
stderr: "inherit",
});
const code = await proc.exited;
process.exit(code);
}

// Handle alias management subcommand
if (command === "alias") {
const aliasArgs = args.slice(1);
Expand Down
203 changes: 202 additions & 1 deletion bun.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@
"vitepress": "^1.6.4"
},
"dependencies": {
"@opentui/core": "^0.1.81",
"@opentui/react": "^0.1.81",
"@types/react": "^19.2.14",
"better-sqlite3": "^12.6.2",
"fast-xml-parser": "^5.3.7",
"mongodb": "^7.1.0",
"nanoid": "^5.1.6",
"openai": "^6.22.0",
"papaparse": "^5.5.3",
"react": "^19.2.4",
"string-width": "^8.2.0",
"xlsx": "^0.18.5"
}
Expand Down
Loading