diff --git a/COMMANDS.md b/COMMANDS.md index 9ea1405..a68a6e8 100644 --- a/COMMANDS.md +++ b/COMMANDS.md @@ -167,6 +167,7 @@ fable-agent plinius godmode "improve explanation quality" - `--repo ` - `--out ` - `--dry-run` + - `--run ` ### `familiar` diff --git a/src/fable5/forgejo-intake.ts b/src/fable5/forgejo-intake.ts index c04522a..b21a6dd 100644 --- a/src/fable5/forgejo-intake.ts +++ b/src/fable5/forgejo-intake.ts @@ -1,6 +1,7 @@ import * as fs from "node:fs"; import * as path from "node:path"; import { findPromptInjection, type PromptInjectionFinding } from "../core/prompt-injection-safety.js"; +import { emitChannelEvent } from "./channel.js"; export type ForgejoIntakeKind = "issue" | "pull" | "wiki"; export type ForgejoRoute = "security" | "seo" | "client-report" | "data-pipeline" | "dev" | "wiki" | "triage" | "human-review"; @@ -48,6 +49,8 @@ export interface ForgejoIntakeOptions { token?: string; outDir?: string; dryRun?: boolean; + runId?: string; + channelRoot?: string; now?: Date; fetcher?: ForgejoFetch; } @@ -98,11 +101,13 @@ export function createForgejoIntakeReceipt(item: ForgejoItem, now = new Date()): export async function intakeForgejoItem(opts: ForgejoIntakeOptions): Promise<{ receipt: ForgejoIntakeReceipt; path?: string }> { const parsed = parseForgejoRef(opts.ref, opts.repo); + if (opts.runId) emitChannelEvent(opts.runId, { source: "intake", type: "started", data: { ref: opts.ref, repo: parsed.repo, kind: parsed.kind } }, opts.channelRoot, opts.now); const baseUrl = opts.baseUrl?.replace(/\/$/, "") ?? parsed.baseUrl; if (!baseUrl) throw new Error("FORGEJO_URL is required unless ISSUE is a full Forgejo URL"); const item = await fetchForgejoItem(baseUrl, parsed, opts.token, opts.fetcher ?? fetch); const receipt = createForgejoIntakeReceipt(item, opts.now); + if (opts.runId) emitChannelEvent(opts.runId, { source: "intake", type: "receipt", data: receipt }, opts.channelRoot, opts.now); if (opts.dryRun) return { receipt }; const outDir = opts.outDir ?? ".fable/tasks"; fs.mkdirSync(outDir, { recursive: true }); diff --git a/src/index.ts b/src/index.ts index 3b6d162..ebf558e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1492,7 +1492,8 @@ forgejo .option("--repo ", "Repo slug for numeric issue refs, e.g. org/repo") .option("--out ", "Receipt output directory", ".fable/tasks") .option("--dry-run", "Print receipt JSON without writing a file") - .action(async (ref: string, opts: { repo?: string; out?: string; dryRun?: boolean }) => { + .option("--run ", "Emit intake events to .runs//channel.jsonl") + .action(async (ref: string, opts: { repo?: string; out?: string; dryRun?: boolean; run?: string }) => { try { const { intakeForgejoItem } = await import("./fable5/forgejo-intake.js"); const result = await intakeForgejoItem({ @@ -1500,6 +1501,7 @@ forgejo repo: opts.repo, outDir: opts.out, dryRun: opts.dryRun, + runId: opts.run, baseUrl: process.env.FORGEJO_URL, token: process.env.FORGEJO_TOKEN, });