Skip to content

fix(vscode): batch instructions honors nested strategy - #260

Open
dsk-dev-ai wants to merge 2 commits into
microsoft:mainfrom
dsk-dev-ai:feature/vscode-batch-nested-strategy
Open

fix(vscode): batch instructions honors nested strategy#260
dsk-dev-ai wants to merge 2 commits into
microsoft:mainfrom
dsk-dev-ai:feature/vscode-batch-nested-strategy

Conversation

@dsk-dev-ai

Copy link
Copy Markdown

Summary

Fixes #58. The VS Code Batch Instructions command (agentrc.batchInstructions) now honors strategy: "nested" in agentrc.config.json. Previously it only swapped the output filename to AGENTS.md while still calling the flat generation API, so nested repositories received a single flat file instead of the hub + detail structure.

What changed

vscode-extension/src/commands/batch.ts — the per-root loop now branches on strategy:

  • Nested (config.strategy === "nested"):
    • Resolves detailDir = config.detailDir ?? ".agents" and claudeMd = config.claudeMd ?? false.
    • Calls generateNestedInstructions({ repoPath, model, onProgress, detailDir, claudeMd }).
    • Persists via writeNestedInstructions(workspacePath, result, false) — writes AGENTS.md, .agents/{slug}.md, and optional CLAUDE.md.
    • Counts wrote/skipped per root from the returned FileAction[] and forwards result.warnings to progress.
  • Flat: the existing generateCopilotInstructions + safeWriteFile implementation is unchanged.

The nested branch mirrors the already-shipped single-root command (vscode-extension/src/commands/instructions.ts), reusing the same exported core services and configuration defaults. No changes to packages/core, the CLI, or any APIs.

Behavior preserved

  • Skip-if-exists: writeNestedInstructions(..., false) delegates to the same safeWriteFile guard used by the flat path.
  • Progress reporting and wrote / skipped / failed per-root counters and the final Done: … (N roots) message.
  • Non-fatal config loading (missing/malformed agentrc.config.json falls back to flat).
  • Flat repositories behave exactly as before.

Verification

  • npm run lint — clean
  • npm run typecheck — clean
  • npm test — 675 passed (31 files)
  • Extension: npx eslint . — clean; npx tsc --noEmit introduces no new errors; npx prettier --check — clean

Files changed

vscode-extension/src/commands/batch.ts   strategy branch (nested vs flat)
CHANGELOG.md                             Bug Fix entry

Copilot AI review requested due to automatic review settings August 2, 2026 08:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the VS Code extension’s multi-root “Batch Instructions” command to correctly honor strategy: "nested" from agentrc.config.json, aligning batch behavior with the single-root nested instructions flow.

Changes:

  • Branch batch generation per workspace root into nested (generateNestedInstructions + writeNestedInstructions) vs flat (generateCopilotInstructions + safeWriteFile).
  • Surface nested-generation warnings during batch runs and keep per-root wrote/skipped/failed counters.
  • Add a changelog entry documenting the nested-strategy batch fix.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
vscode-extension/src/commands/batch.ts Adds nested-strategy handling to batch instructions generation/writing.
CHANGELOG.md Documents the nested-strategy batch instructions bug fix.
Suppressed comments (1)

vscode-extension/src/commands/batch.ts:68

  • The warning updates in the nested branch omit the workspace root prefix, so warnings from different roots can’t be attributed in the batch output.
            for (const warning of nestedResult.warnings) {
              reporter.update(`Warning: ${warning}`);
            }

Comment on lines +49 to +56
reporter.update(`[${name}] Generating nested instructions…`);
const nestedResult = await generateNestedInstructions({
repoPath: workspacePath,
model,
onProgress: (msg) => reporter.update(msg),
detailDir,
claudeMd
});
Comment thread vscode-extension/src/commands/batch.ts
Comment thread CHANGELOG.md

### 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)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 2, 2026 08:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (3)

vscode-extension/src/commands/batch.ts:70

  • Nested-strategy warnings are logged without the root prefix, which can make warnings hard to attribute in a multi-root batch run. Prefix warning updates with [${name}] like other batch messages.
            for (const warning of nestedResult.warnings) {
              reporter.update(`Warning: ${warning}`);
            }

vscode-extension/src/commands/batch.ts:56

  • In batch mode, progress updates emitted via onProgress don't include the workspace root name, so messages like "Checking Copilot CLI..." / "Generating detail..." can become ambiguous when multiple roots are processed. Prefix these nested-strategy progress messages with [${name}] for consistency with the flat branch.

This issue also appears on line 68 of the same file.

            const nestedResult = await generateNestedInstructions({
              repoPath: workspacePath,
              model,
              onProgress: (msg) => reporter.update(msg),
              detailDir,
              claudeMd
            });

vscode-extension/src/commands/batch.ts:10

  • Import order in this commands folder consistently places node:path immediately after the vscode import (e.g., vscode-extension/src/commands/init.ts:1-2, instructions.ts:1-2). In this file, node:path is imported after relative imports, which deviates from the local convention.
import path from "node:path";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extension: batch instructions should support nested strategy

2 participants