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
66 lines • 2.51 kB
TypeScript
/**
* Claude Code aiwg-hooks installer (PUW-010 / #1111).
*
* When `aiwg use --provider claude` runs and the operator hasn't opted
* out via `--no-hooks`, this module:
* 1. Copies the aiwg-hooks addon's JS handler scripts to .claude/hooks/
* 2. Reads existing .claude/settings.json (backing up first if no AIWG
* marker is present, per ADR-3 §5)
* 3. Merges AIWG hook entries with `_aiwg_managed: true` tagging
* 4. Writes settings.json atomically
*
* Schema: Claude Code requires `hooks` to be an object keyed by event
* name, each value an array of matcher groups. See #107.
*
* {
* "hooks": {
* "<EventName>": [
* { "matcher": "<optional regex>",
* "hooks": [{ "type": "command", "command": "..." }] }
* ]
* }
* }
*
* The merge preserves operator-authored entries. Legacy array-shaped
* hook fields written by older AIWG builds are migrated to the object
* shape on read. `aiwg refresh --restore-hooks` reads the most-recent
* .bak.<timestamp> file and restores it.
*/
export interface InstallOptions {
/** Project root absolute path (where .claude/ lives) */
projectPath: string;
/** Framework root (where agentic/code/addons/aiwg-hooks/ lives) */
frameworkRoot: string;
/** Don't write files; describe what would happen */
dryRun?: boolean;
/** Force overwrite even when settings.json has no AIWG marker (with backup) */
force?: boolean;
/** Verbose logging */
verbose?: boolean;
}
export interface InstallResult {
installedScripts: string[];
settingsPath: string;
backupPath?: string;
registeredEvents: string[];
warnings: string[];
/** True when the installer migrated a legacy array-shaped `hooks` field */
migratedFromLegacy?: boolean;
}
/**
* Install AIWG hooks for Claude Code.
*
* Returns null if the addon source isn't present (e.g., aiwg-hooks not
* installed). Otherwise returns an InstallResult describing what was
* written.
*/
export declare function installAiwgHooks(opts: InstallOptions): Promise<InstallResult | null>;
/**
* Restore the most-recent settings.json backup (per ADR-3 §5 rollback).
*
* Reads `.claude/settings.json.bak.<RFC3339>` files and restores the
* lexicographically-latest one (timestamp ordering). Returns the path
* restored or null if no backup exists.
*/
export declare function restoreSettingsBackup(projectPath: string): Promise<string | null>;
//# sourceMappingURL=claude-hooks-installer.d.ts.map