Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ All notable changes to this project will be documented in this file.

### Bug Fixes

- **Batch Instructions honors nested strategy** — the VS Code "Batch Instructions" command now generates hub + detail files (`.agents/*.md`, optional `CLAUDE.md`) for repositories configured with `strategy: "nested"` instead of a single flat `AGENTS.md` (#58)

- **Config scaffolding for simple repos** — `agentrc init` and the TUI now create `agentrc.config.json` even when no areas are detected, producing a minimal `{}` stub. Previously failed with "No areas detected. Cannot scaffold agentrc.config.json."

## [2.1.0]
Expand Down
80 changes: 54 additions & 26 deletions vscode-extension/src/commands/batch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import * as vscode from "vscode";
import { generateCopilotInstructions, loadAgentrcConfig, safeWriteFile } from "../services.js";
import {
generateCopilotInstructions,
generateNestedInstructions,
loadAgentrcConfig,
safeWriteFile,
writeNestedInstructions
} from "../services.js";
import { VscodeProgressReporter } from "../progress.js";
import path from "node:path";

Expand Down Expand Up @@ -34,35 +40,57 @@ export async function batchInstructionsCommand(): Promise<void> {
const workspacePath = folder.uri.fsPath;
const name = folder.name;
try {
let outputPath = path.join(workspacePath, ".github", "copilot-instructions.md");
try {
const config = await loadAgentrcConfig(workspacePath);
if (config?.strategy === "nested") {
outputPath = path.join(workspacePath, "AGENTS.md");
}
} catch {
// Non-fatal
}
const config = await loadAgentrcConfig(workspacePath).catch(() => undefined);

reporter.update(`[${name}] Generating…`);
const content = await generateCopilotInstructions({
repoPath: workspacePath,
model
});
if (config?.strategy === "nested") {
const detailDir = config.detailDir ?? ".agents";
const claudeMd = config.claudeMd ?? false;

if (!content) {
skipped++;
continue;
}
reporter.update(`[${name}] Generating nested instructions…`);
const nestedResult = await generateNestedInstructions({
repoPath: workspacePath,
model,
onProgress: (msg) => reporter.update(msg),
detailDir,
claudeMd
});

const { wrote: didWrite, reason } = await safeWriteFile(outputPath, content, false);
if (didWrite) {
wrote++;
const actions = await writeNestedInstructions(workspacePath, nestedResult, false);
if (actions.some((a) => a.action === "wrote")) {
wrote++;
} else {
skipped++;
reporter.update(
`[${name}] Skipped: no files written (${Array.from(new Set(actions.map((a) => a.action))).join(", ")})`
);
}

for (const warning of nestedResult.warnings) {
reporter.update(`Warning: ${warning}`);
}
} else {
skipped++;
reporter.update(
`[${name}] Skipped: ${reason === "exists" ? "file already exists" : (reason ?? "unknown")}`
);
const outputPath = path.join(workspacePath, ".github", "copilot-instructions.md");

reporter.update(`[${name}] Generating…`);
const content = await generateCopilotInstructions({
repoPath: workspacePath,
model
});

if (!content) {
skipped++;
continue;
}

const { wrote: didWrite, reason } = await safeWriteFile(outputPath, content, false);
if (didWrite) {
wrote++;
} else {
skipped++;
reporter.update(
`[${name}] Skipped: ${reason === "exists" ? "file already exists" : (reason ?? "unknown")}`
);
}
}
} catch (err) {
failed++;
Expand Down