b8e82008e3
- Added `toExtensionId()` method to all capability types for granular extension identification and disabling. - Added `disabledExtensions` and `includeDisabled` options to LoadOptions for filtering disabled capabilities by extension ID. - Added plugin manifest support for `extensions` entry points with automatic discovery from installed plugins. - Fixed skill loading to properly respect disabled skill names from custom directories. - Improved cross-platform path handling by using `path.basename()` instead of string splitting in context file and state manager. - Refactored capability index loading to validate source metadata and filter disabled extensions before processing.
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
/**
|
|
* Hooks Capability
|
|
*
|
|
* Pre/post tool execution hooks defined as shell scripts.
|
|
*/
|
|
import { defineCapability } from ".";
|
|
import type { SourceMeta } from "./types";
|
|
|
|
/**
|
|
* A hook script.
|
|
*/
|
|
export interface Hook {
|
|
/** Hook name (filename without extension) */
|
|
name: string;
|
|
/** Absolute path to hook file */
|
|
path: string;
|
|
/** Hook type (pre/post) and associated tool */
|
|
type: "pre" | "post";
|
|
/** Tool this hook applies to, or "*" for all */
|
|
tool: string;
|
|
/** Source level */
|
|
level: "user" | "project";
|
|
/** Source metadata */
|
|
_source: SourceMeta;
|
|
}
|
|
|
|
export const hookCapability = defineCapability<Hook>({
|
|
id: "hooks",
|
|
displayName: "Hooks",
|
|
description: "Pre/post tool execution hooks",
|
|
key: hook => `${hook.type}:${hook.tool}:${hook.name}`,
|
|
toExtensionId: hook => `hook:${hook.type}:${hook.tool}:${hook.name}`,
|
|
validate: hook => {
|
|
if (!hook.name) return "Missing name";
|
|
if (!hook.path) return "Missing path";
|
|
if (hook.type !== "pre" && hook.type !== "post") return "Invalid type (must be 'pre' or 'post')";
|
|
if (!hook.tool) return "Missing tool";
|
|
return undefined;
|
|
},
|
|
});
|