/** * Tools Engine Operations — business logic layer. * * Contains all tools domain logic migrated from * `packages/cleo/src/dispatch/engines/tools-engine.ts` (ENG-MIG-8 / T1575). * * Sub-domains: * issue.* - Issue diagnostics * skill.* - Skill discovery, dispatch, catalog, precedence * provider.* - CAAMP provider registry * adapter.* - Provider adapter management * * Each exported function returns `EngineResult` and is importable from * `@cleocode/core/internal` so the CLI dispatch layer can call them without * any intermediate engine file. * * @task T1575 — ENG-MIG-8 * @epic T1566 */ import { catalog, detectAllProviders, discoverSkill, discoverSkills, getAllProviders } from '@cleocode/caamp'; import type { SkillImportHermesRequest, SkillImportHermesResponse, SkillMigrateRequest, SkillMigrateResponse, SkillPruneTelemetryRequest, SkillPruneTelemetryResponse, SkillStatsRequest, SkillStatsResponse } from '@cleocode/contracts'; import { AdapterManager } from '../adapters/index.js'; import { type EngineResult } from '../engine-result.js'; import { type HookEvent } from '../hooks/types.js'; import { collectDiagnostics } from '../issue/diagnostics.js'; import { paginate } from '../pagination.js'; import { type DoctorDiagnoseReport } from '../skills/doctor.js'; /** Shape for provider hook info returned by queryHookProviders. */ interface ProviderHookInfo { id: string; name: string | undefined; supportedHooks: string[]; } /** * Collect issue diagnostics. */ export declare function toolsIssueDiagnostics(): EngineResult>; /** * List all discovered skills. */ export declare function toolsSkillList(limit?: number, offset?: number): Promise>; count: number; total: number; filtered: number; page: ReturnType['page']; }>>; /** * Show a single skill by name. */ export declare function toolsSkillShow(name: string): Promise>; }>>; /** * Find skills matching a query string. */ export declare function toolsSkillFind(query?: string): Promise>; count: number; query: string; }>>; /** * Federated find — multi-source skill query (T9731). * * Always queries local skills + canonical marketplace. When `federated` * is `true`, also fans out to every peer in `~/.cleo/federation.json`. * * Returns ranked results plus per-source warnings so callers can surface * network-failure context in the CLI. * * @param query - Search query (case-insensitive). * @param federated - OPT-IN flag for federation fan-out (default `false`). * @param limit - Maximum number of results returned (default `25`). */ export declare function toolsSkillFederatedFind(query?: string, federated?: boolean, limit?: number): Promise>; /** * Get dispatch matrix entries for a skill. */ export declare function toolsSkillDispatch(name: string): EngineResult<{ skill: string; dispatch: { byTaskType: string[]; byKeyword: string[]; byProtocol: string[]; }; }>; /** * Verify a skill's installation and catalog status. */ export declare function toolsSkillVerify(name: string): Promise>; /** * Get dependency tree for a skill. */ export declare function toolsSkillDependencies(name: string): EngineResult<{ skill: string; direct: ReturnType; tree: ReturnType; }>; /** * Get spawn-capable providers by capability. */ export declare function toolsSkillSpawnProviders(capability?: 'supportsSubagents' | 'supportsProgrammaticSpawn' | 'supportsInterAgentComms' | 'supportsParallelSpawn'): Promise>; /** * Run the read-only skill-store doctor diagnose pass. * * @remarks * Thin wrapper over {@link diagnoseSkillStore} from `@cleocode/core/skills/doctor` * — exists so the dispatch layer can route `tools.skill.doctor.diagnose` without * importing the diagnose module directly. The handler is read-only and never * mutates filesystem or db state. * * @param options.verbose - When true, the human renderer included on the * envelope `data.report.rendered` field contains per-skill detail. * * @returns Engine result carrying the {@link DoctorDiagnoseReport} plus the * rendered human-readable summary. * * @task T9652 */ export declare function toolsSkillDoctorDiagnose(options?: { verbose?: boolean; }): Promise>; /** * Run the Sphere B telemetry rollup powering `cleo skills stats`. * * Always returns the top-N rollup (`top`). The `bySource`, `byLifecycle`, * and `agentCreated` facets are populated only when the corresponding flag * is `true` — `null` otherwise so callers can distinguish "not requested" * from "zero rows". * * @param request - Faceting flags from {@link SkillStatsRequest}. * * @task T9690 */ export declare function toolsSkillStats(request?: SkillStatsRequest): Promise>; /** * Migrate Hermes `~/.hermes/skills/.usage.json` sidecars into CLEO `skills.db`. * * @remarks * Thin wrapper over {@link importFromHermes} so the dispatch layer can route * `tools.skill.import-hermes` without importing the skills domain module * directly. The full provenance + counter-synthesis logic lives in * `packages/core/src/skills/hermes-importer.ts`. * * @param request - Import flags (Hermes home override, dry-run mode). * @returns Engine result carrying per-skill outcomes + summary counters. * * @task T9691 */ export declare function toolsSkillImportHermes(request?: SkillImportHermesRequest): Promise>; /** * Prune `skill_usage` rows older than the configured window. * * @remarks * Uses {@link pruneUsageOlderThan} from `@cleocode/core/store/skills-store`. * The window defaults to **180 days** (mirrors Hermes `archive_after_days`) * when the request omits `olderThanDays`. Dry-run mode computes the cutoff * and the projected `deletedRows` without mutating the database. * * @param request - Prune flags (window, dry-run, vacuum). * @returns Engine result with before/after counters and file-size deltas. * * @task T9693 */ export declare function toolsSkillPruneTelemetry(request?: SkillPruneTelemetryRequest): Promise>; /** * Drive the legacy XDG store → `~/.cleo/skills/` migration. * * @remarks * Thin wrapper around the pure helpers in `../skills/migration.js` (moved * from caamp under T9741). Selects the action based on the request flags: * * - both `dryRun` and `rollback` are true → `E_INVALID_INPUT` * - `rollback=true` → {@link runRollback} * - `dryRun=true` → {@link planMigration} * - default → {@link runMigration} (with * `recordRow` wired to `upsertSkillRow` so the skills.db registry is * kept in lock-step with the on-disk copy) * * The handler resolves the bundled canonical-skill names via * {@link listCanonicalSkillNames} so {@link MigratedSkillRecord.sourceType} * is classified correctly (`'canonical'` vs `'user'`). Errors are surfaced * as `engineError('E_INTERNAL', …)`; the dispatch boundary converts that * into a LAFS envelope. * * @param request - Migrate flags (see {@link SkillMigrateRequest}). * @returns Engine result with the migration outcome. * * @task T9742 */ export declare function toolsSkillMigrate(request?: SkillMigrateRequest): Promise>; /** * Get catalog info (protocols, profiles, resources, or summary). */ export declare function toolsSkillCatalogInfo(): EngineResult<{ available: boolean; version: string | null; libraryRoot: string | null; skillCount: number; protocolCount: number; profileCount: number; }>; /** * List catalog protocols. */ export declare function toolsSkillCatalogProtocols(limit?: number, offset?: number): EngineResult<{ protocols: Array<{ name: string; path: string | null; }>; count: number; total: number; filtered: number; page: ReturnType['page']; }>; /** * List catalog profiles. */ export declare function toolsSkillCatalogProfiles(limit?: number, offset?: number): EngineResult<{ profiles: Array<{ name: string; description: string; extends: string | undefined; skillCount: number; skills: string[]; }>; count: number; total: number; filtered: number; page: ReturnType['page']; }>; /** * List catalog shared resources. */ export declare function toolsSkillCatalogResources(limit?: number, offset?: number): EngineResult<{ resources: Array<{ name: string; path: string | null; }>; count: number; total: number; filtered: number; page: ReturnType['page']; }>; /** * Show skill precedence map. */ export declare function toolsSkillPrecedenceShow(): Promise>; /** * Resolve skill paths for a specific provider. */ export declare function toolsSkillPrecedenceResolve(providerId: string, scope: 'global' | 'project', projectRoot: string): Promise>; /** * Install a skill to one or more providers. */ export declare function toolsSkillInstall(name: string, projectRoot: string, source?: string, isGlobal?: boolean): Promise; targets: string[]; }>>; /** * Uninstall a skill from all providers. */ export declare function toolsSkillUninstall(name: string, projectRoot: string, isGlobal?: boolean): Promise>; /** * Refresh all tracked skills that have updates available. */ export declare function toolsSkillRefresh(projectRoot: string): Promise; checked: number; }>>; /** * List all registered providers. */ export declare function toolsProviderList(limit?: number, offset?: number): EngineResult<{ providers: ReturnType; count: number; total: number; filtered: number; page: ReturnType['page']; }>; /** * Detect all available providers in the environment. */ export declare function toolsProviderDetect(): EngineResult<{ providers: ReturnType; count: number; }>; /** * Check injection status for all installed providers. */ export declare function toolsProviderInjectStatus(projectRoot: string, scope?: 'project' | 'global', content?: string): Promise>; /** * Check if a provider supports a specific capability. */ export declare function toolsProviderSupports(providerId: string, capability: string): Promise>; /** * Query hook providers for a specific event. */ export declare function toolsProviderHooks(event: string): Promise>; /** * Inject CLEO directives into all installed provider instruction files. */ export declare function toolsProviderInject(projectRoot: string, scope?: 'project' | 'global', references?: string[], content?: string): Promise; count: number; }>>; /** * List all discovered adapters. */ export declare function toolsAdapterList(projectRoot: string): EngineResult<{ adapters: ReturnType; count: number; }>; /** * Show a single adapter by ID. */ export declare function toolsAdapterShow(projectRoot: string, id: string): EngineResult<{ manifest: unknown; initialized: boolean; active: boolean; }>; /** * Detect active adapters. */ export declare function toolsAdapterDetect(projectRoot: string): EngineResult<{ detected: string[]; count: number; }>; /** * Get adapter health status. */ export declare function toolsAdapterHealth(projectRoot: string, id?: string): EngineResult<{ adapters: ReturnType; count: number; }>; /** * Activate an adapter by ID. */ export declare function toolsAdapterActivate(projectRoot: string, id: string): Promise>; /** * Dispose one or all adapters. */ export declare function toolsAdapterDispose(projectRoot: string, id?: string): Promise>; export {}; //# sourceMappingURL=engine-ops.d.ts.map