From 4a30e0e88897cd904dce06b443d6bc4a82cc38d9 Mon Sep 17 00:00:00 2001 From: Sebastien Tardif Date: Wed, 8 Jul 2026 08:49:46 -0400 Subject: [PATCH] fix: align create Quick Action and docs with patchloom 0.10 CLI create requires --content/--stdin and --apply to write files; preview-only create returns exit 2. Prompt for content and pass both flags. Recommend CLI 0.10.0 and 54 MCP tools in the README. Signed-off-by: Sebastien Tardif --- README.md | 4 ++-- src/commands/quickActions.ts | 18 ++++++++++---- test/unit/quickActions.test.ts | 43 ++++++++++++++++++++++++++++------ 3 files changed, 52 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 115693d..d9407d5 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,7 @@ The extension detects outdated CLI builds and warns with upgrade guidance. It re Set `patchloom.path` in settings, or add the CLI to your `PATH`. **CLI compatibility warning** -Run `Patchloom: Open Releases` to download the latest release. The extension requires 0.3.0 or newer; 0.7.0 is recommended. +Run `Patchloom: Open Releases` to download the latest release. The extension requires 0.3.0 or newer; 0.10.0 is recommended. **MCP config not injected** Run `Patchloom: Configure MCP` and select the target editor config. @@ -183,7 +183,7 @@ File bugs and feature requests at [patchloom/patchloom-vscode/issues](https://gi ## Requirements - VS Code 1.90 or newer (or compatible editors: Cursor, Windsurf, VSCodium) -- [Patchloom CLI](https://github.com/patchloom/patchloom) 0.3.0 or newer (0.7.0+ recommended for 43 MCP tools, LLM-aligned CLI arguments, post-write formatter hook, and transaction engine unification) +- [Patchloom CLI](https://github.com/patchloom/patchloom) 0.3.0 or newer (0.10.0+ recommended for 54 MCP tools, correct preview exit codes, optional `--contain` path guarding, schema-driven MCP descriptions, and agent reliability fixes) ## Contributing diff --git a/src/commands/quickActions.ts b/src/commands/quickActions.ts index 92e9353..521325c 100644 --- a/src/commands/quickActions.ts +++ b/src/commands/quickActions.ts @@ -203,7 +203,7 @@ export async function runQuickAction(): Promise { { label: "Create a new file", description: "Scaffold a new file in the workspace", - detail: "Builds `patchloom create `", + detail: "Builds `patchloom create --content --apply`", run: async () => { const folder = await activeWorkspaceFolder({ promptIfMany: true, @@ -230,7 +230,16 @@ export async function runQuickAction(): Promise { return; } - const action = buildCreateQuickAction(absolutePath); + // Empty content is allowed; CLI requires --content or --stdin and --apply to write. + const content = await vscode.window.showInputBox({ + prompt: "Initial file content (leave empty for an empty file)", + placeHolder: "// new file" + }); + if (content === undefined) { + return; + } + + const action = buildCreateQuickAction(absolutePath, content); const result = await executePatchloom(binaryPath, action.args, folder.uri.fsPath); if (result.exitCode !== 0) { @@ -858,12 +867,13 @@ export function buildSearchQuickAction(workspacePath: string, pattern: string, g }; } -export function buildCreateQuickAction(filePath: string): PlannedQuickAction { +export function buildCreateQuickAction(filePath: string, content = ""): PlannedQuickAction { return { title: `Create ${path.basename(filePath)}`, targetPath: filePath, targetArgIndices: [1], - args: ["create", filePath] + // CLI requires --content/--stdin and --apply; preview-only create returns exit 2 and does not write. + args: ["create", filePath, "--content", content, "--apply"] }; } diff --git a/test/unit/quickActions.test.ts b/test/unit/quickActions.test.ts index 1ba81d8..7e9306f 100644 --- a/test/unit/quickActions.test.ts +++ b/test/unit/quickActions.test.ts @@ -152,14 +152,31 @@ test("buildSearchQuickAction includes glob when provided", () => { assert.deepEqual(action.targetArgIndices, [4]); }); -test("buildCreateQuickAction builds a create command", () => { - const action = buildCreateQuickAction("/workspace/demo/src/newfile.ts"); +test("buildCreateQuickAction builds a create command with content and apply", () => { + const action = buildCreateQuickAction("/workspace/demo/src/newfile.ts", "hello"); assert.equal(action.title, "Create newfile.ts"); - assert.deepEqual(action.args, ["create", "/workspace/demo/src/newfile.ts"]); + assert.deepEqual(action.args, [ + "create", + "/workspace/demo/src/newfile.ts", + "--content", + "hello", + "--apply" + ]); assert.deepEqual(action.targetArgIndices, [1]); }); +test("buildCreateQuickAction allows empty content", () => { + const action = buildCreateQuickAction("/workspace/demo/empty.txt"); + assert.deepEqual(action.args, [ + "create", + "/workspace/demo/empty.txt", + "--content", + "", + "--apply" + ]); +}); + test("buildSearchQuickAction preserves spaces in pattern as a single arg", () => { const action = buildSearchQuickAction("/workspace/demo", "hello world"); @@ -220,9 +237,15 @@ test("buildSearchQuickAction with regex special characters", () => { }); test("buildCreateQuickAction with spaces in path", () => { - const action = buildCreateQuickAction("/workspace/my project/src/new file.ts"); + const action = buildCreateQuickAction("/workspace/my project/src/new file.ts", "x"); assert.equal(action.title, "Create new file.ts"); - assert.deepEqual(action.args, ["create", "/workspace/my project/src/new file.ts"]); + assert.deepEqual(action.args, [ + "create", + "/workspace/my project/src/new file.ts", + "--content", + "x", + "--apply" + ]); }); test("buildDocGetQuickAction with deeply nested selector", () => { @@ -232,9 +255,15 @@ test("buildDocGetQuickAction with deeply nested selector", () => { }); test("buildCreateQuickAction with unicode filename", () => { - const action = buildCreateQuickAction("/workspace/demo/docs/日本語.md"); + const action = buildCreateQuickAction("/workspace/demo/docs/日本語.md", "# title"); assert.equal(action.title, "Create 日本語.md"); - assert.deepEqual(action.args, ["create", "/workspace/demo/docs/日本語.md"]); + assert.deepEqual(action.args, [ + "create", + "/workspace/demo/docs/日本語.md", + "--content", + "# title", + "--apply" + ]); }); test("buildSearchQuickAction with unicode pattern", () => {