diff --git a/.agents/skills/jobbank-search/cli/src/commands/detail.ts b/.agents/skills/jobbank-search/cli/src/commands/detail.ts new file mode 100644 index 0000000..b752b3e --- /dev/null +++ b/.agents/skills/jobbank-search/cli/src/commands/detail.ts @@ -0,0 +1,164 @@ +import { defineCommand, option } from "@bunli/core" +import { z } from "zod" +import { fetchWithUA, writeError, BASE_URL } from "../helpers.js" +import { parse as parseHtml } from "node-html-parser" + +export const detail = defineCommand({ + name: "detail", + description: "Full detail for a single job posting", + options: { + format: option(z.enum(["json", "plain"]).default("json"), { + description: "Output format: json, plain", + }), + }, + handler: async ({ positional, flags, signal }) => { + if (signal.aborted) return + + const id = positional[0] + if (!id) { + writeError("Job ID is required", "MISSING_REQUIRED") + process.exit(1) + } + + const url = `${BASE_URL}/job/${id}/` + + try { + const response = await fetchWithUA(url) + + if (response.status === 404) { + writeError("Job not found", "NOT_FOUND") + process.exit(1) + } + + if (!response.ok) { + writeError(`Failed to fetch job page: ${response.status} ${response.statusText}`, "API_ERROR") + process.exit(1) + } + + const html = await response.text() + + if (signal.aborted) return + + const root = parseHtml(html) + + // Find all