MCPcopy Create free account
hub / github.com/Noumena-Network/code / withProjectDir

Function withProjectDir

src/utils/agentsmd.test.ts:41–58  ·  view source on GitHub ↗
(
  fn: (projectDir: string) => Promise<void>,
)

Source from the content-addressed store, hash-verified

39}
40
41async function withProjectDir(
42 fn: (projectDir: string) => Promise<void>,
43): Promise<void> {
44 const projectDir = await mkdtemp(join(tmpdir(), 'agentsmd-project-'))
45 const originalCwd = process.cwd()
46 await mkdir(join(projectDir, '.git'), { recursive: true })
47 process.chdir(projectDir)
48 setOriginalCwd(projectDir)
49 clearAgentsMemoryFilesCache()
50 try {
51 await fn(projectDir)
52 } finally {
53 clearAgentsMemoryFilesCache()
54 process.chdir(originalCwd)
55 setOriginalCwd(originalCwd)
56 await rm(projectDir, { recursive: true, force: true })
57 }
58}
59
60describe('agentsmd project memory discovery', () => {
61 it('discovers AGENTS.md in the project root', async () => {

Callers 1

agentsmd.test.tsFile · 0.85

Calls 4

mkdirFunction · 0.85
rmFunction · 0.85
setOriginalCwdFunction · 0.50

Tested by

no test coverage detected