Skip to content
Open
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
15 changes: 14 additions & 1 deletion src/lib/debug.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down Expand Up @@ -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([]);
});
});
29 changes: 27 additions & 2 deletions src/lib/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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 [];
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

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 ?? "";
Expand Down Expand Up @@ -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 });
}
Expand Down