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, conan, vcpkg, meson, julia)
which <ecosystem> Show active CLI binary for an ecosystem (npm, jsr, pypi, conda, cargo, go, nuget, composer, gem, pub, conan, vcpkg, meson, julia, maven, gradle, sbt, hex, rebar3, swift, cocoapods, carthage)

OPTIONS:
-D, --dev Install as a development dependency
Expand Down
22 changes: 15 additions & 7 deletions src/compliance/osv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,21 @@ export class OsvClient {
return [];
}

const queries: OsvQueryItem[] = queryable.map(({ pkg, osvEcosystem }) => ({
package: {
name: pkg.name,
ecosystem: osvEcosystem,
},
version: pkg.version.replace(/^[~^>=<\s]+/, "").trim(),
}));
const queries: OsvQueryItem[] = queryable.map(({ pkg, osvEcosystem }) => {
let osvName = pkg.name;
if (osvEcosystem === "Maven" && osvName.includes("/")) {
osvName = osvName.replace("/", ":");
} else if (osvEcosystem === "SwiftURL") {
osvName = osvName.replace(/^https?:\/\//i, "").replace(/\.git$/i, "");
}
return {
package: {
name: osvName,
ecosystem: osvEcosystem,
},
version: pkg.version.replace(/^[~^>=<\s]+/, "").trim(),
};
});

try {
const response = await fetch(OsvClient.OSV_BATCH_URL, {
Expand Down
8 changes: 6 additions & 2 deletions src/compliance/sbom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ export class SbomGenerator {
const components = packages.map((pkg) => {
const purlEcosystem = engineRegistry.getSbomPurlType(pkg.ecosystem);
const cleanVer = pkg.version.replace(/^[~^>=<\s]+/, "");
const purlName =
purlEcosystem === "maven" ? pkg.packageName.replace(":", "/") : pkg.packageName;
return {
type: "library",
name: pkg.packageName,
version: cleanVer,
purl: `pkg:${purlEcosystem}/${pkg.packageName}@${cleanVer}`,
purl: `pkg:${purlEcosystem}/${purlName}@${cleanVer}`,
licenses: [
{
license: {
Expand Down Expand Up @@ -91,6 +93,8 @@ export class SbomGenerator {
const spdxPackages = packages.map((pkg, idx) => {
const safeId = pkg.packageName.replace(/[^a-zA-Z0-9]/g, "-");
const purlEcosystem = engineRegistry.getSbomPurlType(pkg.ecosystem);
const purlName =
purlEcosystem === "maven" ? pkg.packageName.replace(":", "/") : pkg.packageName;
return {
name: pkg.packageName,
SPDXID: `SPDXRef-Package-${safeId}-${idx}`,
Expand All @@ -104,7 +108,7 @@ export class SbomGenerator {
{
referenceCategory: "PACKAGE-MANAGER",
referenceType: "purl",
referenceLocator: `pkg:${purlEcosystem}/${pkg.packageName}@${pkg.version.replace(/^[~^>=<]/, "")}`,
referenceLocator: `pkg:${purlEcosystem}/${purlName}@${pkg.version.replace(/^[~^>=<]/, "")}`,
},
],
};
Expand Down
10 changes: 10 additions & 0 deletions src/dispatcher/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ export class PolyDispatcher {
logExecutionPlan("add", pkg, engine.name, command, finalArgs);
}

// 4.5 Apply Tier 2 manifest mutation if supported by engine (JVM, Elixir, Swift)
const mutation = engine.applyManifestAdd?.(pkg, cwd);
if (mutation?.changed && !options?.silent && !options?.agent) {
logInfo(`[manifest] Updated ${mutation.manifestFile}`);
}

// 5. Execute native command
const result = await engine.execute(command, finalArgs, cwd, {
silent: options?.silent || options?.agent,
Expand All @@ -102,6 +108,10 @@ export class PolyDispatcher {
}

const engine = this.getEngineForEcosystem(pkg.ecosystem, cwd);
const mutation = engine.applyManifestRemove?.(pkg, cwd);
if (mutation?.changed && !options?.silent && !options?.agent) {
logInfo(`[manifest] Updated ${mutation.manifestFile}`);
}
const { command, args } = engine.resolveRemoveArgs(pkg);

if (!options?.silent) {
Expand Down
56 changes: 56 additions & 0 deletions src/doctor/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,62 @@ export class PolyDoctor {
args: ["--version"],
hint: "https://julialang.org/downloads/",
},
{
id: "toolchain-maven",
name: "Apache Maven",
cmd: "mvn",
args: ["--version"],
hint: "https://maven.apache.org",
},
{
id: "toolchain-gradle",
name: "Gradle Build Tool",
cmd: "gradle",
args: ["--version"],
hint: "https://gradle.org",
},
{
id: "toolchain-sbt",
name: "Scala sbt",
cmd: "sbt",
args: ["--version"],
hint: "https://www.scala-sbt.org",
},
{
id: "toolchain-elixir",
name: "Elixir Mix",
cmd: "mix",
args: ["--version"],
hint: "https://elixir-lang.org",
},
{
id: "toolchain-rebar3",
name: "Erlang Rebar3",
cmd: "rebar3",
args: ["version"],
hint: "https://rebar3.org",
},
{
id: "toolchain-swift",
name: "Swift Package Manager",
cmd: "swift",
args: ["--version"],
hint: "https://www.swift.org",
},
{
id: "toolchain-cocoapods",
name: "CocoaPods",
cmd: "pod",
args: ["--version"],
hint: "https://cocoapods.org",
},
{
id: "toolchain-carthage",
name: "Carthage",
cmd: "carthage",
args: ["version"],
hint: "https://github.com/Carthage/Carthage",
},
];

for (const tc of toolchains) {
Expand Down
16 changes: 16 additions & 0 deletions src/engines/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ export abstract class BaseEngine {
*/
abstract resolveUpdateArgs(pkg?: PackageSpec): { command: string; args: string[] };

/**
* Optional manifest mutation hook executed before running add CLI commands (for Tier 2 ecosystems).
*/
applyManifestAdd?(
pkg: PackageSpec,
cwd: string,
): { manifestFile: string; changed: boolean } | null;

/**
* Optional manifest mutation hook executed before running remove CLI commands (for Tier 2 ecosystems).
*/
applyManifestRemove?(
pkg: PackageSpec,
cwd: string,
): { manifestFile: string; changed: boolean } | null;

/**
* Executes a native command asynchronously with performance timing.
*/
Expand Down
26 changes: 26 additions & 0 deletions src/engines/declarative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ export interface DeclarativeCommandSpec {
install: (ctx?: EngineContext) => string[];
/** Formats dependency update command arguments. */
update: (pkg?: PackageSpec, ctx?: EngineContext) => string[];
/** Optional Tier 2 manifest mutator executed prior to CLI add command. */
mutateAdd?: (
pkg: PackageSpec,
cwd: string,
ctx?: EngineContext,
) => { manifestFile: string; changed: boolean } | null;
/** Optional Tier 2 manifest mutator executed prior to CLI remove command. */
mutateRemove?: (
pkg: PackageSpec,
cwd: string,
ctx?: EngineContext,
) => { manifestFile: string; changed: boolean } | null;
}

export interface EngineAdapter {
Expand Down Expand Up @@ -92,6 +104,20 @@ export class DeclarativeEngine extends BaseEngine {
resolveUpdateArgs(pkg?: PackageSpec): { command: string; args: string[] } {
return { command: this.activeCommand, args: this.spec.update(pkg, this.ctx) };
}

override applyManifestAdd(
pkg: PackageSpec,
cwd: string,
): { manifestFile: string; changed: boolean } | null {
return this.spec.mutateAdd ? this.spec.mutateAdd(pkg, cwd, this.ctx) : null;
}

override applyManifestRemove(
pkg: PackageSpec,
cwd: string,
): { manifestFile: string; changed: boolean } | null {
return this.spec.mutateRemove ? this.spec.mutateRemove(pkg, cwd, this.ctx) : null;
}
}

/**
Expand Down
11 changes: 11 additions & 0 deletions src/engines/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ export {
mesonAdapter,
vcpkgAdapter,
} from "./cpp-julia.js";
export {
TIER2_MANIFEST_ADAPTERS,
carthageAdapter,
cocoapodsAdapter,
gradleAdapter,
hexAdapter,
mavenAdapter,
rebar3Adapter,
sbtAdapter,
swiftAdapter,
} from "./tier2-manifest.js";
export {
DeclarativeEngine,
defineDeclarativeAdapter,
Expand Down
Loading
Loading