f1f6516056
- Removed export leakage by demoting many helper and const symbols to module-local scope. - Renamed underscore-prefixed internals and cache fields, then updated related references and `satisfies never` checks. - Deleted obsolete logic branches and helpers, including harmony-stream interruption flow and unused benchmark runtime helpers. - Updated Biome config and manifests by broadening lint coverage and removing an unused `@napi-rs/cli` dev dependency. - Adjusted tests and utilities to use renamed test helpers and remove redundant private test-only helpers/locals.
62 lines
2.1 KiB
TypeScript
62 lines
2.1 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, test, vi } from "bun:test";
|
|
import * as fs from "node:fs/promises";
|
|
import * as os from "node:os";
|
|
import * as path from "node:path";
|
|
import { type ContextFile, contextFileCapability } from "@oh-my-pi/pi-coding-agent/capability/context-file";
|
|
import { resetSettingsForTest, Settings } from "@oh-my-pi/pi-coding-agent/config/settings";
|
|
import { initializeWithSettings, loadCapability } from "@oh-my-pi/pi-coding-agent/discovery";
|
|
|
|
describe("disabledExtensions runtime filtering", () => {
|
|
let tempDir = "";
|
|
let tempHomeDir = "";
|
|
let originalHome: string | undefined;
|
|
|
|
beforeEach(async () => {
|
|
resetSettingsForTest();
|
|
originalHome = process.env.HOME;
|
|
tempHomeDir = await fs.mkdtemp(path.join(os.tmpdir(), "omp-disabled-ext-home-"));
|
|
process.env.HOME = tempHomeDir;
|
|
vi.spyOn(os, "homedir").mockReturnValue(tempHomeDir);
|
|
tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "omp-disabled-ext-"));
|
|
await fs.mkdir(path.join(tempDir, ".omp"), { recursive: true });
|
|
await fs.writeFile(path.join(tempDir, ".omp", "AGENTS.md"), "# project instructions\n");
|
|
|
|
const settings = await Settings.init({
|
|
inMemory: true,
|
|
cwd: tempDir,
|
|
overrides: {
|
|
disabledExtensions: ["context-file:project:AGENTS.md"],
|
|
},
|
|
});
|
|
initializeWithSettings(settings);
|
|
});
|
|
|
|
afterEach(async () => {
|
|
resetSettingsForTest();
|
|
vi.restoreAllMocks();
|
|
if (originalHome === undefined) {
|
|
delete process.env.HOME;
|
|
} else {
|
|
process.env.HOME = originalHome;
|
|
}
|
|
await fs.rm(tempHomeDir, { recursive: true, force: true });
|
|
await fs.rm(tempDir, { recursive: true, force: true });
|
|
});
|
|
|
|
test("hides disabled context files from runtime loads by default", async () => {
|
|
const result = await loadCapability<ContextFile>(contextFileCapability.id, { cwd: tempDir });
|
|
|
|
expect(result.items).toHaveLength(0);
|
|
});
|
|
|
|
test("can include disabled context files for dashboard-style loads", async () => {
|
|
const result = await loadCapability<ContextFile>(contextFileCapability.id, {
|
|
cwd: tempDir,
|
|
includeDisabled: true,
|
|
});
|
|
|
|
expect(result.items).toHaveLength(1);
|
|
expect(path.basename(result.items[0]!.path)).toBe("AGENTS.md");
|
|
});
|
|
});
|