Skip to content

Conversation

@marius-kilocode
Copy link
Collaborator

Implements hierarchical/nested AGENTS.md loading (plus optional ~/.kilocode/AGENTS.md) with guardrails.

  • Extension: root (cwd) → active file directory rules.
  • CLI: cwd rules (no active editor).
  • Global: ~/.kilocode/AGENTS.md if present.
  • Limits: max 6 files + max 10k chars; deterministic truncation.
  • Adds preloaded notice so the model knows AGENTS rules are already in-context.

Fixes:

  • Avoid passing activePath: undefined under exactOptionalPropertyTypes.

Files:

  • src/core/prompts/sections/agent-rules.ts
  • src/core/fs/find-up.ts
  • src/core/prompts/sections/custom-instructions.ts

Tests:

  • cd src && pnpm test core/prompts/sections/__tests__/
  • cd cli && pnpm check-types

@changeset-bot
Copy link

changeset-bot bot commented Jan 6, 2026

🦋 Changeset detected

Latest commit: fb8d596

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
kilo-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kiloconnect
Copy link
Contributor

kiloconnect bot commented Jan 6, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

This PR introduces hierarchical loading of AGENTS.md files from nested directories, with proper size and file-count limits to prevent prompt overflow. The implementation is clean and well-structured.

Key observations:

  • ✅ Proper error handling with try/catch blocks and null checks
  • ✅ Size limits enforced (MAX_AGENT_RULE_FILES = 6, MAX_AGENT_RULE_CHARS = 10000)
  • ✅ Symlink resolution with proper fallbacks
  • ✅ Deduplication via seenPaths Set prevents duplicate content
  • ✅ Global ~/.kilocode/AGENTS.md support with correct ordering
  • ✅ Tests cover main scenarios (nesting, truncation, limits, fallback)
  • ✅ Documentation updated to reflect removal of AGENT.md (singular) support
Files Reviewed (6 files)
  • .changeset/nested-agents-md-rules.md - Changeset for the feature
  • apps/kilocode-docs/docs/advanced-usage/migrating-from-cursor-windsurf.md - Documentation updates
  • src/core/fs/find-up.ts - New utility for directory chain traversal
  • src/core/prompts/sections/agent-rules.ts - Main implementation for nested AGENTS.md loading
  • src/core/prompts/sections/custom-instructions.ts - Integration with existing custom instructions
  • src/core/prompts/sections/__tests__/agent-rules.spec.ts - Test coverage
  • src/core/prompts/sections/__tests__/custom-instructions.spec.ts - Removed obsolete tests for AGENT.md

@marius-kilocode marius-kilocode enabled auto-merge (squash) January 7, 2026 11:40
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.

2 participants