ability-docs-memory
ability-docs-memory
Section titled “ability-docs-memory”Documentation search engine built on graph-ability — crawls, chunks, indexes, and searches documentation with 4-signal hybrid recall including structural navigation
Overview
Section titled “Overview”ability-docs-memory is a Kadi/AGENTS ability that crawls, chunks, indexes, and searches documentation using a graph-backed DocNode model and a 4-signal hybrid recall (semantic, keyword, graph, structural). It ships tools for indexing, searching, and inspecting documentation stored in the graph database. The ability is implemented to run as a native in-process library, as a remote ability via a Kadi broker, or as a CLI service.
Quick Start
Section titled “Quick Start”-
Install package dependencies:
npm install -
Install the ability into your Kadi environment (local path or package registry):
kadi install . -
Start the ability (serves the tools to the broker):
kadi run start
Alternative local run methods:
-
Use the packaged start script (defined in agent.json):
npm run setup(runsnpm install && npm run build)
npm start(runsnode dist/index.js broker) -
Run TypeScript source directly for development (requires
tsx):npx tsx src/index.ts
| Tool | Description |
|---|---|
| docs-search | Search documentation using 4-signal hybrid recall (semantic, keyword, graph, structural). |
| docs-reindex | Reindex documentation into the graph database — full pipeline: crawl → chunk (by markdown headings) → batch-store. |
| docs-page | Fetch a single documentation page by slug. Returns all chunks (DocNode vertices) for that page. |
| docs-index-status | Get documentation index statistics: total DocNodes, counts by collection, health and last indexed time. |
Configuration
Section titled “Configuration”Primary configuration sources and fields:
-
agent.json (package root)
name(string) — ability name, default read by the ability client (example:"ability-docs-memory").version(string) — ability version.entrypoint(string) — runtime entry file (dist/index.js).abilities(object) — declared dependent abilities (e.g."graph-ability": "^0.0.7","secret-ability": "^0.9.0").brokers(object) — broker definitions e.g."local": "ws://localhost:8080/kadi".scripts.setupandscripts.startare provided (setupruns install+build,startruns packaged entrypoint).
-
Environment
BROKER_URL— If set, overrides broker URL resolution. The runtime checks this env var first when connecting the internalKadiClient.
-
Broker resolution behavior (implemented in
src/index.ts):- If
process.env.BROKER_URLis set, it is used. - Otherwise
agent.jsonis searched fordefaultBrokeror the first key inagent.json.brokers. - If no broker is found, fallback:
ws://localhost:8080/kadi.
- If
-
Docs configuration (loaded via
loadDocsConfigWithVaultin./lib/config.js):- Default collection:
agents-docs - Default database:
agents_memory - The config loader supports integration with Vault via
secret-abilityfor secret-managed credentials (seeloadDocsConfigWithVaultinsrc/index.ts).
- Default collection:
Important file paths referenced by the runtime:
agent.json— package metadata + broker settings (root).dist/index.js— compiled entrypoint (packaged runtime).src/index.ts— runtime bootstrap and client setup../lib/config.js— docs configuration loader (uses Vault integration)../lib/schema.js—DOCNODE_SCHEMA(DocNode vertex schema)../tools/search.js—registerSearchToolimplementation../tools/reindex.js—registerReindexToolimplementation../tools/page.js—registerPageToolimplementation../tools/index-status.js—registerIndexStatusToolimplementation.
Architecture
Section titled “Architecture”High-level data flow and key components:
-
KadiClient
- The ability constructs a
KadiClient(from@kadi.build/core) using the name/version fromagent.jsonand a resolved broker URL. This client is used to load native abilities and to register/invoke tools.
- The ability constructs a
-
Config loader (
loadDocsConfigWithVault)- Loads documentation configuration and optionally fetches secrets via
secret-ability(Vault) to supply credentials or protected settings.
- Loads documentation configuration and optionally fetches secrets via
-
Graph ability (
graph-ability)- The ability attempts to
client.loadNative('graph-ability')to access a graph database API for creating vertices, edges, and indexes. If native load fails, the ability continues — tools will run but may operate remotely via broker-invoked graph-ability.
- The ability attempts to
-
Crawler & Chunker (docs-reindex)
- docs-reindex implements the full pipeline: crawl documentation pages, chunk each page by markdown headings (creating smaller semantic units), and produce DocNode vertices for each chunk.
-
Batch store (graph-batch-store)
- Chunked DocNodes are written to the graph database in batches. The runtime marks
graph-batch-storeas a long-running tool (seeLONG_RUNNING_TOOLSset), which affects lifecycle handling for long-running batch operations.
- Chunked DocNodes are written to the graph database in batches. The runtime marks
-
DocNode model and DOCNODE_SCHEMA
- DocNodes represent document chunks (title, slug, content, headings, metadata). The schema is defined in
./lib/schema.jsand is the persistent vertex model stored in the graph (databaseagents_memory, default collectionagents-docs).
- DocNodes represent document chunks (title, slug, content, headings, metadata). The schema is defined in
-
Indexing & Signals
- Each DocNode is indexed across multiple signals:
- Semantic vectors (embedding-based similarity)
- Keyword indexes (token/term indexes)
- Graph signals (edges: NEXT_SECTION, REFERENCES)
- Structural navigation signals (section relationships to enable “next section” traversal)
- The search tool (
docs-search) integrates these 4 signals to produce hybrid recall results with structural navigation support (e.g., navigate toNEXT_SECTIONand followREFERENCES).
- Each DocNode is indexed across multiple signals:
-
Tools
- Tools are registered from
./tools/*.jsand exposed via the Kadi broker for remote invocation or invoked directly when loaded as a native library.
- Tools are registered from
Key runtime behaviors:
- The ability will try to load
graph-abilitynatively. If that fails it continues but logs a warning and may rely on broker-based access to graph services. - The
LONG_RUNNING_TOOLSset includes'graph-batch-store'so the runtime treats that tool as long-lived and keeps it available for asynchronous batch indexing jobs.
Development
Section titled “Development”Local development tips and commands:
-
Install dependencies:
npm install -
Set up (agent.json provides a
setupscript):npm run setup(runsnpm install && npm run build— ensure abuildscript / tsc step exists in your repo) -
Run packaged ability:
npm start(runsnode dist/index.js brokerperagent.json) -
Run from source for rapid iteration (no build required):
npx tsx src/index.ts -
Useful environment variables:
BROKER_URL— force a broker URL to use (overrides agent.json broker resolution).NODE_ENV— runtime environment.
-
Registering and testing tools:
- Tools are registered in
src/index.tsvia calls to:registerSearchTool(./tools/search.js)registerReindexTool(./tools/reindex.js)registerPageTool(./tools/page.js)registerIndexStatusTool(./tools/index-status.js)
- Use
client.invoke('docs-search', { ... })or the Kadi CLI to call tools remotely.
- Tools are registered in
- The package declares runtime dependencies in the source agent metadata: it relies on
graph-abilityandsecret-ability. - Schema for DocNode is located at
./lib/schema.js(exportDOCNODE_SCHEMA). - See
src/index.tsfor broker resolution logic, client creation, and ability/tool registration sequence.
If you need examples of payloads for docs-search, docs-reindex, or other tools, or a sample docs config file (docs.yml/docs.json) tuned for your documentation site, tell me which target documentation source and I will provide an example config and example tool invocation.
Quick Start
Section titled “Quick Start”cd ability-docs-memorynpm installkadi installkadi run startConfiguration
Section titled “Configuration”agent.json
Section titled “agent.json”| Field | Value |
|---|---|
| Version | 0.0.1 |
| Type | ability |
| Entrypoint | dist/index.js |
Abilities
Section titled “Abilities”graph-ability^0.0.7secret-ability^0.9.0
Brokers
Section titled “Brokers”- local:
ws://localhost:8080/kadi
Architecture
Section titled “Architecture”Development
Section titled “Development”npm installnpm run buildkadi run start