Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ COMMANDS:
mcp [install] Start stdio MCP server or 1-click install for Claude Desktop, Cursor, Windsurf
init [--ide] Initialize workspace or generate AI agent guidelines (.cursorrules, CLAUDE.md)
completion <shell> Generate native shell tab auto-completion (bash, zsh, fish, powershell)
which <ecosystem> Show active CLI binary for an ecosystem (npm, jsr, pypi, conda, cargo, go, nuget, composer, gem, pub)
which <ecosystem> Show active CLI binary for an ecosystem (npm, jsr, pypi, conda, cargo, go, nuget, composer, gem, pub, conan, vcpkg, meson, julia)

OPTIONS:
-D, --dev Install as a development dependency
Expand Down
35 changes: 35 additions & 0 deletions src/doctor/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,41 @@ export class PolyDoctor {
args: ["--version"],
hint: "https://dart.dev/get-dart",
},
{
id: "toolchain-conan",
name: "Conan C/C++",
cmd: "conan",
args: ["--version"],
hint: "https://conan.io",
},
{
id: "toolchain-vcpkg",
name: "vcpkg C/C++",
cmd: "vcpkg",
args: ["version"],
hint: "https://vcpkg.io",
},
{
id: "toolchain-meson",
name: "Meson Build",
cmd: "meson",
args: ["--version"],
hint: "https://mesonbuild.com",
},
{
id: "toolchain-cmake",
name: "CMake",
cmd: "cmake",
args: ["--version"],
hint: "https://cmake.org",
},
{
id: "toolchain-julia",
name: "Julia Pkg.jl",
cmd: "julia",
args: ["--version"],
hint: "https://julialang.org/downloads/",
},
];

for (const tc of toolchains) {
Expand Down
133 changes: 133 additions & 0 deletions src/engines/cpp-julia.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import type { PackageSpec } from "../types.js";
import { type EngineAdapter, defineDeclarativeAdapter } from "./declarative.js";

function formatConanTarget(pkg: PackageSpec): string {
const fullName = pkg.namespace ? `${pkg.namespace}/${pkg.name}` : pkg.name;
if (!pkg.version) return fullName;
const cleanVer = pkg.version.replace(/^[~^>=<]+/, "");
return fullName.includes("/") ? fullName : `${fullName}/${cleanVer}`;
}

/** C / C++ — Conan (ConanCenter) */
export const conanAdapter: EngineAdapter = defineDeclarativeAdapter({
id: "conan",
ecosystem: "conan",
aliases: ["cpp", "c++"],
purlTypes: ["conan"],
manifests: ["conanfile.txt", "conanfile.py"],
lockfiles: ["conan.lock"],
osvEcosystem: "ConanCenter",
sbomPurlType: "conan",
supportedClis: ["conan"],
commands: {
command: "conan",
add: (pkg) => ["install", `--requires=${formatConanTarget(pkg)}`, "--build=missing"],
remove: (pkg) => ["remove", `${pkg.name}/*`, "-c"],
install: () => ["install", ".", "--build=missing"],
update: (pkg) =>
pkg
? ["install", `--requires=${formatConanTarget(pkg)}`, "--update", "--build=missing"]
: ["install", ".", "--update", "--build=missing"],
},
resolveScriptCommand: (script) =>
script === "test" ? ["ctest", ["--test-dir", "build"]] : ["conan", ["build", "."]],
injectRegistryEnv: (endpoint, env) => {
env.CONAN_HOME = endpoint.url;
},
injectRegistryFlags: (endpoint, args) => {
if (args[0] === "install" && !args.includes("-r")) {
args.push("-r", endpoint.url);
}
},
});

/** C / C++ — vcpkg (Manifest Mode) */
export const vcpkgAdapter: EngineAdapter = defineDeclarativeAdapter({
id: "vcpkg",
ecosystem: "vcpkg",
aliases: [],
purlTypes: ["vcpkg"],
manifests: ["vcpkg.json", "vcpkg-configuration.json"],
lockfiles: ["vcpkg-configuration.json"],
osvEcosystem: undefined,
sbomPurlType: "vcpkg",
supportedClis: ["vcpkg"],
commands: {
command: "vcpkg",
add: (pkg) => ["add", "port", pkg.name],
remove: (pkg) => ["remove", pkg.name],
install: () => ["install"],
update: (pkg) => (pkg ? ["upgrade", pkg.name, "--no-dry-run"] : ["upgrade", "--no-dry-run"]),
},
resolveScriptCommand: (script) =>
script === "test" ? ["ctest", ["--test-dir", "build"]] : ["cmake", ["--build", "build"]],
injectRegistryEnv: (endpoint, env) => {
env.VCPKG_BINARY_SOURCES = endpoint.url;
},
});

/** C / C++ — Meson WrapDB */
export const mesonAdapter: EngineAdapter = defineDeclarativeAdapter({
id: "meson",
ecosystem: "meson",
aliases: ["wrap", "wrapdb"],
purlTypes: ["meson", "wrap"],
manifests: ["meson.build"],
lockfiles: [],
osvEcosystem: undefined,
sbomPurlType: "meson",
supportedClis: ["meson"],
commands: {
command: "meson",
add: (pkg) => ["wrap", "install", pkg.name],
remove: () => ["subprojects", "purge", "--confirm"],
install: () => ["subprojects", "download"],
update: (pkg) => (pkg ? ["wrap", "update", pkg.name] : ["subprojects", "update"]),
},
resolveScriptCommand: (script) =>
script === "test" ? ["meson", ["test", "-C", "build"]] : ["meson", ["compile", "-C", "build"]],
});

/** Julia — Pkg.jl (General Registry) */
export const juliaAdapter: EngineAdapter = defineDeclarativeAdapter({
id: "julia",
ecosystem: "julia",
aliases: ["pkg.jl", "pkgjl"],
purlTypes: ["julia"],
manifests: ["Project.toml"],
lockfiles: ["Manifest.toml"],
osvEcosystem: undefined,
sbomPurlType: "julia",
supportedClis: ["julia"],
commands: {
command: "julia",
add: (pkg) => {
const cleanVer = pkg.version?.replace(/^[~^>=<]+/, "");
const expr = cleanVer
? `using Pkg; Pkg.add(PackageSpec(name="${pkg.name}", version="${cleanVer}"))`
: `using Pkg; Pkg.add("${pkg.name}")`;
return ["--project=.", "-e", expr];
},
remove: (pkg) => ["--project=.", "-e", `using Pkg; Pkg.rm("${pkg.name}")`],
install: () => ["--project=.", "-e", "using Pkg; Pkg.instantiate()"],
update: (pkg) => [
"--project=.",
"-e",
pkg ? `using Pkg; Pkg.update("${pkg.name}")` : "using Pkg; Pkg.update()",
],
},
resolveScriptCommand: (script) =>
script === "test"
? ["julia", ["--project=.", "-e", "using Pkg; Pkg.test()"]]
: ["julia", ["--project=.", "-e", script]],
injectRegistryEnv: (endpoint, env) => {
env.JULIA_PKG_SERVER = endpoint.url;
},
});

export const CPP_JULIA_ADAPTERS: readonly EngineAdapter[] = [
conanAdapter,
vcpkgAdapter,
mesonAdapter,
juliaAdapter,
];
7 changes: 7 additions & 0 deletions src/engines/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ export {
nugetAdapter,
pubAdapter,
} from "./backend-mobile.js";
export {
CPP_JULIA_ADAPTERS,
conanAdapter,
juliaAdapter,
mesonAdapter,
vcpkgAdapter,
} from "./cpp-julia.js";
export {
DeclarativeEngine,
defineDeclarativeAdapter,
Expand Down
4 changes: 4 additions & 0 deletions src/engines/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fs from "node:fs";
import type { Ecosystem, EngineContext } from "../types.js";
import { BACKEND_MOBILE_ADAPTERS } from "./backend-mobile.js";
import type { BaseEngine } from "./base.js";
import { CPP_JULIA_ADAPTERS } from "./cpp-julia.js";
import { type EngineAdapter, defineDeclarativeAdapter } from "./declarative.js";
import { GoEngine } from "./go.js";
import { NodeEngine } from "./node.js";
Expand Down Expand Up @@ -290,6 +291,9 @@ engineRegistry.register(goAdapter);
for (const adapter of BACKEND_MOBILE_ADAPTERS) {
engineRegistry.register(adapter);
}
for (const adapter of CPP_JULIA_ADAPTERS) {
engineRegistry.register(adapter);
}

/** Ensures a PackageSpec target cleanly detects its first existing manifest file in cwd if missing. */
export function resolveEcosystemLockContext(ecosystem: Ecosystem, cwd: string): EngineContext {
Expand Down
6 changes: 5 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ export type BuiltinEcosystem =
| "nuget"
| "composer"
| "gem"
| "pub";
| "pub"
| "conan"
| "vcpkg"
| "meson"
| "julia";
export type Ecosystem = BuiltinEcosystem | (string & {});

export interface EngineContext {
Expand Down
114 changes: 114 additions & 0 deletions src/workspace/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,121 @@ export function extractDirectDependencies(manifestPath: string, ecosystem: Ecosy
}
break;
}
case "conan":
case "vcpkg":
case "meson":
case "julia": {
for (const item of extractCppJuliaDependencies(manifestPath, content, ecosystem)) {
deps.push(`${item.ecosystem}:${item.name}@${item.version}`);
}
break;
}
}

return deps.sort();
}

function extractCppJuliaDependencies(
manifestPath: string,
content: string,
ecosystem: string,
): Array<{ ecosystem: string; name: string; version: string }> {
const results: Array<{ ecosystem: string; name: string; version: string }> = [];
const lowerPath = manifestPath.toLowerCase();

if (ecosystem === "conan") {
if (lowerPath.endsWith(".txt")) {
let inRequires = false;
for (const rawLine of content.split(/\r?\n/)) {
const line = rawLine.trim();
if (!line || line.startsWith("#")) continue;
if (line.startsWith("[")) {
inRequires = line === "[requires]" || line === "[tool_requires]";
continue;
}
if (inRequires) {
const ref = line.split("@")[0]?.trim() ?? "";
const slashIdx = ref.indexOf("/");
if (slashIdx > 0) {
const name = ref.slice(0, slashIdx).trim();
const version = ref.slice(slashIdx + 1).trim() || "*";
if (name) results.push({ ecosystem, name, version });
}
}
}
} else if (lowerPath.endsWith(".py")) {
const matches = content.matchAll(/["']([A-Za-z0-9_.+-]+)\/([^"'@\s]+)(?:@[^"']*)?["']/g);
for (const m of matches) {
if (m[1] && m[2]) {
results.push({ ecosystem, name: m[1], version: m[2] });
}
}
}
return results;
}

if (ecosystem === "vcpkg") {
try {
const parsed = JSON.parse(content) as {
dependencies?: Array<string | { name?: string; "version>="?: string }>;
};
for (const dep of parsed.dependencies ?? []) {
if (typeof dep === "string") {
if (dep.trim()) results.push({ ecosystem, name: dep.trim(), version: "*" });
} else if (
dep &&
typeof dep === "object" &&
typeof dep.name === "string" &&
dep.name.trim()
) {
results.push({
ecosystem,
name: dep.name.trim(),
version: dep["version>="]?.trim() || "*",
});
}
}
} catch {
// Ignore malformed vcpkg.json during lockfile hashing
}
return results;
}

if (ecosystem === "meson") {
const seen = new Set<string>();
const matches = content.matchAll(/\b(?:dependency|subproject)\(\s*["']([^"']+)["']/g);
for (const m of matches) {
const name = m[1]?.trim();
if (name && !seen.has(name)) {
seen.add(name);
results.push({ ecosystem, name, version: "*" });
}
}
return results;
}

// Julia Project.toml: parse [deps] UUID entries and optional [compat] version constraints
const compatVersions = new Map<string, string>();
let section = "";
const depNames: string[] = [];
for (const rawLine of content.split(/\r?\n/)) {
const line = rawLine.replace(/#.*$/, "").trim();
if (!line) continue;
const secMatch = line.match(/^\[([^\]]+)\]$/);
if (secMatch) {
section = secMatch[1]?.trim() ?? "";
continue;
}
if (section === "deps") {
const kv = line.match(/^([A-Za-z0-9_]+)\s*=\s*"([^"]+)"/);
if (kv?.[1]) depNames.push(kv[1]);
} else if (section === "compat") {
const kv = line.match(/^([A-Za-z0-9_]+)\s*=\s*"([^"]+)"/);
if (kv?.[1] && kv[2]) compatVersions.set(kv[1], kv[2].trim());
}
}
for (const name of depNames) {
results.push({ ecosystem, name, version: compatVersions.get(name) ?? "*" });
}
return results;
}
4 changes: 4 additions & 0 deletions tests/completion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ test("Shell Auto-Completion - Dynamic Resolution", async (t) => {
"composer",
"gem",
"pub",
"conan",
"vcpkg",
"meson",
"julia",
]);
});

Expand Down
Loading
Loading