Skip to content

feat(vscode): create empty notebooks via notebook_edit#11726

Merged
markijbema merged 2 commits into
mainfrom
mark/notebook-create-action
Jun 26, 2026
Merged

feat(vscode): create empty notebooks via notebook_edit#11726
markijbema merged 2 commits into
mainfrom
mark/notebook-create-action

Conversation

@markijbema

Copy link
Copy Markdown
Contributor

What changed

Adds a create action to the notebook_edit tool so an agent can create a new empty .ipynb on disk and then insert cells into it. This closes the "creating a fresh notebook doesn't work well" limitation noted in #11644.

  • CLI (packages/opencode/src/kilocode/): new create action in the notebook protocol (EditRequest/EditResult), expected_revision made optional, already_exists error code. notebook_edit accepts action: "create" with no kind/source/index/expected_revision, validates before the permission prompt, and returns the new notebook's initial revision.
  • VS Code extension (packages/kilo-vscode/src/services/notebook/): resolveNotebookCreatePath resolves the parent directory (must exist, inside the request root, pass access checks), rejects non-.ipynb and already-existing files. The adapter writes a minimal valid empty .ipynb, opens it, and returns the initial content revision.
  • Regenerated @kilocode/sdk; added a changeset.

Why

The VS Code notebook API has no way to create a notebook file at a pathopenNotebookDocument(type, data) only creates an unsaved untitled notebook with no on-disk path, which is why the original fresh-notebook flow failed. The bridge instead writes a minimal valid empty .ipynb to disk and opens it, so subsequent path-based notebook_edit/notebook_execute calls work.

Notes

  • Reuses the existing notebook_edit permission and the experimental.native_notebook_tools experiment — no new permission, no cloud schema change.
  • .ipynb only for this iteration; the parent directory must already exist (no mkdir -p); existing files are never overwritten.

Testing

  • packages/opencode: typecheck + notebook tool/service tests (new create case).
  • packages/kilo-vscode: typecheck + lint + 30 notebook unit tests (5 new create cases: success, already-exists, missing-parent, non-.ipynb, access-denied).
  • SDK package typechecks; opencode-annotation and kilocode_change guards pass.

The full VS Code-host test suite was not run locally (.vscode-test IPC socket path is too long inside the worktree); CI will exercise it.

Mark IJbema added 2 commits June 26, 2026 13:25
Add a create action to the notebook_edit tool so an agent can make a new empty
.ipynb on disk, then insert cells. The VS Code notebook API has no way to create
a notebook file at a path (openNotebookDocument only makes an unsaved untitled
notebook), so the bridge writes a minimal valid empty .ipynb and opens it.

Reuses the existing notebook_edit permission and native_notebook_tools
experiment; .ipynb only for now, parent directory must already exist.
@markijbema markijbema marked this pull request as ready for review June 26, 2026 11:51
Comment thread packages/opencode/src/kilocode/notebook/protocol.ts
Comment thread packages/kilo-vscode/src/services/notebook/adapter.ts
Comment thread packages/kilo-vscode/src/services/notebook/path.ts
@kilo-code-bot

kilo-code-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 3
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/kilocode/notebook/protocol.ts 147 already_exists is added to the protocol, but the VS Code bridge still downgrades it to execution_failed.
packages/kilo-vscode/src/services/notebook/adapter.ts 256 Notebook creation writes unconditionally after validation, so a concurrent creator can be overwritten instead of receiving already_exists.
packages/kilo-vscode/src/services/notebook/path.ts 125 Any realpath(target) failure is treated as "missing", which misclassifies provider/permission errors and feeds the overwrite path.
Files Reviewed (11 files)
  • .changeset/notebook-create-action.md - 0 issues
  • packages/kilo-vscode/src/services/notebook/adapter.ts - 1 issue
  • packages/kilo-vscode/src/services/notebook/bridge.ts - 0 issues
  • packages/kilo-vscode/src/services/notebook/path.ts - 1 issue
  • packages/kilo-vscode/src/services/notebook/types.ts - 0 issues
  • packages/kilo-vscode/tests/unit/notebook-core.test.ts - 0 issues
  • packages/opencode/src/kilocode/notebook/protocol.ts - 1 issue
  • packages/opencode/src/kilocode/tool/notebook-host.ts - 0 issues
  • packages/opencode/test/kilocode/notebook-tools.test.ts - 0 issues
  • packages/sdk/js/src/v2/gen/types.gen.ts - 0 issues
  • packages/sdk/openapi.json - 0 issues

Reviewed by gpt-5.4-20260305 · Input: 147.2K · Output: 12.7K · Cached: 369.2K

Review guidance: REVIEW.md from base branch main

@markijbema markijbema merged commit 91fa341 into main Jun 26, 2026
31 of 34 checks passed
@markijbema markijbema deleted the mark/notebook-create-action branch June 26, 2026 12:22
vkeerthivikram pushed a commit to vkeerthivikram/kilocode that referenced this pull request Jun 30, 2026
…action

feat(vscode): create empty notebooks via notebook_edit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants