Files
orcs-code/src/projectOnboardingState.ts
ZhaoXiaoLuo b3f3dc4e66 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>
2026-04-12 21:31:33 +08:00

48 lines
1.4 KiB
TypeScript

import memoize from 'lodash-es/memoize.js'
import {
getCurrentProjectConfig,
saveCurrentProjectConfig,
} from './utils/config.js'
export {
getSteps,
isProjectOnboardingComplete,
type Step,
} from './projectOnboardingSteps.js'
import { isProjectOnboardingComplete } from './projectOnboardingSteps.js'
export function maybeMarkProjectOnboardingComplete(): void {
// Short-circuit on cached config — isProjectOnboardingComplete() hits
// the filesystem, and REPL.tsx calls this on every prompt submit.
if (getCurrentProjectConfig().hasCompletedProjectOnboarding) {
return
}
if (isProjectOnboardingComplete()) {
saveCurrentProjectConfig(current => ({
...current,
hasCompletedProjectOnboarding: true,
}))
}
}
export const shouldShowProjectOnboarding = memoize((): boolean => {
const projectConfig = getCurrentProjectConfig()
// Short-circuit on cached config before isProjectOnboardingComplete()
// hits the filesystem — this runs during first render.
if (
projectConfig.hasCompletedProjectOnboarding ||
projectConfig.projectOnboardingSeenCount >= 4 ||
process.env.IS_DEMO
) {
return false
}
return !isProjectOnboardingComplete()
})
export function incrementProjectOnboardingSeenCount(): void {
saveCurrentProjectConfig(current => ({
...current,
projectOnboardingSeenCount: current.projectOnboardingSeenCount + 1,
}))
}