fix(instructions): deduplicate workspace content in nested AGENTS.md generation - #259
Open
dsk-dev-ai wants to merge 7 commits into
Open
fix(instructions): deduplicate workspace content in nested AGENTS.md generation#259dsk-dev-ai wants to merge 7 commits into
dsk-dev-ai wants to merge 7 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves agentrc instructions generation for large monorepos by reducing duplicated workspace-wide content in nested AGENTS.md outputs, normalizing nested hub headings, and allowing VS Code settings to reference a configurable instruction file path.
Changes:
- Thread root
AGENTS.mdcontent into nested hub/detail generation prompts to discourage restating workspace-wide conventions. - Normalize nested
AGENTS.mdheadings to avoid “Copilot Instructions:” titles. - Add
instructionFilesupport so generated VS Code settings can reference a selected instruction file (default remains.github/copilot-instructions.md), with new tests covering the behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/services/instructions.ts | Adds root-context prompt section plumbing and heading normalization for nested hubs/details. |
| packages/core/src/services/generator.ts | Allows VS Code settings generation to reference a configurable instruction file path. |
| plugin/skills/nested-hub/SKILL.md | Updates nested hub generation guidance to avoid repeating root content and adjust headings. |
| src/commands/instructions.ts | Wires root hub content into subsequent per-area generation in the CLI flow. |
| src/services/tests/instructions.test.ts | Adds tests for root-context prompt section, heading normalization, and propagation into nested area generation. |
| src/services/tests/generator.test.ts | Adds tests ensuring VS Code settings respect instructionFile and the default. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/commands/instructions.ts:95
rootContentis set to the freshly generated hub content before writing it to disk. IfwriteNestedInstructions(...)later skips the rootAGENTS.mdbecause it already exists and--forceisn’t set, the subsequent per-area generation will be deduped against unwritten root instructions (potentially causing area/crate files to omit workspace-wide guidance that isn’t actually present in the on-disk root file). Consider only propagatingrootContentwhen the root hub was actually written (or, if skipped, load the existing root file content instead).
detailDir,
claudeMd
});
rootContent = nestedResult.hub.content;
Author
|
I've addressed the Copilot review feedback, updated the implementation accordingly, and all checks continue to pass. Happy to make any additional changes based on maintainer feedback. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #45. When
agentrc instructionsgenerates nested instruction files for alarge monorepo (e.g. a Rust workspace with 24+ crates), the per-crate
AGENTS.mdfiles no longer duplicate the workspace-wide root instructions, dropthe misleading
# Copilot Instructions: <crate> crateheading, and now know whatthe root file already covers so the LLM only emits crate-unique context.
Approach
The content of these files is LLM-generated from skills (see
plugin/skills/nested-hub/SKILL.md,plugin/skills/nested-detail/SKILL.md), sodeduplication is done at generation time: after the root
AGENTS.mdhub isgenerated, its content is fed back into the per-area / per-crate generation
prompts as a "Root instructions already cover" section, and the skill prompt
explicitly instructs the model to only cover crate-unique details and never
repeat the root file. A deterministic post-processing step normalizes the
top-level heading.
Changes (per issue findings)
{ workspace = true }, error types, logging, testing, build commands)rootContenton the generation options), embedded in the prompt viabuildRootContextSection()(## Root instructions already cover … Do NOT repeat or restate it), and thenested-hubskill instructs crate-unique-only output.nested-hubskill drops the crate-unique-only rule and the root-context section, so workspace-wide facts live only in the root file.# Copilot Instructions: <crate> crateheading on AGENTS.mdnormalizeAgentsHeading()rewrites the heading to# <crate>(falling back to the name in the heading) for all nested AGENTS.md output.instructionFile(default unchanged:.github/copilot-instructions.md), so a repo can consistently reference a single instruction file in VS Code settings. Choosing one strategy per repo remains an explicitagentrc instructions --strategydecision.Commit history (branch
feature/deduplicate-agents-md, base8d0c05c)Files changed
Net: +213 / −14 across 6 files.
Verification
npm run lint,npm run typecheck,npm testall green (685 tests across 31 files, +10 new).rootContentis unset (--areas-only, single--area, flat strategy) — falls back to the previous prompt.Confidence
High for F2/F3/F4 (~90%): heading normalization is deterministic, and the
root-context prompt section + skill guidance directly target the observed
duplication. Note the dedup itself is prompt-driven (LLM), so output varies per
model run — the deterministic fallback (
buildExistingInstructionsSection"do not restate it" rule) remains as a safety net.
Partial for F1 (~70%): the generator can now reference a single instruction
file, but enforcing a single strategy per repo (root AGENTS.md + per-directory
vs. copilot-instructions.md +
.github/instructions/*.instructions.mdglobs)and the post-generation dedup pass listed under "Suggested improvements" are
not implemented and can be follow-ups.
Follow-ups (out of scope here)
instructionFilethroughinit/pr/generateCLI + VS Code extension callers (currently API-available, callers keep the default).