import { init_agent_scope, resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agent/agent-scope.js";
import { init_paths } from "../config/paths.js";
import { init_loader, loadConfig } from "../config/loader.js";
import { isAbsolute, resolve } from "path";
import { homedir } from "os";
//#region src/utils/helpers.ts
init_loader();
init_agent_scope();
init_paths();
function getWorkspacePath(customPath) {
	if (customPath) return customPath.replace(/^~/, homedir());
	const cfg = loadConfig();
	return resolveAgentWorkspaceDir(cfg, resolveDefaultAgentId(cfg));
}
function createPathResolver(extensionDir, workspaceDir) {
	return (input) => {
		if (input.startsWith("~")) return input.replace("~", process.env.HOME || "");
		if (input.startsWith(".")) return resolve(extensionDir, input);
		if (!isAbsolute(input)) return resolve(workspaceDir, input);
		return input;
	};
}
/**
* Resolve a path to absolute, supporting ~ home directory and cwd-relative paths.
*/
function resolveToCwd(path, cwd) {
	if (path.startsWith("~")) return path.replace(/^~/, process.env.HOME || process.env.USERPROFILE || "");
	if (path.startsWith("/")) return path;
	return `${cwd}/${path}`;
}
//#endregion
export { createPathResolver, getWorkspacePath, resolveToCwd };

//# sourceMappingURL=helpers.js.map