pi-wsearch 0.2.1 → 0.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-wsearch",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Pi extension: web.search + web.fetch",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/scrape.ts CHANGED
@@ -713,6 +713,7 @@ async function archivedFetch(
713
713
  maxChars: number,
714
714
  ): Promise<ScrapeResult | undefined> {
715
715
  if (signal?.aborted) return undefined;
716
+ if (isPrivateHost(url.hostname)) return undefined;
716
717
  try {
717
718
  const { ctrl, done } = withTimeout('archive lookup', 10_000, signal);
718
719
  let snapshotUrl: string | undefined;
package/src/tools.ts CHANGED
@@ -333,9 +333,10 @@ export function registerWebTools(pi: ExtensionAPI) {
333
333
  return makeFetchResult(res, params);
334
334
  },
335
335
  renderResult(result, options, theme) {
336
- const lines = resultText(result).split('\n');
336
+ const raw = italicizeIndices(resultText(result), theme);
337
+ const lines = raw.split('\n');
337
338
  if (!options.expanded) return new Text(previewWithHint(lines, theme), 0, 0);
338
- return new Text(colorizedResult(resultText(result), theme), 0, 0);
339
+ return new Text(colorizedResult(raw, theme), 0, 0);
339
340
  },
340
341
  });
341
342
  }
@@ -371,6 +372,14 @@ function fmtSize(chars: number): string {
371
372
 
372
373
  const PREVIEW_LINES = 10;
373
374
 
375
+ /** Display-only: the model-facing markers (`indices …`, `- *N*`) render as
376
+ * genuine ANSI italics in the TUI; the content text itself is untouched. */
377
+ function italicizeIndices(text: string, theme: Theme): string {
378
+ return text
379
+ .replace(/^(indices - 0 - \d+ sections?)$/gm, (m) => theme.italic(m))
380
+ .replace(/^- \*(\d+)\* /gm, (_, n: string) => `- ${theme.italic(n)} `);
381
+ }
382
+
374
383
  function colorizedResult(text: string, theme: Theme): string {
375
384
  return text
376
385
  .split('\n')
@@ -421,7 +430,9 @@ function fetchErrorResult(details: FetchDetails): FetchResult {
421
430
  function buildFetchResult(res: Awaited<ReturnType<typeof scrape>>, sections: number[]): FetchResult {
422
431
  const want = [...new Set(sections.map((i) => Math.max(0, Math.min(res.sections.length - 1, i))))];
423
432
  const chosen = want.map((i) => res.sections[i]).filter(Boolean);
424
- const body = res.outline.length ? res.outline.map((h) => `- ${h}`).join('\n') + '\n\n' : '';
433
+ const body = res.outline.length
434
+ ? `indices - 0 - ${res.outline.length - 1} section${res.outline.length === 1 ? '' : 's'}\n${res.outline.map((h, i) => `- *${i}* ${h}`).join('\n')}\n\n`
435
+ : '';
425
436
  const parts: string[] = [];
426
437
  want.forEach((idx) => {
427
438
  const s = res.sections[idx];