@deplens/core
v0.1.6
Published
Core engine for inspecting installed package exports and types
Readme
@deplens/core
Programmatic API for inspecting installed packages: runtime exports, parsed type signatures, and JSDoc.
Install
npm i @deplens/coreUsage
import { runInspect, runDiff } from "@deplens/core";
const output = await runInspect({
target: "ai",
showTypes: true,
filter: "generate",
resolveFrom: process.cwd(),
});
console.log(output);
const diff = await runDiff({
package: "express",
from: "4.18.0",
to: "4.19.0",
format: "json",
});
console.log(diff.output);runInspect returns a string when no custom writers are provided. If you pass write or writeError, it will stream to those instead.
Options
target(string, required): package name or import path (e.g.react,next/server)filter(string): substring filter for export namesshowTypes(boolean): include type signatures from.d.tskind(string[]): filter by export kind (function,class,object,constant)depth(number): object inspection depth (0–5)resolveFrom(string): base directory for module resolutioncwd(string): working directory for the inspectionwrite(function): output sink (defaults to collecting and returning a string)writeError(function): error output sink
JSDoc options:
jsdoc(string):off|compact|fulljsdocOutput(string):off|section|inline|onlyjsdocQuery(object):symbols: string or string[]sections:summary|params|returns|tagstags.include/tags.exclude: string[]mode:compact|fullmaxLen: numbertruncate:none|sentence|word
Example: JSDoc focused on params/returns
await runInspect({
target: "ai",
showTypes: true,
jsdocOutput: "section",
jsdocQuery: {
symbols: "generateText",
sections: ["params", "returns"],
tags: { include: ["param", "returns"] },
mode: "compact",
truncate: "sentence",
maxLen: 220,
},
});Notes
- JSDoc is extracted from
.d.tsdeclarations, not runtime JS. --resolve-fromis essential in monorepos to avoid false negatives.
License
MIT
