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 init in a directory.
- The command finishes immediately with exit code
0 but produces no terminal output and does not create the .agents folder.
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])).href yields: file:///path/to/global/bin/ag-kit
import.meta.url yields: 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;
Issue Description
Describe the bug
When running
ag-kitcommands (likeag-kit initornpx @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 comparingprocess.argv[1]toimport.meta.url. However, when installed globally or run vianpx, Node.js executes the script through a symlink. Sincepath.resolvedoes not resolve symlinks, the comparison fails, resulting inisDirectRunbeingfalse.To Reproduce
npm install -g @vudovn/ag-kit(or run via npx:npx @vudovn/ag-kit init)ag-kit initin a directory.0but produces no terminal output and does not create the.agentsfolder.Root Cause
In
bin/index.js(line 431):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.jsSince these paths do not match, the CLI commands never parse/execute.
Suggested Fix
Resolve the symlink using
fs.realpathSyncbefore checking if the CLI is being run directly: