midudev/autoskills · error · Error
could not resolve autoskills package version for registry…
Error message
could not resolve autoskills package version for registry download
What it means
getRegistryRawBaseUrls builds the GitHub raw-content base URLs used to download skill files from the skills-registry. When no explicit registryBaseUrl (option or AUTOSKILLS_REGISTRY_BASE_URL env var) is set, it derives the URL from the autoskills package's own version via getPackageVersion(). If that version cannot be resolved (e.g. package.json is unreadable or missing in the packaged/bundled install), it throws this error rather than guessing a version.
Solutions
- Set the AUTOSKILLS_REGISTRY_BASE_URL environment variable to a registry raw base URL to bypass version resolution.
- Pass registryBaseUrl in InstallOptions when calling the installer.
- Ensure the autoskills package was installed normally (pnpm/npm install with lockfile) so its package.json with a version field is present.
- Check that getPackageVersion()'s lookup path (package.json next to the module) was not stripped by your bundler/build config; include it as an asset if bundling.
Example fix
// before $ autoskills install some-skill // no env, broken package.json -> throws // after $ export AUTOSKILLS_REGISTRY_BASE_URL=https://raw.githubusercontent.com/org/repo/main/packages/autoskills/skills-registry $ autoskills install some-skill
Defensive patterns
Strategy: fallback
Validate before calling
import { readFileSync, existsSync } from "node:fs";
function canResolvePackageVersion(pkgDir) {
try {
const pkg = JSON.parse(readFileSync(join(pkgDir, "package.json"), "utf-8"));
return typeof pkg.version === "string" && pkg.version.length > 0;
} catch { return false; }
}
const ready = canResolvePackageVersion(pkgDir) || !!process.env.AUTOSKILLS_REGISTRY_BASE_URL; Try / catch
try {
await install(opts);
} catch (e) {
if (e.message.includes("could not resolve autoskills package version")) {
await install({ ...opts, registryBaseUrl: process.env.AUTOSKILLS_REGISTRY_BASE_URL ?? FALLBACK_BASE_URL });
} else throw e;
} Prevention
- Always install autoskills via a normal package manager install so package.json ships with a version.
- Set AUTOSKILLS_REGISTRY_BASE_URL explicitly in CI and Docker images.
- If bundling, configure the bundler to preserve package.json as an asset.
- Smoke-test installs from the packaged artifact, not just from source.
When it happens
Trigger: Calling downloadRegistryFile (via downloadRegistryEntry -> install) with no opts.registryBaseUrl and no AUTOSKILLS_REGISTRY_BASE_URL set, while getPackageVersion() returns falsy — typically when the package was installed in a way that loses or renames package.json (bundlers, certain monorepo symlinks, trimmed publish artifacts).
Common situations: Running the CLI from a bundled/dist build that didn't ship package.json; running from a workspace where the package has no version field; exotic install layouts (pnpm hoisting oddities, copying source out of node_modules); CI sandboxes stripping files.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
AI-assisted analysis of midudev/autoskills@0ec725320d (2026-09-15).
Data as JSON: /api/errors/9c86b2228c061c8d.
Report an issue: GitHub.
Appendix: source
Thrown at packages/autoskills/installer.ts:192
const rel = relative(from, to);
return rel.split("\\").join("/");
}
function normalizeRegistryRelPath(rel: string): string {
return rel.split("\\").join("/");
}
function sha256Buffer(buf: Buffer): string {
return createHash("sha256").update(buf).digest("hex");
}
function getRegistryRawBaseUrls(opts: InstallOptions): string[] {
const configured = opts.registryBaseUrl || process.env.AUTOSKILLS_REGISTRY_BASE_URL;
if (configured) return [configured.replace(/\/+$/, "")];
const version = getPackageVersion();
if (!version) {
throw new Error("could not resolve autoskills package version for registry download");
}
return [
`${DEFAULT_REGISTRY_RAW_BASE_URL_PREFIX}/v${version}/packages/autoskills/skills-registry`,
`${DEFAULT_REGISTRY_RAW_BASE_URL_PREFIX}/main/packages/autoskills/skills-registry`,
];
}
function getInstallRegistryDir(opts: InstallOptions): string {
return opts.registryDir || getRegistryDir();
}
export function getAutoskillsCacheDir(): string {
return (
process.env.AUTOSKILLS_CACHE_DIR || join(homedir(), ".cache", "autoskills", "skills-registry")
);
}
View on GitHub (pinned to 0ec725320d)