cbrowser 20.0.1 → 20.0.2

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/dist/cli.js CHANGED
@@ -2793,17 +2793,22 @@ async function main() {
2793
2793
  process.exit(1);
2794
2794
  }
2795
2795
  const { askCbrowser } = await import("./help-client.js");
2796
+ const { formatAnswerForTerminal, sourceLines, sourcePath, sourceUrls } = await import("./help-format.js");
2796
2797
  try {
2797
2798
  const r = await askCbrowser(question, { context: typeof options.context === "string" ? options.context : undefined });
2798
2799
  if (options.json === true || getOutputOptions().json) {
2799
- printData("ask", { question: r.question, answer: r.answer, sources: r.sources });
2800
+ // The answer stays as the service sent it (markdown); the links are added beside it.
2801
+ printData("ask", { question: r.question, answer: r.answer, sources: r.sources, sourceUrls: sourceUrls(r.sources) });
2800
2802
  }
2801
2803
  else {
2802
- console.log(r.answer);
2803
- if (r.sources.length > 0) {
2804
+ // A terminal gets plain text and full links (help-format.ts).
2805
+ const known = r.sources.map(sourcePath).filter((p) => p !== null);
2806
+ console.log(formatAnswerForTerminal(r.answer, known));
2807
+ const lines = sourceLines(r.sources);
2808
+ if (lines.length > 0) {
2804
2809
  console.log("\nSources:");
2805
- for (const s of r.sources)
2806
- console.log(` - ${s.split("\n")[0].slice(0, 120)}`);
2810
+ for (const line of lines)
2811
+ console.log(` - ${line}`);
2807
2812
  }
2808
2813
  }
2809
2814
  process.exit(0);