diff --git a/src/na.ts b/src/na.ts new file mode 100644 index 000000000000..98b456557eb7 --- /dev/null +++ b/src/na.ts @@ -0,0 +1,35 @@ +const completionSpec: Fig.Spec = { + name: "na", + description: + "Agent alias: run agent-specific commands directly (npm/yarn/pnpm/bun/deno)", + args: [ + { + name: "subcommand", + description: "Agent subcommand (e.g. run, add)", + isOptional: true, + }, + { + name: "args", + description: "Arguments passed through to the agent", + isVariadic: true, + isOptional: true, + }, + ], + options: [ + { + name: "-C", + description: "Change directory before running the command", + args: { name: "path", template: "folders" }, + }, + { + name: ["-h", "--help"], + description: "Show help", + }, + { + name: ["-v", "--version"], + description: "Show version", + }, + ], +}; + +export default completionSpec; diff --git a/src/nci.ts b/src/nci.ts new file mode 100644 index 000000000000..32434a965955 --- /dev/null +++ b/src/nci.ts @@ -0,0 +1,22 @@ +const completionSpec: Fig.Spec = { + name: "nci", + description: + "Clean install with frozen/immutable lockfile behavior for the detected agent", + options: [ + { + name: "-C", + description: "Change directory before running the command", + args: { name: "path", template: "folders" }, + }, + { + name: ["-h", "--help"], + description: "Show help", + }, + { + name: ["-v", "--version"], + description: "Show version", + }, + ], +}; + +export default completionSpec; diff --git a/src/ni.ts b/src/ni.ts index fe8874d18047..90f1f01663b0 100644 --- a/src/ni.ts +++ b/src/ni.ts @@ -2,55 +2,59 @@ import { npmSearchGenerator } from "./npm"; const completionSpec: Fig.Spec = { name: "ni", - description: "Use the right package manager - install", + description: + "Use the right package manager: install deps or add packages with the correct agent", + args: { + name: "packages", + description: "Packages to add (omit to run install)", + isOptional: true, + isVariadic: true, + generators: npmSearchGenerator, + suggestions: ["vite", "@types/node", "typescript", "eslint", "prettier"], + }, options: [ { - name: "-g", - description: - "Operates in 'global' mode, so that packages are installed into the prefix folder instead of the current working directory", + name: ["-D", "--save-dev"], + description: "Install as devDependency", }, { - name: "-D", - description: "Package will appear in your `devDependencies`", + name: ["-P", "--production"], + description: "Install only production dependencies", }, { - name: "-P", - description: "Save package to your `peerDependencies`", + name: "--frozen", + description: + "Use frozen/immutable install (ci / frozen-lockfile / immutable)", }, { - name: "-O", - description: "Save package to your `optionalDependencies`", + name: ["-g", "--global"], + description: "Install package globally (uses default agent)", }, { - name: "--frozen", - description: "Don't generate a lockfile and fail if an update is needed", + name: ["-i", "--interactive"], + description: "Interactive mode to search and select packages to install", }, { name: "-C", - description: "Change directory", - args: [ - { - name: "directory", - description: "The directory to move", - template: "folders", - }, - { - name: "target", - description: "The target directory", - template: "folders", - }, - ], + description: "Change directory before running the command", + args: { name: "path", template: "folders" }, + }, + { + name: "?", + description: "Print the resolved command for the current agent", + priority: 51, }, { name: ["-h", "--help"], - description: "Output usage information", + description: "Show help", + priority: 49, + }, + { + name: ["-v", "--version"], + description: "Show version", + priority: 49, }, ], - args: { - name: "package", - generators: npmSearchGenerator, - debounce: true, - isVariadic: true, - }, }; + export default completionSpec; diff --git a/src/nlx.ts b/src/nlx.ts new file mode 100644 index 000000000000..a131807321eb --- /dev/null +++ b/src/nlx.ts @@ -0,0 +1,61 @@ +import { npxSuggestions } from "./npx"; + +// Merge curated lists (currently only npx exports suggestions). +// If bunx/pnpx add their own in the future, they can be merged here too. +const curatedSuggestions: Fig.Suggestion[] = ( + npxSuggestions as Fig.Suggestion[] +).map((s) => { + if (typeof s === "string") return { name: s, loadSpec: s }; + const name = Array.isArray(s.name) ? s.name[0] : s.name; + return { ...s, ...(name && { loadSpec: name }) }; +}); + +const completionSpec: Fig.Spec = { + name: "nlx", + description: "Download & execute a package binary with the correct agent", + args: { + name: "command", + isCommand: true, + description: "The package binary to run (e.g. vitest, tsc, prisma, next)", + // Prefer curated CLI list, but also surface local node_modules/.bin executables + generators: { + script: [ + "bash", + "-c", + "until [[ -d node_modules/ ]] || [[ $PWD = '/' ]]; do cd ..; done; ls -1 node_modules/.bin/", + ], + postProcess: function (out) { + const curated = curatedSuggestions.reduce((acc, cur) => { + const name = + typeof cur === "string" + ? cur + : Array.isArray(cur.name) + ? cur.name[0] + : cur.name; + return name ? acc.concat(name) : acc; + }, [] as string[]); + return out + .split("\\n") + .filter((name) => !!name && !curated.includes(name)) + .map((name) => ({ + name, + icon: "fig://icon?type=command", + loadSpec: name, + })); + }, + }, + suggestions: curatedSuggestions, + isOptional: true, + }, + options: [ + { + name: "-C", + description: "Change directory before running the command", + args: { name: "path", template: "folders" }, + }, + { name: ["-h", "--help"], description: "Show help" }, + { name: ["-v", "--version"], description: "Show version" }, + ], +}; + +export default completionSpec; diff --git a/src/nr.ts b/src/nr.ts index dd13cb89cc90..6de01fc8421d 100644 --- a/src/nr.ts +++ b/src/nr.ts @@ -2,28 +2,52 @@ import { npmScriptsGenerator } from "./npm"; const completionSpec: Fig.Spec = { name: "nr", - description: "Use the right package manager - run", - options: [ + description: "Run package.json scripts with the correct agent", + args: [ { - name: ["-h", "--help"], - description: "Output usage information", + name: "script", + description: "The script name from package.json", + isOptional: true, + generators: npmScriptsGenerator, + debounce: true, + }, + { + name: "scriptArgs", + description: "Arguments passed to the script", + isOptional: true, + isVariadic: true, }, ], - args: { - name: "script", - description: "The script to run", - filterStrategy: "fuzzy", - generators: npmScriptsGenerator, - }, - additionalSuggestions: [ + options: [ { name: "-", - // Run the suggestion directory on insert - // eslint-disable-next-line @withfig/fig-linter/no-useless-insertvalue - insertValue: "-\n", - description: "Run the last command", - type: "shortcut", + description: "Rerun the last command", + priority: 60, + }, + { + name: "--completion-bash", + description: "Print bash completion script", + priority: 49, + }, + { + name: "--completion-zsh", + description: "Print zsh completion script", + priority: 49, + }, + { + name: "-C", + description: "Change directory before running the command", + args: { name: "path", template: "folders" }, + }, + { + name: ["-h", "--help"], + description: "Show help", + }, + { + name: ["-v", "--version"], + description: "Show version", }, ], }; + export default completionSpec; diff --git a/src/nu.ts b/src/nu.ts deleted file mode 100644 index 0a19185cc9da..000000000000 --- a/src/nu.ts +++ /dev/null @@ -1,16 +0,0 @@ -const completionSpec: Fig.Spec = { - name: "nu", - description: "Use the right package manage - upgrade", - options: [ - { - name: "-i", - description: - "Display the outdated packages before performing any upgrade", - }, - { - name: ["-h", "--help"], - description: "Output usage information", - }, - ], -}; -export default completionSpec; diff --git a/src/nun.ts b/src/nun.ts new file mode 100644 index 000000000000..dc8e6ac6d4e1 --- /dev/null +++ b/src/nun.ts @@ -0,0 +1,38 @@ +import { npmSearchGenerator } from "./npm"; + +const completionSpec: Fig.Spec = { + name: "nun", + description: "Uninstall dependencies with the correct agent", + args: { + name: "packages", + description: "Packages to remove (omit to enter interactive mode)", + isOptional: true, + isVariadic: true, + generators: npmSearchGenerator, + }, + options: [ + { + name: "-m", + description: "Interactive multiple selection to remove", + }, + { + name: ["-g", "--global"], + description: "Uninstall globally", + }, + { + name: "-C", + description: "Change directory before running the command", + args: { name: "path", template: "folders" }, + }, + { + name: ["-h", "--help"], + description: "Show help", + }, + { + name: ["-v", "--version"], + description: "Show version", + }, + ], +}; + +export default completionSpec; diff --git a/src/nup.ts b/src/nup.ts new file mode 100644 index 000000000000..e636c3b319a2 --- /dev/null +++ b/src/nup.ts @@ -0,0 +1,26 @@ +const completionSpec: Fig.Spec = { + name: "nup", + description: "Upgrade dependencies with the correct agent", + options: [ + { + name: ["-i", "--interactive"], + description: + "Interactive upgrade (Yarn Berry: up -i, Yarn 1: upgrade-interactive, pnpm: update -i)", + }, + { + name: "-C", + description: "Change directory before running the command", + args: { name: "path", template: "folders" }, + }, + { + name: ["-h", "--help"], + description: "Show help", + }, + { + name: ["-v", "--version"], + description: "Show version", + }, + ], +}; + +export default completionSpec;