import { resolveStateDir } from "../config/paths-state.js";
import { init_paths, resolveBundledSkillsDir } from "../config/paths.js";
import { loadConfig } from "../config/loader.js";
import { loadSkills } from "../agent/skills/index.js";
import { getWorkspacePath } from "../config/workspace-path-helpers.js";
import "../config/index.js";
//#region src/tui/tui-skills-autocomplete.ts
init_paths();
/** `@skill` autocomplete from workspace + global + bundled skill directories. */
function createSkillsAutocompleteProvider() {
	let cached = null;
	const refresh = () => {
		cached = loadSkills({
			workspaceDir: getWorkspacePath(loadConfig()),
			builtinDir: resolveBundledSkillsDir(),
			globalDir: resolveStateDir()
		}).skills.map((skill) => ({
			name: skill.name,
			description: skill.description?.slice(0, 120)
		}));
	};
	return (query) => {
		if (!cached) refresh();
		const skills = cached ?? [];
		const q = query.toLowerCase();
		return (q ? skills.filter((s) => s.name.toLowerCase().includes(q) || (s.description?.toLowerCase().includes(q) ?? false)) : skills).slice(0, 30);
	};
}
/** Test helper — build skill list without caching. */
function listSkillAutocompleteSuggestions() {
	return loadSkills({
		workspaceDir: getWorkspacePath(loadConfig()),
		builtinDir: resolveBundledSkillsDir(),
		globalDir: resolveStateDir()
	}).skills.map((s) => ({
		name: s.name,
		description: s.description
	}));
}
//#endregion
export { createSkillsAutocompleteProvider, listSkillAutocompleteSuggestions };

//# sourceMappingURL=tui-skills-autocomplete.js.map