chore(cleanup): remove system-check skills
Remove check_system_memory, check_storage, check_battery_and_cpu and check_internet_connection along with their windows/ implementation and the empty mac/ placeholder. These general-purpose system-check skills have no place in Max's exclusive freelance-coach pipeline, which now runs server-side in Max API. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
bae5ace70c
commit
7c480e1ce4
@@ -1,6 +1,4 @@
|
||||
import type { SkillDefinition } from './types'
|
||||
import { windowsSkills } from './windows'
|
||||
import { macSkills } from './mac'
|
||||
import { memorySkills } from './memory'
|
||||
import { webSkills } from './web'
|
||||
import { browserSkills } from './browser'
|
||||
@@ -8,8 +6,7 @@ import { browserSkills } from './browser'
|
||||
export type { SkillDefinition } from './types'
|
||||
|
||||
export function loadSkills(): SkillDefinition[] {
|
||||
const platformSkills = process.platform === 'darwin' ? macSkills : windowsSkills
|
||||
return [...platformSkills, ...memorySkills, ...webSkills, ...browserSkills]
|
||||
return [...memorySkills, ...webSkills, ...browserSkills]
|
||||
}
|
||||
|
||||
export function findSkill(name: string): SkillDefinition | undefined {
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
import type { SkillDefinition } from '../types'
|
||||
|
||||
// A completer : equivalents macOS des competences Windows (osascript / open / etc.).
|
||||
export const macSkills: SkillDefinition[] = []
|
||||
@@ -1,34 +0,0 @@
|
||||
import { execFile } from 'child_process'
|
||||
import { promisify } from 'util'
|
||||
import { POWERSHELL_EXE } from './lib/systemPaths'
|
||||
import type { SkillDefinition } from '../types'
|
||||
|
||||
const execFileAsync = promisify(execFile)
|
||||
|
||||
interface ConnectionInfo {
|
||||
Connected: boolean
|
||||
Ip: string | null
|
||||
}
|
||||
|
||||
const PS_SCRIPT = `
|
||||
$ping = Test-Connection -ComputerName 8.8.8.8 -Count 1 -Quiet -ErrorAction SilentlyContinue
|
||||
$ip = (Get-NetIPAddress -AddressFamily IPv4 -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.InterfaceAlias -notmatch 'Loopback' -and $_.IPAddress -notlike '169.254.*' } |
|
||||
Select-Object -First 1).IPAddress
|
||||
[PSCustomObject]@{ Connected = [bool]$ping; Ip = $ip } | ConvertTo-Json
|
||||
`
|
||||
|
||||
export const checkInternet: SkillDefinition = {
|
||||
name: 'check_internet_connection',
|
||||
description: "Teste si la connexion internet fonctionne et donne l'adresse IP locale.",
|
||||
parameters: { type: 'object', properties: {} },
|
||||
execute: async () => {
|
||||
const { stdout } = await execFileAsync(POWERSHELL_EXE, ['-NoProfile', '-Command', PS_SCRIPT], {
|
||||
timeout: 10000
|
||||
})
|
||||
const data = JSON.parse(stdout) as ConnectionInfo
|
||||
return data.Connected
|
||||
? `Internet fonctionne. Adresse IP locale : ${data.Ip ?? 'inconnue'}.`
|
||||
: 'Pas de connexion internet detectee.'
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import type { SkillDefinition } from '../types'
|
||||
import { systemMemory } from './systemMemory'
|
||||
import { systemStorage } from './systemStorage'
|
||||
import { systemStatus } from './systemStatus'
|
||||
import { checkInternet } from './checkInternet'
|
||||
|
||||
export const windowsSkills: SkillDefinition[] = [
|
||||
systemMemory,
|
||||
systemStorage,
|
||||
systemStatus,
|
||||
checkInternet
|
||||
]
|
||||
@@ -1,9 +0,0 @@
|
||||
import { join } from 'path'
|
||||
|
||||
// Sur certaines configurations, le PATH de l'environnement ou tourne l'app ne contient pas
|
||||
// System32 : un execFile('powershell.exe', ...) ou execFile('taskkill', ...) en nom nu echoue
|
||||
// alors avec ENOENT. On resout donc toujours les chemins absolus des binaires systeme utilises.
|
||||
const systemRoot = process.env.SystemRoot || process.env.windir || 'C:\\Windows'
|
||||
const system32 = join(systemRoot, 'System32')
|
||||
|
||||
export const POWERSHELL_EXE = join(system32, 'WindowsPowerShell', 'v1.0', 'powershell.exe')
|
||||
@@ -1,16 +0,0 @@
|
||||
import { freemem, totalmem } from 'os'
|
||||
import type { SkillDefinition } from '../types'
|
||||
|
||||
const toGo = (bytes: number): string => (bytes / 1024 ** 3).toFixed(1)
|
||||
|
||||
export const systemMemory: SkillDefinition = {
|
||||
name: 'check_system_memory',
|
||||
description: "Renvoie l'etat de la memoire RAM de l'ordinateur (totale, utilisee, libre).",
|
||||
parameters: { type: 'object', properties: {} },
|
||||
execute: async () => {
|
||||
const total = totalmem()
|
||||
const free = freemem()
|
||||
const used = total - free
|
||||
return `Memoire RAM : ${toGo(used)} Go utilises sur ${toGo(total)} Go (${toGo(free)} Go libres).`
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
import { execFile } from 'child_process'
|
||||
import { promisify } from 'util'
|
||||
import { POWERSHELL_EXE } from './lib/systemPaths'
|
||||
import type { SkillDefinition } from '../types'
|
||||
|
||||
const execFileAsync = promisify(execFile)
|
||||
|
||||
interface StatusInfo {
|
||||
BatteryPercent: number | null
|
||||
Charging: boolean | null
|
||||
CpuPercent: number
|
||||
}
|
||||
|
||||
const PS_SCRIPT = `
|
||||
$battery = Get-CimInstance Win32_Battery -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||
$cpu = (Get-CimInstance Win32_Processor | Measure-Object -Property LoadPercentage -Average).Average
|
||||
[PSCustomObject]@{
|
||||
BatteryPercent = if ($battery) { $battery.EstimatedChargeRemaining } else { $null }
|
||||
Charging = if ($battery) { $battery.BatteryStatus -eq 2 } else { $null }
|
||||
CpuPercent = [math]::Round($cpu, 0)
|
||||
} | ConvertTo-Json
|
||||
`
|
||||
|
||||
export const systemStatus: SkillDefinition = {
|
||||
name: 'check_battery_and_cpu',
|
||||
description:
|
||||
'Renvoie le niveau de batterie (si ordinateur portable) et la charge processeur actuelle.',
|
||||
parameters: { type: 'object', properties: {} },
|
||||
execute: async () => {
|
||||
const { stdout } = await execFileAsync(POWERSHELL_EXE, ['-NoProfile', '-Command', PS_SCRIPT])
|
||||
const data = JSON.parse(stdout) as StatusInfo
|
||||
|
||||
const batteryText =
|
||||
data.BatteryPercent !== null
|
||||
? `Batterie a ${data.BatteryPercent}%${data.Charging ? ' (en charge)' : ''}.`
|
||||
: 'Pas de batterie detectee (ordinateur fixe).'
|
||||
|
||||
return `${batteryText} Processeur utilise a ${data.CpuPercent}%.`
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
import { execFile } from 'child_process'
|
||||
import { promisify } from 'util'
|
||||
import { POWERSHELL_EXE } from './lib/systemPaths'
|
||||
import type { SkillDefinition } from '../types'
|
||||
|
||||
const execFileAsync = promisify(execFile)
|
||||
|
||||
interface VolumeInfo {
|
||||
DriveLetter: string
|
||||
SizeGB: number
|
||||
FreeGB: number
|
||||
}
|
||||
|
||||
const PS_SCRIPT = `Get-Volume | Where-Object { $_.DriveLetter } | Select-Object DriveLetter,@{N='SizeGB';E={[math]::Round($_.Size/1GB,1)}},@{N='FreeGB';E={[math]::Round($_.SizeRemaining/1GB,1)}} | ConvertTo-Json`
|
||||
|
||||
export const systemStorage: SkillDefinition = {
|
||||
name: 'check_storage',
|
||||
description:
|
||||
"Renvoie l'espace de stockage utilise et disponible sur les disques de l'ordinateur.",
|
||||
parameters: { type: 'object', properties: {} },
|
||||
execute: async () => {
|
||||
const { stdout } = await execFileAsync(POWERSHELL_EXE, ['-NoProfile', '-Command', PS_SCRIPT])
|
||||
const parsed = JSON.parse(stdout) as VolumeInfo | VolumeInfo[]
|
||||
const volumes = Array.isArray(parsed) ? parsed : [parsed]
|
||||
return volumes
|
||||
.map(
|
||||
(v) =>
|
||||
`Disque ${v.DriveLetter} : ${(v.SizeGB - v.FreeGB).toFixed(1)} Go utilises sur ${v.SizeGB} Go (${v.FreeGB} Go libres)`
|
||||
)
|
||||
.join('. ')
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user