Files
oh-my-pi/packages/coding-agent/test/discovery/pi-config-dir.test.ts
T
Ogrodev b99039ded2 fix(coding-agent): profile-scope native config discovery and load symlinked extension dirs
Native user-level config discovery (MCP, skills, rules, slash commands, prompts, instructions, hooks, tools, settings, extensions, and the top-level SYSTEM.md/RULES.md/AGENTS.md) now resolves the user scope through getAgentDir() in builtin.ts, omp-extension-roots.ts, and the discovery-layer getUserPath() helper. A named profile sees only its own ~/.omp/profiles/<name>/agent config instead of the default profile's ~/.omp/agent leaking into every profile, matching the /mcp config writer and getMCPConfigPath("user").

discoverExtensionModulePaths now detects top-level symlinked directories that the native glob skips (follow_links=false) and synthesizes their index/package.json entry-point matches, so an extension shared across profiles via a symlink loads like a real directory. Symlinked extension files were already handled.

cli: check --tiny-worker on the profile-flag-stripped resolvedArgv, matching the adjacent --smoke-test check and launch routing.
2026-06-04 15:07:55 -03:00

40 lines
1.6 KiB
TypeScript

import { afterEach, describe, expect, test } from "bun:test";
import * as os from "node:os";
import * as path from "node:path";
import type { LoadContext } from "@oh-my-pi/pi-coding-agent/capability/types";
import { getConfigDirs } from "@oh-my-pi/pi-coding-agent/config";
import { getUserPath } from "@oh-my-pi/pi-coding-agent/discovery/helpers";
import { getAgentDir } from "@oh-my-pi/pi-utils";
describe("PI_CONFIG_DIR", () => {
const original = process.env.PI_CONFIG_DIR;
afterEach(() => {
if (original === undefined) {
delete process.env.PI_CONFIG_DIR;
} else {
process.env.PI_CONFIG_DIR = original;
}
});
test("getUserPath resolves the native user scope via getAgentDir (profile-aware)", () => {
const ctx: LoadContext = {
cwd: "/work/project",
home: "/home/tester",
repoRoot: null,
};
// Native user config follows the active profile through getAgentDir(), not
// ctx.home, so it stays in sync with builtin.ts and getMCPConfigPath("user").
// The old behavior joined ctx.home + ".omp/agent" and leaked the default
// profile's config into every profile.
expect(getUserPath(ctx, "native", "commands")).toBe(path.join(getAgentDir(), "commands"));
expect(getUserPath(ctx, "native", "commands")).not.toContain(ctx.home);
});
test("getConfigDirs respects PI_CONFIG_DIR for user base", () => {
process.env.PI_CONFIG_DIR = ".config/omp";
const result = getConfigDirs("commands", { project: false });
const expected = path.resolve(path.join(os.homedir(), ".config/omp", "agent", "commands"));
expect(result[0]).toEqual({ path: expected, source: ".omp", level: "user" });
});
});