trickle-cli 0.1.216 → 0.1.219

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.
@@ -13,5 +13,6 @@
13
13
  export interface HintsOptions {
14
14
  values?: boolean;
15
15
  errors?: boolean;
16
+ show?: string;
16
17
  }
17
18
  export declare function hintsCommand(targetFile: string | undefined, opts: HintsOptions): Promise<void>;
@@ -277,8 +277,11 @@ async function hintsCommand(targetFile, opts) {
277
277
  const typeStr = typeToString(v.type);
278
278
  const scope = v.funcName ? ` (in ${v.funcName})` : "";
279
279
  const sampleStr = formatSample(v.sample);
280
- // In error mode, always show values (crash-time state)
281
- if ((opts.errors || opts.values) && v.sample !== undefined) {
280
+ const nbShowMode = opts.show || (opts.errors ? "both" : (opts.values ? "both" : "types"));
281
+ if (nbShowMode === "values" && v.sample !== undefined) {
282
+ console.log(`${v.varName} = ${sampleStr}${scope}`);
283
+ }
284
+ else if (nbShowMode === "both" && v.sample !== undefined) {
282
285
  console.log(`${v.varName}: ${typeStr} = ${sampleStr}${scope}`);
283
286
  }
284
287
  else {
@@ -322,6 +325,12 @@ async function hintsCommand(targetFile, opts) {
322
325
  const obs = lineObs.get(lineNo);
323
326
  if (!obs || obs.size === 0) {
324
327
  console.log(src);
328
+ // Show error underline on the error line
329
+ if (opts.errors && errLine && lineNo === errLine) {
330
+ const indent = src.match(/^(\s*)/)?.[1] || "";
331
+ const contentLen = src.trimEnd().length - indent.length;
332
+ console.log(indent + "~".repeat(Math.max(contentLen, 1)) + ` ← ${errMsg}`);
333
+ }
325
334
  continue;
326
335
  }
327
336
  // Insert type hints inline after variable names
@@ -365,9 +374,14 @@ async function hintsCommand(targetFile, opts) {
365
374
  if (isFuncParam && afterVar.startsWith(":"))
366
375
  continue;
367
376
  }
368
- // Build the hint string error mode always shows values (crash-time state)
377
+ // Build the hint string based on --show mode
378
+ const showMode = opts.show || (opts.errors ? "both" : (opts.values ? "both" : "types"));
379
+ const hasSample = v.sample !== undefined && v.sample !== null;
369
380
  let hint;
370
- if ((opts.errors || opts.values) && v.sample !== undefined && v.sample !== null) {
381
+ if (showMode === "values" && hasSample) {
382
+ hint = ` = ${formatSample(v.sample)}`;
383
+ }
384
+ else if (showMode === "both" && hasSample) {
371
385
  const sampleStr = formatSample(v.sample);
372
386
  hint = sampleStr ? `: ${typeStr} = ${sampleStr}` : `: ${typeStr}`;
373
387
  }
@@ -378,6 +392,12 @@ async function hintsCommand(targetFile, opts) {
378
392
  annotated = annotated.substring(0, varEnd) + hint + annotated.substring(varEnd);
379
393
  }
380
394
  console.log(annotated);
395
+ // Show error underline on the error line
396
+ if (opts.errors && errLine && lineNo === errLine) {
397
+ const indent = src.match(/^(\s*)/)?.[1] || "";
398
+ const contentLen = src.trimEnd().length - indent.length;
399
+ console.log(indent + "~".repeat(Math.max(contentLen, 1)) + ` ← ${errMsg}`);
400
+ }
381
401
  }
382
402
  console.log("```");
383
403
  console.log("");
package/dist/index.js CHANGED
@@ -540,6 +540,7 @@ program
540
540
  .description("Output source code with inline type hints from runtime observations (for AI agents)")
541
541
  .option("--values", "Include sample values alongside types")
542
542
  .option("--errors", "Show error mode — variables at crash time with values that caused the error")
543
+ .option("--show <mode>", "What to show inline: types, values, or both (default: both in error mode, types otherwise)")
543
544
  .action(async (file, opts) => {
544
545
  await (0, hints_1.hintsCommand)(file, opts);
545
546
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trickle-cli",
3
- "version": "0.1.216",
3
+ "version": "0.1.219",
4
4
  "description": "Zero-code runtime observability for JS/Python + AI agent debugging. Traces LangChain, CrewAI, OpenAI, Anthropic, Gemini. Eval, security, compliance, cost tracking. Free, local-first.",
5
5
  "keywords": [
6
6
  "observability",
@@ -17,6 +17,7 @@ import * as path from "path";
17
17
  export interface HintsOptions {
18
18
  values?: boolean;
19
19
  errors?: boolean;
20
+ show?: string; // "types", "values", "both" (default: "both" in error mode, "types" otherwise)
20
21
  }
21
22
 
22
23
  interface TypeNode {
@@ -268,8 +269,10 @@ export async function hintsCommand(
268
269
  const typeStr = typeToString(v.type);
269
270
  const scope = v.funcName ? ` (in ${v.funcName})` : "";
270
271
  const sampleStr = formatSample(v.sample);
271
- // In error mode, always show values (crash-time state)
272
- if ((opts.errors || opts.values) && v.sample !== undefined) {
272
+ const nbShowMode = opts.show || (opts.errors ? "both" : (opts.values ? "both" : "types"));
273
+ if (nbShowMode === "values" && v.sample !== undefined) {
274
+ console.log(`${v.varName} = ${sampleStr}${scope}`);
275
+ } else if (nbShowMode === "both" && v.sample !== undefined) {
273
276
  console.log(`${v.varName}: ${typeStr} = ${sampleStr}${scope}`);
274
277
  } else {
275
278
  console.log(`${v.varName}: ${typeStr}${scope}`);
@@ -312,6 +315,12 @@ export async function hintsCommand(
312
315
 
313
316
  if (!obs || obs.size === 0) {
314
317
  console.log(src);
318
+ // Show error underline on the error line
319
+ if (opts.errors && errLine && lineNo === errLine) {
320
+ const indent = src.match(/^(\s*)/)?.[1] || "";
321
+ const contentLen = src.trimEnd().length - indent.length;
322
+ console.log(indent + "~".repeat(Math.max(contentLen, 1)) + ` ← ${errMsg}`);
323
+ }
315
324
  continue;
316
325
  }
317
326
 
@@ -357,9 +366,13 @@ export async function hintsCommand(
357
366
  if (isFuncParam && afterVar.startsWith(":")) continue;
358
367
  }
359
368
 
360
- // Build the hint string error mode always shows values (crash-time state)
369
+ // Build the hint string based on --show mode
370
+ const showMode = opts.show || (opts.errors ? "both" : (opts.values ? "both" : "types"));
371
+ const hasSample = v.sample !== undefined && v.sample !== null;
361
372
  let hint: string;
362
- if ((opts.errors || opts.values) && v.sample !== undefined && v.sample !== null) {
373
+ if (showMode === "values" && hasSample) {
374
+ hint = ` = ${formatSample(v.sample)}`;
375
+ } else if (showMode === "both" && hasSample) {
363
376
  const sampleStr = formatSample(v.sample);
364
377
  hint = sampleStr ? `: ${typeStr} = ${sampleStr}` : `: ${typeStr}`;
365
378
  } else {
@@ -371,6 +384,12 @@ export async function hintsCommand(
371
384
  }
372
385
 
373
386
  console.log(annotated);
387
+ // Show error underline on the error line
388
+ if (opts.errors && errLine && lineNo === errLine) {
389
+ const indent = src.match(/^(\s*)/)?.[1] || "";
390
+ const contentLen = src.trimEnd().length - indent.length;
391
+ console.log(indent + "~".repeat(Math.max(contentLen, 1)) + ` ← ${errMsg}`);
392
+ }
374
393
  }
375
394
 
376
395
  console.log("```");
package/src/index.ts CHANGED
@@ -541,7 +541,8 @@ program
541
541
  .description("Output source code with inline type hints from runtime observations (for AI agents)")
542
542
  .option("--values", "Include sample values alongside types")
543
543
  .option("--errors", "Show error mode — variables at crash time with values that caused the error")
544
- .action(async (file: string | undefined, opts: { values?: boolean; errors?: boolean }) => {
544
+ .option("--show <mode>", "What to show inline: types, values, or both (default: both in error mode, types otherwise)")
545
+ .action(async (file: string | undefined, opts: { values?: boolean; errors?: boolean; show?: string }) => {
545
546
  await hintsCommand(file, opts);
546
547
  });
547
548