Files
esh-pfi-infrastructure/scripts/kb
T
vh 68fa80f44d feat(scripts): add kb — direct search over the personal Worldtree KB
The Worldtree HTTP API cannot answer a question about the operator's notes.
/search there searches conversation MESSAGES, so a note that plainly exists
comes back as a clean empty result with no error attached. On 2026-09-14 a
search for 'shrimp' returned 0 hits; searching for 'the' and 'a' also returned
0, which is the only reason the empty result was read as an empty ACCOUNT
rather than an empty KB. kb reads the markdown tree directly instead:
deterministic, ~0.9s for 7,634 files, no tokens.

Two measurements shaped the design rather than being assumed:

  7,492 of 7,634 notes are INGESTED library material (4,155 fiction chapters,
  3,287 book sections, 50 academic papers) and only ~142 are hand-written.
  A flat relevance list buries the wanted note under a hundred chapters of
  Austen, so NOTES and LIBRARY are ranked and reported separately.

  Only 137 notes carry a frontmatter summary: key. Ingested notes use a
  '## Summary' body heading instead and some have neither, so the description
  falls back through all three shapes.

Two bugs caught by controls before shipping, both of which produced confident
wrong output rather than an error:

  Deriving the word list from argv meant a quoted
NOTES — 40 matches, showing 12

  Sous Vide Shrimp
    ATLAS/Cooking/Sous Vide/Sous Vide Shrimp.md
    Thawed shrimp should be sous vide at 135°F (57°C) for 30-40 minutes.

  Beef Stew
    ATLAS/Cooking/Sous Vide/Beef Stew.md
    This note outlines sous vide cooking temperatures and times for stew meat

  Pulled Pork
    ATLAS/Cooking/Sous Vide/Pulled Pork.md
    This note explains how to cook pulled pork sous vide: set the precision

  Brisket Sous Vide
    ATLAS/Cooking/Sous Vide/Brisket Sous Vide.md
    Here''s a concise summary:

  Ribs Sous Vide
    ATLAS/Cooking/Sous Vide/Ribs Sous Vide.md
    Here''s a concise summary:

  Derusting Solution
    ATLAS/Chemistry/Derusting Solution.md
    This note details how to create an enhanced rust removal soak by adding specific

  CNC with Raspberry Pi, USBIP & Camera
    clippings/CNC with Raspberry Pi, USBIP & Camera.md
    Here''s a concise summary of the note:

  SF - Victor
    ATLAS/Buy List/SF - Victor.md
    This order confirmation details 7 separate shipments totaling $2,533.45,

  Espresso Martini
    ATLAS/Cooking/Espresso Martini.md
    This note provides a recipe for a cocktail combining vodka, coffee liqueur,

  Brazilian Cheese Bread - Pão de Queijo
    ATLAS/Cooking/Brazilian Cheese Bread - Pão de Queijo.md
    This note provides a recipe for Brazilian cheese bread (#brazilian #food

  Congee Chao
    ATLAS/Cooking/Congee Chao.md
    This note provides the basic ratio (1 part rice to 7 parts water) for making

  White Bread
    ATLAS/Cooking/Baking/White Bread.md
    Here''s a concise summary:

LIBRARY (ingested books, fiction, papers) — 635 matches, showing 12

  Pride and Prejudice — CHAPTER XXI.
    fiction/rex390-pnp/ch23.md
    Following Mr. Collins’s proposal, Elizabeth encounters Wickham and learns that Jane has received a letter from Caroline Bingley announcing the party's immediate departure for London. While Jane interprets this move as definitive proof of Bingley’s indifference and permanent absence, Elizabeth remain

  Pride and Prejudice — CHAPTER XXIV.
    fiction/rex390-pnp/ch26.md
    Following Bingley’s letter confirming his settlement in London and growing intimacy with Miss Darcy, Elizabeth doubts the sincerity of his attachment to Jane, while Jane remains optimistic that external influences rather than design are responsible for their separation. The sisters debate these diff

  Pride and Prejudice — “On the Stairs.” CHAPTERXXVII.
    fiction/rex390-pnp/ch29.md
    Elizabeth reunites with Jane in London, where Mrs. Gardiner reveals that Jane suffers from periodic dejection despite her cheerful exterior, and the women debate whether Mr. Wickham’s pursuit of Miss King is motivated by mercenary or prudent reasons. Elizabeth then accepts an invitation from her aun

  Pride and Prejudice — CHAPTER XXXII.
    fiction/rex390-pnp/ch34.md
    Mr. Darcy’s frequent visits to Hunsford Parsonage spark speculation among the locals, particularly Mrs. Collins, who suspects he is in love with Elizabeth despite her own dismissal of the idea. Their initial interactions reveal a clash of perspectives on social convenience and local attachment, whil

  Pride and Prejudice — Chapter XLVI.
    fiction/rex390-pnp/ch48.md
    Following Lydia’s elopement with Wickham, Elizabeth Bennet informs Mr. Darcy of the scandal, reflecting that her earlier failure to reveal Wickham’s true character may have prevented the crisis and doubting their intent to marry due to their lack of funds. While Darcy offers sympathetic silence befo

  Pride and Prejudice — CHAPTER XIII
    fiction/rex390-pnp/ch15.md
    Mr. Bennet announces that Mr. Collins, the heir to Longbourn, will visit on November 18th, prompting mixed reactions from his family regarding the entail and Collins’s pompous letter. Upon arrival, the tall and stately visitor formally compliments Mrs. Bennet’s daughters and praises the estate, thou

  Pride and Prejudice — Covering a screen. CHAPTER VIII.
    fiction/rex390-pnp/ch10.md
    In Chapter VIII, Elizabeth endures the superficial sympathy and class-based mockery of the Bingley sisters while they criticize her muddy appearance and "low connections," even as Darcy defends her eyes and acknowledges her sisterly affection. The chapter highlights a clash of values when Darcy argu

  Pride and Prejudice — “Conjecturing as to the date.” CHAPTER XLIII.
    fiction/rex390-pnp/ch45.md
    Elizabeth’s visit to Pemberley fundamentally shifts her perception of Mr. Darcy, as the estate’s elegance and Mrs. Reynolds’ glowing testimony reveal his true character as a kind master and brother. This admiration deepens into gratitude upon seeing his portrait, softening her view of his past pride

  Pride and Prejudice — CHAPTER LVI.
    fiction/rex390-pnp/ch58.md
    Lady Catherine de Bourgh arrives at Longbourn to confront Elizabeth Bennet, demanding she promise never to accept Mr. Darcy’s hand based on claims of superior lineage and the scandal surrounding the Bennet family. She argues that Elizabeth’s inferior birth and lack of fortune constitute a disgracefu

  Pride and Prejudice — PRIDE. and PREJUDICE
    fiction/rex390-pnp/ch02.md
    Jane Austen’s *Pride and Prejudice* is presented as her most perfect work, distinguished by its structural regularity where every incident drives the plot toward a denouement strictly connected to earlier events. The novel’s supreme merit lies in its masterpieces of humor and character creation, whi

  Pride and Prejudice — A note for Miss Bennet. CHAPTER VII.
    fiction/rex390-pnp/ch09.md
    Mr. Bennet’s estate entailed on a distant relation leaves his daughters with limited financial security, yet the family’s attention is dominated by the arrival of the militia in Meryton rather than Mr. Bingley’s fortune. Mrs. Bennet successfully engineers Jane’s stay at Netherfield by sending her ou

  Pride and Prejudice — CHAPTER XVI.
    fiction/rex390-pnp/ch18.md
    In Chapter XVI, Mr. Collins and the Bennet cousins visit Meryton, where Mr. Wickham captivates the room and initiates a conversation with Elizabeth regarding Mr. Darcy’s character. Wickham claims that Darcy unjustly withheld a valuable living promised by his father, attributing this act to jealousy
  arrived as ONE element and became a single three-word pattern. The phrase
  never appears in a note titled 'Sous Vide Shrimp', so the tool reported
  'no match' for a note it had just found for the bare word 'shrimp'. The
  needle is now split on whitespace.

  Resolving the payload from dirname $0 broke the moment it was symlinked onto
  PATH. Now readlink -f.

cat refuses any path resolving outside the KB root — the remote half runs as
root because the volume is root-owned.
2026-09-14 18:17:21 -07:00

40 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# kb — search the operator's personal Worldtree knowledge base.
#
# The KB is a ~7,600-file markdown tree inside a Docker volume on corviduo-dev.
# It is NOT reachable through the Worldtree HTTP API: `/search` there searches
# conversation MESSAGES, not notes, and returns a clean empty result for a note
# that plainly exists — a false negative with no error attached. (2026-09-14: a
# search for "shrimp" returned 0 hits; so did "the" and "a", which is the only
# reason the empty result was recognised as an empty ACCOUNT rather than an
# empty KB.) So this reads the files directly. Deterministic, ~0.9s, no tokens.
#
# Usage:
# kb <query> search titles, keywords and body; notes first
# kb -c <query> also show the matching body lines
# kb -n <N> <query> cap results per group (default 12)
# kb --notes <query> personal notes only (skip the ingested library)
# kb --library <query> ingested books/fiction/papers only
# kb cat <path> print a note (path as printed by a search)
# kb ls [subdir] list the tree
#
# Env: KB_HOST (default corviduo-dev), KB_ROOT (default the volume mountpoint).
set -euo pipefail
KB_HOST="${KB_HOST:-corviduo-dev}"
KB_USER="${KB_USER:-infra-ops}"
KB_ROOT="${KB_ROOT:-/var/lib/docker/volumes/worldtree-personal_worldtree-kb/_data}"
# readlink -f, not dirname of $0: this is installed on PATH as a SYMLINK
# (~/.local/bin/kb -> scripts/kb, same shape as `booth`), and resolving the
# LINK's directory looks for the payload in ~/.local/bin where it is not.
SELF="$(readlink -f "${BASH_SOURCE[0]}")"
PAYLOAD="${SELF%/*}/kb-search.py"
[ $# -gt 0 ] || { sed -n '2,20p' "$SELF" | sed 's/^# \{0,1\}//'; exit 0; }
[ -f "$PAYLOAD" ] || { echo "kb: missing payload $PAYLOAD" >&2; exit 1; }
# One round trip: the payload runs remotely under sudo (the volume is root-owned)
# and does all the ranking there, so a search is one ssh handshake, not N.
exec ssh -o BatchMode=yes -o ConnectTimeout=10 "${KB_USER}@${KB_HOST}" \
"sudo -n python3 - $(printf '%q ' "$KB_ROOT" "$@")" < "$PAYLOAD"