aiwg
Version:
Deployment tool and support utility for AI context. Copies agents, skills, commands, rules, and behaviors into the paths each AI platform reads (Claude Code, Codex, Copilot, Cursor, Warp, OpenClaw, and 6 more) so one source of truth works across 10 platfo
92 lines • 3.14 kB
TypeScript
/**
* CLI Extension Loader
*
* Resolves addon-contributed CLI commands via `.aiwg/cli-extensions.json`.
* When an addon declares `cli_commands` in its manifest, `aiwg use <addon>`
* registers the namespace here. The router falls through to this loader
* when no built-in command matches.
*
* @implements #478
* @architecture Addon manifests → cli-extensions.json → dynamic import → execute
*/
/**
* Shape of a single subcommand entry in cli-extensions.json
*/
interface CliSubcommand {
file: string;
description: string;
hook_event?: string;
}
/**
* Shape of a namespace entry in cli-extensions.json
*/
interface CliNamespace {
source: string;
description: string;
subcommands: Record<string, CliSubcommand>;
}
/**
* Full cli-extensions.json structure
*/
interface CliExtensionsRegistry {
[namespace: string]: CliNamespace;
}
/**
* Context passed to addon CLI command handlers
*/
export interface CliCommandContext {
cwd: string;
frameworkRoot: string;
namespace: string;
subcommand: string;
}
/**
* Result from an addon CLI command handler
*/
export interface CliCommandResult {
exitCode: number;
message?: string;
}
/**
* Write the cli-extensions registry to the current project
*/
export declare function writeRegistry(cwd: string, registry: CliExtensionsRegistry): Promise<void>;
/**
* Register an addon's CLI commands into the project's cli-extensions.json
*
* Called by `aiwg use <addon>` after reading the addon manifest.
*/
export declare function registerCliCommands(cwd: string, namespace: string, description: string, source: string, subcommands: Record<string, CliSubcommand>): Promise<void>;
/**
* Try to execute an addon-contributed CLI command
*
* Returns null if the namespace is not registered (caller should show "unknown command").
* Returns a CliCommandResult if the namespace is found.
*/
export declare function tryExecuteCliExtension(rawCommand: string, commandArgs: string[], cwd: string, frameworkRoot: string): Promise<CliCommandResult | null>;
/**
* Register Claude Code hooks from addon manifest hook_event annotations.
*
* Reads .claude/settings.json, merges hook entries for subcommands that
* declare hook_event, and writes back. Idempotent — duplicate entries
* are skipped. Only registers events in AUTO_HOOK_EVENTS.
*
* Schema: writes the object-keyed form Claude Code requires (#107). If
* an existing settings.json has a legacy array-shaped `hooks` field, it
* is migrated to the object shape during this write.
*
* @implements #480
*/
export declare function registerHooks(cwd: string, namespace: string, subcommands: Record<string, CliSubcommand>): Promise<string[]>;
/**
* Remove Claude Code hooks for a given namespace.
*
* Strips hook entries whose command matches `aiwg <namespace> *`.
* Removes empty groups. Writes back only if changes were made.
*
* Migrates legacy array-shaped `hooks` fields to object form on write
* (#107).
*/
export declare function unregisterHooks(cwd: string, namespace: string): Promise<number>;
export {};
//# sourceMappingURL=cli-extension-loader.d.ts.map