agent-readable-ts can be used as a library from TypeScript or JavaScript, and
as a CLI for inspecting local files or npm packages.
npm install agent-readable-tsNode 20 or newer is required.
import { agentHelp } from "agent-readable-ts";
console.log(agentHelp(SomeClass)); // class constructor
console.log(agentHelp(new SomeClass())); // class instance
console.log(agentHelp(someFunction)); // function or arrow function
console.log(agentHelp({ a: 1 })); // plain objectThe programmatic API uses runtime JavaScript reflection. It can show public
members, parameter names when available, and agentNotes()/agentHelp() output,
but it cannot recover TypeScript-only types from compiled JavaScript.
The CLI can inspect installed npm packages, local JavaScript files, and local TypeScript files.
npx agent-readable-ts commander
npx agent-readable-ts commander:Command
npx agent-readable-ts ./src/widget.ts:Widgetcommander is only an example target. Use any trusted installed package, local
module, or local TypeScript file.
Usage:
agent-readable-ts [--install] <package-name>[:<export-name>]
agent-readable-ts <module-path>[:<export-name>]package-name: an installed npm package, such ascommander,pino, or@scope/package.module-path: a.js,.mjs,.cjs, or.tsfile path relative to the current directory.export-name: the named export to document. Use dots for nested access, such asThings.Helper.--install: allow the CLI to fetch a package on demand when it is not installed locally.
If no export name is given for a package, all exports are listed. If no export name is given for a file, the module namespace object is documented.
.ts files require tsx. It is included as a dev dependency in this repo, and
npx resolves it automatically when running from this package.
Use one of these when you do not want to add a dependency to the current project:
npx agent-readable-ts commander
npm exec -- agent-readable-ts commander:Command
pnpm dlx agent-readable-ts ./src/widget.ts:WidgetPackages already installed in the current project load directly. For anything
else, the CLI refuses to fetch unless --install is passed:
npx agent-readable-ts --install left-padFetched packages go into ~/.cache/agent-readable-ts, or the directory named by
AGENT_READABLE_CACHE. They are never installed into the current project.
The install uses npm install --ignore-scripts, so package lifecycle scripts are
not run. Cached packages load offline without requiring --install again.
The CLI imports packages and local modules in order to inspect them. Importing a module executes its top-level code. Only inspect packages and files you trust to run on your machine.