diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e881698..9e4ba90c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] diff --git a/vscode-extension/src/commands/batch.ts b/vscode-extension/src/commands/batch.ts index 7ed64c66..e9874031 100644 --- a/vscode-extension/src/commands/batch.ts +++ b/vscode-extension/src/commands/batch.ts @@ -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"; @@ -34,35 +40,57 @@ export async function batchInstructionsCommand(): Promise { 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++;