diff --git a/AGENTS.md b/AGENTS.md index 1a28b2e..b2d7712 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -47,7 +47,7 @@ src/ workspace/readiness.ts Workspace readiness: environment detection, folder selection test/ unit/ Unit tests (node:test, dependency-injected, no VS Code API) - batchApply.test.ts Batch template and operation count parsing (11 tests) + batchApply.test.ts Batch template and operation count parsing (12 tests) binary.test.ts Binary discovery, managed install, compatibility, workspace env (59 tests) binaryDiscovery.test.ts Real executable discovery on PATH (13 tests) initializeProject.test.ts Status display, agents file classification, formatError (26 tests) diff --git a/src/commands/batchApply.ts b/src/commands/batchApply.ts index fe5601f..b488861 100644 --- a/src/commands/batchApply.ts +++ b/src/commands/batchApply.ts @@ -21,6 +21,11 @@ export function parseBatchOperationCount(plan: string): number { return plan.split("\n").filter((line) => line.trim().length > 0).length; } +/** CLI argv for Batch Apply. Global --contain first (CLI 0.10+ path guard). */ +export function buildBatchApplyArgs(): string[] { + return ["--contain", "batch", "--apply"]; +} + export async function batchApply(): Promise { const binaryPath = await ensurePatchloomReadyOrNotify("Upgrade Patchloom before running batch operations."); if (!binaryPath) { @@ -53,8 +58,7 @@ export async function batchApply(): Promise { const plan = doc.getText(); const log = getPatchloomLog(); - // Global --contain rejects plan ops that escape the workspace root (CLI 0.10+). - const args = ["--contain", "batch", "--apply"]; + const args = buildBatchApplyArgs(); log?.logCommand(binaryPath, args, folder.uri.fsPath); const result = await executePatchloomWithStdin(binaryPath, args, folder.uri.fsPath, plan); diff --git a/test/unit/batchApply.test.ts b/test/unit/batchApply.test.ts index 5c5abe1..6c832d1 100644 --- a/test/unit/batchApply.test.ts +++ b/test/unit/batchApply.test.ts @@ -1,6 +1,10 @@ import assert from "node:assert/strict"; import test from "node:test"; -import { buildBatchTemplate, parseBatchOperationCount } from "../../src/commands/batchApply.js"; +import { + buildBatchApplyArgs, + buildBatchTemplate, + parseBatchOperationCount +} from "../../src/commands/batchApply.js"; test("buildBatchTemplate returns line-oriented format with four operations", () => { const template = buildBatchTemplate(); @@ -73,3 +77,7 @@ test("buildBatchTemplate file.append line has file and quoted content", () => { assert.ok(appendLine, "template should contain a file.append line"); assert.match(appendLine, /file\.append \S+ ".+"/, "file.append should have file and quoted content"); }); + +test("buildBatchApplyArgs prefixes global --contain before batch --apply", () => { + assert.deepEqual(buildBatchApplyArgs(), ["--contain", "batch", "--apply"]); +}); diff --git a/walkthrough/initialize.md b/walkthrough/initialize.md index 1af214d..fd38449 100644 --- a/walkthrough/initialize.md +++ b/walkthrough/initialize.md @@ -4,8 +4,8 @@ Generate an `AGENTS.md` file that tells AI agents how to work with your codebase. Click **Initialize Project** above to run `patchloom agent-rules` in -your workspace. This analyzes your project and creates a tailored -configuration. +your workspace. You can choose integration mode (CLI + MCP, CLI only, or +MCP only) and shell platform examples (all, Linux/macOS, or Windows). ## What AGENTS.md Contains