Skip to content

feat: local RAG knowledge base with 4 sources + auto-consult#182

Merged
pluginslab merged 2 commits intodevfrom
feature/local-rag-knowledge-base
Mar 22, 2026
Merged

feat: local RAG knowledge base with 4 sources + auto-consult#182
pluginslab merged 2 commits intodevfrom
feature/local-rag-knowledge-base

Conversation

@ivdimova
Copy link
Copy Markdown
Collaborator

Summary

  • 4 knowledge sources feed into the same vector store: site code, database schema, WP API signatures, and 13 bundled reference docs
  • Auto-consult: ReAct agent automatically injects top-2 RAG results before reasoning — no explicit "search" needed
  • Settings UI: Knowledge Base card with Build/Rebuild Index button, progress bar, and status display
  • Code search broadened: renamed to "Search knowledge base" with wider keyword coverage
  • Bugfix: codebase-extract.php used undefined register_agentic_ability() — fixed and added missing registration

New Files

File Purpose
includes/abilities/schema-extract.php SHOW TABLES + DESCRIBE with semantic context for core WP tables
includes/abilities/wp-api-extract.php Extract function signatures + docblocks from wp-includes/
includes/abilities/docs-extract.php Read + chunk bundled markdown docs by heading boundaries
src/extensions/services/knowledge-base.js Indexing orchestration service with progress tracking
docs/knowledge/*.md (13 files) Curated WP reference: schema, hooks, options, CPTs, roles, REST API, cron, queries, security, themes, plugins, performance, multisite

Modified Files

File Change
includes/class-abilities.php Register 4 new abilities (schema, api, docs, codebase-extract)
includes/abilities/codebase-extract.php Fix: register_agentic_ability()wp_agentic_admin_register_ability()
src/extensions/services/react-agent.js Auto-consult: init vector store + inject RAG context before ReAct loop
src/extensions/abilities/codebase-index.js Delegates to knowledge-base.js service, skips if indexed < 5min ago
src/extensions/abilities/code-search.js Label/description/keywords broadened for knowledge base
src/extensions/components/SettingsTab.jsx Knowledge Base card: build/clear index, progress bar, status table

Test plan

  • Go to Settings tab → click "Build Index" → verify progress bar completes and status table shows counts for all 4 sources
  • Open browser console, set wpAgenticLogLevel = 3, ask a question → verify [ReactAgent] Auto-consult: injected 2 RAG results appears
  • Ask "what hooks fire when a post is published?" → verify answer uses knowledge base context
  • Ask "search for wp_options" → verify results include db:// schema chunks
  • Click "Clear Index" → verify status disappears and auto-consult stops injecting
  • In chat, say "index the codebase" → verify it still works via the ability (delegates to same service)
  • npm test — 71/71 unit tests pass

🤖 Generated with Claude Code

ivdimova and others added 2 commits March 22, 2026 11:55
Expand the local RAG system from code-only indexing into a full
knowledge base with four sources: site code, database schema,
WordPress API signatures, and bundled reference docs. The ReAct
agent automatically consults the knowledge base before reasoning.

New PHP abilities:
- schema-extract: SHOW TABLES + DESCRIBE with semantic context
  for core WP tables and sensitive column redaction
- wp-api-extract: scans wp-includes/ for function signatures
  and docblocks, groups ~5 per chunk
- docs-extract: reads curated markdown from docs/knowledge/,
  chunks by heading boundaries

New knowledge base docs (docs/knowledge/):
- database-schema, hooks-lifecycle, options-api, post-types,
  user-roles, rest-api, cron, queries, security,
  theme-development, plugin-development, performance, multisite

Settings UI (Knowledge Base card):
- Build/Rebuild Index button with progress bar
- Status display: last built, chunk counts by source
- Clear Index button
- Indexing service extracted into knowledge-base.js

Auto-consult (react-agent.js):
- Before ReAct loop, initializes vector store from IndexedDB
- Searches top-2 results matching user message
- Injects as [Relevant knowledge base context] prefix (~1750 chars)
- Best-effort: failures do not block the agent

Code search broadened:
- Label: "Search knowledge base" (was "Search site codebase")
- Keywords: added database, schema, wordpress, documentation

Bugfix: codebase-extract.php used undefined register_agentic_ability()
- Fixed to wp_agentic_admin_register_ability() and added missing
  registration in class-abilities.php.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Auto-consult only injects RAG context when user enables the library
icon toggle in the chat input (next to web search globe). Saves ~500
tokens on every message when knowledge base is not needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Owner

@pluginslab pluginslab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4-source knowledge base with auto-consult gated behind a library icon toggle (same pattern as web search globe). RAG context only injected when the user opts in — saves ~500 tokens per message otherwise. Settings UI with build/clear index. LGTM!

@pluginslab pluginslab merged commit 19923bb into dev Mar 22, 2026
1 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants