import { shell } from 'electron' import { findFileByName } from './lib/fileSearch' import type { SkillDefinition } from '../types' import { asString } from '../argUtils' export const searchFile: SkillDefinition = { name: 'search_file', description: "Cherche un fichier ou dossier LOCAL (sur l'ordinateur, pas sur internet/YouTube) par son nom, de maniere approximative (ignore l'ordre des mots, les apostrophes, la casse). Commence par les dossiers utilisateur courants, puis scanne tout le stockage en profondeur si besoin (peut prendre un peu de temps). Ouvre le resultat trouve. Pour une video en ligne, utiliser navigate_browser (avec search_web pour trouver l'URL) a la place.", parameters: { type: 'object', properties: { name: { type: 'string', description: 'Nom (ou partie du nom) du fichier/dossier a chercher' } }, required: ['name'] }, execute: async (args) => { const name = asString(args.name).trim() if (!name) throw new Error('nom manquant') const foundPath = await findFileByName(name) if (!foundPath) { return `Aucun fichier ou dossier correspondant a "${name}" trouve, meme apres un scan complet du stockage.` } await shell.openPath(foundPath) return `Trouve et ouvert : ${foundPath}.` } }