Files
ruvnet--RuView/tools/ruview-cli/src/commands/job.ts
T
rUv 3f462a254d feat(tools): scaffold ruview MCP server + CLI + ADR-104 (#705)
Adds two new npm packages that expose RuView's WiFi-DensePose
sensing capabilities outside the Cognitum appliance ecosystem:

- tools/ruview-mcp/ (@ruv/ruview-mcp) — MCP server with 6 tools:
  ruview_csi_latest, ruview_pose_infer, ruview_count_infer,
  ruview_registry_list, ruview_train_count, ruview_job_status.
  Uses @modelcontextprotocol/sdk with stdio transport.
  6/6 smoke tests pass. TypeScript strict mode, Node 20.

- tools/ruview-cli/ (@ruv/ruview-cli) — Yargs CLI with matching
  subcommands: csi tail, pose infer, count infer, cogs list,
  train count, job status. Same fail-open pattern as the cog
  binaries (WARN to stderr, exit 0 on unavailable sensing-server).

- docs/adr/ADR-104-ruview-mcp-cli-distribution.md — design rationale,
  6-row threat table, packaging plan, acceptance gates, failure modes.

- docs/research/sota-2026-05-22/HORIZON.md — 12-hour horizon plan
  with 7 milestones tracked (M1 complete in this commit).

Both packages are private:true pending the user's publish decision.
Inference is via subprocess to the signed cog binaries (ADR-100/101/103)
— no JS/WASM ML engine bundled.
2026-05-21 23:33:18 -04:00

74 lines
2.0 KiB
TypeScript

/**
* ruview job — Job management commands.
*
* job status --id <job_id> — poll a background training job.
*/
import type { Argv } from "yargs";
import { readFileSync, existsSync } from "node:fs";
import { loadConfig } from "../config.js";
export function jobCommand(cli: Argv): void {
cli.command(
"job <action>",
"Job management commands",
(y) =>
y
.positional("action", {
choices: ["status"] as const,
description: "Action to perform",
})
.option("id", {
type: "string",
demandOption: true,
description: "Job ID returned by ruview train count",
}),
async (args) => {
const config = loadConfig();
if (args.action === "status") {
const jobId = args.id as string;
const { default: path } = await import("node:path");
const logPath = path.join(config.jobsDir, `${jobId}.log`);
if (!existsSync(logPath)) {
process.stdout.write(
JSON.stringify({
ok: false,
error: `Job ${jobId} not found at ${logPath}. ` +
"The CLI process that started the job may have been restarted.",
}) + "\n"
);
process.exit(0);
}
const content = readFileSync(logPath, "utf8");
const lines = content.split("\n");
const recentLog = lines.slice(Math.max(0, lines.length - 20));
// Derive status from the log content.
let status: string = "running";
if (content.includes("# exit code: 0")) {
status = "done";
} else if (content.includes("# exit code:") || content.includes("# ERROR:")) {
status = "failed";
}
process.stdout.write(
JSON.stringify(
{
ok: true,
job_id: jobId,
status,
log_path: logPath,
recent_log: recentLog,
},
null,
2
) + "\n"
);
}
}
);
}