{"id":413247,"date":"2026-11-26T15:02:21","date_gmt":"2026-11-26T15:02:21","guid":{"rendered":"https:\/\/en-gb.wordpress.org\/plugins\/cw-knowledge-base-and-ai-assistant\/"},"modified":"2026-11-26T15:12:19","modified_gmt":"2026-11-26T15:12:19","slug":"cw-knowledge-base-and-ai-assistant","status":"publish","type":"plugin","link":"https:\/\/wordpress.org\/plugins\/cw-knowledge-base-and-ai-assistant\/","author":15819979,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"1.0.1","stable_tag":"1.0.1","tested":"7.1.5","requires":"6.0","requires_php":"8.0","requires_plugins":null,"header_name":"CW Knowledge Base and AI Assistant","header_author":"Craig West","header_description":"A knowledge base and AI assistant for WordPress: an encrypted OpenRouter key store, an AI chat interface, a Markdown RAG knowledge base, and BIO memory-jogger questions.","last_updated":"2026-11-26 15:12:19","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"","header_author_uri":"","rating":0,"author_block_rating":0,"active_installs":0,"downloads":19,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description"],"tags":{"1.0.1":{"tag":"1.0.1","author":"craigwestwpbtn","date":"2026-11-26 15:12:19","revision":3827419},"v1.0.1":{"tag":"v1.0.1","author":"craigwestwpbtn","date":"2026-11-26 15:02:02","revision":3827383}},"upgrade_notice":{"1.0.1":"<p>Security and WordPress.org listing fixes. No settings or knowledge-base files are changed.<\/p>","1.0.0":"<p>First unified release. If you are replacing the four separate plugins, deactivate and delete them before activating CW Knowledge Base and AI Assistant. The uploads folders and database tables are reused, so no content is lost.<\/p>"},"ratings":[],"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0.1","v1.0.1"],"block_files":[],"assets_screenshots":[],"screenshots":[]},"plugin_section":[],"plugin_tags":[148285,191735,14090,223725,70446],"plugin_category":[],"plugin_contributors":[295703,295702],"plugin_business_model":[],"class_list":["post-413247","plugin","type-plugin","status-publish","hentry","plugin_tags-ai-assistant","plugin_tags-ai-chatbot","plugin_tags-knowledge-base","plugin_tags-openrouter","plugin_tags-rag","plugin_contributors-craigwest","plugin_contributors-craigwestwpbtn","plugin_committers-craigwestwpbtn"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/cw-knowledge-base-and-ai-assistant.svg","icon_2x":false,"generated":true},"screenshots":[],"raw_content":"<!--section=description-->\n<p>CW Knowledge Base and AI Assistant combines four related WordPress modules into one plugin:<\/p>\n\n<ul>\n<li><strong>OpenRouter key store<\/strong> \u2014 stores the OpenRouter API key and model encrypted in a custom database table, never in <code>wp_options<\/code>, and shares them through simple <code>wp2bor_*<\/code> functions.<\/li>\n<li><strong>Chat<\/strong> \u2014 a ChatGPT-style front-end and wp-admin chat that calls OpenRouter, reads the Markdown knowledge base, and lets visitors rate answers or submit <code>UPDATE:<\/code> corrections.<\/li>\n<li><strong>RAG<\/strong> \u2014 converts BIO posts and uploaded Markdown into a plain-text knowledge base in <code>wp-content\/uploads\/rag\/<\/code>, with an index, topic files, category files, tag files and a machine-readable search index.<\/li>\n<li><strong>BIO Questions<\/strong> \u2014 imports memory-jogger questions from CSV files, creates draft posts from them, and turns answered posts into RAG documents.<\/li>\n<\/ul>\n\n<p>WordPress.org category: Knowledge Base \/ AI Chatbots.<\/p>\n\n<p>Everything is plain Markdown on disk. There is no vector database and no embedding service. The RAG module writes files; the Chat module reads them.<\/p>\n\n<h4>How the pieces fit together<\/h4>\n\n<ol>\n<li><strong>BIO Questions<\/strong> reads CSV files from <code>wp-content\/uploads\/questions\/<\/code> and creates draft posts titled with each question. When an editor adds an answer and saves, the draft publishes.<\/li>\n<li><strong>RAG<\/strong> turns published, draft and private BIO posts into <code>topic-*.md<\/code> documents and links them from <code>cat-*.md<\/code> and <code>tag-*.md<\/code> files.<\/li>\n<li><strong>Chat<\/strong> searches the generated index, reads the matching documents, and calls OpenRouter for the answer.<\/li>\n<li>Visitors can rate an answer or type <code>UPDATE:<\/code> to submit a correction. An administrator approves corrections on the <strong>Chat \u2192 Feedback<\/strong> screen; an approved correction is written to the knowledge base and indexed immediately.<\/li>\n<li>Administrators can also upload Markdown directly on the <strong>RAG<\/strong> screen, or upload a chat transcript from the chat footer.<\/li>\n<\/ol>\n\n<h4>Admin screens<\/h4>\n\n<ul>\n<li><strong>OpenRouter<\/strong> \u2014 save and test the API key and model. The key is shown masked.<\/li>\n<li><strong>Chat<\/strong> \u2014 the same chat interface as the front end, plus <strong>Feedback<\/strong> and <strong>Report<\/strong> sub-screens.<\/li>\n<li><strong>RAG<\/strong> \u2014 rebuild the knowledge base, upload Markdown, re-index the folder, process chat transcripts and posts, and inspect the knowledge status.<\/li>\n<li><strong>QUESTIONS<\/strong> \u2014 import CSV question files, generate draft posts, and fill demo answers for testing.<\/li>\n<\/ul>\n\n<h4>Knowledge base files<\/h4>\n\n<p>The RAG module writes to <code>wp-content\/uploads\/rag\/<\/code>:<\/p>\n\n<ul>\n<li><code>index.md<\/code> \u2014 the router: one short row per document with a summary and searchable keywords.<\/li>\n<li><code>topic-&lt;slug&gt;.md<\/code> \u2014 one canonical document per BIO post; the answers live here.<\/li>\n<li><code>cat-&lt;category&gt;.md<\/code> \u2014 a link index over the topics in one BIO category, plus answers folded in from chats and topics.<\/li>\n<li><code>tag-&lt;tag&gt;.md<\/code> \u2014 a link index over the topics sharing a tag.<\/li>\n<li><code>.wp2brag-search.json<\/code> \u2014 machine-readable document and section index with line numbers and snippets.<\/li>\n<li><code>correction-feedback-&lt;id&gt;.md<\/code> \u2014 approved <code>UPDATE:<\/code> corrections.<\/li>\n<li><code>chat-*.md<\/code> \u2014 uploaded chat transcripts waiting to be filed.<\/li>\n<li><code>archive\/<\/code> \u2014 chat transcripts already filed into category summaries.<\/li>\n<\/ul>\n\n<p>The plugin never deletes hand-added Markdown files. It only removes its own generated <code>topic-<\/code>, <code>cat-<\/code> and <code>tag-<\/code> files when the underlying post or term is gone.<\/p>\n\n<h4>Memory-jogger questions<\/h4>\n\n<p>The BIO Questions module reads CSV files from <code>wp-content\/uploads\/questions\/<\/code>. Each row is <code>question,category,tag<\/code>. The category is a life area such as <code>Childhood<\/code>, <code>Family<\/code>, <code>School<\/code>, <code>Work<\/code> or <code>Hobbies<\/code>. The plugin prefixes generated categories with <code>BIO-<\/code>, so <code>Childhood<\/code> becomes <code>BIO-Childhood<\/code>.<\/p>\n\n<p>On the <strong>QUESTIONS<\/strong> screen an administrator can:<\/p>\n\n<ul>\n<li>upload a CSV, load one CSV into the table, or reseed every CSV;<\/li>\n<li>generate draft posts from 1 to 200 questions, in sequential or random order;<\/li>\n<li>delete generated posts without deleting the questions;<\/li>\n<li>clear the questions table or remove it entirely;<\/li>\n<li>fill demo answers for testing.<\/li>\n<\/ul>\n\n<p>An empty answer is still catalogued by RAG as <code>_No answer recorded yet._<\/code>. Answer drafts before rebuilding, or filter the post statuses with <code>wp2brag_post_statuses<\/code>, so unanswered prompts do not appear in the knowledge base.<\/p>\n\n<h4>Ratings and corrections<\/h4>\n\n<p>A thumbs up or down is stored as a pending feedback row. A rating alone never changes the knowledge base; it is review material and can be exported as JSONL from the Feedback screen. A thumbs down can be followed by a note.<\/p>\n\n<p>An <code>UPDATE:<\/code> message is treated as a correction. It is not sent to OpenRouter. The previous question and answer are stored with the correction, and an administrator approves or rejects it on <strong>Chat \u2192 Feedback<\/strong>. An approved correction becomes <code>correction-feedback-&lt;id&gt;.md<\/code> and is indexed immediately.<\/p>\n\n<h4>Security and privacy<\/h4>\n\n<ul>\n<li>The OpenRouter API key is encrypted with libsodium secretbox, or OpenSSL AES-256-GCM as a fallback. The encryption key is derived from the WordPress auth salt. Define <code>WP2BOR_KEY<\/code> in <code>wp-config.php<\/code> to pin it independently of the salts.<\/li>\n<li>The API key is never printed in full. The admin screen shows only the last four characters.<\/li>\n<li>Chat history is kept in the browser in a hidden form field and is lost when the page reloads. The only chat text written to the database is the feedback snapshot a visitor explicitly submits.<\/li>\n<li>The chat appearance settings are stored in the browser's <code>localStorage<\/code> and are not sent to the server.<\/li>\n<li>Uploads are restricted to the WordPress uploads folder. The plugin refuses to overwrite its generated files.<\/li>\n<\/ul>\n\n<h4>External services<\/h4>\n\n<p>This plugin connects to the following external service.<\/p>\n\n<p><strong>OpenRouter<\/strong> \u2014 used by the Chat module to generate answers.<\/p>\n\n<ul>\n<li>Endpoint: <code>https:\/\/openrouter.ai\/api\/v1\/chat\/completions<\/code><\/li>\n<li>Key test endpoint: <code>https:\/\/openrouter.ai\/api\/v1\/key<\/code><\/li>\n<li>Data sent: the chat messages, the selected model, and the conversation context. No site data is sent unless it is part of a chat message or a document the chat reads.<\/li>\n<li>The API key is supplied by the site owner.<\/li>\n<li>OpenRouter terms: https:\/\/openrouter.ai\/terms<\/li>\n<li>OpenRouter privacy policy: https:\/\/openrouter.ai\/privacy<\/li>\n<\/ul>\n\n<h4>Installation<\/h4>\n\n<ol>\n<li>Upload the <code>cw-knowledge-base-and-ai-assistant<\/code> folder to <code>wp-content\/plugins\/<\/code>, or install the zip through <strong>Plugins \u2192 Add New \u2192 Upload Plugin<\/strong>.<\/li>\n<li>Activate <strong>CW Knowledge Base and AI Assistant<\/strong>.<\/li>\n<li>Open <strong>OpenRouter<\/strong> in wp-admin and save an API key and model. The chat needs this key; the RAG and BIO Questions modules work without it.<\/li>\n<li>Open <strong>RAG<\/strong> and choose <strong>Rebuild knowledge<\/strong> to generate the first catalog.<\/li>\n<li>Open <strong>Chat<\/strong> or the generated front-end Chat page to start asking questions.<\/li>\n<\/ol>\n\n<h4>Frequently Asked Questions<\/h4>\n\n<h4>Does the chat need an OpenRouter key?<\/h4>\n\n<p>Yes. The Chat module calls OpenRouter. The RAG and BIO Questions modules work without a key.<\/p>\n\n<h4>Where is the knowledge base stored?<\/h4>\n\n<p>In <code>wp-content\/uploads\/rag\/<\/code>. The folder name is set by <code>WP2BRAG_DOCS_FOLDER<\/code> and <code>WP2BCHAT_DOCS_FOLDER<\/code>. Change both constants together if you rename the folder.<\/p>\n\n<h4>Can I edit the Markdown by hand?<\/h4>\n\n<p>Yes. Add or edit <code>.md<\/code> files in <code>wp-content\/uploads\/rag\/<\/code>, then choose <strong>Re-index folder<\/strong> on the RAG screen. The plugin never deletes hand-added files.<\/p>\n\n<h4>What happens when I uninstall?<\/h4>\n\n<p>The Markdown catalog and the feedback table are kept. The chat page and plugin options are removed. The encrypted OpenRouter credentials and the BIO questions table are only dropped when you explicitly opt in.<\/p>\n\n<h4>Can I use the chat without the RAG module?<\/h4>\n\n<p>Yes. RAG is the primary source, but the chat also has a fallback 2nd Brain wiki in <code>wp-content\/uploads\/2ndbrain\/<\/code>. If neither source exists, the chat answers from the model's own knowledge.<\/p>\n\n<h4>Does the plugin send my documents to OpenRouter?<\/h4>\n\n<p>Only the text the chat actually reads while answering a question. The RAG generator itself is deterministic and does not call any external service.<\/p>\n\n<h4>Changelog<\/h4>\n\n<h4>1.0.1<\/h4>\n\n<ul>\n<li>Security: sanitize the posted chat transcript and conversation history before writing Markdown to <code>wp-content\/uploads\/rag\/<\/code>.<\/li>\n<li>Security: decode and sanitize the JSON list of cited documents posted with feedback.<\/li>\n<li>Fixed the WordPress.org contributor list so it includes the plugin owner account.<\/li>\n<\/ul>\n\n<h4>1.0.0<\/h4>\n\n<ul>\n<li>Initial unified release.<\/li>\n<li>Combines 06 OpenRouter 1.0.3, 100 BIO Questions 1.5.1, 20 Chat 2.1.0 and 25 RAG 2.0.0.<\/li>\n<li>Single text domain: <code>cw-knowledge-base-and-ai-assistant<\/code>.<\/li>\n<li>Single activation entry point and a merged uninstall routine.<\/li>\n<li>OpenRouter key store, Chat, RAG and BIO Questions keep their original admin screens and settings.<\/li>\n<\/ul>","raw_excerpt":"An encrypted OpenRouter key store, AI chat, Markdown RAG knowledge base, and BIO memory-jogger questions for WordPress.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/413247","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=413247"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/craigwestwpbtn"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=413247"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=413247"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=413247"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=413247"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=413247"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=413247"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}