Prefer AGENTS.md over CLAUDE.md for project instructions (#439)

* Prefer AGENTS.md over CLAUDE.md for project instructions

* fix: preserve CLAUDE.md fallback behavior

* fix: isolate onboarding tests and preserve legacy init

* fix: restore full fsOperations exports in test mock and align compact cwd

* Fix onboarding test isolation and init migration guidance

* Tighten init prompt coverage and onboarding copy

* Handle nested project instruction paths consistently

* Fix NEW_INIT feature gate for Bun build

---------

Co-authored-by: 赵小落 <zhaoxiaoluo@zhaoxiaoluodeMac-mini.local>
Co-authored-by: zhaomo01 <zhaomo01@baidu.com>
This commit is contained in:
ZhaoXiaoLuo
2026-04-12 21:31:33 +08:00
committed by GitHub
parent 2e0e14d713
commit b3f3dc4e66
18 changed files with 521 additions and 105 deletions

View File

@@ -9,7 +9,10 @@ const sessionTranscriptModule = feature('KAIROS')
import { APIUserAbortError } from '@anthropic-ai/sdk'
import { markPostCompaction } from 'src/bootstrap/state.js'
import { getInvokedSkillsForAgent } from '../../bootstrap/state.js'
import {
getInvokedSkillsForAgent,
getOriginalCwd,
} from '../../bootstrap/state.js'
import type { QuerySource } from '../../constants/querySource.js'
import type { CanUseToolFn } from '../../hooks/useCanUseTool.js'
import type { Tool, ToolUseContext } from '../../Tool.js'
@@ -68,6 +71,7 @@ import {
} from '../../utils/messages.js'
import { expandPath } from '../../utils/path.js'
import { getPlan, getPlanFilePath } from '../../utils/plans.js'
import { getProjectInstructionFilePaths } from '../../utils/projectInstructions.js'
import {
isSessionActivityTrackingActive,
sendSessionActivitySignal,
@@ -1689,8 +1693,13 @@ function shouldExcludeFromPostCompactRestore(
// and to also match child directory memory files (.claude/rules/*.md, etc.)
try {
const normalizedMemoryPaths = new Set(
MEMORY_TYPE_VALUES.map(type => expandPath(getMemoryPath(type))),
MEMORY_TYPE_VALUES.filter(type => type !== 'Project').map(type =>
expandPath(getMemoryPath(type)),
),
)
for (const path of getProjectInstructionFilePaths(getOriginalCwd())) {
normalizedMemoryPaths.add(expandPath(path))
}
if (normalizedMemoryPaths.has(normalizedFilename)) {
return true