Skip to content

Commit 65c23de

Browse files
authored
test: cover batch --contain args and document agent-rules picks (#192)
Extract buildBatchApplyArgs for testability of CLI 0.10 path guarding. Update Initialize walkthrough for mode/platform choices. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
1 parent 7868fdb commit 65c23de

4 files changed

Lines changed: 18 additions & 6 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ src/
4747
workspace/readiness.ts Workspace readiness: environment detection, folder selection
4848
test/
4949
unit/ Unit tests (node:test, dependency-injected, no VS Code API)
50-
batchApply.test.ts Batch template and operation count parsing (11 tests)
50+
batchApply.test.ts Batch template and operation count parsing (12 tests)
5151
binary.test.ts Binary discovery, managed install, compatibility, workspace env (59 tests)
5252
binaryDiscovery.test.ts Real executable discovery on PATH (13 tests)
5353
initializeProject.test.ts Status display, agents file classification, formatError (26 tests)

src/commands/batchApply.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ export function parseBatchOperationCount(plan: string): number {
2121
return plan.split("\n").filter((line) => line.trim().length > 0).length;
2222
}
2323

24+
/** CLI argv for Batch Apply. Global --contain first (CLI 0.10+ path guard). */
25+
export function buildBatchApplyArgs(): string[] {
26+
return ["--contain", "batch", "--apply"];
27+
}
28+
2429
export async function batchApply(): Promise<void> {
2530
const binaryPath = await ensurePatchloomReadyOrNotify("Upgrade Patchloom before running batch operations.");
2631
if (!binaryPath) {
@@ -53,8 +58,7 @@ export async function batchApply(): Promise<void> {
5358

5459
const plan = doc.getText();
5560
const log = getPatchloomLog();
56-
// Global --contain rejects plan ops that escape the workspace root (CLI 0.10+).
57-
const args = ["--contain", "batch", "--apply"];
61+
const args = buildBatchApplyArgs();
5862
log?.logCommand(binaryPath, args, folder.uri.fsPath);
5963

6064
const result = await executePatchloomWithStdin(binaryPath, args, folder.uri.fsPath, plan);

test/unit/batchApply.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import assert from "node:assert/strict";
22
import test from "node:test";
3-
import { buildBatchTemplate, parseBatchOperationCount } from "../../src/commands/batchApply.js";
3+
import {
4+
buildBatchApplyArgs,
5+
buildBatchTemplate,
6+
parseBatchOperationCount
7+
} from "../../src/commands/batchApply.js";
48

59
test("buildBatchTemplate returns line-oriented format with four operations", () => {
610
const template = buildBatchTemplate();
@@ -73,3 +77,7 @@ test("buildBatchTemplate file.append line has file and quoted content", () => {
7377
assert.ok(appendLine, "template should contain a file.append line");
7478
assert.match(appendLine, /file\.append \S+ ".+"/, "file.append should have file and quoted content");
7579
});
80+
81+
test("buildBatchApplyArgs prefixes global --contain before batch --apply", () => {
82+
assert.deepEqual(buildBatchApplyArgs(), ["--contain", "batch", "--apply"]);
83+
});

walkthrough/initialize.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Generate an `AGENTS.md` file that tells AI agents how to work with
44
your codebase.
55

66
Click **Initialize Project** above to run `patchloom agent-rules` in
7-
your workspace. This analyzes your project and creates a tailored
8-
configuration.
7+
your workspace. You can choose integration mode (CLI + MCP, CLI only, or
8+
MCP only) and shell platform examples (all, Linux/macOS, or Windows).
99

1010
## What AGENTS.md Contains
1111

0 commit comments

Comments
 (0)