Dev Week 18

Another backdated blog post.

I've found some nirvana: AI + BookStack for a self-writing Knowledge Base.

I have tried Wiki softwares for developing knowledge bases, including MediaWiki (the software behind Wikipedia family of websites) and Trac (Python-based), but they always fail my use cases. Those are excellent for knowledge graphs, which have arbitrarily many connections, but not so great for a general knowledge base. You must manage the indexes and connections yourself, which becomes tedious very quickly.

Enter BookStack (GitHub). The simplest way to use BookStack is to have Books with pages. If you fall in love with it as much as I have, you'll also be using chapters and shelves.

Shelves have books, books have pages and chapters; chapters have pages. This provides 4 levels deep of organization.

A book can appear on multiple shelves; a shelf is a lightweight grouping of some books into a logical unit. Your "Network Security" book could appear on both the Network shelf and the Security shelf.

There's a BookStack API integration on GitHub/Pypi, which is just a lightweight wrapper that dynamically loads the OpenAPI spec from your BookStack instance to know what the API looks like (i.e. it doesn't have the API pre-built in; this library could likely be aimed at other APIs without substantial effort).

There was a bug, as the url they constructed to grab the OpenAPI spec ended with an extraneous /, resulting in a redirect, which caused the authentication to fail to apply after the client tried to visit the redirected url that didn't contain the /. I submitted a PR and hopefully it will get merged in someday.

Using this BookStack API library, I wrote a script (in a Jupyter Notebook) to download the entire hierarchy of content from my BookStack, and a printer that accepts an optional depth. Here's an example snippet:

Systems and Infrastructure
Gentoo
📄 Miscellaneous
📄 Portage Package Management
Desktop Environments
📗 Input Configuration
📄 X11 Input Tools (xev, xinput)
📄 Kernel Input Tools (evtest, showkey)
📄 udev Configuration
📄 libinput Setup
📗 X11 System
📄 Window Management with xdotool and X11 Tools
📄 X Authentication
Linux
📗 Application Standards
📄 XDG Base Directory Specification
📄 Icon Themes and Resources
📄 Desktop Entry Files
📄 Application Autostart
📄 Runtime Directories
System Administration
📄 Sudo Configuration
📄 Borg and Frontends
📄 Common CLI Tools Reference
📄 Mount Information
📗 System Logging
📄 Logrotate Configuration
📄 Rsyslog Setup
📄 Systemd Journal Management

The benefit of this is that I can quickly and easily share my structure with [insert your friendly chatbot's name here] and ask for recommendations on the existing structure and how to restructure based on new content.

As an example, the XDG Base Directory Specification would have originally gone in the Desktop Environments book since it's related to X11, but Claude suggested that since it's a specification and more general to Linux and not tied to desktop environments, it makes more sense to put it in the Linux book. A big part of my development of this whole structure is understanding how the pieces relate to each other. For example, I don't know whether a Riesling wine is a type of grape or a company (I just looked it up, and it's a variety of grape). By codifying my knowledge into a knowledge base as I learn, it helps me solidify the hierarchy of knowledge and relationships between concepts.

Sometimes I expect a knowledge base article for a given topic to be pretty straightforward, in which case I just ask the AI, "please write a md kb article about common SSH tunneling commands." (md: markdown format; kb: Knowledge Base.) For concepts I'm less certain about, such as XAuth, I follow a line of questioning until I feel the conversation covers my previous lack of understanding reasonably well, and then ask, "would you please summarize our conversation as a md kb article?"

From there, if it's not clear where it fits in the hierarchy, I can some context from the output of my program, such as the snippet included above, removing anything clearly unrelated, and ask for it to propose where the new KB article fits, and to suggest any improvements to the overall structure and organization. Just a few days ago I did a major restructuring, because one of my books was originally "Linux and Gentoo", which was extremely restrictive and made it more difficult to add content for either one. Claude even included some of the 📗 and 📄 emojis in its output along with following the same indentation structure, making it very easy to verify and integrate the suggestions into my BookStack instance.

Overall, I'm elated with this combination. I haven't verified every piece of information in all the articles, and I'm certain there's a lot of information that isn't correct, but I feel like the happiest rat collecting all manner of shiny objects and gathering them back in my tunnel. It gives me a sense of satisfaction with building my own knowledge base of things I care about and am interested in. It also incentivizes me to try to understand things that I previously had no hope of remembering later. Now I have a hierarchy clearly laid out. Sometimes it's more important to know where to find information than it is to know the information itself. This is especially true today in the Information Age (AI Age? AI Era?), when it's impossible to know everything and vital to be able to figure anything out quickly, since that's the majority of my day-to-day life now.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.