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
86 lines • 3.63 kB
TypeScript
/**
* Skill Deployment Collision Detector
*
* Scans target platform directories before `aiwg use` to identify name conflicts
* between skills being deployed and existing skills already present.
*
* Severity levels:
* - none — target path does not exist, deploy silently
* - info — target exists and is owned by the same namespace, overwrite silently
* - warn — target exists and is owned by a different namespace or user, prompt user
* - error — name matches a known platform built-in or AIWG CLI command, block deployment
*
* @see adr-skill-namespace-strategy.md
* @implements #698
* @implements #804
*/
import type { Platform } from '../../agents/types.js';
export type CollisionSeverity = 'none' | 'info' | 'warn' | 'error';
export interface CollisionResult {
/** Skill name being deployed */
skillName: string;
/** Full path that would be written */
targetPath: string;
/** Severity of the collision */
severity: CollisionSeverity;
/** Human-readable reason */
reason: string;
/** Whether this collision blocks deployment */
blocksDeployment: boolean;
}
export interface CollisionCheckOptions {
/** Platform being deployed to */
platform: Platform;
/** Project root directory */
projectPath: string;
/** Skill names about to be deployed */
skillNames: string[];
/** Namespace of the deploying package (e.g. 'aiwg') */
namespace?: string;
/** Base skills directory (computed from platform if not provided) */
skillsBaseDir?: string;
/** Source skills directory for content hash comparison (skips unchanged files) */
sourceSkillsDir?: string;
}
/**
* Determine if an existing skill directory is owned by the given namespace.
*
* A skill is owned by `namespace` when ANY of:
* 1. Its SKILL.md frontmatter contains `namespace: {namespace}`
* 2. Its parent directory is named after the namespace (e.g. `.claude/skills/aiwg/`)
*
* This generalises the original AIWG-only check to support any package namespace,
* enabling correct cross-namespace collision severity for third-party packages (#804).
*
* @param skillPath - Absolute path to the skill directory
* @param namespace - Namespace to test ownership against (default: 'aiwg')
*/
export declare function isOwnedByNamespace(skillPath: string, namespace?: string): Promise<boolean>;
/**
* Check for deployment collisions before writing skills to a platform directory.
*
* Ownership comparison uses the deploying package's namespace:
* - Same namespace overwrites → `info` severity (silent upgrade)
* - Cross-namespace or user-owned overwrites → `warn` severity (user confirmation)
*
* @param options - Collision check parameters
* @returns Array of collision results, one per skill name. Only non-`none` results
* are returned (clean deployments are omitted).
*/
export declare function checkCollisions(options: CollisionCheckOptions): Promise<CollisionResult[]>;
/**
* Format collision results as a human-readable warning block.
*
* @param results - Collision results from `checkCollisions()`
* @param options - Formatting options
* @param options.verbose - When false, suppress info-level messages (same-namespace updates)
* @returns Formatted string for CLI output, or empty string if no results
*/
export declare function formatCollisionReport(results: CollisionResult[], options?: {
verbose?: boolean;
}): string;
/**
* Check if any collision results block deployment.
*/
export declare function hasBlockingCollisions(results: CollisionResult[]): boolean;
//# sourceMappingURL=collision-detector.d.ts.map