agent-readable-ts 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,291 +1,23 @@
1
1
  # agent-readable-ts
2
2
 
3
- Coding agents hallucinate a library's API — inventing methods, using stale signatures, or misusing real methods because the correct usage rules (lifecycle order, preconditions, anti-patterns) are not visible from the API surface alone.
3
+ [![CI](https://github.com/zydo/agent-readable-ts/actions/workflows/ci.yml/badge.svg)](https://github.com/zydo/agent-readable-ts/actions/workflows/ci.yml)
4
+ [![npm](https://img.shields.io/npm/v/agent-readable-ts.svg)](https://www.npmjs.com/package/agent-readable-ts)
4
5
 
5
- `agent-readable-ts` lets a library author attach those rules next to a class, object, or function. A package-level function `agentHelp(target)` returns curated, agent-oriented Markdown: the real public runtime surface that can be discovered safely, plus any author-supplied behavioral rules. An agent that calls `agentHelp(target)` before writing code against the target sees the real callable surface and the right usage rules.
6
+ `agent-readable-ts` helps coding agents inspect the live public surface of a
7
+ TypeScript or JavaScript API before they write code against it.
6
8
 
7
- > **For coding agents:** Install the agent skill to have this run automatically before coding against unfamiliar packages:
8
- > ```sh
9
- > npx skills add zydo/skills --skill agent-readable
10
- > ```
9
+ Library authors can add agent-oriented usage rules next to a class, object, or
10
+ function. Consumers call `agentHelp(target)` or the `agent-readable-ts` CLI to get
11
+ compact Markdown with the real callable surface plus any author-supplied
12
+ behavioral notes.
11
13
 
12
- **Token efficiency.** When an agent hallucinates an API, the resulting code fails — and each failed attempt triggers a retry cycle that burns tokens without making progress. `agent-readable-ts` generates compact, precise, accurate descriptions of publicly exposed interfaces (verified by runtime introspection on live packages). Calling `npx agent-readable-ts <package>` on unfamiliar packages and classes *before* writing code surfaces the real API upfront, preventing that waste.
13
-
14
- ## Other languages
15
-
16
- - **Python:** [agent-readable](https://github.com/zydo/agent-readable) — same idea for Python packages and classes.
17
-
18
- ## Install
14
+ To let your coding agent automatically call `agentHelp()` before using an
15
+ unfamiliar API, install the companion skill:
19
16
 
20
17
  ```sh
21
- npm install agent-readable-ts
18
+ npx skills add zydo/skills --skill agent-readable
22
19
  ```
23
20
 
24
- ## CLI
25
-
26
- The package includes a CLI for generating documentation from the command line. It works with local files **and installed npm packages**.
27
-
28
- ```sh
29
- npx agent-readable-ts commander # list all exports
30
- npx agent-readable-ts commander:Command # document a specific export
31
- npx agent-readable-ts ./src/widget.ts:Widget # a local TypeScript file
32
- ```
33
-
34
- ### Usage
35
-
36
- ```sh
37
- agent-readable-ts <package-name>[:<export-name>]
38
- agent-readable-ts <module-path>[:<export-name>]
39
- ```
40
-
41
- - **`package-name`** — any installed npm package (e.g. `commander`, `pino`, `@scope/package`)
42
- - **`module-path`** — a file path (`.js`, `.mjs`, or `.ts`) relative to the current directory
43
- - **`export-name`** — the named export to document (use dots for nested access, e.g. `Things.Helper`)
44
-
45
- 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.
46
-
47
- > `.ts` files require `tsx` to be installed. It is included as a devDependency, and `npx` resolves it automatically.
48
-
49
- ### Examples
50
-
51
- List all exports from an installed package:
52
-
53
- ```sh
54
- npm install commander
55
- npx agent-readable-ts commander
56
- ```
57
-
58
- Output:
59
-
60
- ```markdown
61
- # commander
62
-
63
- ## Exports
64
-
65
- - `CommanderError` class
66
- - `InvalidArgumentError` class
67
- - `Argument` class
68
- - `Option` class
69
- - `Help` class
70
- - `Command` class
71
- - `createCommand(name: string): Command` function
72
- - `createOption(flags: string, description: string): Option` function
73
- - `createArgument(name: string, description: string): Argument` function
74
- - `program` object
75
- ```
76
-
77
- Document a specific export with full type signatures:
78
-
79
- ```sh
80
- npx agent-readable-ts commander:Command
81
- ```
82
-
83
- Output:
84
-
85
- ```markdown
86
- # Command
87
-
88
- ## Public API
89
-
90
- - `action(fn: (this: this, ...args: any[]) => void | Promise<void>): this` method
91
- - `addArgument(arg: Argument): this` method
92
- - `addCommand(cmd: Command, opts: CommandOptions): this` method
93
- - `addOption(option: Option): this` method
94
- - `alias(): string` method
95
- - `argument(name: string, description: string, defaultValue: unknown): this` method
96
- - `command(nameAndArgs: string, description: string, opts: ExecutableCommandOptions): this` method
97
- - `description(): string` method
98
- - `error(message: string, errorOptions: ErrorOptions): never` method
99
- - `hook(event: HookEvent, listener: (...args: any[]) => void | Promise<void>): this` method
100
- - `option(flags: string, description: string, defaultValue: unknown): this` method
101
- - `parse(argv: readonly string[], parseOptions: ParseOptions): this` method
102
- - `parseAsync(argv: readonly string[], parseOptions: ParseOptions): Promise<this>` method
103
- - `requiredOption(flags: string, description: string, defaultValue: unknown): this` method
104
- - `version(str: string, flags: string, description: string): this` method
105
- - ... (80+ methods total)
106
-
107
- ## Agent usage rules
108
-
109
- - Prefer the public API listed above.
110
- - Do not use private, protected, underscored, or internal members.
111
- - Do not invent unsupported behavior.
112
- - If usage is ambiguous, prefer the simplest documented usage pattern.
113
- ```
114
-
115
- Document a local file:
116
-
117
- ```sh
118
- npx agent-readable-ts ./src/widget.ts:Widget # a class export
119
- npx agent-readable-ts ./src/util.ts:connect # a function export
120
- npx agent-readable-ts ./dist/api.js:fetch # a .js file with adjacent api.d.ts
121
- ```
122
-
123
- ## Two protocols
124
-
125
- | Protocol | Role | Output behavior |
126
- | -------------- | ----------------- | ------------------------------------------------ |
127
- | `agentHelp()` | Full replacement | Returned Markdown is used verbatim |
128
- | `agentNotes()` | Additive guidance | Notes are appended after auto-generated API docs |
129
-
130
- ### `agentHelp()` — Full replacement
131
-
132
- If a target implements `agentHelp()`, the returned string **is** the output verbatim. No auto-generated sections are added.
133
-
134
- ```ts
135
- import { AgentHelper, agentHelp } from "agent-readable-ts";
136
-
137
- class RateLimiter implements AgentHelper {
138
- agentHelp(): string {
139
- return `# RateLimiter
140
-
141
- ## Usage
142
-
143
- - Create with \`new RateLimiter(maxRequests)\`.
144
- - Call \`acquire()\` before making a request.
145
- - Call \`release()\` after the request completes.
146
-
147
- ## Limits
148
-
149
- - Default max is 100 concurrent requests.
150
- - Exceeding the limit blocks until a slot opens.
151
- `;
152
- }
153
- }
154
-
155
- console.log(agentHelp(new RateLimiter()));
156
- ```
157
-
158
- Output:
159
-
160
- ```markdown
161
- # RateLimiter
162
-
163
- ## Usage
164
-
165
- - Create with `new RateLimiter(maxRequests)`.
166
- - Call `acquire()` before making a request.
167
- - Call `release()` after the request completes.
168
-
169
- ## Limits
170
-
171
- - Default max is 100 concurrent requests.
172
- - Exceeding the limit blocks until a slot opens.
173
- ```
174
-
175
- If the target also defines `agentNotes()`, a warning is written to stderr and the notes are dropped.
176
-
177
- ### `agentNotes()` — Additive guidance
178
-
179
- Define `agentNotes()` on any class to append usage rules to the auto-generated documentation. Notes accumulate across the inheritance chain in parent-to-child order.
180
-
181
- ```ts
182
- import { AgentNoter, agentHelp } from "agent-readable-ts";
183
-
184
- class Sensor {
185
- calibrate(offset: number): void {}
186
- read(): number {
187
- return 0;
188
- }
189
-
190
- agentNotes(): string {
191
- return `
192
- ## Do
193
-
194
- - Call \`calibrate()\` once during setup, before \`read()\`.
195
-
196
- ## Do not
197
-
198
- - Do not call \`read()\` before \`calibrate()\` on first use.
199
- `;
200
- }
201
- }
202
-
203
- console.log(agentHelp(new Sensor()));
204
- ```
205
-
206
- ### `agentHelp(target)` entry point
207
-
208
- The single entry point accepts:
209
-
210
- - Class constructors
211
- - Class instances
212
- - Plain objects
213
- - Plain functions
214
- - Arrow functions
215
- - Bound method values
216
- - Callable objects
217
-
218
- ```ts
219
- import { agentHelp } from "agent-readable-ts";
220
-
221
- agentHelp(MyClass); // class constructor
222
- agentHelp(new MyClass()); // class instance
223
- agentHelp({ a: 1 }); // plain object
224
- agentHelp(myFunction); // function
225
- agentHelp(obj.method.bind(obj)); // bound method
226
- ```
227
-
228
- ## Examples
229
-
230
- ### Example 1: Wrapping a class you do not own
231
-
232
- ```ts
233
- import { agentHelp } from "agent-readable-ts";
234
-
235
- class Client {
236
- connect(url: string): void {}
237
- query(sql: string): unknown {
238
- return undefined;
239
- }
240
- }
241
-
242
- class DocumentedClient extends Client {
243
- agentNotes(): string {
244
- return `
245
- ## Do
246
-
247
- - Call \`connect()\` before \`query()\`.
248
-
249
- ## Do not
250
-
251
- - Do not pass untrusted SQL directly to \`query()\`.
252
- `;
253
- }
254
- }
255
-
256
- console.log(agentHelp(new DocumentedClient()));
257
- ```
258
-
259
- Output:
260
-
261
- ```markdown
262
- # DocumentedClient
263
-
264
- ## Public API
265
-
266
- - `connect(url)` method
267
- - `query(sql)` method
268
-
269
- ## Agent usage rules
270
-
271
- - Prefer the public API listed above.
272
- - Do not use private, protected, underscored, or internal members.
273
- - Do not invent unsupported behavior.
274
- - If usage is ambiguous, prefer the simplest documented usage pattern.
275
-
276
- ## Notes from DocumentedClient
277
-
278
- ## Do
279
-
280
- - Call `connect()` before `query()`.
281
-
282
- ## Do not
283
-
284
- - Do not pass untrusted SQL directly to `query()`.
285
- ```
286
-
287
- ### Example 2: Inheritance with accumulated notes
288
-
289
21
  ```ts
290
22
  import { agentHelp } from "agent-readable-ts";
291
23
 
@@ -296,255 +28,41 @@ class Sensor {
296
28
  }
297
29
 
298
30
  agentNotes(): string {
299
- return `
300
- ## Do
301
-
302
- - Call \`calibrate()\` once during setup, before \`read()\`.
303
-
304
- ## Do not
305
-
306
- - Do not call \`read()\` before \`calibrate()\` on first use.
307
- `;
308
- }
309
- }
310
-
311
- class CalibratedSensor extends Sensor {
312
- reset(): void {}
313
-
314
- override agentNotes(): string {
315
- return `
316
- ## Do
317
-
318
- - Use \`reset()\` only when recalibration is required.
319
-
320
- ## Do not
321
-
322
- - Do not call \`reset()\` in the hot read path.
323
- `;
324
- }
325
- }
326
-
327
- console.log(agentHelp(new CalibratedSensor()));
328
- ```
329
-
330
- Output:
331
-
332
- ```markdown
333
- # CalibratedSensor
334
-
335
- ## Public API
336
-
337
- - `calibrate(offset)` method
338
- - `read()` method
339
- - `reset()` method
340
-
341
- ## Agent usage rules
342
-
343
- - Prefer the public API listed above.
344
- - Do not use private, protected, underscored, or internal members.
345
- - Do not invent unsupported behavior.
346
- - If usage is ambiguous, prefer the simplest documented usage pattern.
347
-
348
- ## Notes from Sensor
349
-
350
- ## Do
351
-
352
- - Call `calibrate()` once during setup, before `read()`.
353
-
354
- ## Do not
355
-
356
- - Do not call `read()` before `calibrate()` on first use.
357
-
358
- ## Notes from CalibratedSensor (extends Sensor; if notes conflict, these take precedence)
359
-
360
- ## Do
361
-
362
- - Use `reset()` only when recalibration is required.
363
-
364
- ## Do not
365
-
366
- - Do not call `reset()` in the hot read path.
367
- ```
368
-
369
- ### Example 3: Full control via `agentHelp()`
370
-
371
- ```ts
372
- import { agentHelp } from "agent-readable-ts";
373
-
374
- class RateLimiter {
375
- agentHelp(): string {
376
- return `# RateLimiter
377
-
378
- ## Usage
379
-
380
- - Create with \`new RateLimiter(maxRequests)\`.
381
- - Call \`acquire()\` before making a request.
382
- - Call \`release()\` after the request completes.
383
-
384
- ## Limits
385
-
386
- - Default max is 100 concurrent requests.
387
- - Exceeding the limit blocks until a slot opens.
388
- `;
389
- }
390
- agentNotes(): string {
391
- return "This is ignored because agentHelp() owns the full output.";
392
- }
393
- }
394
-
395
- console.log(agentHelp(new RateLimiter()));
396
- ```
397
-
398
- Output:
399
-
400
- ```markdown
401
- # RateLimiter
402
-
403
- ## Usage
404
-
405
- - Create with `new RateLimiter(maxRequests)`.
406
- - Call `acquire()` before making a request.
407
- - Call `release()` after the request completes.
408
-
409
- ## Limits
410
-
411
- - Default max is 100 concurrent requests.
412
- - Exceeding the limit blocks until a slot opens.
413
- ```
414
-
415
- A warning is written to stderr noting that `agentNotes()` is ignored.
416
-
417
- ### Example 4: Any class, no setup
418
-
419
- ```ts
420
- import { agentHelp } from "agent-readable-ts";
421
-
422
- class Cache {
423
- get(key: string): unknown {
424
- return undefined;
425
- }
426
- set(key: string, value: unknown): void {}
427
- clear(): void {}
428
- }
429
-
430
- console.log(agentHelp(new Cache()));
431
- ```
432
-
433
- Output:
434
-
435
- ```markdown
436
- # Cache
437
-
438
- ## Public API
439
-
440
- - `clear()` method
441
- - `get(key)` method
442
- - `set(key, value)` method
443
-
444
- ## Agent usage rules
445
-
446
- - Prefer the public API listed above.
447
- - Do not use private, protected, underscored, or internal members.
448
- - Do not invent unsupported behavior.
449
- - If usage is ambiguous, prefer the simplest documented usage pattern.
450
- ```
451
-
452
- ### Example 5: Functions and bound methods
453
-
454
- ```ts
455
- import { agentHelp } from "agent-readable-ts";
456
-
457
- function connect(host: string, port: number): void {}
458
-
459
- class Runner {
460
- execute(command: string): number {
461
- return 0;
31
+ return "- Call `calibrate()` once during setup, before `read()`.";
462
32
  }
463
33
  }
464
34
 
465
- const runner = new Runner();
466
-
467
- console.log(agentHelp(connect));
468
- console.log(agentHelp(runner.execute.bind(runner)));
35
+ console.log(agentHelp(new Sensor()));
469
36
  ```
470
37
 
471
- Output for `connect`:
472
-
473
- ````markdown
474
- # connect
475
-
476
- ## Signature
38
+ ## Install
477
39
 
478
- ```ts
479
- connect(host, port)
40
+ ```sh
41
+ npm install agent-readable-ts
480
42
  ```
481
43
 
482
- ## Agent usage rules
483
-
484
- - Call this function according to the signature above.
485
- - Do not invent unsupported parameters, return values, side effects, or lifecycle behavior.
486
- - Do not use private, underscored, or internal implementation details.
487
- - If usage is ambiguous, prefer the simplest documented usage pattern.
488
- ````
489
-
490
- Output for the bound method:
44
+ For one-off CLI use:
491
45
 
492
- ````markdown
493
- # execute
494
-
495
- ## Signature
496
-
497
- ```ts
498
- execute(arg0)
46
+ ```sh
47
+ npx agent-readable-ts commander
48
+ npm exec -- agent-readable-ts commander:Command
49
+ pnpm dlx agent-readable-ts ./src/widget.ts:Widget
499
50
  ```
500
51
 
501
- ## Agent usage rules
502
-
503
- - Call this function according to the signature above.
504
- - Do not invent unsupported parameters, return values, side effects, or lifecycle behavior.
505
- - Do not use private, underscored, or internal implementation details.
506
- - If usage is ambiguous, prefer the simplest documented usage pattern.
507
- ````
508
-
509
- ## Warning output
52
+ See [Getting Started](docs/getting-started.md) for full install and CLI usage.
510
53
 
511
- By default, advisory warnings are written to `process.stderr`. You can redirect or silence them:
512
-
513
- ```ts
514
- import { setWarnOutput, getWarnOutput } from "agent-readable-ts";
515
-
516
- // Redirect to a custom sink
517
- setWarnOutput((chunk: string) => {
518
- console.log("[WARN]", chunk.trim());
519
- });
520
-
521
- // Or use an object with a write method
522
- setWarnOutput({ write(chunk: string) { /* handle */ } });
523
-
524
- // Silence warnings
525
- setWarnOutput(null);
526
-
527
- // Restore default
528
- setWarnOutput(process.stderr);
529
- ```
54
+ ## Documentation
530
55
 
531
- ## Limitations in TypeScript
56
+ - [Getting Started](docs/getting-started.md)
57
+ - [Why agent-readable-ts?](docs/why.md)
58
+ - [Examples](docs/examples.md)
59
+ - [Authoring Notes](docs/authoring.md)
60
+ - [FAQ](docs/faq.md)
532
61
 
533
- Runtime JavaScript reflection cannot read TypeScript type annotations, interfaces, overloads, generic parameters, return types, or doc comments. The auto-generated documentation is intentionally conservative:
62
+ ## Other Languages
534
63
 
535
- - **Parameter names** are recovered from `Function.prototype.toString()` when possible. For native or bound functions, names fall back to `arg0`, `arg1`, etc. using `Function.length`. Destructured parameters also fall back to `argN`.
536
- - **Type information** is available in two ways:
537
- - **CLI with `.ts` source**: full types are extracted by parsing the source file with the TypeScript compiler API.
538
- - **CLI with `.js`/`.mjs`/`.cjs` files**: types are extracted from adjacent `.d.ts`/`.d.mts`/`.d.cts` declaration files if present (covers published packages).
539
- - **Library API (`agentHelp()`)**: no type information — only runtime parameter names and arity.
540
- - **No per-method descriptions.** Authors convey prose through `agentNotes()` or by implementing `agentHelp()`.
541
- - **Constructors are not invoked** during introspection. Construction guidance belongs in notes.
542
- - **Instance fields** can only be discovered from an actual instance or plain object, not from a class constructor.
543
- - **Getters are not invoked** during introspection.
544
- - **TypeScript `private` and `protected`** are compile-time constructs. The library excludes names starting with `_` but cannot perfectly detect visibility at runtime.
545
- - **JavaScript `#private` fields and methods** are not reflectable and never appear in output.
546
- - **Module-level documentation** is not supported.
547
- - **Dynamic package import or CLI-based introspection** is intentionally omitted.
64
+ - **Python:** [agent-readable](https://github.com/zydo/agent-readable) provides
65
+ the same idea for Python packages and classes.
548
66
 
549
67
  ## License
550
68
 
package/dist/src/cli.js CHANGED
@@ -6,8 +6,12 @@ import { pathToFileURL } from "node:url";
6
6
  import { resolve } from "node:path";
7
7
  import { readFileSync } from "node:fs";
8
8
  function usage() {
9
- process.stderr.write("Usage: agent-readable-ts <module-path>[:<export-name>]\n" +
10
- " agent-readable-ts <package-name>[:<export-name>]\n");
9
+ process.stderr.write("Usage: agent-readable-ts [--install] <module-path>[:<export-name>]\n" +
10
+ " agent-readable-ts [--install] <package-name>[:<export-name>]\n" +
11
+ "\n" +
12
+ "Options:\n" +
13
+ " --install Allow fetching a package on demand (with npm install) when it\n" +
14
+ " is not already installed locally or in the cache.\n");
11
15
  process.exit(1);
12
16
  }
13
17
  function fail(message) {
@@ -38,9 +42,9 @@ async function handleFile(modulePath, exportName) {
38
42
  process.stdout.write(agentHelp(target, typeSigs));
39
43
  }
40
44
  // ── package-based handling ─────────────────────────────────────────────────────
41
- async function handlePackage(spec, exportName) {
45
+ async function handlePackage(spec, exportName, allowInstall) {
42
46
  const { name } = splitPackageSpec(spec);
43
- const { mod, typesDir } = await loadPackage(spec);
47
+ const { mod, typesDir } = await loadPackage(spec, undefined, allowInstall);
44
48
  const dtsPath = resolvePackageTypesPath(name, typesDir);
45
49
  // No export name: list all exports
46
50
  if (!exportName) {
@@ -58,13 +62,21 @@ async function handlePackage(spec, exportName) {
58
62
  process.stdout.write(agentHelp(target, typeSigs));
59
63
  }
60
64
  // ── main ───────────────────────────────────────────────────────────────────────
61
- const specifier = process.argv[2];
65
+ const args = process.argv.slice(2);
66
+ const allowInstall = args.includes("--install");
67
+ const positional = args.filter((arg) => arg !== "--install");
68
+ const unknownFlag = positional.find((arg) => arg.startsWith("--"));
69
+ if (unknownFlag) {
70
+ process.stderr.write(`Error: Unknown option "${unknownFlag}"\n`);
71
+ usage();
72
+ }
73
+ const specifier = positional[0];
62
74
  if (!specifier)
63
75
  usage();
64
76
  try {
65
77
  const { modulePath, exportName } = parseSpecifier(specifier);
66
78
  if (isBarePackageName(modulePath)) {
67
- await handlePackage(modulePath, exportName);
79
+ await handlePackage(modulePath, exportName, allowInstall);
68
80
  }
69
81
  else {
70
82
  await handleFile(modulePath, exportName);
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,SAAS,KAAK;IACZ,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,0DAA0D;QAC1D,2DAA2D,CAC5D,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,SAAS,IAAI,CAAC,OAAe;IAC3B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,OAAO,IAAI,CAAC,CAAC;IAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,kFAAkF;AAElF,iFAAiF;AACjF,SAAS,QAAQ,CAAC,UAAyB;IACzC,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAC7B,MAAM,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC5C,OAAO,OAAO,IAAI,CAAC,CAAC,CAAC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,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAChD,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,WAAW,CAAC,CAAC;AAE7D,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;AACnE,IAAI,WAAW,EAAE,CAAC;IAChB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,0BAA0B,WAAW,KAAK,CAAC,CAAC;IACjE,KAAK,EAAE,CAAC;AACV,CAAC;AAED,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;AAChC,IAAI,CAAC,SAAS;IAAE,KAAK,EAAE,CAAC;AAExB,IAAI,CAAC;IACH,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IAC7D,IAAI,iBAAiB,CAAC,UAAU,CAAC,EAAE,CAAC;QAClC,MAAM,aAAa,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;IAC5D,CAAC;SAAM,CAAC;QACN,MAAM,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC;AAAC,OAAO,GAAG,EAAE,CAAC;IACb,IAAI,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AACzD,CAAC"}
@@ -24,7 +24,7 @@ export declare function formatExportList(packageName: string, exports: ExportDes
24
24
  export declare function listRuntimeExports(mod: Record<string, unknown>): ExportDescriptor[];
25
25
  export declare function isModuleNotFound(err: unknown): boolean;
26
26
  export declare function isInstalledIn(name: string, dir: string): boolean;
27
- export declare function ensureCacheInstall(name: string, install: string, dir?: string): string;
27
+ export declare function ensureCacheInstall(name: string, install: string, dir?: string, allowInstall?: boolean): string;
28
28
  export declare function resolvePackageRootFromDir(name: string, dir: string): string | null;
29
29
  export declare function resolveLocalPackageRoot(name: string): string | null;
30
30
  export declare function importFromDir(name: string, dir: string): Promise<Record<string, unknown>>;
@@ -32,5 +32,5 @@ export interface LoadedPackage {
32
32
  mod: Record<string, unknown>;
33
33
  typesDir: string;
34
34
  }
35
- export declare function loadPackage(spec: string, cacheDir?: string): Promise<LoadedPackage>;
35
+ export declare function loadPackage(spec: string, cacheDir?: string, allowInstall?: boolean): Promise<LoadedPackage>;
36
36
  //# sourceMappingURL=packages.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"packages.d.ts","sourceRoot":"","sources":["../../src/packages.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,eAAO,MAAM,SAAS,QAC8D,CAAC;AAIrF,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAQnG;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAM7D;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAKhF;AAID,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAc3E;AAoBD,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,gBAAgB,GAAG,SAAS,CAc1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uB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAwBnE;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAkB/F;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,MAAkB,EAC5B,YAAY,UAAQ,GACnB,OAAO,CAAC,aAAa,CAAC,CAiBxB"}
@@ -149,18 +149,33 @@ export function isInstalledIn(name, dir) {
149
149
  return false;
150
150
  }
151
151
  }
152
- export function ensureCacheInstall(name, install, dir = CACHE_DIR) {
152
+ export function ensureCacheInstall(name, install, dir = CACHE_DIR, allowInstall = false) {
153
153
  mkdirSync(dir, { recursive: true });
154
154
  const pkgJson = join(dir, "package.json");
155
155
  if (!existsSync(pkgJson)) {
156
156
  writeFileSync(pkgJson, JSON.stringify({ name: "agent-readable-cache", private: true }) + "\n");
157
157
  }
158
158
  if (!isInstalledIn(name, dir)) {
159
+ if (!allowInstall) {
160
+ throw new Error(`Package "${name}" is not installed. ` +
161
+ `Run "npm install ${install}" in your project, or re-run with --install to fetch it on demand.`);
162
+ }
159
163
  process.stderr.write(`Installing ${install} on demand into ${dir} ...\n`);
160
164
  try {
161
165
  // Save into the cache's own package.json so previously fetched packages are
162
166
  // not pruned as "extraneous" when a different package is installed later.
163
- execFileSync("npm", ["install", install, "--prefix", dir, "--save", "--no-audit", "--no-fund", "--loglevel=error"], { stdio: ["ignore", "ignore", "inherit"] });
167
+ // --ignore-scripts prevents arbitrary lifecycle scripts from running.
168
+ execFileSync("npm", [
169
+ "install",
170
+ install,
171
+ "--prefix",
172
+ dir,
173
+ "--save",
174
+ "--ignore-scripts",
175
+ "--no-audit",
176
+ "--no-fund",
177
+ "--loglevel=error",
178
+ ], { stdio: ["ignore", "ignore", "inherit"] });
164
179
  }
165
180
  catch (err) {
166
181
  throw new Error(`Failed to install "${install}": ${err instanceof Error ? err.message : String(err)}`);
@@ -251,7 +266,7 @@ export async function importFromDir(name, dir) {
251
266
  rmSync(loaderPath, { force: true });
252
267
  }
253
268
  }
254
- export async function loadPackage(spec, cacheDir = CACHE_DIR) {
269
+ export async function loadPackage(spec, cacheDir = CACHE_DIR, allowInstall = false) {
255
270
  const { name, install } = splitPackageSpec(spec);
256
271
  // Prefer a copy already resolvable from the current project.
257
272
  try {
@@ -264,7 +279,7 @@ export async function loadPackage(spec, cacheDir = CACHE_DIR) {
264
279
  }
265
280
  }
266
281
  // Not installed locally: fetch on demand into the cache, then load from there.
267
- const dir = ensureCacheInstall(name, install, cacheDir);
282
+ const dir = ensureCacheInstall(name, install, cacheDir, allowInstall);
268
283
  const mod = await importFromDir(name, dir);
269
284
  return { mod, typesDir: resolvePackageRootFromDir(name, dir) ?? dir };
270
285
  }
@@ -1 +1 @@
1
- {"version":3,"file":"packages.js","sourceRoot":"","sources":["../../src/packages.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA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AAC;QACH,MAAM,GAAG,GAAG,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,CAA4B,CAAC;QAC5D,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,uBAAuB,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;IAC3E,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,0BAA0B,IAAI,MAAM,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC1G,CAAC;IACH,CAAC;IAED,+EAA+E;IAC/E,MAAM,GAAG,GAAG,kBAAkB,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;IACtE,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC3C,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,yBAAyB,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC;AACxE,CAAC"}
@@ -0,0 +1,112 @@
1
+ # Authoring Notes
2
+
3
+ Start with clear public method names and JSDoc. Add `agentNotes()` only when a
4
+ class or object has cross-method rules that are easy to miss.
5
+
6
+ Use `agentHelp()` rarely, when the auto-generated output is not the right shape
7
+ and you want to provide the full Markdown response yourself.
8
+
9
+ ## `agentNotes()`
10
+
11
+ Define `agentNotes()` to append usage guidance after the generated public API
12
+ docs.
13
+
14
+ ```ts
15
+ import { AgentNoter } from "agent-readable-ts";
16
+
17
+ interface Connection {}
18
+
19
+ class DatabasePool implements AgentNoter {
20
+ acquire(): Promise<Connection> {
21
+ throw new Error("not implemented");
22
+ }
23
+
24
+ release(conn: Connection): void {}
25
+
26
+ shutdown(): Promise<void> {
27
+ return Promise.resolve();
28
+ }
29
+
30
+ agentNotes(): string {
31
+ return `
32
+ ## Do
33
+
34
+ - Always call \`release(conn)\` after every \`acquire()\`, even on error.
35
+ - Call \`shutdown()\` during graceful application teardown.
36
+
37
+ ## Do not
38
+
39
+ - Do not call \`acquire()\` after \`shutdown()\`.
40
+ - Do not share a \`Connection\` object across async tasks.
41
+ `;
42
+ }
43
+ }
44
+ ```
45
+
46
+ `agentNotes()` is a good fit for:
47
+
48
+ - lifecycle and call ordering rules;
49
+ - preconditions and cleanup requirements;
50
+ - sync vs async constraints;
51
+ - streaming vs non-streaming behavior;
52
+ - important do and do-not guidance.
53
+
54
+ Avoid duplicating obvious method-level information that belongs in names,
55
+ signatures, or JSDoc.
56
+
57
+ ## Inheritance
58
+
59
+ Notes accumulate across the inheritance chain in parent-to-child order.
60
+
61
+ Unlike Python, TypeScript does not automatically merge notes from separate
62
+ prototype methods. Implement `agentNotes()` on each class that has its own
63
+ cross-method rules.
64
+
65
+ ## `agentHelp()`
66
+
67
+ Implement `agentHelp()` for full control over the returned Markdown:
68
+
69
+ ```ts
70
+ import { AgentHelper } from "agent-readable-ts";
71
+
72
+ class RateLimiter implements AgentHelper {
73
+ agentHelp(): string {
74
+ return `# RateLimiter
75
+
76
+ ## Usage
77
+
78
+ - Create with \`new RateLimiter(maxRequests)\`.
79
+ - Call \`acquire()\` before making a request.
80
+ - Call \`release()\` after the request completes.
81
+ `;
82
+ }
83
+ }
84
+ ```
85
+
86
+ If both `agentHelp()` and `agentNotes()` are defined on the same target,
87
+ `agentHelp()` wins and `agentNotes()` is ignored. The library emits a warning,
88
+ but authors should treat this as an API design error.
89
+
90
+ ## Warning Output
91
+
92
+ By default, advisory warnings are written to `process.stderr`. You can redirect
93
+ or silence them:
94
+
95
+ ```ts
96
+ import { getWarnOutput, setWarnOutput } from "agent-readable-ts";
97
+
98
+ setWarnOutput((chunk: string) => {
99
+ console.log("[WARN]", chunk.trim());
100
+ });
101
+
102
+ setWarnOutput({
103
+ write(chunk: string) {
104
+ console.log(chunk);
105
+ },
106
+ });
107
+
108
+ setWarnOutput(null);
109
+ setWarnOutput(process.stderr);
110
+ ```
111
+
112
+ `getWarnOutput()` returns the current warning sink.
@@ -0,0 +1,166 @@
1
+ # Examples
2
+
3
+ ## Installed Package
4
+
5
+ List all exports from an installed package:
6
+
7
+ ```sh
8
+ npm install commander
9
+ npx agent-readable-ts commander
10
+ ```
11
+
12
+ Example output:
13
+
14
+ ```markdown
15
+ # commander
16
+
17
+ ## Exports
18
+
19
+ - `CommanderError` class
20
+ - `InvalidArgumentError` class
21
+ - `Argument` class
22
+ - `Option` class
23
+ - `Help` class
24
+ - `Command` class
25
+ - `createCommand(name: string): Command` function
26
+ - `createOption(flags: string, description: string): Option` function
27
+ - `createArgument(name: string, description: string): Argument` function
28
+ - `program` object
29
+ ```
30
+
31
+ Document a specific export:
32
+
33
+ ```sh
34
+ npx agent-readable-ts commander:Command
35
+ ```
36
+
37
+ ## Local File
38
+
39
+ ```sh
40
+ npx agent-readable-ts ./src/widget.ts:Widget
41
+ npx agent-readable-ts ./src/util.ts:connect
42
+ npx agent-readable-ts ./dist/api.js:fetch
43
+ ```
44
+
45
+ For `.js`, `.mjs`, and `.cjs` files, the CLI can read adjacent `.d.ts`,
46
+ `.d.mts`, and `.d.cts` declaration files when they exist.
47
+
48
+ ## Wrapping a Class You Do Not Own
49
+
50
+ ```ts
51
+ import { agentHelp } from "agent-readable-ts";
52
+
53
+ class Client {
54
+ connect(url: string): void {}
55
+ query(sql: string): unknown {
56
+ return undefined;
57
+ }
58
+ }
59
+
60
+ class DocumentedClient extends Client {
61
+ agentNotes(): string {
62
+ return `
63
+ ## Do
64
+
65
+ - Call \`connect()\` before \`query()\`.
66
+
67
+ ## Do not
68
+
69
+ - Do not pass untrusted SQL directly to \`query()\`.
70
+ `;
71
+ }
72
+ }
73
+
74
+ console.log(agentHelp(new DocumentedClient()));
75
+ ```
76
+
77
+ ## Inheritance With Accumulated Notes
78
+
79
+ ```ts
80
+ import { agentHelp } from "agent-readable-ts";
81
+
82
+ class Sensor {
83
+ calibrate(offset: number): void {}
84
+ read(): number {
85
+ return 0;
86
+ }
87
+
88
+ agentNotes(): string {
89
+ return `
90
+ ## Do
91
+
92
+ - Call \`calibrate()\` once during setup, before \`read()\`.
93
+
94
+ ## Do not
95
+
96
+ - Do not call \`read()\` before \`calibrate()\` on first use.
97
+ `;
98
+ }
99
+ }
100
+
101
+ class CalibratedSensor extends Sensor {
102
+ reset(): void {}
103
+
104
+ override agentNotes(): string {
105
+ return `
106
+ ## Do
107
+
108
+ - Use \`reset()\` only when recalibration is required.
109
+
110
+ ## Do not
111
+
112
+ - Do not call \`reset()\` in the hot read path.
113
+ `;
114
+ }
115
+ }
116
+
117
+ console.log(agentHelp(new CalibratedSensor()));
118
+ ```
119
+
120
+ Notes are emitted in parent-to-child order. If rules conflict, the child class
121
+ guidance should be treated as more specific.
122
+
123
+ ## Full Control With `agentHelp()`
124
+
125
+ ```ts
126
+ import { agentHelp } from "agent-readable-ts";
127
+
128
+ class RateLimiter {
129
+ agentHelp(): string {
130
+ return `# RateLimiter
131
+
132
+ ## Usage
133
+
134
+ - Create with \`new RateLimiter(maxRequests)\`.
135
+ - Call \`acquire()\` before making a request.
136
+ - Call \`release()\` after the request completes.
137
+ `;
138
+ }
139
+ }
140
+
141
+ console.log(agentHelp(new RateLimiter()));
142
+ ```
143
+
144
+ When `agentHelp()` exists, its returned Markdown is used verbatim.
145
+
146
+ ## Functions and Bound Methods
147
+
148
+ ```ts
149
+ import { agentHelp } from "agent-readable-ts";
150
+
151
+ function connect(host: string, port: number): void {}
152
+
153
+ class Runner {
154
+ execute(command: string): number {
155
+ return 0;
156
+ }
157
+ }
158
+
159
+ const runner = new Runner();
160
+
161
+ console.log(agentHelp(connect));
162
+ console.log(agentHelp(runner.execute.bind(runner)));
163
+ ```
164
+
165
+ Bound methods may lose original parameter names at runtime and fall back to
166
+ `arg0`, `arg1`, and so on.
package/docs/faq.md ADDED
@@ -0,0 +1,59 @@
1
+ # FAQ
2
+
3
+ ## Which Node versions are supported?
4
+
5
+ Node 20 or newer.
6
+
7
+ ## Should I use the library API or the CLI?
8
+
9
+ Use `agentHelp(target)` when the target is already loaded in your program.
10
+
11
+ Use the CLI when you want better TypeScript signatures from source files or
12
+ declaration files:
13
+
14
+ ```sh
15
+ npx agent-readable-ts ./src/widget.ts:Widget
16
+ npx agent-readable-ts commander:Command
17
+ ```
18
+
19
+ ## Can runtime reflection recover TypeScript types?
20
+
21
+ No. TypeScript types, interfaces, overloads, generic parameters, return types,
22
+ and doc comments are erased from compiled JavaScript.
23
+
24
+ The CLI can recover more type information by parsing `.ts` files or adjacent
25
+ declaration files.
26
+
27
+ ## Why do some parameters show up as `arg0`?
28
+
29
+ Parameter names come from `Function.prototype.toString()` when possible. Native
30
+ functions, bound functions, destructured parameters, and some compiled output do
31
+ not preserve useful names, so the library falls back to `arg0`, `arg1`, and so
32
+ on.
33
+
34
+ ## Are constructors or getters invoked?
35
+
36
+ No. Constructors are not called during introspection, and getters are not
37
+ invoked.
38
+
39
+ ## Are private members shown?
40
+
41
+ JavaScript `#private` fields and methods are not reflectable and never appear.
42
+
43
+ TypeScript `private` and `protected` are compile-time constructs. The library
44
+ excludes names starting with `_`, but runtime JavaScript cannot perfectly detect
45
+ TypeScript visibility.
46
+
47
+ ## Does the CLI fetch packages automatically?
48
+
49
+ No. Missing packages are only fetched when you pass `--install`.
50
+
51
+ Fetched packages go into an isolated cache and are installed with
52
+ `--ignore-scripts`. See [Getting Started](getting-started.md#on-demand-package-fetching).
53
+
54
+ ## Is this the same as the Python package?
55
+
56
+ It is the TypeScript and JavaScript sibling of
57
+ [agent-readable](https://github.com/zydo/agent-readable). The shared idea is the
58
+ same: inspect the current API surface and author-provided usage rules before
59
+ coding against an unfamiliar target.
@@ -0,0 +1,94 @@
1
+ # Getting Started
2
+
3
+ `agent-readable-ts` can be used as a library from TypeScript or JavaScript, and
4
+ as a CLI for inspecting local files or npm packages.
5
+
6
+ ## Install
7
+
8
+ ```sh
9
+ npm install agent-readable-ts
10
+ ```
11
+
12
+ Node 20 or newer is required.
13
+
14
+ ## Library Usage
15
+
16
+ ```ts
17
+ import { agentHelp } from "agent-readable-ts";
18
+
19
+ console.log(agentHelp(SomeClass)); // class constructor
20
+ console.log(agentHelp(new SomeClass())); // class instance
21
+ console.log(agentHelp(someFunction)); // function or arrow function
22
+ console.log(agentHelp({ a: 1 })); // plain object
23
+ ```
24
+
25
+ The programmatic API uses runtime JavaScript reflection. It can show public
26
+ members, parameter names when available, and `agentNotes()`/`agentHelp()` output,
27
+ but it cannot recover TypeScript-only types from compiled JavaScript.
28
+
29
+ ## CLI Usage
30
+
31
+ The CLI can inspect installed npm packages, local JavaScript files, and local
32
+ TypeScript files.
33
+
34
+ ```sh
35
+ npx agent-readable-ts commander
36
+ npx agent-readable-ts commander:Command
37
+ npx agent-readable-ts ./src/widget.ts:Widget
38
+ ```
39
+
40
+ `commander` is only an example target. Use any trusted installed package, local
41
+ module, or local TypeScript file.
42
+
43
+ Usage:
44
+
45
+ ```sh
46
+ agent-readable-ts [--install] <package-name>[:<export-name>]
47
+ agent-readable-ts <module-path>[:<export-name>]
48
+ ```
49
+
50
+ - `package-name`: an installed npm package, such as `commander`, `pino`, or
51
+ `@scope/package`.
52
+ - `module-path`: a `.js`, `.mjs`, `.cjs`, or `.ts` file path relative to the
53
+ current directory.
54
+ - `export-name`: the named export to document. Use dots for nested access, such
55
+ as `Things.Helper`.
56
+ - `--install`: allow the CLI to fetch a package on demand when it is not
57
+ installed locally.
58
+
59
+ If no export name is given for a package, all exports are listed. If no export
60
+ name is given for a file, the module namespace object is documented.
61
+
62
+ `.ts` files require `tsx`. It is included as a dev dependency in this repo, and
63
+ `npx` resolves it automatically when running from this package.
64
+
65
+ ## One-Off Execution
66
+
67
+ Use one of these when you do not want to add a dependency to the current project:
68
+
69
+ ```sh
70
+ npx agent-readable-ts commander
71
+ npm exec -- agent-readable-ts commander:Command
72
+ pnpm dlx agent-readable-ts ./src/widget.ts:Widget
73
+ ```
74
+
75
+ ## On-Demand Package Fetching
76
+
77
+ Packages already installed in the current project load directly. For anything
78
+ else, the CLI refuses to fetch unless `--install` is passed:
79
+
80
+ ```sh
81
+ npx agent-readable-ts --install left-pad
82
+ ```
83
+
84
+ Fetched packages go into `~/.cache/agent-readable-ts`, or the directory named by
85
+ `AGENT_READABLE_CACHE`. They are never installed into the current project.
86
+
87
+ The install uses `npm install --ignore-scripts`, so package lifecycle scripts are
88
+ not run. Cached packages load offline without requiring `--install` again.
89
+
90
+ ## Security
91
+
92
+ The CLI imports packages and local modules in order to inspect them. Importing a
93
+ module executes its top-level code. Only inspect packages and files you trust to
94
+ run on your machine.
package/docs/why.md ADDED
@@ -0,0 +1,43 @@
1
+ # Why agent-readable-ts?
2
+
3
+ Coding agents often guess a library API from stale memory: inventing methods,
4
+ using old signatures, or missing lifecycle rules that are not visible from a
5
+ method list alone.
6
+
7
+ `agent-readable-ts` gives agents a small, live, API-shaped context before they
8
+ write code:
9
+
10
+ - the public callable surface that can be discovered safely;
11
+ - TypeScript signatures when the CLI can parse source or declaration files;
12
+ - author-supplied usage rules from `agentNotes()`;
13
+ - full custom guidance from `agentHelp()` when a library needs it.
14
+
15
+ This reduces failed edit-test-retry loops and keeps the agent focused on the API
16
+ that exists in the current project.
17
+
18
+ ## Why Not Just README Docs?
19
+
20
+ README files are written for people and often cover happy-path examples. Coding
21
+ agents need a compact answer to narrower questions:
22
+
23
+ - What members exist on this object right now?
24
+ - Which methods are public?
25
+ - What is the current call shape?
26
+ - Are there ordering, cleanup, async, or safety rules?
27
+
28
+ `agent-readable-ts` puts that information next to the implementation and exposes
29
+ it through one consistent inspection path.
30
+
31
+ ## Runtime and Source Inspection
32
+
33
+ TypeScript type annotations do not exist at runtime. The library API therefore
34
+ uses conservative JavaScript reflection. The CLI fills more gaps by parsing
35
+ `.ts` source or adjacent `.d.ts` declaration files for packages and JavaScript
36
+ modules.
37
+
38
+ When type detail matters, prefer the CLI:
39
+
40
+ ```sh
41
+ npx agent-readable-ts ./src/widget.ts:Widget
42
+ npx agent-readable-ts commander:Command
43
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-readable-ts",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Attach agent-oriented documentation to any class, object, or function",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -17,6 +17,7 @@
17
17
  "agent-readable-ts": "dist/src/cli.js"
18
18
  },
19
19
  "files": [
20
+ "docs",
20
21
  "dist/src"
21
22
  ],
22
23
  "scripts": {