fix full-suite isolation regressions
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
import { describe, it, expect, beforeEach, afterEach, mock } from "bun:test"
|
||||
import { mkdirSync, writeFileSync, rmSync } from "fs"
|
||||
import { describe, it, expect, beforeEach, afterEach } from "bun:test"
|
||||
import { mkdirSync, mkdtempSync, writeFileSync, rmSync } from "node:fs"
|
||||
import { join } from "path"
|
||||
import { tmpdir } from "os"
|
||||
|
||||
const TEST_DIR = join(tmpdir(), "agents-global-skills-test-" + Date.now())
|
||||
const TEMP_HOME = join(TEST_DIR, "home")
|
||||
|
||||
describe("discoverGlobalAgentsSkills", () => {
|
||||
let testDir: string
|
||||
let tempHome: string
|
||||
|
||||
beforeEach(() => {
|
||||
mkdirSync(TEST_DIR, { recursive: true })
|
||||
mkdirSync(TEMP_HOME, { recursive: true })
|
||||
testDir = mkdtempSync(join(tmpdir(), "agents-global-skills-test-"))
|
||||
tempHome = join(testDir, "home")
|
||||
mkdirSync(tempHome, { recursive: true })
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
mock.restore()
|
||||
rmSync(TEST_DIR, { recursive: true, force: true })
|
||||
rmSync(testDir, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
it("#given a skill in ~/.agents/skills/ #when discoverGlobalAgentsSkills is called #then it discovers the skill", async () => {
|
||||
@@ -25,19 +25,14 @@ description: A skill from global .agents/skills directory
|
||||
---
|
||||
Skill body.
|
||||
`
|
||||
const agentsGlobalSkillsDir = join(TEMP_HOME, ".agents", "skills")
|
||||
const agentsGlobalSkillsDir = join(tempHome, ".agents", "skills")
|
||||
const skillDir = join(agentsGlobalSkillsDir, "agent-global-skill")
|
||||
mkdirSync(skillDir, { recursive: true })
|
||||
writeFileSync(join(skillDir, "SKILL.md"), skillContent)
|
||||
|
||||
mock.module("os", () => ({
|
||||
homedir: () => TEMP_HOME,
|
||||
tmpdir,
|
||||
}))
|
||||
|
||||
//#when
|
||||
const { discoverGlobalAgentsSkills } = await import("./loader")
|
||||
const skills = await discoverGlobalAgentsSkills()
|
||||
const { discoverGlobalAgentsSkills } = await import(`./loader?test=${crypto.randomUUID()}`)
|
||||
const skills = await discoverGlobalAgentsSkills(tempHome)
|
||||
const skill = skills.find(s => s.name === "agent-global-skill")
|
||||
|
||||
//#then
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { promises as fs } from "fs"
|
||||
import * as fs from "node:fs/promises"
|
||||
import { homedir } from "os"
|
||||
import { dirname, extname, isAbsolute, join, relative } from "path"
|
||||
import picomatch from "picomatch"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { promises as fs } from "fs"
|
||||
import * as fs from "node:fs/promises"
|
||||
import { basename } from "path"
|
||||
import { parseFrontmatter } from "../../shared/frontmatter"
|
||||
import { sanitizeModelField } from "../../shared/model-sanitizer"
|
||||
|
||||
@@ -56,8 +56,8 @@ export async function loadProjectAgentsSkills(directory?: string): Promise<Recor
|
||||
return skillsToCommandDefinitionRecord(deduplicateSkillsByName(allSkills.flat()))
|
||||
}
|
||||
|
||||
export async function loadGlobalAgentsSkills(): Promise<Record<string, CommandDefinition>> {
|
||||
const agentsGlobalDir = join(homedir(), ".agents", "skills")
|
||||
export async function loadGlobalAgentsSkills(homeDirectory: string = homedir()): Promise<Record<string, CommandDefinition>> {
|
||||
const agentsGlobalDir = join(homeDirectory, ".agents", "skills")
|
||||
const skills = await loadSkillsFromDir({ skillsDir: agentsGlobalDir, scope: "user" })
|
||||
return skillsToCommandDefinitionRecord(skills)
|
||||
}
|
||||
@@ -166,7 +166,7 @@ export async function discoverProjectAgentsSkills(directory?: string): Promise<L
|
||||
return deduplicateSkillsByName(allSkills.flat())
|
||||
}
|
||||
|
||||
export async function discoverGlobalAgentsSkills(): Promise<LoadedSkill[]> {
|
||||
const agentsGlobalDir = join(homedir(), ".agents", "skills")
|
||||
export async function discoverGlobalAgentsSkills(homeDirectory: string = homedir()): Promise<LoadedSkill[]> {
|
||||
const agentsGlobalDir = join(homeDirectory, ".agents", "skills")
|
||||
return loadSkillsFromDir({ skillsDir: agentsGlobalDir, scope: "user" })
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { promises as fs } from "fs"
|
||||
import * as fs from "node:fs/promises"
|
||||
import { join } from "path"
|
||||
import { resolveSymlinkAsync, isMarkdownFile } from "../../shared/file-utils"
|
||||
import type { LoadedSkill, SkillScope } from "./types"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { promises as fs } from "fs"
|
||||
import * as fs from "node:fs/promises"
|
||||
import { join } from "path"
|
||||
import yaml from "js-yaml"
|
||||
import type { SkillMcpConfig } from "../skill-mcp-manager/types"
|
||||
|
||||
Reference in New Issue
Block a user