fix(cli): validate notebook_edit before permission prompt

This commit is contained in:
Mark IJbema
2026-06-25 14:53:16 +02:00
parent 5271db7f39
commit 8fbb57a7cb
2 changed files with 5 additions and 3 deletions
@@ -136,6 +136,7 @@ export const NotebookEditTool = Tool.define<
parameters: EditParams,
execute: (params, ctx) =>
Effect.gen(function* () {
const edit = yield* cellEdit(params)
yield* ctx.ask({
permission: "notebook_edit",
patterns: [params.path],
@@ -147,7 +148,6 @@ export const NotebookEditTool = Tool.define<
expectedRevision: params.expected_revision,
},
})
const edit = yield* cellEdit(params)
const result = yield* run(
notebook.request({
operation: "edit",
@@ -121,15 +121,17 @@ describe("native notebook tools", () => {
)
it.instance(
"rejects insert without kind and source",
"rejects insert without kind and source before asking for permission",
() =>
Effect.gen(function* () {
const edit = yield* NotebookEditTool.pipe(Effect.flatMap(Tool.init))
const ctx = context([])
const asks: Parameters<Tool.Context["ask"]>[0][] = []
const ctx = context(asks)
const exit = yield* edit
.execute({ path: "analysis.ipynb", expected_revision: "content:read", index: 0, action: "insert" }, ctx)
.pipe(Effect.exit)
expect(exit._tag).toBe("Failure")
expect(asks).toEqual([])
}),
{ git: true },
)