From cec9f6fc05f2c126bf83e6ab65b1f4bd3f8c5e5a Mon Sep 17 00:00:00 2001 From: marius-kilocode Date: Fri, 29 May 2026 16:09:24 +0200 Subject: [PATCH] fix(cli): describe notebooks without readable cells --- .../opencode/src/kilocode/tool/notebook.ts | 2 +- .../test/kilocode/read-notebook.test.ts | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/kilocode/tool/notebook.ts b/packages/opencode/src/kilocode/tool/notebook.ts index 4b254c790d6..51d1006f7a2 100644 --- a/packages/opencode/src/kilocode/tool/notebook.ts +++ b/packages/opencode/src/kilocode/tool/notebook.ts @@ -42,5 +42,5 @@ export async function open(filepath: string): Promise { cells.push(render(cell.cell_type, text)) } - return Readable.from([cells.join("\n\n")]) + return Readable.from([cells.length ? cells.join("\n\n") : "(Notebook contains no markdown or code cell content.)"]) } diff --git a/packages/opencode/test/kilocode/read-notebook.test.ts b/packages/opencode/test/kilocode/read-notebook.test.ts index 85e96023045..e4a6fa2da1e 100644 --- a/packages/opencode/test/kilocode/read-notebook.test.ts +++ b/packages/opencode/test/kilocode/read-notebook.test.ts @@ -114,6 +114,29 @@ describe("kilocode notebook reads", () => { }), ) + it.live("reports valid notebooks with no readable cells without exposing payloads", () => + Effect.gen(function* () { + const dir = yield* tmpdirScoped() + const filepath = path.join(dir, "empty-content.ipynb") + const content = JSON.stringify({ + metadata: { marker: "NOTEBOOK_METADATA_SHOULD_NOT_APPEAR" }, + cells: [ + null, + { cell_type: "raw", source: ["RAW_CONTENT_SHOULD_NOT_APPEAR"] }, + { cell_type: "code", source: null, outputs: ["INVALID_OUTPUT_SHOULD_NOT_APPEAR"] }, + ], + }) + yield* put(filepath, content) + + const result = yield* run(dir, { filePath: filepath }) + + expect(result.output).toContain("Notebook contains no markdown or code cell content") + expect(result.output).not.toContain("NOTEBOOK_METADATA_SHOULD_NOT_APPEAR") + expect(result.output).not.toContain("RAW_CONTENT_SHOULD_NOT_APPEAR") + expect(result.output).not.toContain("INVALID_OUTPUT_SHOULD_NOT_APPEAR") + }), + ) + it.live("applies read pagination to extracted cell text", () => Effect.gen(function* () { const dir = yield* tmpdirScoped()