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
60 lines • 2.17 kB
TypeScript
/**
* Hook bridge shim — env-var contract substitution + canonical schemas.
*
* Per ADR-3 §2: hook authors write canonical $AIWG_* env vars. Translators
* substitute them with the provider-native equivalents at deploy time so
* authors don't need to maintain N copies of the same hook.
*/
/**
* Substitute canonical AIWG env vars with the provider's native equivalents.
*
* Example for codex:
* "$AIWG_PROJECT_DIR/scripts/scan.sh" → "$CODEX_WORKSPACE/scripts/scan.sh"
*
* When a provider has no native equivalent for a given canonical var, the
* canonical name is preserved. Hook authors who need the value despite the
* gap can rely on the runtime shim setting $AIWG_PROJECT_DIR (etc.) before
* invoking the command — that's the per-ADR-3-§2 fallback.
*/
export declare function substituteEnvVars(input: string, provider: string): string;
/**
* Canonical AIWG stdin schema (per ADR-3 §3). Translators wrap the hook
* command with a small shim that normalizes the provider's native stdin to
* this shape before piping to the actual hook.
*/
export interface AiwgHookStdin {
event: string;
tool?: string;
args?: unknown[];
project_dir?: string;
session_id?: string;
}
/**
* Canonical exit-code mapping per ADR-3 §4.
*
* AIWG canonical:
* 0 = allow
* 1 = block
* 2 = warn-and-continue
*
* Provider mapping returns the native exit code(s) that mean each AIWG
* semantic. Used by the wrapper shim to translate hook exit codes back to
* what the provider expects.
*/
export declare const EXIT_CODE_MAP: Record<string, {
allow: number;
block: number;
warn: number;
}>;
/**
* Generate a small bash shim that:
* 1. exports $AIWG_PROJECT_DIR + $AIWG_TOOL_NAME from native env vars
* 2. reads native stdin, transforms to AIWG canonical JSON
* 3. pipes to the hook command
* 4. translates the exit code back per ADR-3 §4
*
* The shim is what gets installed as the actual hook artifact on the
* provider; the AIWG hook command runs inside it.
*/
export declare function generateShimBash(provider: string, hookCommand: string, args?: string[]): string;
//# sourceMappingURL=shim.d.ts.map