Skip to content

feat: add --agent flag to print detected package manager name#329

Merged
antfu merged 1 commit intoantfu-collective:mainfrom
Luc0-0:feat/agent-flag
Apr 21, 2026
Merged

feat: add --agent flag to print detected package manager name#329
antfu merged 1 commit intoantfu-collective:mainfrom
Luc0-0:feat/agent-flag

Conversation

@Luc0-0
Copy link
Copy Markdown
Contributor

@Luc0-0 Luc0-0 commented Mar 28, 2026

Closes #326

Problem

There's no way to get just the detected package manager name from ni without parsing the full ni -v table output. This makes it awkward to use in CI pipelines and shell scripts where you need the bare agent name for conditional logic.

Solution

Adds a --agent flag that prints only the detected package manager name to stdout — no colors, no version info, just the agent name followed by a newline.

$ ni --agent
pnpm

$ ni --agent
bun

Works with any ni command since it's handled in the runner before agent-specific logic runs. Prints unknown if no lock file is found and no default is configured.

Also updated the help output (ni -h) to document the new flag.

Use case

# capture in a variable
PM=$(ni --agent)

# use in CI conditionals
if [ "$(ni --agent)" = "pnpm" ]; then
  pnpm install --frozen-lockfile
fi

@antfu antfu merged commit b11f14d into antfu-collective:main Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a command that prints only the detected package manager name

2 participants