UNPKG

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

89 lines 2.78 kB
/** * Local Cache Adapter * * Lists and resolves packages already present in the local package cache * (~/.cache/aiwg/packages/) and registered in ~/.aiwg/packages.yaml. * * Used by `aiwg use <name>` to check installed packages before falling back * to the bundled npm package. * * @implements #557 */ import { existsSync } from 'fs'; import { listPackages } from '../package-registry.js'; /** * LocalCacheAdapter * * Does not fetch — only resolves already-cached packages. */ export class LocalCacheAdapter { id = 'local-cache'; name = 'Local Package Cache'; /** * Can resolve any ref that matches a key in the local registry. * This is checked by the registry coordinator after parsing the ref, * so canResolve is always false (resolution happens via list()). */ canResolve(_ref) { return false; // Only used via explicit lookup, not auto-resolution } async resolve(_ref) { return null; } /** * No-op — local cache adapter never fetches */ async fetch(_source, _options) { throw new Error('LocalCacheAdapter does not support fetch — use GitAdapter instead'); } /** * List all packages in the local registry */ async list() { return listPackages(); } /** * Look up a package by name (partial match on key or name component) * Returns the PackageInfo if found and the cache path still exists. */ async lookupByName(name) { const packages = await listPackages(); // Exact key match first ("owner/name") const exactKey = packages.find((p) => p.key === name); if (exactKey) return exactKey; // Match by name component only const byName = packages.find((p) => p.name === name); if (byName) return byName; return undefined; } /** * Look up cache path for a package by name. * Returns the cache path if installed and present on disk. */ async resolveCachePath(name) { const { getPackageEntry } = await import('../package-registry.js'); const packages = await listPackages(); let key; // Exact key match if (packages.some((p) => p.key === name)) { key = name; } else { // Match by name component const byName = packages.find((p) => p.name === name); if (byName) key = byName.key; } if (!key) return undefined; const entry = await getPackageEntry(key); if (!entry) return undefined; if (!existsSync(entry.cachePath)) return undefined; return entry.cachePath; } } //# sourceMappingURL=local-cache.js.map