bug: CLI exits silently when run via global symlink or npx due to unresolved symlink path in isDirectRun
Author: leandrosilvaferreiraCreated Jul 17, 2026Updated Sep 27, 2026
Issue Description
Describe the bug
When running ag-kit commands (like ag-kit init or npx @vudovn/ag-kit init), the CLI exits silently with no output and does not perform any actions.
This happens because the CLI checks if it is executed directly (isDirectRun) by comparing process.argv[1] to import.meta.url. However, when installed globally or run via npx, Node.js executes the script through a symlink. Since path.resolve does not resolve symlinks, the comparison fails, resulting in isDirectRun being false.
To Reproduce
- Install the CLI globally:
npm install -g @vudovn/ag-kit(or run via npx:npx @vudovn/ag-kit init) - Run
ag-kit initin a directory. - The command finishes immediately with exit code
0but produces no terminal output and does not create the.agentsfolder.
Root Cause
In bin/index.js (line 431):
const isDirectRun = process.argv[1]
&& pathToFileURL(path.resolve(process.argv[1])).href === import.meta.url;When run via symlink:
pathToFileURL(path.resolve(process.argv[1])).hrefyields:file:///path/to/global/bin/ag-kitimport.meta.urlyields:file:///path/to/global/lib/node_modules/@vudovn/ag-kit/bin/index.js
Since these paths do not match, the CLI commands never parse/execute.
Suggested Fix
Resolve the symlink using fs.realpathSync before checking if the CLI is being run directly:
import fs from "node:fs";
// Resolve symlink of argv[1] if it exists
const resolvedArgv = process.argv[1] ? fs.realpathSync(process.argv[1]) : "";
const isDirectRun = resolvedArgv
&& pathToFileURL(resolvedArgv).href === import.meta.url;Source: vudovn/ag-kit