diff --git a/src/lib/debug.test.ts b/src/lib/debug.test.ts index 7aa76d195..f3a4a8387 100644 --- a/src/lib/debug.test.ts +++ b/src/lib/debug.test.ts @@ -3,7 +3,7 @@ import { describe, it, expect } from "vitest"; // Import from compiled dist/ so coverage is attributed correctly. -import { redact } from "../../dist/lib/debug"; +import { getDebugCompletionMessages, redact } from "../../dist/lib/debug"; describe("redact", () => { it("redacts NVIDIA_API_KEY=value patterns", () => { @@ -50,3 +50,16 @@ describe("redact", () => { expect(redact(clean)).toBe(clean); }); }); + +describe("getDebugCompletionMessages", () => { + it("suggests --output when no tarball path is provided", () => { + expect(getDebugCompletionMessages()).toEqual([ + "Done. If filing a bug, run with --output and attach the tarball to your issue:", + " nemoclaw debug --output /tmp/nemoclaw-debug.tar.gz", + ]); + }); + + it("omits the redundant --output hint when a tarball was already written", () => { + expect(getDebugCompletionMessages("/tmp/nemoclaw-debug.tar.gz")).toEqual([]); + }); +}); diff --git a/src/lib/debug.ts b/src/lib/debug.ts index aa898cf44..9dcf68bf4 100644 --- a/src/lib/debug.ts +++ b/src/lib/debug.ts @@ -446,6 +446,10 @@ function collectKernelMessages(collectDir: string): void { // Tarball // --------------------------------------------------------------------------- +/** + * Archive the collected diagnostics into a tarball and print the sharing + * guidance that goes with the generated file. + */ function createTarball(collectDir: string, output: string): void { spawnSync("tar", ["czf", output, "-C", dirname(collectDir), basename(collectDir)], { stdio: "inherit", @@ -458,10 +462,30 @@ function createTarball(collectDir: string, output: string): void { info("Attach this file to your GitHub issue."); } +/** + * Return the final user-facing completion lines for the debug command. + * When a tarball was already written, the tarball creation step has already + * printed the attachment guidance, so we do not repeat it here. + */ +export function getDebugCompletionMessages(output?: string): string[] { + if (output) { + return []; + } + + return [ + "Done. If filing a bug, run with --output and attach the tarball to your issue:", + " nemoclaw debug --output /tmp/nemoclaw-debug.tar.gz", + ]; +} + // --------------------------------------------------------------------------- // Main entry point // --------------------------------------------------------------------------- +/** + * Collect local and sandbox diagnostics for a NemoClaw environment and + * optionally bundle the results into a tarball for issue reporting. + */ export function runDebug(opts: DebugOptions = {}): void { const quick = opts.quick ?? false; const output = opts.output ?? ""; @@ -504,8 +528,9 @@ export function runDebug(opts: DebugOptions = {}): void { } console.log(""); - info("Done. If filing a bug, run with --output and attach the tarball to your issue:"); - info(" nemoclaw debug --output /tmp/nemoclaw-debug.tar.gz"); + for (const message of getDebugCompletionMessages(output)) { + info(message); + } } finally { rmSync(collectDir, { recursive: true, force: true }); }